Mercurial > forge
changeset 11410:c20550232685 octave-forge
Conversion of enum types implemented.
author | i7tiol |
---|---|
date | Tue, 22 Jan 2013 20:24:30 +0000 |
parents | 21794ea37065 |
children | b75c6b42bbc0 |
files | main/database/NEWS main/database/doc/README-postgresql main/database/src/converters.h main/database/src/pq_connection.cc main/database/src/pq_exec.cc |
diffstat | 5 files changed, 26 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/main/database/NEWS Tue Jan 22 19:43:04 2013 +0000 +++ b/main/database/NEWS Tue Jan 22 20:24:30 2013 +0000 @@ -41,12 +41,12 @@ State: -Alpha, but can already be useful. Not all base types implemented yet, -also no enum types yet. All commands should work with pq_exec_params, -copy from stdin and copy to stdout are implemented from/to files at -client side. The whole framework including conversion of composite and -array types with the resulting possible recursion and a number of base -types are implemented. Large object import, export, and unlink works. +Alpha, but can already be useful. Not all base types implemented +yet. All commands should work with pq_exec_params, copy from stdin and +copy to stdout are implemented from/to files at client side. The whole +framework including conversion of composite and array types with the +resulting possible recursion, enum types, and a number of base types +are implemented. Large object import, export, and unlink works. Please report bugs. If you want to implement a new type-converter for a base type yourself, you can do it in converters.cc and tell me
--- a/main/database/doc/README-postgresql Tue Jan 22 19:43:04 2013 +0000 +++ b/main/database/doc/README-postgresql Tue Jan 22 20:24:30 2013 +0000 @@ -38,12 +38,12 @@ State: -Alpha, but can already be useful. Not all base types implemented yet, -also no enum types yet. All commands should work with pq_exec_params, -copy from stdin and copy to stdout are implemented from/to files at -client side. The whole framework including conversion of composite and -array types with the resulting possible recursion and a number of base -types are implemented. Large object import, export, and unlink works. +Alpha, but can already be useful. Not all base types implemented +yet. All commands should work with pq_exec_params, copy from stdin and +copy to stdout are implemented from/to files at client side. The whole +framework including conversion of composite and array types with the +resulting possible recursion, enum types, and a number of base types +are implemented. Large object import, export, and unlink works. Please report bugs. If you want to implement a new type-converter for a base type yourself, you can do it in converters.cc and tell me
--- a/main/database/src/converters.h Tue Jan 22 19:43:04 2013 +0000 +++ b/main/database/src/converters.h Tue Jan 22 20:24:30 2013 +0000 @@ -83,6 +83,13 @@ extern oct_pq_conv_t *conv_ptrs[OCT_PQ_NUM_CONVERTERS]; +// these prototypes are needed because pointers to these functions are +// stored in the converter structures of each found enum type +int to_octave_str_text (const char *c, octave_value &ov, int nb); +int to_octave_bin_text (const char *c, octave_value &ov, int nb); +int from_octave_str_text (const octave_value &ov, oct_pq_dynvec_t &val); +int from_octave_bin_text (const octave_value &ov, oct_pq_dynvec_t &val); + // append bytes of value 'val' of type 'type' to dynamic char vector 'dv' #define OCT_PQ_PUT(dv, type, val) \ dv.resize (dv.size () + sizeof (type)); \
--- a/main/database/src/pq_connection.cc Tue Jan 22 19:43:04 2013 +0000 +++ b/main/database/src/pq_connection.cc Tue Jan 22 20:24:30 2013 +0000 @@ -371,10 +371,10 @@ t_conv->is_enum = true; t_conv->is_not_constant = true; t_conv->name = name; - t_conv->to_octave_str = NULL; - t_conv->to_octave_bin = NULL; - t_conv->from_octave_str = NULL; - t_conv->from_octave_bin = NULL; + t_conv->to_octave_str = &to_octave_str_text; + t_conv->to_octave_bin = &to_octave_bin_text; + t_conv->from_octave_str = &from_octave_str_text; + t_conv->from_octave_bin = &from_octave_bin_text; // we trust there is always an array type in the table oct_pq_conv_t *&by_oid = conv_map[oid], *&by_aoid = conv_map[aoid],
--- a/main/database/src/pq_exec.cc Tue Jan 22 19:43:04 2013 +0000 +++ b/main/database/src/pq_exec.cc Tue Jan 22 20:24:30 2013 +0000 @@ -168,6 +168,9 @@ @item any composite type\n\ @tab One-dimensional cell-array with entries of types corresponding to the respective Postgresql types. Entries may also correspond to an array-type or composite type; this is allowed to lead to arbitrarily deep nesting.\n\ @tab yes\n\ +@item any enum type\n\ +@tab string\n\ +@tab yes\n\ @end multitable\n\ Octaves @code{NA} corresponds to a Postgresql NULL value (not @code{NaN}, which is interpreted as a value of a float type!).\n\ @seealso{pq_update_types}\n\