annotate main/database/src/converters_arr_comp.cc @ 12612:2257648e8ce1 octave-forge

avoid using const_cast, new release 2.3.2 * pq_connection.h/cc: octave_pq_connection now contains pointer to object of new class octave_pq_connection_rep, containing the pq-specific members formerly in octave_pq_connection. * pq_exec.cc, pq_close.cc, pq_update_types.cc, pq_conninfo.cc, pq_lo.cc: Remove const_cast, use octave_pq_connection_rep object instead. * __pq_connect__.cc, converters.h/cc, converters_arr_comp.cc, command.h/cc: Use octave_pq_connection_rep instead of octave_pq_connection.
author i7tiol
date Tue, 05 May 2015 07:31:33 +0000
parents ed5361361a0f
children 1af86934c14e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
1 /*
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
2
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
3 Copyright (C) 2012, 2013 Olaf Till <i7tiol@t-online.de>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
4
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
8 (at your option) any later version.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
9
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
13 GNU General Public License for more details.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
14
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
16 along with this program; If not, see <http://www.gnu.org/licenses/>.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
17
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
18 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
19
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
20 #include <octave/oct.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
21 #include <octave/ov-struct.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
22 #include <octave/Cell.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
23 #include <octave/lo-ieee.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
24
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
25 #include <stdint.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
26
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
27 #include "converters.h"
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
28 #include "pq_connection.h"
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
29
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
30 #define ERROR_RETURN_NO_PG_TYPE \
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
31 { \
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
32 error ("could not determine postgresql type for Octave parameter"); \
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
33 return NULL; \
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
34 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
35
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
36 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
37 std::string &name,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
38 pq_oct_type_t &oct_type)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
39 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
40 oct_pq_conv_t *conv = NULL;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
41
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
42 // printf ("pgtype_from_spec(%s): simple ", name.c_str ());
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
43
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
44 oct_type = simple; // default
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
45 int l;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
46 while (name.size () >= 2 && ! name.compare (l = name.size () - 2, 2, "[]"))
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
47 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
48 name.erase (l, 2);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
49 oct_type = array;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
50
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
51 // printf ("array ");
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
52 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
53
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
54 oct_pq_name_conv_map_t::const_iterator iter;
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
55
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
56 if ((iter = conn.name_conv_map.find (name.c_str ())) ==
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
57 conn.name_conv_map.end ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
58 error ("no converter found for type %s",
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
59 name.c_str ());
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
60 else
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
61 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
62 // printf ("(looked up in name map) ");
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
63
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
64 conv = iter->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
65
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
66 if (oct_type == array && ! conv->aoid)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
67 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
68 error ("%s: internal error, type %s, specified as array, has no array type in system catalog", name.c_str ());
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
69 return conv;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
70 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
71
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
72 if (! (oct_type == array) && conv->is_composite)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
73 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
74 oct_type = composite;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
75
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
76 // printf ("composite ");
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
77 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
78 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
79
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
80 // printf ("\n");
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
81
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
82 return conv;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
83 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
84
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
85 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn, Oid oid,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
86 pq_oct_type_t &oct_type)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
87 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
88 // printf ("pgtype_from_spec(%u): ", oid);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
89
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
90 oct_pq_conv_t *conv = NULL;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
91
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
92 oct_pq_conv_map_t::const_iterator iter;
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
93
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
94 if ((iter = conn.conv_map.find (oid)) == conn.conv_map.end ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
95 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
96 error ("no converter found for element oid %u", oid);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
97 return conv;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
98 }
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
99 conv = iter->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
100 // printf ("(looked up %s in oid map) ", conv->name.c_str ());
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
101
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
102 if (conv->aoid == oid)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
103 oct_type = array;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
104 else if (conv->is_composite)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
105 oct_type = composite;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
106 else
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
107 oct_type = simple;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
108
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
109 // printf ("oct_type: %i\n", oct_type);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
110
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
111 return conv;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
112 }
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
113
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
114 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn, Oid oid,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
115 oct_pq_conv_t *&c_conv,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
116 pq_oct_type_t &oct_type)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
117 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
118 if (c_conv)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
119 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
120 if (c_conv->aoid == oid)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
121 oct_type = array;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
122 else if (c_conv->is_composite)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
123 oct_type = composite;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
124 else
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
125 oct_type = simple;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
126 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
127 else
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
128 c_conv = pgtype_from_spec (conn, oid, oct_type);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
129
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
130 return c_conv;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
131 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
132
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
133 oct_pq_conv_t *pgtype_from_octtype (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
134 const octave_value &param)
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
135 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
136 // printf ("pgtype_from_octtype: ");
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
137
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
138 if (param.is_bool_scalar ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
139 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
140 // printf ("bool\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
141 return conn.name_conv_map.find ("bool")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
142 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
143 else if (param.is_real_scalar ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
144 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
145 if (param.is_double_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
146 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
147 // printf ("float8\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
148 return conn.name_conv_map.find ("float8")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
149 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
150 else if (param.is_single_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
151 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
152 // printf ("float4\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
153 return conn.name_conv_map.find ("float4")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
154 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
155 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
156
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
157 if (param.is_scalar_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
158 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
159 if (param.is_int16_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
160 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
161 // printf ("int2\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
162 return conn.name_conv_map.find ("int2")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
163 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
164 else if (param.is_int32_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
165 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
166 // printf ("int4\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
167 return conn.name_conv_map.find ("int4")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
168 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
169 else if (param.is_int64_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
170 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
171 // printf ("int8\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
172 return conn.name_conv_map.find ("int8")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
173 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
174 else if (param.is_uint32_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
175 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
176 // printf ("oid\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
177 return conn.name_conv_map.find ("oid")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
178 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
179 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
180
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
181 if (param.is_uint8_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
182 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
183 // printf ("bytea\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
184 return conn.name_conv_map.find ("bytea")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
185 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
186 else if (param.is_string ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
187 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
188 // printf ("text\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
189 return conn.name_conv_map.find ("text")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
190 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
191
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
192 // is_real_type() is true for strings, so is_numeric_type() would
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
193 // still be needed if strings were not recognized above
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
194 if (param.is_real_type ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
195 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
196 switch (param.numel ())
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
197 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
198 case 2:
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
199 // printf ("point\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
200 return conn.name_conv_map.find ("point")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
201 case 3:
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
202 // printf ("circle\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
203 return conn.name_conv_map.find ("circle")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
204 case 4:
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
205 // printf ("lseg\n");
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
206 return conn.name_conv_map.find ("lseg")->second.get_copy ();
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
207 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
208 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
209
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
210 ERROR_RETURN_NO_PG_TYPE
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
211 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
212
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
213 octave_idx_type count_row_major_order (dim_vector &dv,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
214 oct_mo_count_state &state, bool init)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
215 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
216 if (init)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
217 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
218 state.nd = dv.length ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
219
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
220 state.cur.resize (state.nd);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
221
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
222 state.pd.resize (state.nd);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
223
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
224 // cannot be done with resize in multiple initializations
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
225 // (resizing to n<2 not possible) and there is no fill() method
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
226 for (octave_idx_type i = 0; i < state.nd; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
227 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
228 state.cur(i) = 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
229 state.pd(i) = 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
230 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
231
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
232 for (octave_idx_type i = 0; i < state.nd - 1; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
233 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
234 state.pd(i + 1) = state.pd(i) * dv(i);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
235 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
236
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
237 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
238 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
239 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
240 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
241 octave_idx_type nd = state.nd;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
242
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
243 if (nd > 0)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
244 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
245 octave_idx_type ret = 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
246
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
247 state.cur(nd - 1)++;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
248
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
249 for (octave_idx_type i = nd - 1; i > 0; i--)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
250 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
251 if (state.cur(i) == dv(i))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
252 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
253 state.cur(i) = 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
254 state.cur(i - 1)++;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
255 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
256
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
257 ret += state.cur(i) * state.pd(i);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
258 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
259
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
260 if (state.cur(0) == dv(0))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
261 ret = -1; // signals overflow
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
262 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
263 ret += state.cur(0) * state.pd(0);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
264
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
265 return ret;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
266 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
267 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
268 return -1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
269 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
270 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
271
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
272 int from_octave_bin_array (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
273 const octave_value &oct_arr,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
274 oct_pq_dynvec_t &val, oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
275 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
276 octave_scalar_map m = oct_arr.scalar_map_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
277 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
278 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
279 error ("Postgresql array parameter no Octave structure");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
280 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
281 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
282
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
283 if (! m.isfield ("ndims") || ! m.isfield ("data"))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
284 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
285 error ("field 'ndims' or 'data' missing in parameter for Postgresql array");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
286 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
287 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
288
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
289 octave_idx_type nd_pq = m.contents ("ndims").int_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
290 Cell arr = m.contents ("data").cell_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
291 if (error_state || nd_pq < 0)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
292 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
293 error ("'ndims' and 'data' could not be converted to non-negative integer and cell-array in parameter for Postgresql array");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
294 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
295 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
296
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
297 RowVector lb;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
298
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
299 // Are lbounds given?
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
300 if (m.isfield ("lbounds"))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
301 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
302 lb = m.contents ("lbounds").row_vector_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
303 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
304 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
305 error ("could not convert given enumeration bases for array to row vector");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
306 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
307 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
308 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
309
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
310 octave_idx_type nl = arr.numel ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
311
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
312 // dimensions of Octaves representation of postgresql array
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
313 dim_vector d = arr.dims ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
314 d.chop_trailing_singletons ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
315 int nd_oct = d.length ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
316 if (nd_oct == 2 && d(1) == 1)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
317 nd_oct = 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
318
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
319 // check dimensions
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
320 if (nd_oct > nd_pq)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
321 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
322 error ("given representation of postgresql array has more dimensions than specified");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
323 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
324 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
325
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
326 // check lbounds
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
327 if (nd_pq > 0 && lb.is_empty ())
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
328 lb.resize (nd_pq, 1); // fill with 1
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
329 else if (lb.length () != nd_pq)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
330 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
331 error ("number of specified enumeration bases for array does not match specified number of dimensions");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
332 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
333 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
334
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
335 // ndim
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
336 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nd_pq))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
337 // always make a NULL-bitmap, we don't scan for NULLs to see if it
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
338 // is really necessary
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
339 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) 1))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
340 // element OID
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
341 OCT_PQ_PUT(val, uint32_t, htobe32 ((uint32_t) conv->oid))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
342 // dims, lbounds
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
343 for (int i = 0; i < nd_pq; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
344 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
345 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) (i < nd_oct ? d(i) : 1)))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
346 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) lb(i)))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
347 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
348 // elements
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
349 oct_mo_count_state state;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
350 count_row_major_order (d, state, true); // initialize counter
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
351 for (int i = 0, ti = 0; ti < nl;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
352 ti++, i = count_row_major_order (d, state, false))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
353 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
354 if (arr(i).is_real_scalar () && arr(i).isna ().bool_value ())
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
355 // a length value (uint32_t) would not have the 6 highest bits
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
356 // set (while this has all bits set)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
357 { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
358 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
359 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
360 OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
361
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
362 if (conv->is_composite)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
363 {
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
364 if (from_octave_bin_composite (conn, arr(i), val, conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
365 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
366 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
367 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
368 {
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
369 if (conv->from_octave_bin (conn, arr(i), val))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
370 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
371 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
372
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
373 OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
374 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
375 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
376
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
377 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
378 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
379
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
380 int from_octave_bin_composite (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
381 const octave_value &oct_comp,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
382 oct_pq_dynvec_t &val,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
383 oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
384 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
385 Cell rec (oct_comp.cell_value ());
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
386 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
387 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
388 error ("Octaves representation of a composite type could not be converted to cell-array");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
389 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
390 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
391
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
392 octave_idx_type nl = rec.numel ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
393
11645
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
394 if (size_t (nl) != conv->el_oids.size ())
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11407
diff changeset
395 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
396 error ("Octaves representation of a composite type has incorrect number of elements (%i, should have %i)",
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
397 nl, conv->el_oids.size ());
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
398
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
399 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
400 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
401
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
402 // ncols
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
403 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nl))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
404 // elements
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
405 for (int i = 0; i < nl; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
406 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
407 // element OID
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11407
diff changeset
408 OCT_PQ_PUT(val, uint32_t, htobe32 ((uint32_t) conv->el_oids[i]))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
409 if (rec(i).is_real_scalar () && rec(i).isna ().bool_value ())
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
410 // a length value (uint32_t) would not have the 6 highest bits
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
411 // set (while this has all bits set)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
412 { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
413 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
414 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
415 OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
416
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
417 oct_pq_conv_t *el_conv;
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
418 pq_oct_type_t oct_type;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
419
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
420 if (! (el_conv = pgtype_from_spec (conn,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
421 conv->el_oids[i],
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
422 conv->conv_cache[i],
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
423 oct_type)))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
424 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
425
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
426 switch (oct_type)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
427 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
428 case simple:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
429 if (el_conv->from_octave_bin (conn, rec(i), val))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
430 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
431 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
432
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
433 case array:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
434 if (from_octave_bin_array (conn, rec(i), val, el_conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
435 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
436 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
437
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
438 case composite:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
439 if (from_octave_bin_composite (conn, rec(i), val, el_conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
440 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
441 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
442
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
443 default:
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
444 // should not get here
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
445 error ("internal error, undefined type identifier");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
446 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
447 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
448
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
449 OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
450 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
451 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
452
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
453 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
454 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
455
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
456 int from_octave_str_array (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
457 const octave_value &oct_arr,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
458 oct_pq_dynvec_t &val, octave_value &type)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
459 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
460 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
461 error ("not implemented");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
462 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
463
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
464 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
465 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
466
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
467 int from_octave_str_composite (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
468 const octave_value &oct_comp,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
469 oct_pq_dynvec_t &val,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
470 octave_value &type)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
471 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
472 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
473 error ("not implemented");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
474 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
475
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
476 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
477 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
478
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
479 int to_octave_bin_array (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
480 const char *v, octave_value &ov, int nb,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
481 oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
482 {
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
483 const char *p = v;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
484
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
485 // ndim
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
486 OCT_PQ_DECL_GET_INT32(ndim, p, int32_t)
11645
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
487 // Has NULL bitmap. Since this information is not used, comment it
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
488 // out to avoid a warning and increase the pointer manually.
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
489 //
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
490 // OCT_PQ_DECL_GET_INT32(hasnull, p, int32_t)
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
491 p += 4;
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11644
diff changeset
492 //
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
493 // element OID
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
494 OCT_PQ_DECL_GET_INT32(oid, p, uint32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
495
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
496 // check element OID
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
497 if (oid != conv->oid)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
498 {
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
499 error ("element oid %i sent by server does not match element oid %i expected for array with oid %i",
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
500 oid, conv->oid, conv->aoid);
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
501 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
502 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
503
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
504 // dims, lbounds
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
505 dim_vector dv;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
506 dv.resize (ndim, 0); // ndim < 2 is treated as ndim == 2
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
507 if (ndim == 1)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
508 dv(1) = 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
509
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
510 RowVector lbounds (ndim);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
511
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
512 for (int i = 0; i < ndim; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
513 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
514 OCT_PQ_GET_INT32(dv(i), p, int32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
515 OCT_PQ_GET_INT32(lbounds(i), p, int32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
516 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
517 //
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
518
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
519 // elements
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
520 octave_idx_type nl = dv.numel ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
521 Cell c (dv);
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
522 oct_mo_count_state state;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
523 count_row_major_order (dv, state, true); // initialize counter
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
524 for (int i = 0, ti = 0; ti < nl;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
525 ti++, i = count_row_major_order (dv, state, false))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
526 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
527 OCT_PQ_DECL_GET_INT32(null_id, p, int32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
528 if (null_id == -1)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
529 // NULL
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
530 c(i) = octave_value (octave_NA);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
531 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
532 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
533 uint32_t nb_el = uint32_t (null_id);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
534
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
535 octave_value ov_el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
536
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
537 if (conv->is_composite)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
538 {
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
539 if (to_octave_bin_composite (conn, p, ov_el, nb_el, conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
540 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
541 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
542 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
543 {
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
544 if (conv->to_octave_bin (conn, p, ov_el, nb_el))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
545 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
546 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
547
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
548 p += nb_el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
549
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
550 c(i) = ov_el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
551 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
552 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
553
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
554 octave_scalar_map m;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
555 m.assign ("data", octave_value (c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
556 m.assign ("ndims", octave_value (ndim));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
557 m.assign ("lbounds", octave_value (lbounds));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
558
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
559 ov = octave_value (m);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
560
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
561 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
562 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
563
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
564 int to_octave_bin_composite (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
565 const char *v, octave_value &ov, int nb,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
566 oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
567 {
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
568 const char *p = v;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
569
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
570 // ncols
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
571 OCT_PQ_DECL_GET_INT32(nl, p, int32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
572
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
573 // elements
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
574 Cell c (nl, 1);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
575 for (int i = 0; i < nl; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
576 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
577 // element OID
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
578 OCT_PQ_DECL_GET_INT32(oid, p, uint32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
579
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
580 OCT_PQ_DECL_GET_INT32(null_id, p, int32_t)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
581
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
582 if (null_id == -1)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
583 // NULL
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
584 c(i) = octave_value (octave_NA);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
585 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
586 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
587 uint32_t nb_el = uint32_t (null_id);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
588
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
589 oct_pq_conv_t *el_conv;
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
590 pq_oct_type_t oct_type;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
591
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
592 if (! (el_conv = pgtype_from_spec (conn, oid, conv->conv_cache[i],
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
593 oct_type)))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
594 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
595
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
596 octave_value el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
597 switch (oct_type)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
598 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
599 case simple:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
600 if (el_conv->to_octave_bin (conn, p, el, nb_el))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
601 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
602 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
603
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
604 case array:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
605 if (to_octave_bin_array (conn, p, el, nb_el, el_conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
606 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
607 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
608
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
609 case composite:
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11646
diff changeset
610 if (to_octave_bin_composite (conn, p, el, nb_el, el_conv))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
611 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
612 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
613
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
614 default:
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
615 // should not get here
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
616 error ("internal error, undefined type identifier");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
617 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
618 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
619
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
620 p += nb_el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
621
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
622 c(i) = el;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
623 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
624 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
625
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
626 ov = octave_value (c);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
627
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
628 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
629 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
630
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
631
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
632 int to_octave_str_array (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
633 const char *v, octave_value &ov, int nb,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
634 oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
635 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
636 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
637 error ("not implemented");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
638 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
639
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
640 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
641 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
642
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
643 int to_octave_str_composite (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
644 const char *v, octave_value &ov, int nb,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11657
diff changeset
645 oct_pq_conv_t *conv)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
646 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
647 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
648 error ("not implemented");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
649 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
650
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
651 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
652 }