Merge lp:~zorba-coders/zorba/bug1109853 into lp:zorba/jdbc-module
- bug1109853
- Merge into jdbc-module
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Chris Hillery | ||||
Approved revision: | 48 | ||||
Merged at revision: | 46 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug1109853 | ||||
Merge into: | lp:zorba/jdbc-module | ||||
Diff against target: |
406 lines (+78/-31) 9 files modified
include/javaids.h (+8/-0) include/jdbc.h (+1/-0) include/sqltypes.h (+2/-0) src/jdbc.xq (+25/-25) src/jdbc.xq.src/connection/connectionoptions.cpp (+0/-2) src/jdbc.xq.src/javaids.cpp (+7/-1) src/jdbc.xq.src/jdbc.cpp (+2/-0) src/jdbc.xq.src/jsonitemsequence.cpp (+16/-1) src/jdbc.xq.src/sqltypes.cpp (+17/-2) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug1109853 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rodolfo Ochoa | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+145525@code.launchpad.net |
Commit message
BLOB support added
Fixing error in documentation due line numbering
Description of the change
BLOB support added
Fixing error in documentation due line numbering
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug1109853-2013-01-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Pending.
Rodolfo Ochoa (rodolfo-ochoa) wrote : | # |
Sorry I added this later, I find out this problem when I was creating the paper.
Chris Hillery (ceejatec) wrote : | # |
Unless I'm missing something, the following if condition (and the corresponding block of code) is repeated twice in jsonitemsequenc
+ } else if (SQLTypes:
Also, what's the story behind the various new // **** and // ---- comments?
Chris Hillery (ceejatec) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug1109853 into lp:zorba/jdbc-module failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug1109853-2013-02-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Rodolfo Ochoa (rodolfo-ochoa) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug1109853 into lp:zorba/jdbc-module failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug1109853-2013-02-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug1109853-2013-02-
All tests succeeded!
Preview Diff
1 | === modified file 'include/javaids.h' |
2 | --- include/javaids.h 2013-01-05 01:04:21 +0000 |
3 | +++ include/javaids.h 2013-02-02 04:42:22 +0000 |
4 | @@ -77,6 +77,7 @@ |
5 | jmethodID getInt; |
6 | jmethodID getDouble; |
7 | jmethodID getString; |
8 | + jmethodID getBLOB; |
9 | }; |
10 | class JavaResultSetMetadata { |
11 | public: |
12 | @@ -120,6 +121,13 @@ |
13 | jmethodID getParameterClassName; |
14 | jmethodID getParameterType; |
15 | }; |
16 | +class JavaBlob { |
17 | +public: |
18 | + bool init(); |
19 | + jclass classID; |
20 | + jmethodID getBytes; |
21 | + jmethodID length; |
22 | +}; |
23 | |
24 | |
25 | }}; // namespace zorba, jdbc |
26 | |
27 | === modified file 'include/jdbc.h' |
28 | --- include/jdbc.h 2013-01-09 19:41:52 +0000 |
29 | +++ include/jdbc.h 2013-02-02 04:42:22 +0000 |
30 | @@ -51,6 +51,7 @@ |
31 | extern JavaResultSetMetadata jResultSetMetadata; |
32 | extern JavaPreparedStatement jPreparedStatement; |
33 | extern JavaParameterMetadata jParameterMetadata; |
34 | +extern JavaBlob jBlob; |
35 | extern bool isOutputJSON; |
36 | |
37 | #define CHECK_EXCEPTION if ((lException = env->ExceptionOccurred())) throw JavaException(); |
38 | |
39 | === modified file 'include/sqltypes.h' |
40 | --- include/sqltypes.h 2012-12-22 14:35:53 +0000 |
41 | +++ include/sqltypes.h 2013-02-02 04:42:22 +0000 |
42 | @@ -71,6 +71,8 @@ |
43 | static void init(); |
44 | static bool isInt(long lType); |
45 | static bool isFloat(long lType); |
46 | + static bool isString(long lType); |
47 | + static bool isBLOB(long lType); |
48 | |
49 | }; |
50 | |
51 | |
52 | === modified file 'src/jdbc.xq' |
53 | --- src/jdbc.xq 2013-01-09 19:59:40 +0000 |
54 | +++ src/jdbc.xq 2013-02-02 04:42:22 +0000 |
55 | @@ -57,7 +57,7 @@ |
56 | :) |
57 | |
58 | (:~ |
59 | - : 2.1 Opens a connection to a database. |
60 | + : Opens a connection to a database. |
61 | : Returns a URI identifying the connection that has been opened. The implementing code determines from the $connection-config either explicitly (interpreting the driver attribute) or implicitly (using the type attribute) which driver it has to load. |
62 | : |
63 | : @param $connection-config json object that has the host and user informations. |
64 | @@ -82,7 +82,7 @@ |
65 | $connection-config as object() ) as xs:anyURI external; |
66 | |
67 | (:~ |
68 | - : 2.1 Opens a connection to a database with specified options. |
69 | + : Opens a connection to a database with specified options. |
70 | : Returns a URI identifying the connection that has been opened. The implementing code determines from the $connection-config either explicitly (interpreting the driver attribute) or implicitly (using the type attribute) which driver it has to load. |
71 | : |
72 | : @param $connection-config json object that has the host and user informations. |
73 | @@ -121,7 +121,7 @@ |
74 | $options as object()?) as xs:anyURI external; |
75 | |
76 | (:~ |
77 | - : 2.2 Verify if a connection is still active. |
78 | + : Verify if a connection is still active. |
79 | : |
80 | : @param $connection-id The identifier to the connection to be verify. |
81 | : |
82 | @@ -134,7 +134,7 @@ |
83 | $connection-id as xs:anyURI) as xs:boolean external; |
84 | |
85 | (:~ |
86 | - : 2.3 Returns a set with options for a specified connection. |
87 | + : Returns a set with options for a specified connection. |
88 | : |
89 | : @param $connection-id The identifier to the connection to be verify. |
90 | : |
91 | @@ -158,7 +158,7 @@ |
92 | :) |
93 | |
94 | (:~ |
95 | - : 3.1 Commit current transaction from an active connection. |
96 | + : Commit current transaction from an active connection. |
97 | : |
98 | : @param $connection-id The identifier to the connection to be commited. |
99 | : |
100 | @@ -172,7 +172,7 @@ |
101 | $connection-id as xs:anyURI) as empty-sequence() external; |
102 | |
103 | (:~ |
104 | - : 3.2 Rollback the current transaction of a connection. |
105 | + : Rollback the current transaction of a connection. |
106 | : |
107 | : @param $connection-id The identifier to the connection to be rollbacked. |
108 | : |
109 | @@ -191,7 +191,7 @@ |
110 | :) |
111 | |
112 | (:~ |
113 | - : 4.1 Executes any kind of SQL statement. |
114 | + : Executes any kind of SQL statement. |
115 | : |
116 | : @param $connection-id The identifier to an active connection. |
117 | : @param $sql The query string to be executed. |
118 | @@ -207,7 +207,7 @@ |
119 | $sql as xs:string ) as xs:anyURI external; |
120 | |
121 | (:~ |
122 | - : 4.2 Executes non-updating SQL statements. |
123 | + : Executes non-updating SQL statements. |
124 | : |
125 | : @param $connection-id The identifier to an active connection. |
126 | : @param $sql The query string to be executed. |
127 | @@ -228,7 +228,7 @@ |
128 | $sql as xs:string) as object()* external; |
129 | |
130 | (:~ |
131 | - : 4.3 Executes updating SQL statements. |
132 | + : Executes updating SQL statements. |
133 | : |
134 | : @param $connection-id The identifier to an active connection. |
135 | : @param $sql The query string to be executed. |
136 | @@ -250,7 +250,7 @@ |
137 | :) |
138 | |
139 | (:~ |
140 | - : 5.1 Creates a prepared statement for multiple executions with diferent values. |
141 | + : Creates a prepared statement for multiple executions with diferent values. |
142 | : |
143 | : @param $connection-id The identifier to an active connection. |
144 | : @param $sql The query string to be executed. |
145 | @@ -269,7 +269,7 @@ |
146 | $sql as xs:string) as xs:anyURI external; |
147 | |
148 | (:~ |
149 | - : 5.2.1 Set the value of the designated parameter with the given value, this function will assign only numeric values. |
150 | + : Set the value of the designated parameter with the given value, this function will assign only numeric values. |
151 | : |
152 | : @param $prepared-statement The identifier to a prepared statement. |
153 | : @param $parameter-index The index from the parameter to be set. |
154 | @@ -288,7 +288,7 @@ |
155 | $value as xs:anyAtomicType) as empty-sequence() external; |
156 | |
157 | (:~ |
158 | - : 5.2.2 Set the value of the designated parameter with the given value, this function will assign only string values. |
159 | + : Set the value of the designated parameter with the given value, this function will assign only string values. |
160 | : |
161 | : @param $prepared-statement The identifier to a prepared statement. |
162 | : @param $parameter-index The index from the parameter to be set. |
163 | @@ -307,7 +307,7 @@ |
164 | $value as xs:string) as empty-sequence() external; |
165 | |
166 | (:~ |
167 | - : 5.2.3 Set the value of the designated parameter with the given value, this function will assign only boolean values. |
168 | + : Set the value of the designated parameter with the given value, this function will assign only boolean values. |
169 | : |
170 | : @param $prepared-statement The identifier to a prepared statement. |
171 | : @param $parameter-index The index from the parameter to be set. |
172 | @@ -326,7 +326,7 @@ |
173 | $value as xs:boolean) as empty-sequence() external; |
174 | |
175 | (:~ |
176 | - : 5.2.4 Set the value of the designated parameter with the given value, this function will assign only null values if possible. |
177 | + : Set the value of the designated parameter with the given value, this function will assign only null values if possible. |
178 | : |
179 | : @param $prepared-statement The identifier to a prepared statement. |
180 | : @param $parameter-index The index from the parameter to be set. |
181 | @@ -343,7 +343,7 @@ |
182 | $parameter-index as xs:integer) as empty-sequence() external; |
183 | |
184 | (:~ |
185 | - : 5.2.5 Set the value of the designated parameter with the given value, |
186 | + : Set the value of the designated parameter with the given value, |
187 | : this function will assign any value you send |
188 | : and it will try to cast to the correct type. |
189 | : |
190 | @@ -364,7 +364,7 @@ |
191 | $value as xs:anyAtomicType) as empty-sequence() external; |
192 | |
193 | (:~ |
194 | - : 5.3 Clears the current parameter values immediately. |
195 | + : Clears the current parameter values immediately. |
196 | : |
197 | : @param $prepared-statement The identifier to a prepared statement. |
198 | : |
199 | @@ -378,7 +378,7 @@ |
200 | $prepared-statement as xs:anyURI) as empty-sequence() external; |
201 | |
202 | (:~ |
203 | - : 5.4 Retrieves the number, types and properties of the prepared statement parameters. |
204 | + : Retrieves the number, types and properties of the prepared statement parameters. |
205 | : |
206 | : @param $prepared-statement The identifier to a prepared statement. |
207 | : |
208 | @@ -402,7 +402,7 @@ |
209 | $prepared-statement as xs:anyURI) as object() external; |
210 | |
211 | (:~ |
212 | - : 5.5 Executes SQL statements prepared with 5.1 jsql:prepare-statement with values set |
213 | + : Executes SQL statements prepared with 5.1 jsql:prepare-statement with values set |
214 | : and returns an identifier to a Dataset. |
215 | : |
216 | : @param $prepared-statement The identifier to a prepared statement. |
217 | @@ -417,7 +417,7 @@ |
218 | $prepared-statement as xs:anyURI) as xs:anyURI external; |
219 | |
220 | (:~ |
221 | - : 5.6 Executes a non-updating SQL statement prepared with 5.1 jsql:prepare-statement. |
222 | + : Executes a non-updating SQL statement prepared with 5.1 jsql:prepare-statement. |
223 | : |
224 | : @param $prepared-statement The identifier to a prepared statement. |
225 | : |
226 | @@ -435,7 +435,7 @@ |
227 | $prepared-statement as xs:anyURI) as object()* external; |
228 | |
229 | (:~ |
230 | - : 5.7 Executes an updating SQL statement prepared with 5.1 jsql:prepare-statement. |
231 | + : Executes an updating SQL statement prepared with 5.1 jsql:prepare-statement. |
232 | : |
233 | : @param $prepared-statement The identifier to a prepared statement. |
234 | : |
235 | @@ -450,7 +450,7 @@ |
236 | $prepared-statement as xs:anyURI) as xs:integer external; |
237 | |
238 | (:~ |
239 | - : 5.8 Closes and frees from memory any prepared SQL statement created with jdbc:prepare-statement |
240 | + : Closes and frees from memory any prepared SQL statement created with jdbc:prepare-statement |
241 | : |
242 | : @param $prepared-statement The identifier to a prepared statement. |
243 | : |
244 | @@ -469,7 +469,7 @@ |
245 | :) |
246 | |
247 | (:~ |
248 | - : 6.1 This function returns a sequence of objects representing the rows of data from a non-updating query. |
249 | + : This function returns a sequence of objects representing the rows of data from a non-updating query. |
250 | : |
251 | : @param $dataset-id The identifier to a DataSet. |
252 | : |
253 | @@ -486,7 +486,7 @@ |
254 | $dataset-id as xs:anyURI) as object()* external; |
255 | |
256 | (:~ |
257 | - : 6.2 Return the metadata of the result of a particular DataSet. |
258 | + : Return the metadata of the result of a particular DataSet. |
259 | : |
260 | : @param $dataset-id The identifier to a DataSet. |
261 | : |
262 | @@ -517,7 +517,7 @@ |
263 | $dataset-id as xs:anyURI) as object() external; |
264 | |
265 | (:~ |
266 | - : 6.3 Return the number of affected rows of a particular DataSet. |
267 | + : Return the number of affected rows of a particular DataSet. |
268 | : |
269 | : @param $dataset-id The identifier to a DataSet. |
270 | : |
271 | @@ -531,7 +531,7 @@ |
272 | $dataset-id as xs:anyURI) as xs:integer external; |
273 | |
274 | (:~ |
275 | - : 6.4 Closes and free resources from a particular DataSet. |
276 | + : Closes and free resources from a particular DataSet. |
277 | : |
278 | : @param $dataset-id The identifier to a DataSet. |
279 | : |
280 | |
281 | === modified file 'src/jdbc.xq.src/connection/connectionoptions.cpp' |
282 | --- src/jdbc.xq.src/connection/connectionoptions.cpp 2012-12-27 22:13:59 +0000 |
283 | +++ src/jdbc.xq.src/connection/connectionoptions.cpp 2013-02-02 04:42:22 +0000 |
284 | @@ -67,6 +67,4 @@ |
285 | return ItemSequence_t(new SingletonItemSequence(result)); |
286 | } |
287 | |
288 | - |
289 | - |
290 | }}; // namespace zorba, jdbc |
291 | |
292 | === modified file 'src/jdbc.xq.src/javaids.cpp' |
293 | --- src/jdbc.xq.src/javaids.cpp 2013-01-05 01:04:21 +0000 |
294 | +++ src/jdbc.xq.src/javaids.cpp 2013-02-02 04:42:22 +0000 |
295 | @@ -70,6 +70,7 @@ |
296 | getInt = env->GetMethodID(classID, "getInt", "(I)I"); |
297 | getDouble = env->GetMethodID(classID, "getDouble", "(I)D"); |
298 | getString = env->GetMethodID(classID, "getString", "(I)Ljava/lang/String;"); |
299 | + getBLOB = env->GetMethodID(classID, "getBlob", "(I)Ljava/sql/Blob;"); |
300 | return true; |
301 | } |
302 | bool JavaResultSetMetadata::init() { |
303 | @@ -111,7 +112,12 @@ |
304 | getParameterType = env->GetMethodID(classID, "getParameterType", "(I)I"); |
305 | return true; |
306 | } |
307 | - |
308 | + bool JavaBlob::init() { |
309 | + classID = env->FindClass("java/sql/Blob"); |
310 | + getBytes = env->GetMethodID(classID, "getBytes", "(JI)[B"); |
311 | + length = env->GetMethodID(classID, "length", "()J"); |
312 | + return true; |
313 | + } |
314 | |
315 | }}; // namespace zorba, jdbc |
316 | |
317 | |
318 | === modified file 'src/jdbc.xq.src/jdbc.cpp' |
319 | --- src/jdbc.xq.src/jdbc.cpp 2013-01-09 22:41:07 +0000 |
320 | +++ src/jdbc.xq.src/jdbc.cpp 2013-02-02 04:42:22 +0000 |
321 | @@ -69,6 +69,7 @@ |
322 | JavaResultSetMetadata jResultSetMetadata; |
323 | JavaPreparedStatement jPreparedStatement; |
324 | JavaParameterMetadata jParameterMetadata; |
325 | +JavaBlob jBlob; |
326 | bool isOutputJSON = true; |
327 | |
328 | zorba::ExternalFunction* |
329 | @@ -333,6 +334,7 @@ |
330 | jResultSetMetadata.init(); |
331 | jPreparedStatement.init(); |
332 | jParameterMetadata.init(); |
333 | + jBlob.init(); |
334 | SQLTypes::init(); |
335 | JDBC_MODULE_CATCH |
336 | } |
337 | |
338 | === modified file 'src/jdbc.xq.src/jsonitemsequence.cpp' |
339 | --- src/jdbc.xq.src/jsonitemsequence.cpp 2012-12-30 14:54:17 +0000 |
340 | +++ src/jdbc.xq.src/jsonitemsequence.cpp 2013-02-02 04:42:22 +0000 |
341 | @@ -78,7 +78,7 @@ |
342 | double value = env->CallDoubleMethod(oResultSet, jResultSet.getDouble, i+1); |
343 | CHECK_EXCEPTION |
344 | aValue = itemFactory->createDouble(value); |
345 | - } else { |
346 | + } else if (SQLTypes::isString(columnTypes[i])) { |
347 | jstring sValue = (jstring) env->CallObjectMethod(oResultSet, jResultSet.getString, i+1); |
348 | CHECK_EXCEPTION |
349 | if (sValue!=NULL) { |
350 | @@ -89,6 +89,21 @@ |
351 | } else { |
352 | aValue = itemFactory->createJSONNull(); |
353 | } |
354 | + } else if (SQLTypes::isBLOB(columnTypes[i])) { |
355 | + jobject oBlob = env->CallObjectMethod(oResultSet, jResultSet.getBLOB, i+1); |
356 | + CHECK_EXCEPTION |
357 | + if (oBlob!=NULL) { |
358 | + jint length = env->CallIntMethod(oBlob, jBlob.length); |
359 | + CHECK_EXCEPTION |
360 | + jbyteArray bytes = (jbyteArray) env->CallObjectMethod(oBlob, jBlob.getBytes, 1, length); |
361 | + CHECK_EXCEPTION |
362 | + const char* byteString = (const char*)(env->GetByteArrayElements(bytes, 0)); |
363 | + aValue = itemFactory->createBase64Binary(byteString, length); |
364 | + } else { |
365 | + aValue = itemFactory->createJSONNull(); |
366 | + } |
367 | + } else if (columnTypes[i]==SQLTypes::_NULL) { |
368 | + aValue = itemFactory->createJSONNull(); |
369 | } |
370 | elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue)); |
371 | } |
372 | |
373 | === modified file 'src/jdbc.xq.src/sqltypes.cpp' |
374 | --- src/jdbc.xq.src/sqltypes.cpp 2012-12-24 01:58:02 +0000 |
375 | +++ src/jdbc.xq.src/sqltypes.cpp 2013-02-02 04:42:22 +0000 |
376 | @@ -101,13 +101,28 @@ |
377 | VARCHAR = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "VARCHAR", "I")); |
378 | } |
379 | |
380 | +bool SQLTypes::isBLOB(long lType) { |
381 | + return ( |
382 | + (lType == BINARY) || (lType == BLOB) || (lType==LONGVARBINARY) || (lType==VARBINARY) || |
383 | + (lType == ARRAY) || (lType == DATALINK) || (lType==JAVA_OBJECT) || (lType==OTHER) || |
384 | + (lType == REF) |
385 | + ); |
386 | +} |
387 | + |
388 | +bool SQLTypes::isString(long lType) { |
389 | + return ( |
390 | + (lType == CHAR) || (lType == CLOB) || (lType == LONGVARCHAR) || (lType==LONGNVARCHAR) || |
391 | + (lType==NCHAR) || (lType==NCLOB) || (lType==NVARCHAR) || (lType==VARCHAR) || |
392 | + (lType==DATE) || (lType==TIME) || (lType==TIMESTAMP) || (lType==SQLXML) |
393 | + ); |
394 | +} |
395 | + |
396 | bool SQLTypes::isInt(long lType){ |
397 | - return ( (lType == INTEGER) || (lType==BIGINT) || (lType==TINYINT) || (lType==BIT) ); |
398 | + return ( (lType == INTEGER) || (lType==BIGINT) || (lType==TINYINT) || (lType==SMALLINT) || (lType==BIT) ); |
399 | } |
400 | |
401 | bool SQLTypes::isFloat(long lType){ |
402 | return ((lType == DECIMAL) || (lType==DOUBLE) || (lType==FLOAT) || (lType==NUMERIC) || (lType==REAL) ); |
403 | } |
404 | |
405 | - |
406 | }}; // namespace zorba, jdbc |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug1109853- 2013-01- 30T03-42- 05.903Z/ log.html
Log at: http://