Mercurial > forge
annotate main/database/src/converters.cc @ 11655:6bbb1584d933 octave-forge
More efficient code order in float converters (probably useless with -O0).
Some more explanations in timeformat notes.
author | i7tiol |
---|---|
date | Sat, 27 Apr 2013 08:19:00 +0000 |
parents | bd5a8f1bdfb8 |
children | d38859613a53 |
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-float.h> |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
22 #include <octave/ov-uint8.h> |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
23 |
11553
35e9e4b6ab34
Fix configuration of postgresql include directories.
i7tiol
parents:
11480
diff
changeset
|
24 #include <libpq-fe.h> |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
25 // FIXME: needed for NAMEDATALEN, but defining a lot of stuff which |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
26 // might conflict with names here |
11553
35e9e4b6ab34
Fix configuration of postgresql include directories.
i7tiol
parents:
11480
diff
changeset
|
27 #include <pg_config_manual.h> |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
28 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
29 #include "converters.h" |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
30 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
31 // remember to adjust OCT_PQ_NUM_CONVERTERS in converters.h |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
32 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
33 // helper function for debugging |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
34 void print_conv (oct_pq_conv_t *c) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
35 { |
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:
11429
diff
changeset
|
36 printf ("oid: %u, aoid: %u, c: %i, e: %i, nc: %i, n: %s, to_s: %i, to_b: %i, fr_s: %i, fr_b: %i,", |
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:
11429
diff
changeset
|
37 c->oid, c->aoid, c->is_composite, c->is_enum, c->is_not_constant, c->name.c_str (), c->to_octave_str ? 1 : 0, c->to_octave_bin ? 1 : 0, c->from_octave_str ? 1 : 0, c->from_octave_bin ? 1 : 0); |
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:
11429
diff
changeset
|
38 |
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:
11429
diff
changeset
|
39 printf (", el_oids:"); |
11645
bd5a8f1bdfb8
Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents:
11553
diff
changeset
|
40 for (size_t i = 0; i < c->el_oids.size (); i++) |
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:
11429
diff
changeset
|
41 printf (" %u", c->el_oids[i]); |
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:
11429
diff
changeset
|
42 |
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:
11429
diff
changeset
|
43 printf ("\n"); |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
44 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
45 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
46 /* type bool */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
47 |
11409 | 48 int to_octave_str_bool (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
49 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
50 bool tp = (*c == 't' ? true : false); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
51 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
52 ov = octave_value (tp); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
53 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
54 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
55 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
56 |
11409 | 57 int to_octave_bin_bool (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
58 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
59 ov = octave_value (bool (*c)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
60 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
61 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
62 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
63 |
11407 | 64 int from_octave_str_bool (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
65 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
66 bool b = ov.bool_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
67 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
68 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
69 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
70 error ("can not convert octave_value to bool value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
71 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
72 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
73 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
74 val.push_back (b ? '1' : '0'); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
75 val.push_back ('\0'); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
76 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
77 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
78 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
79 |
11407 | 80 int from_octave_bin_bool (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
81 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
82 bool b = ov.bool_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
83 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
84 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
85 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
86 error ("can not convert octave_value to bool value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
87 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
88 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
89 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
90 val.push_back (char (b)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
91 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
92 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
93 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
94 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
95 oct_pq_conv_t conv_bool = {0, // 16 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
96 0, // 1000 |
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:
11429
diff
changeset
|
97 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
98 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
99 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
100 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
101 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
102 "bool", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
103 &to_octave_str_bool, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
104 &to_octave_bin_bool, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
105 &from_octave_str_bool, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
106 &from_octave_bin_bool}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
107 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
108 /* end type bool */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
109 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
110 /* type oid */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
111 |
11409 | 112 int to_octave_str_oid (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
113 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
114 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
115 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
116 |
11409 | 117 int to_octave_bin_oid (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
118 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
119 ov = octave_value (octave_uint32 (be32toh (*((uint32_t *) c)))); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
120 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
121 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
122 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
123 |
11407 | 124 int from_octave_str_oid (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
125 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
126 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
127 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
128 |
11407 | 129 int from_octave_bin_oid (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
130 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
131 uint32_t oid = ov.uint_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
132 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
133 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
134 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
135 error ("can not convert octave_value to oid value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
136 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
137 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
138 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
139 OCT_PQ_PUT(val, uint32_t, htobe32 (oid)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
140 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
141 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
142 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
143 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
144 oct_pq_conv_t conv_oid = {0, // 26 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
145 0, |
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:
11429
diff
changeset
|
146 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
147 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
148 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
149 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
150 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
151 "oid", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
152 &to_octave_str_oid, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
153 &to_octave_bin_oid, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
154 &from_octave_str_oid, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
155 &from_octave_bin_oid}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
156 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
157 /* end type oid */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
158 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
159 /* type float8 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
160 |
11409 | 161 int to_octave_str_float8 (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
162 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
163 // not implemented |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
164 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
165 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
166 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
167 |
11409 | 168 int to_octave_bin_float8 (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
169 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
170 union |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
171 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
172 double d; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
173 int64_t i; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
174 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
175 swap; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
176 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
177 swap.i = be64toh (*((int64_t *) c)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
178 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
179 ov = octave_value (swap.d); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
180 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
181 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
182 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
183 |
11407 | 184 int from_octave_str_float8 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
185 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
186 // not implemented |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
187 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
188 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
189 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
190 |
11407 | 191 int from_octave_bin_float8 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
192 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
193 union |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
194 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
195 double d; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
196 int64_t i; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
197 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
198 swap; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
199 |
11655
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
200 swap.d = ov.double_value (); |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
201 |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
202 if (error_state) |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
203 { |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
204 error ("can not convert octave_value to float8 value"); |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
205 return 1; |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
206 } |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
207 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
208 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
209 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
210 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
211 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
212 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
213 oct_pq_conv_t conv_float8 = {0, // 701 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
214 0, // 1022 |
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:
11429
diff
changeset
|
215 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
216 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
217 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
218 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
219 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
220 "float8", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
221 &to_octave_str_float8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
222 &to_octave_bin_float8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
223 &from_octave_str_float8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
224 &from_octave_bin_float8}; |
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 /* end type float8 */ |
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 /* type float4 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
229 |
11409 | 230 int to_octave_str_float4 (const char *c, octave_value &ov, int nb) |
11394
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 // not implemented |
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 return 1; |
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 |
11409 | 237 int to_octave_bin_float4 (const char *c, octave_value &ov, int nb) |
11394
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 union |
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 float f; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
242 int32_t i; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
243 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
244 swap; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
245 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
246 swap.i = be32toh (*((int32_t *) c)); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
247 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
248 ov = octave_value (swap.f); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
249 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
250 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
251 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
252 |
11407 | 253 int from_octave_str_float4 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
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 // not implemented |
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 return 1; |
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 |
11407 | 260 int from_octave_bin_float4 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
261 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
262 union |
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 float f; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
265 int32_t i; |
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 swap; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
268 |
11655
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
269 swap.f = ov.float_value (); |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
270 |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
271 if (error_state) |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
272 { |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
273 error ("can not convert octave_value to float4 value"); |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
274 return 1; |
6bbb1584d933
More efficient code order in float converters (probably useless with -O0).
i7tiol
parents:
11645
diff
changeset
|
275 } |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
276 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
277 OCT_PQ_PUT(val, int32_t, htobe32 (swap.i)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
278 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
279 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
280 } |
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 oct_pq_conv_t conv_float4 = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
283 0, |
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:
11429
diff
changeset
|
284 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
285 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
286 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
287 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
288 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
289 "float4", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
290 &to_octave_str_float4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
291 &to_octave_bin_float4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
292 &from_octave_str_float4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
293 &from_octave_bin_float4}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
294 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
295 /* end type float4 */ |
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 /* type bytea */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
298 |
11409 | 299 int to_octave_str_bytea (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
300 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
301 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
302 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
303 |
11409 | 304 int to_octave_bin_bytea (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
305 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
306 uint8NDArray m (dim_vector (nb, 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 uint8_t *p = (uint8_t *) m.fortran_vec (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
309 for (octave_idx_type i = 0; i < nb; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
310 *(p++) = uint8_t (*(c++)); |
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 ov = octave_value (m); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
313 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
314 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
315 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
316 |
11407 | 317 int from_octave_str_bytea (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
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 return 1; |
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 |
11407 | 322 int from_octave_bin_bytea (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
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 uint8NDArray b = ov.uint8_array_value (); |
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 if (! error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
327 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
328 dim_vector dv = b.dims (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
329 if (dv.length () > 2 || (dv(0) > 1 && dv(1) > 1)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
330 error ("bytea representation must be one-dimensional"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
331 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
332 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
333 if (error_state) |
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 error ("can not convert octave_value to bytea representation"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
336 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
339 octave_idx_type nl = b.numel (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
340 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
341 for (int i = 0; i < nl; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
342 val.push_back (b(i).value ()); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
343 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
344 return 0; |
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 oct_pq_conv_t conv_bytea = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
348 0, |
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:
11429
diff
changeset
|
349 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
350 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
351 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
352 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
353 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
354 "bytea", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
355 &to_octave_str_bytea, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
356 &to_octave_bin_bytea, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
357 &from_octave_str_bytea, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
358 &from_octave_bin_bytea}; |
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 /* end type bytea */ |
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 /* type text */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
363 |
11409 | 364 int to_octave_str_text (const char *c, octave_value &ov, int nb) |
11394
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 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
367 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
368 |
11409 | 369 int to_octave_bin_text (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
370 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
371 std::string s (c, nb); |
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 ov = octave_value (s); |
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 return 0; |
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 |
11407 | 378 int from_octave_str_text (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
379 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
380 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
381 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
382 |
11407 | 383 int from_octave_bin_text (const octave_value &ov, oct_pq_dynvec_t &val) |
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 std::string s = ov.string_value (); |
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 if (error_state) |
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 error ("can not convert octave_value to string"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
390 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
393 octave_idx_type l = s.size (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
394 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
395 for (int i = 0; i < l; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
396 val.push_back (s[i]); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
397 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
398 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
399 } |
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 oct_pq_conv_t conv_text = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
402 0, |
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:
11429
diff
changeset
|
403 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
404 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
405 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
406 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
407 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
408 "text", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
409 &to_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
410 &to_octave_bin_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
411 &from_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
412 &from_octave_bin_text}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
413 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
414 /* end type text */ |
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 /* type varchar */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
417 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
418 oct_pq_conv_t conv_varchar = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
419 0, |
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:
11429
diff
changeset
|
420 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
421 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
422 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
423 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
424 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
425 "varchar", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
426 &to_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
427 &to_octave_bin_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
428 &from_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
429 &from_octave_bin_text}; |
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 /* end type varchar */ |
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 /* type bpchar */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
434 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
435 oct_pq_conv_t conv_bpchar = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
436 0, |
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:
11429
diff
changeset
|
437 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
438 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
439 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
440 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
441 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
442 "bpchar", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
443 &to_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
444 &to_octave_bin_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
445 &from_octave_str_text, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
446 &from_octave_bin_text}; |
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 /* end type bpchar */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
449 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
450 /* type name */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
451 |
11409 | 452 int to_octave_str_name (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
453 { |
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 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
456 |
11409 | 457 int to_octave_bin_name (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
458 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
459 // FIXME: should we check the string in c? |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
460 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
461 std::string s (c, nb); |
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 ov = octave_value (s); |
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 return 0; |
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 |
11407 | 468 int from_octave_str_name (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
469 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
470 return 1; |
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 |
11407 | 473 int from_octave_bin_name (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
474 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
475 std::string s = ov.string_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
476 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
477 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
478 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
479 error ("can not convert octave_value to string"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
480 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
481 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
482 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
483 octave_idx_type l = s.size (); |
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 if (l >= NAMEDATALEN) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
486 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
487 error ("identifier too long, must be less than %d characters", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
488 NAMEDATALEN); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
489 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
490 } |
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 for (int i = 0; i < l; i++) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
493 val.push_back (s[i]); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
494 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
495 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
496 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
497 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
498 oct_pq_conv_t conv_name = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
499 0, |
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:
11429
diff
changeset
|
500 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
501 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
502 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
503 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
504 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
505 "name", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
506 &to_octave_str_name, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
507 &to_octave_bin_name, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
508 &from_octave_str_name, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
509 &from_octave_bin_name}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
510 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
511 /* end type name */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
512 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
513 /* type int2 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
514 |
11409 | 515 int to_octave_str_int2 (const char *c, octave_value &ov, int nb) |
11394
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 return 1; |
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 |
11409 | 520 int to_octave_bin_int2 (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
521 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
522 ov = octave_value (octave_int16 (int16_t (be16toh (*((int16_t *) c))))); |
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 return 0; |
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 |
11407 | 527 int from_octave_str_int2 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
528 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
529 return 1; |
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 |
11407 | 532 int from_octave_bin_int2 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
533 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
534 int16_t i2 = ov.int_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
535 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
536 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
537 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
538 error ("can not convert octave_value to int2 value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
539 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
542 OCT_PQ_PUT(val, int16_t, htobe16 (i2)) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
543 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
544 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
545 } |
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 oct_pq_conv_t conv_int2 = {0, // 26 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
548 0, |
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:
11429
diff
changeset
|
549 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
550 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
551 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
552 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
553 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
554 "int2", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
555 &to_octave_str_int2, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
556 &to_octave_bin_int2, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
557 &from_octave_str_int2, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
558 &from_octave_bin_int2}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
559 |
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 /* end type int2 */ |
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 /* type int4 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
564 |
11409 | 565 int to_octave_str_int4 (const char *c, octave_value &ov, int nb) |
11394
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 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
568 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
569 |
11409 | 570 int to_octave_bin_int4 (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
571 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
572 ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
573 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
574 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
575 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
576 |
11407 | 577 int from_octave_str_int4 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
578 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
579 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
580 } |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
581 |
11407 | 582 int from_octave_bin_int4 (const octave_value &ov, oct_pq_dynvec_t &val) |
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 int32_t i4 = ov.int_value (); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
585 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
586 if (error_state) |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
587 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
588 error ("can not convert octave_value to int4 value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
589 return 1; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
592 OCT_PQ_PUT(val, int32_t, htobe32 (i4)) |
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 return 0; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
597 oct_pq_conv_t conv_int4 = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
598 0, |
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:
11429
diff
changeset
|
599 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
600 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
601 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
602 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
603 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
604 "int4", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
605 &to_octave_str_int4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
606 &to_octave_bin_int4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
607 &from_octave_str_int4, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
608 &from_octave_bin_int4}; |
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 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
611 /* end type int4 */ |
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 /* type int8 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
614 |
11409 | 615 int to_octave_str_int8 (const char *c, octave_value &ov, int nb) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
616 { |
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 |
11409 | 620 int to_octave_bin_int8 (const char *c, octave_value &ov, int nb) |
11394
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 ov = octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c))))); |
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 return 0; |
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 |
11407 | 627 int from_octave_str_int8 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
628 { |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
629 return 1; |
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 |
11407 | 632 int from_octave_bin_int8 (const octave_value &ov, oct_pq_dynvec_t &val) |
11394
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 int64_t i8 = ov.int64_scalar_value (); |
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 if (error_state) |
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 error ("can not convert octave_value to int8 value"); |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
639 return 1; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
640 } |
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 OCT_PQ_PUT(val, int64_t, htobe64 (i8)) |
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 return 0; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
645 } |
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 oct_pq_conv_t conv_int8 = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
648 0, |
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:
11429
diff
changeset
|
649 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
650 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
651 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
652 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
653 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
654 "int8", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
655 &to_octave_str_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
656 &to_octave_bin_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
657 &from_octave_str_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
658 &from_octave_bin_int8}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
659 |
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 /* end type int8 */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
662 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
663 /* type money */ |
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 oct_pq_conv_t conv_money = {0, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
666 0, |
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:
11429
diff
changeset
|
667 oct_pq_el_oids_t (), |
11480
d14a23884d9c
Cache map lookups of converters for composite type elements.
i7tiol
parents:
11474
diff
changeset
|
668 oct_pq_conv_cache_t (), |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
669 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
670 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
671 false, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
672 "money", |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
673 &to_octave_str_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
674 &to_octave_bin_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
675 &from_octave_str_int8, |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
676 &from_octave_bin_int8}; |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
677 |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
678 /* end type money */ |
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
679 |
11429 | 680 oct_pq_conv_t *t_conv_ptrs[OCT_PQ_NUM_CONVERTERS] = {&conv_bool, |
681 &conv_oid, | |
682 &conv_float8, | |
683 &conv_float4, | |
684 &conv_text, | |
685 &conv_varchar, | |
686 &conv_bpchar, | |
687 &conv_name, | |
688 &conv_bytea, | |
689 &conv_int2, | |
690 &conv_int4, | |
691 &conv_int8, | |
692 &conv_money}; | |
693 | |
694 oct_pq_conv_ptrs_t conv_ptrs (OCT_PQ_NUM_CONVERTERS, t_conv_ptrs); |