Mercurial > forge
annotate main/database/src/converters_arr_comp.cc @ 12718:1af86934c14e octave-forge
Make compatible with Octaves new exception-based error handling.
Retain compatibility with Octaves old error handling based on
error_state.
* src/error_helpers.[h,cc]: Added.
* src/Makefile.in: Integrate error-helpers.[h,cc].
* src/config.h.in: Added.
* configure.ac, src/config.h.in: Test presence of 'error_state' and
presence of 'verror (octave_execution_exception&, const char *,
va_list)'.
* src/__pq_connect__.cc, src/command.cc, src/command.h,
src/converters.cc, src/converters_arr_comp.cc, src/pq_connection.cc,
src/pq_conninfo.cc, src/pq_exec.cc, src/pq_lo.cc,
src/pq_update_types.cc: If necessary, include error-helpers.h, replace
error() with c_verror(), set and check a different error indicator
than error_state, use CHECK_ERROR or SET_ERR, explicitely check for
errors instead of relying on Octave checking error_state when
returning to the prompt.
author | i7tiol |
---|---|
date | Sat, 27 Feb 2016 11:11:04 +0000 |
parents | 2257648e8ce1 |
children | 52ca082757c2 |
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" |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
29 #include "error-helpers.h" |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
30 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
31 #define ERROR_RETURN_NO_PG_TYPE \ |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
32 { \ |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
33 c_verror ("could not determine postgresql type for Octave parameter"); \ |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
34 return NULL; \ |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
35 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
36 |
12612 | 37 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
|
38 std::string &name, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
39 pq_oct_type_t &oct_type) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
40 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
41 oct_pq_conv_t *conv = NULL; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
42 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
43 // printf ("pgtype_from_spec(%s): simple ", name.c_str ()); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
44 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
45 oct_type = simple; // default |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
46 int l; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
47 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
|
48 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
49 name.erase (l, 2); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
50 oct_type = array; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
51 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
52 // printf ("array "); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
53 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
54 |
11714 | 55 oct_pq_name_conv_map_t::const_iterator iter; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
56 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
57 if ((iter = conn.name_conv_map.find (name.c_str ())) == |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
58 conn.name_conv_map.end ()) |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
59 { |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
60 c_verror ("no converter found for type %s", |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
61 name.c_str ()); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
62 return NULL; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
63 } |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
64 else |
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 // printf ("(looked up in name map) "); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
67 |
11714 | 68 conv = iter->second.get_copy (); |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
69 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
70 if (oct_type == array && ! conv->aoid) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
71 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
72 c_verror ("%s: internal error, type %s, specified as array, has no array type in system catalog", name.c_str ()); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
73 return NULL; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
74 } |
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 if (! (oct_type == array) && conv->is_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 oct_type = composite; |
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 ("composite "); |
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 } |
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 // printf ("\n"); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
85 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
86 return conv; |
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 |
12612 | 89 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
|
90 pq_oct_type_t &oct_type) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
91 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
92 // printf ("pgtype_from_spec(%u): ", oid); |
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 oct_pq_conv_t *conv = NULL; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
95 |
11714 | 96 oct_pq_conv_map_t::const_iterator iter; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
97 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
98 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
|
99 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
100 c_verror ("no converter found for element oid %u", oid); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
101 return NULL; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
102 } |
11714 | 103 conv = iter->second.get_copy (); |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
104 // 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
|
105 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
106 if (conv->aoid == oid) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
107 oct_type = array; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
108 else if (conv->is_composite) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
109 oct_type = composite; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
110 else |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
111 oct_type = simple; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
112 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
113 // printf ("oct_type: %i\n", oct_type); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
114 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
115 return conv; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
116 } |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
117 |
12612 | 118 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
|
119 oct_pq_conv_t *&c_conv, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
120 pq_oct_type_t &oct_type) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
121 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
122 if (c_conv) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
123 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
124 if (c_conv->aoid == oid) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
125 oct_type = array; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
126 else if (c_conv->is_composite) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
127 oct_type = composite; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
128 else |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
129 oct_type = simple; |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
130 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
131 else |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
132 c_conv = pgtype_from_spec (conn, oid, oct_type); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
133 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
134 return c_conv; |
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 |
12612 | 137 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
|
138 const octave_value ¶m) |
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 ("pgtype_from_octtype: "); |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
141 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
142 if (param.is_bool_scalar ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
143 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
144 // printf ("bool\n"); |
11714 | 145 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
|
146 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
147 else if (param.is_real_scalar ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
148 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
149 if (param.is_double_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
150 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
151 // printf ("float8\n"); |
11714 | 152 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
|
153 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
154 else if (param.is_single_type ()) |
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 // printf ("float4\n"); |
11714 | 157 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
|
158 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
159 } |
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 if (param.is_scalar_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
162 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
163 if (param.is_int16_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
164 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
165 // printf ("int2\n"); |
11714 | 166 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
|
167 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
168 else if (param.is_int32_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
169 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
170 // printf ("int4\n"); |
11714 | 171 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
|
172 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
173 else if (param.is_int64_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
174 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
175 // printf ("int8\n"); |
11714 | 176 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
|
177 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
178 else if (param.is_uint32_type ()) |
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 // printf ("oid\n"); |
11714 | 181 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
|
182 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
183 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
184 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
185 if (param.is_uint8_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
186 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
187 // printf ("bytea\n"); |
11714 | 188 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
|
189 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
190 else if (param.is_string ()) |
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 // printf ("text\n"); |
11714 | 193 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
|
194 } |
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 // 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
|
197 // still be needed if strings were not recognized above |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
198 if (param.is_real_type ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
199 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
200 switch (param.numel ()) |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
201 { |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
202 case 2: |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
203 // printf ("point\n"); |
11714 | 204 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
|
205 case 3: |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
206 // printf ("circle\n"); |
11714 | 207 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
|
208 case 4: |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
209 // printf ("lseg\n"); |
11714 | 210 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
|
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 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
214 ERROR_RETURN_NO_PG_TYPE |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
215 } |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
216 |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
217 octave_idx_type count_row_major_order (dim_vector &dv, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
218 oct_mo_count_state &state, bool init) |
11394
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 if (init) |
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.nd = dv.length (); |
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 state.cur.resize (state.nd); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
225 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
226 state.pd.resize (state.nd); |
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 // cannot be done with resize in multiple initializations |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
229 // (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
|
230 for (octave_idx_type i = 0; i < state.nd; i++) |
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 state.cur(i) = 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
233 state.pd(i) = 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
234 } |
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 for (octave_idx_type i = 0; i < state.nd - 1; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
237 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
238 state.pd(i + 1) = state.pd(i) * dv(i); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
239 } |
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 return 0; |
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 else |
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 nd = state.nd; |
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 if (nd > 0) |
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 octave_idx_type ret = 0; |
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 state.cur(nd - 1)++; |
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 for (octave_idx_type i = nd - 1; i > 0; i--) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
254 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
255 if (state.cur(i) == dv(i)) |
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 state.cur(i) = 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
258 state.cur(i - 1)++; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
261 ret += state.cur(i) * state.pd(i); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
262 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
263 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
264 if (state.cur(0) == dv(0)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
265 ret = -1; // signals overflow |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
266 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
267 ret += state.cur(0) * state.pd(0); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
268 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
269 return ret; |
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 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
272 return -1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
273 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
274 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
275 |
12612 | 276 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
|
277 const octave_value &oct_arr, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
278 oct_pq_dynvec_t &val, oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
279 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
280 octave_scalar_map m; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
281 bool err; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
282 SET_ERR (m= oct_arr.scalar_map_value (), err); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
283 if (err) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
284 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
285 c_verror ("Postgresql array parameter no Octave structure"); |
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 if (! m.isfield ("ndims") || ! m.isfield ("data")) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
290 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
291 c_verror ("field 'ndims' or 'data' missing in parameter for Postgresql array"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
292 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
293 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
294 |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
295 octave_idx_type nd_pq; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
296 SET_ERR (nd_pq = m.contents ("ndims").int_value (), err); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
297 |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
298 Cell arr; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
299 if (! err) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
300 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
301 SET_ERR (arr = m.contents ("data").cell_value (), err); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
302 } |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
303 if (err || nd_pq < 0) |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
304 { |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
305 c_verror ("'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
|
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 RowVector lb; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
310 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
311 // Are lbounds given? |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
312 if (m.isfield ("lbounds")) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
313 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
314 SET_ERR (lb = m.contents ("lbounds").row_vector_value (), err); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
315 if (err) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
316 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
317 c_verror ("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
|
318 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
319 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
320 } |
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 octave_idx_type nl = arr.numel (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
323 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
324 // dimensions of Octaves representation of postgresql array |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
325 dim_vector d = arr.dims (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
326 d.chop_trailing_singletons (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
327 int nd_oct = d.length (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
328 if (nd_oct == 2 && d(1) == 1) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
329 nd_oct = 1; |
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 // check dimensions |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
332 if (nd_oct > nd_pq) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
333 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
334 c_verror ("given representation of postgresql array has more dimensions than specified"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
335 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
336 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
337 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
338 // check lbounds |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
339 if (nd_pq > 0 && lb.is_empty ()) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
340 lb.resize (nd_pq, 1); // fill with 1 |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
341 else if (lb.numel () != nd_pq) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
342 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
343 c_verror ("number of specified enumeration bases for array does not match specified number of dimensions"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
344 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
345 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
346 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
347 // ndim |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
348 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nd_pq)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
349 // 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
|
350 // is really necessary |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
351 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) 1)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
352 // element OID |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
353 OCT_PQ_PUT(val, uint32_t, htobe32 ((uint32_t) conv->oid)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
354 // dims, lbounds |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
355 for (int i = 0; i < nd_pq; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
356 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
357 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
|
358 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) lb(i))) |
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 // elements |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
361 oct_mo_count_state state; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
362 count_row_major_order (d, state, true); // initialize counter |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
363 for (int i = 0, ti = 0; ti < nl; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
364 ti++, i = count_row_major_order (d, state, false)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
365 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
366 if (arr(i).is_real_scalar () && arr(i).isna ().bool_value ()) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
367 // 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
|
368 // set (while this has all bits set) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
369 { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
370 else |
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 OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
373 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
374 if (conv->is_composite) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
375 { |
11657 | 376 if (from_octave_bin_composite (conn, arr(i), val, conv)) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
377 return 1; |
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 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
380 { |
11657 | 381 if (conv->from_octave_bin (conn, arr(i), val)) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
382 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
383 } |
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 OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
386 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
387 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
388 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
389 return 0; |
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 |
12612 | 392 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
|
393 const octave_value &oct_comp, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
394 oct_pq_dynvec_t &val, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
395 oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
396 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
397 Cell rec; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
398 bool err; |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
399 SET_ERR (rec = oct_comp.cell_value (), err); |
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
400 if (err) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
401 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
402 c_verror ("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
|
403 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
404 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
405 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
406 octave_idx_type nl = rec.numel (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
407 |
11645
bd5a8f1bdfb8
Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents:
11644
diff
changeset
|
408 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
|
409 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
410 c_verror ("Octaves representation of a composite type has incorrect number of elements (%i, should have %i)", |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
411 nl, conv->el_oids.size ()); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
412 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
413 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
416 // ncols |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
417 OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nl)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
418 // elements |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
419 for (int i = 0; i < nl; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
420 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
421 // 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
|
422 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
|
423 if (rec(i).is_real_scalar () && rec(i).isna ().bool_value ()) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
424 // 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
|
425 // set (while this has all bits set) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
426 { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
427 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
428 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
429 OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
430 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
431 oct_pq_conv_t *el_conv; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
432 pq_oct_type_t oct_type; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
433 |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
434 if (! (el_conv = pgtype_from_spec (conn, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
435 conv->el_oids[i], |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
436 conv->conv_cache[i], |
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
437 oct_type))) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
438 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
439 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
440 switch (oct_type) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
441 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
442 case simple: |
11657 | 443 if (el_conv->from_octave_bin (conn, rec(i), val)) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
444 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
445 break; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
446 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
447 case array: |
11657 | 448 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
|
449 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
450 break; |
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 case composite: |
11657 | 453 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
|
454 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
455 break; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
456 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
457 default: |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
458 // should not get here |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
459 c_verror ("internal error, undefined type identifier"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
460 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
461 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
462 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
463 OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
464 } |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
467 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
468 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
469 |
12612 | 470 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
|
471 const octave_value &oct_arr, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
472 oct_pq_dynvec_t &val, octave_value &type) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
473 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
474 // not implemented |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
475 c_verror ("not implemented"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
476 return 1; |
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 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
479 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
480 |
12612 | 481 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
|
482 const octave_value &oct_comp, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
483 oct_pq_dynvec_t &val, |
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
484 octave_value &type) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
485 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
486 // not implemented |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
487 c_verror ("not implemented"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
488 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
489 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
490 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
491 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
492 |
12612 | 493 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
|
494 const char *v, octave_value &ov, int nb, |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
495 oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
496 { |
11715
ed5361361a0f
Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents:
11714
diff
changeset
|
497 const char *p = v; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
498 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
499 // ndim |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
500 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
|
501 // 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
|
502 // 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
|
503 // |
bd5a8f1bdfb8
Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents:
11644
diff
changeset
|
504 // OCT_PQ_DECL_GET_INT32(hasnull, p, int32_t) |
bd5a8f1bdfb8
Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents:
11644
diff
changeset
|
505 p += 4; |
bd5a8f1bdfb8
Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents:
11644
diff
changeset
|
506 // |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
507 // element OID |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
508 OCT_PQ_DECL_GET_INT32(oid, p, uint32_t) |
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 // check element OID |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
511 if (oid != conv->oid) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
512 { |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
513 c_verror ("element oid %i sent by server does not match element oid %i expected for array with oid %i", |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
514 oid, conv->oid, conv->aoid); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
515 return 1; |
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 // dims, lbounds |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
519 dim_vector dv; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
520 dv.resize (ndim, 0); // ndim < 2 is treated as ndim == 2 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
521 if (ndim == 1) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
522 dv(1) = 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
523 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
524 RowVector lbounds (ndim); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
525 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
526 for (int i = 0; i < ndim; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
527 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
528 OCT_PQ_GET_INT32(dv(i), p, int32_t) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
529 OCT_PQ_GET_INT32(lbounds(i), p, int32_t) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
530 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
531 // |
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 // elements |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
534 octave_idx_type nl = dv.numel (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
535 Cell c (dv); |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
536 oct_mo_count_state state; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
537 count_row_major_order (dv, state, true); // initialize counter |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
538 for (int i = 0, ti = 0; ti < nl; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
539 ti++, i = count_row_major_order (dv, state, false)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
540 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
541 OCT_PQ_DECL_GET_INT32(null_id, p, int32_t) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
542 if (null_id == -1) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
543 // NULL |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
544 c(i) = octave_value (octave_NA); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
545 else |
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 uint32_t nb_el = uint32_t (null_id); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
548 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
549 octave_value ov_el; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
550 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
551 if (conv->is_composite) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
552 { |
11657 | 553 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
|
554 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
555 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
556 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
557 { |
11657 | 558 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
|
559 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
562 p += nb_el; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
563 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
564 c(i) = ov_el; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
565 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
566 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
567 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
568 octave_scalar_map m; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
569 m.assign ("data", octave_value (c)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
570 m.assign ("ndims", octave_value (ndim)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
571 m.assign ("lbounds", octave_value (lbounds)); |
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 ov = octave_value (m); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
574 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
575 return 0; |
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 |
12612 | 578 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
|
579 const char *v, octave_value &ov, int nb, |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
580 oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
581 { |
11715
ed5361361a0f
Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents:
11714
diff
changeset
|
582 const char *p = v; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
583 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
584 // ncols |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
585 OCT_PQ_DECL_GET_INT32(nl, p, int32_t) |
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 // elements |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
588 Cell c (nl, 1); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
589 for (int i = 0; i < nl; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
590 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
591 // element OID |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
592 OCT_PQ_DECL_GET_INT32(oid, p, uint32_t) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
593 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
594 OCT_PQ_DECL_GET_INT32(null_id, p, int32_t) |
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 if (null_id == -1) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
597 // NULL |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
598 c(i) = octave_value (octave_NA); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
599 else |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
600 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
601 uint32_t nb_el = uint32_t (null_id); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
602 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
603 oct_pq_conv_t *el_conv; |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
604 pq_oct_type_t oct_type; |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
605 |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
606 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
|
607 oct_type))) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
608 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
609 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
610 octave_value el; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
611 switch (oct_type) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
612 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
613 case simple: |
11657 | 614 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
|
615 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
616 break; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
617 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
618 case array: |
11657 | 619 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
|
620 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
621 break; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
622 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
623 case composite: |
11657 | 624 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
|
625 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
626 break; |
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 default: |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
629 // should not get here |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
630 c_verror ("internal error, undefined type identifier"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
631 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
632 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
633 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
634 p += nb_el; |
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 c(i) = el; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
637 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
638 } |
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 ov = octave_value (c); |
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 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
643 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
644 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
645 |
12612 | 646 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
|
647 const char *v, octave_value &ov, int nb, |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
648 oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
649 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
650 // not implemented |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
651 c_verror ("not implemented"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
652 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
653 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
654 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
655 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
656 |
12612 | 657 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
|
658 const char *v, octave_value &ov, int nb, |
11713
ee2b22964070
Make some functions of class 'command' non-members.
i7tiol
parents:
11657
diff
changeset
|
659 oct_pq_conv_t *conv) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
660 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
661 // not implemented |
12718
1af86934c14e
Make compatible with Octaves new exception-based error handling.
i7tiol
parents:
12612
diff
changeset
|
662 c_verror ("not implemented"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
663 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
664 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
665 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
666 } |