forked from maparent/virtuoso-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyodbc-2.1.12.patch
599 lines (566 loc) · 19.1 KB
/
pyodbc-2.1.12.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
diff -c -N -r pyodbc-2.1.12/src/cnxninfo.cpp pyodbc-2.1.12v/src/cnxninfo.cpp
*** pyodbc-2.1.12/src/cnxninfo.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/cnxninfo.cpp 2011-12-19 15:52:04.000000000 -0500
***************
*** 112,118 ****
HSTMT hstmt = 0;
if (SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_STMT, cnxn->hdbc, &hstmt)))
{
! SQLINTEGER columnsize;
if (SQL_SUCCEEDED(SQLGetTypeInfo(hstmt, SQL_TYPE_TIMESTAMP)) && SQL_SUCCEEDED(SQLFetch(hstmt)))
{
if (SQL_SUCCEEDED(SQLGetData(hstmt, 3, SQL_INTEGER, &columnsize, sizeof(columnsize), 0)))
--- 112,118 ----
HSTMT hstmt = 0;
if (SQL_SUCCEEDED(SQLAllocHandle(SQL_HANDLE_STMT, cnxn->hdbc, &hstmt)))
{
! ULONG columnsize;
if (SQL_SUCCEEDED(SQLGetTypeInfo(hstmt, SQL_TYPE_TIMESTAMP)) && SQL_SUCCEEDED(SQLFetch(hstmt)))
{
if (SQL_SUCCEEDED(SQLGetData(hstmt, 3, SQL_INTEGER, &columnsize, sizeof(columnsize), 0)))
diff -c -N -r pyodbc-2.1.12/src/connection.cpp pyodbc-2.1.12v/src/connection.cpp
*** pyodbc-2.1.12/src/connection.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/connection.cpp 2011-12-19 13:45:06.000000000 -0500
***************
*** 17,22 ****
--- 17,23 ----
#include "wrapper.h"
#include "cnxninfo.h"
#include "sqlwchar.h"
+ #include "virtuoso.h"
static char connection_doc[] =
"Connection objects manage connections to the database.\n"
***************
*** 189,194 ****
--- 190,196 ----
cnxn->conv_count = 0;
cnxn->conv_types = 0;
cnxn->conv_funcs = 0;
+ cnxn->virtuoso = isVirtuoso(hdbc);
//
// Initialize autocommit mode.
***************
*** 747,753 ****
PyErr_SetString(PyExc_TypeError, "Cannot delete the timeout attribute.");
return -1;
}
! int timeout = PyInt_AsLong(value);
if (timeout == -1 && PyErr_Occurred())
return -1;
if (timeout < 0)
--- 749,755 ----
PyErr_SetString(PyExc_TypeError, "Cannot delete the timeout attribute.");
return -1;
}
! long timeout = PyInt_AsLong(value);
if (timeout == -1 && PyErr_Occurred())
return -1;
if (timeout < 0)
diff -c -N -r pyodbc-2.1.12/src/connection.h pyodbc-2.1.12v/src/connection.h
*** pyodbc-2.1.12/src/connection.h 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/connection.h 2011-12-19 13:45:11.000000000 -0500
***************
*** 44,56 ****
bool unicode_results;
// The connection timeout in seconds.
! int timeout;
// These are copied from cnxn info for performance and convenience.
int varchar_maxlength;
int wvarchar_maxlength;
int binary_maxlength;
// Output conversions. Maps from SQL type in conv_types to the converter function in conv_funcs.
//
--- 44,57 ----
bool unicode_results;
// The connection timeout in seconds.
! long timeout;
// These are copied from cnxn info for performance and convenience.
int varchar_maxlength;
int wvarchar_maxlength;
int binary_maxlength;
+ bool virtuoso;
// Output conversions. Maps from SQL type in conv_types to the converter function in conv_funcs.
//
diff -c -N -r pyodbc-2.1.12/src/cursor.cpp pyodbc-2.1.12v/src/cursor.cpp
*** pyodbc-2.1.12/src/cursor.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/cursor.cpp 2011-12-19 13:40:30.000000000 -0500
***************
*** 24,29 ****
--- 24,30 ----
#include "getdata.h"
#include "dbspecific.h"
#include "sqlwchar.h"
+ #include "virtuoso.h"
enum
{
***************
*** 793,798 ****
--- 794,801 ----
FreeParameterData(cur);
+ cur->spasql = (cur->cnxn->virtuoso && isSPASQL(pSql));
+
if (ret == SQL_NO_DATA)
{
// Example: A delete statement that did not delete anything.
***************
*** 1918,1927 ****
if (!cursor)
return 0;
! SQLUINTEGER noscan = SQL_NOSCAN_OFF;
SQLRETURN ret;
Py_BEGIN_ALLOW_THREADS
! ret = SQLGetStmtAttr(cursor->hstmt, SQL_ATTR_NOSCAN, (SQLPOINTER)&noscan, sizeof(SQLUINTEGER), 0);
Py_END_ALLOW_THREADS
if (!SQL_SUCCEEDED(ret))
--- 1921,1930 ----
if (!cursor)
return 0;
! ULONG noscan = SQL_NOSCAN_OFF;
SQLRETURN ret;
Py_BEGIN_ALLOW_THREADS
! ret = SQLGetStmtAttr(cursor->hstmt, SQL_ATTR_NOSCAN, (SQLPOINTER)&noscan, sizeof(ULONG), 0);
Py_END_ALLOW_THREADS
if (!SQL_SUCCEEDED(ret))
***************
*** 1950,1956 ****
return 0;
}
! SQLUINTEGER noscan = PyObject_IsTrue(value) ? SQL_NOSCAN_ON : SQL_NOSCAN_OFF;
SQLRETURN ret;
Py_BEGIN_ALLOW_THREADS
ret = SQLSetStmtAttr(cursor->hstmt, SQL_ATTR_NOSCAN, (SQLPOINTER)noscan, 0);
--- 1953,1959 ----
return 0;
}
! ULONG noscan = PyObject_IsTrue(value) ? SQL_NOSCAN_ON : SQL_NOSCAN_OFF;
SQLRETURN ret;
Py_BEGIN_ALLOW_THREADS
ret = SQLSetStmtAttr(cursor->hstmt, SQL_ATTR_NOSCAN, (SQLPOINTER)noscan, 0);
diff -c -N -r pyodbc-2.1.12/src/cursor.h pyodbc-2.1.12v/src/cursor.h
*** pyodbc-2.1.12/src/cursor.h 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/cursor.h 2011-12-19 11:52:50.000000000 -0500
***************
*** 119,124 ****
--- 119,127 ----
// The Cursor.rowcount attribute from the DB API specification.
int rowcount;
+ // is a SPASQL query on a virtuoso server, requires special datatype handling
+ bool spasql;
+
// A dictionary that maps from column name (PyString) to index into the result columns (PyInteger). This is
// constructued during an execute and shared with each row (reference counted) to implement accessing results by
// column name.
diff -c -N -r pyodbc-2.1.12/src/frag.h pyodbc-2.1.12v/src/frag.h
*** pyodbc-2.1.12/src/frag.h 1969-12-31 19:00:00.000000000 -0500
--- pyodbc-2.1.12v/src/frag.h 2012-05-12 10:47:07.000000000 -0400
***************
*** 0 ****
--- 1,107 ----
+ # define VIRTUOSO_DV_ANY 242
+ # define VIRTUOSO_DV_ARRAY_OF_DOUBLE 195
+ # define VIRTUOSO_DV_ARRAY_OF_FLOAT 202
+ # define VIRTUOSO_DV_ARRAY_OF_LONG 209
+ # define VIRTUOSO_DV_ARRAY_OF_LONG_PACKED 194
+ # define VIRTUOSO_DV_ARRAY_OF_POINTER 193
+ # define VIRTUOSO_DV_ARRAY_OF_XQVAL 212
+ # define VIRTUOSO_DV_ASYNC_QUEUE 245
+ # define VIRTUOSO_DV_BIN 222
+ # define VIRTUOSO_DV_BLOB 125
+ # define VIRTUOSO_DV_BLOB_BIN 131
+ # define VIRTUOSO_DV_BLOB_HANDLE 126
+ # define VIRTUOSO_DV_BLOB_WIDE 132
+ # define VIRTUOSO_DV_BLOB_WIDE_HANDLE 133
+ # define VIRTUOSO_DV_BLOB_XPER 134
+ # define VIRTUOSO_DV_BLOB_XPER_HANDLE 135
+ # define VIRTUOSO_DV_BOX_FLAGS 207
+ # define VIRTUOSO_DV_C_INT 201
+ # define VIRTUOSO_DV_C_SHORT 184
+ # define VIRTUOSO_DV_C_STRING 183
+ # define VIRTUOSO_DV_CHARACTER 192
+ # define VIRTUOSO_DV_CLOP 140
+ # define VIRTUOSO_DV_CLRG 139
+ # define VIRTUOSO_DV_COMP_OFFSET 136
+ # define VIRTUOSO_DV_COMPOSITE 255
+ # define VIRTUOSO_DV_CONNECTION 241
+ # define VIRTUOSO_DV_CUSTOM 203
+ # define VIRTUOSO_DV_DAE 221
+ # define VIRTUOSO_DV_DATE 129
+ # define VIRTUOSO_DV_DATETIME 211
+ # define VIRTUOSO_DV_DB_NULL 204
+ # define VIRTUOSO_DV_DELETED 199
+ # define VIRTUOSO_DV_DICT_HASHTABLE 213
+ # define VIRTUOSO_DV_DICT_ITERATOR 214
+ # define VIRTUOSO_DV_DOUBLE_FLOAT 191
+ # define VIRTUOSO_DV_DOUBLE_PREC 16
+ # define VIRTUOSO_DV_EXEC_CURSOR 224
+ # define VIRTUOSO_DV_FD 250
+ # define VIRTUOSO_DV_FIXED_STRING 240
+ # define VIRTUOSO_DV_FLOAT_PREC 14
+ # define VIRTUOSO_DV_GEO 238
+ # define VIRTUOSO_DV_IGNORE 220
+ # define VIRTUOSO_DV_INDEX_TREE 137
+ # define VIRTUOSO_DV_INT64 247
+ # define VIRTUOSO_DV_IRI_ID 243
+ # define VIRTUOSO_DV_IRI_ID 243
+ # define VIRTUOSO_DV_IRI_ID_8 244
+ # define VIRTUOSO_DV_ITC 138
+ # define VIRTUOSO_DV_LIST_OF_POINTER 196
+ # define VIRTUOSO_DV_LONG_BIN 223
+ # define VIRTUOSO_DV_LONG_CONT_STRING 187
+ # define VIRTUOSO_DV_LONG_INT 189
+ # define VIRTUOSO_DV_LONG_INT_PREC 10
+ # define VIRTUOSO_DV_LONG_PACKED DV_LONG_INT
+ # define VIRTUOSO_DV_LONG_STRING 182
+ # define VIRTUOSO_DV_LONG_WIDE 226
+ # define VIRTUOSO_DV_MEM_WRAPPER 218
+ # define VIRTUOSO_DV_MEMBER_POINTER 200
+ # define VIRTUOSO_DV_MULTIPLE_VALUES 2
+ # define VIRTUOSO_DV_NON_BOX 101
+ # define VIRTUOSO_DV_NULL 180
+ # define VIRTUOSO_DV_NUMERIC 219
+ # define VIRTUOSO_DV_OBJECT 254
+ # define VIRTUOSO_DV_OBJECT_AND_CLASS 197
+ # define VIRTUOSO_DV_OBJECT_REFERENCE 198
+ # define VIRTUOSO_DV_OWNER 130
+ # define VIRTUOSO_DV_PL_CURSOR 234
+ # define VIRTUOSO_DV_PLACEHOLDER 248
+ # define VIRTUOSO_DV_RDF 246
+ # define VIRTUOSO_DV_RDF_ID 248
+ # define VIRTUOSO_DV_RDF_ID_8 249
+ # define VIRTUOSO_DV_REFERENCE 206
+ # define VIRTUOSO_DV_REFERENCE 206
+ # define VIRTUOSO_DV_REXEC_CURSOR 240
+ # define VIRTUOSO_DV_RI_ITERATOR 229
+ # define VIRTUOSO_DV_ROW_EXTENSION 239
+ # define VIRTUOSO_DV_SEND_NO_ANSWER 1
+ # define VIRTUOSO_DV_SHORT_CONT_STRING 186
+ # define VIRTUOSO_DV_SHORT_INT 188
+ # define VIRTUOSO_DV_SHORT_REF 205
+ # define VIRTUOSO_DV_SHORT_STRING 182
+ # define VIRTUOSO_DV_SHORT_STRING_SERIAL 181
+ # define VIRTUOSO_DV_SINGLE_FLOAT 190
+ # define VIRTUOSO_DV_STRING 182
+ # define VIRTUOSO_DV_STRING_PREC 24
+ # define VIRTUOSO_DV_STRING_SESSION 185
+ # define VIRTUOSO_DV_SYMBOL 127
+ # define VIRTUOSO_DV_SYMBOL 127
+ # define VIRTUOSO_DV_SYMBOL 127
+ # define VIRTUOSO_DV_TEXT_BATCH 228
+ # define VIRTUOSO_DV_TEXT_SEARCH 227
+ # define VIRTUOSO_DV_TIME 210
+ # define VIRTUOSO_DV_TIMESTAMP 128
+ # define VIRTUOSO_DV_TIMESTAMP_PREC 26
+ # define VIRTUOSO_DV_TINY_INT 241
+ # define VIRTUOSO_DV_UNAME 217
+ # define VIRTUOSO_DV_WIDE 225
+ # define VIRTUOSO_DV_XML_DTD 236
+ # define VIRTUOSO_DV_XML_ENTITY 230
+ # define VIRTUOSO_DV_XML_MARKUP 233
+ # define VIRTUOSO_DV_XML_PARSER 235
+ # define VIRTUOSO_DV_XML_SCHEMA 237
+ # define VIRTUOSO_DV_XPATH_QUERY 232
+ # define VIRTUOSO_DV_XPATH_QUERY 232
+ # define VIRTUOSO_DV_XQI 231
+ # define VIRTUOSO_DV_XTREE_HEAD 215
+ # define VIRTUOSO_DV_XTREE_NODE 216
\ No newline at end of file
diff -c -N -r pyodbc-2.1.12/src/getdata.cpp pyodbc-2.1.12v/src/getdata.cpp
*** pyodbc-2.1.12/src/getdata.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/getdata.cpp 2012-05-14 23:29:31.000000000 -0400
***************
*** 9,14 ****
--- 9,15 ----
#include "errors.h"
#include "dbspecific.h"
#include "sqlwchar.h"
+ #include "virtuoso.h"
void GetData_init()
{
***************
*** 214,220 ****
// We have allocated our own SQLWCHAR buffer and must now copy it to a Unicode object.
PyObject* result = PyUnicode_FromSQLWCHAR((const SQLWCHAR*)buffer, bytesUsed / element_size);
if (result == 0)
! return false;
pyodbc_free(buffer);
buffer = 0;
return result;
--- 215,221 ----
// We have allocated our own SQLWCHAR buffer and must now copy it to a Unicode object.
PyObject* result = PyUnicode_FromSQLWCHAR((const SQLWCHAR*)buffer, bytesUsed / element_size);
if (result == 0)
! return NULL;
pyodbc_free(buffer);
buffer = 0;
return result;
***************
*** 594,599 ****
--- 595,681 ----
return -1;
}
+ static
+ PyObject *GetDataSPASQL(Cursor *cur, Py_ssize_t column)
+ {
+ // Return a tuple of information sufficient to glean the
+ // real underlying type in case of a Virtuoso SPASQL query
+ int dvtype, flag;
+ SQLHANDLE hdesc = SQL_NULL_HANDLE;
+ SQLRETURN ret;
+ SQLCHAR lang[0x100], dtype[0x100];
+ SQLINTEGER len, dv_dt_type = 0;
+ PyObject *value, *colinfo;
+
+ memset(lang, 0, sizeof(lang));
+ memset(dtype, 0, sizeof(dtype));
+
+ value = GetDataString(cur, column);
+ if (!value)
+ return Py_None;
+
+ // why do the virtuoso extensions number the columns from 1???
+ column += 1;
+
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetStmtAttr(cur->hstmt, SQL_ATTR_IMP_ROW_DESC, &hdesc, SQL_IS_POINTER, NULL);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret)) {
+ return Py_None;
+ }
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetDescField(hdesc, column, SQL_DESC_COL_DV_TYPE, &dvtype, SQL_IS_INTEGER, NULL);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret)) {
+ return Py_None;
+ }
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetDescField(hdesc, column, SQL_DESC_COL_BOX_FLAGS, &flag, SQL_IS_INTEGER, NULL);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret)) {
+ return Py_None;
+ }
+
+ switch (dvtype) {
+ case VIRTUOSO_DV_RDF:
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetDescField(hdesc, column, SQL_DESC_COL_LITERAL_LANG, lang, sizeof(lang), &len);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret))
+ return Py_None;
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetDescField(hdesc, column, SQL_DESC_COL_LITERAL_TYPE, dtype, sizeof(dtype), &len);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret))
+ return Py_None;
+ break;
+ case VIRTUOSO_DV_TIMESTAMP:
+ case VIRTUOSO_DV_DATE:
+ case VIRTUOSO_DV_TIME:
+ case VIRTUOSO_DV_DATETIME:
+ Py_BEGIN_ALLOW_THREADS
+ ret = SQLGetDescField (hdesc, column, SQL_DESC_COL_DT_DT_TYPE, &dv_dt_type, SQL_IS_INTEGER, NULL);
+ Py_END_ALLOW_THREADS;
+ if (!SQL_SUCCEEDED(ret))
+ return Py_None;
+ break;
+ default:
+ break;
+ }
+
+ colinfo = Py_BuildValue("(Oiiiss)",
+ value,
+ dvtype,
+ dv_dt_type,
+ flag,
+ (char *)lang,
+ (char *)dtype);
+ if (!colinfo)
+ return Py_None;
+
+ return colinfo;
+ }
+
PyObject*
GetData(Cursor* cur, Py_ssize_t iCol)
***************
*** 610,615 ****
--- 692,701 ----
if (conv_index != -1)
return GetDataUser(cur, iCol, conv_index);
+ // Check if we have to apply SPASQL processing
+ if (cur->spasql)
+ return GetDataSPASQL(cur, iCol);
+
switch (pinfo->sql_type)
{
case SQL_WCHAR:
diff -c -N -r pyodbc-2.1.12/src/params.cpp pyodbc-2.1.12v/src/params.cpp
*** pyodbc-2.1.12/src/params.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/params.cpp 2011-12-19 12:56:03.000000000 -0500
***************
*** 295,301 ****
long count = (long)PyTuple_GET_SIZE(digits);
char* pch;
! int len;
if (exp >= 0)
{
--- 295,301 ----
long count = (long)PyTuple_GET_SIZE(digits);
char* pch;
! long len;
if (exp >= 0)
{
diff -c -N -r pyodbc-2.1.12/src/pyodbcmodule.cpp pyodbc-2.1.12v/src/pyodbcmodule.cpp
*** pyodbc-2.1.12/src/pyodbcmodule.cpp 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/src/pyodbcmodule.cpp 2012-05-16 10:23:18.000000000 -0400
***************
*** 19,24 ****
--- 19,25 ----
#include "getdata.h"
#include "cnxninfo.h"
#include "dbspecific.h"
+ #include "virtuoso.h"
#include <time.h>
#include <stdarg.h>
***************
*** 890,895 ****
--- 891,914 ----
MAKECONST(SQL_UNION),
MAKECONST(SQL_USER_NAME),
MAKECONST(SQL_XOPEN_CLI_YEAR),
+
+ // Virtuoso Extensions
+ MAKECONST(VIRTUOSO_DV_ANY),
+ MAKECONST(VIRTUOSO_DV_DATE),
+ MAKECONST(VIRTUOSO_DV_DATETIME),
+ MAKECONST(VIRTUOSO_DV_DB_NULL),
+ MAKECONST(VIRTUOSO_DV_DOUBLE_FLOAT),
+ MAKECONST(VIRTUOSO_DV_IRI_ID ),
+ MAKECONST(VIRTUOSO_DV_LONG_INT),
+ MAKECONST(VIRTUOSO_DV_NUMERIC),
+ MAKECONST(VIRTUOSO_DV_RDF),
+ MAKECONST(VIRTUOSO_DV_SINGLE_FLOAT),
+ MAKECONST(VIRTUOSO_DV_STRING ),
+ MAKECONST(VIRTUOSO_DV_TIME),
+ MAKECONST(VIRTUOSO_DV_TIMESTAMP),
+ MAKECONST(VIRTUOSO_DT_TYPE_DATETIME),
+ MAKECONST(VIRTUOSO_DT_TYPE_DATE),
+ MAKECONST(VIRTUOSO_DT_TYPE_TIME)
};
diff -c -N -r pyodbc-2.1.12/src/virtuoso.cpp pyodbc-2.1.12v/src/virtuoso.cpp
*** pyodbc-2.1.12/src/virtuoso.cpp 1969-12-31 19:00:00.000000000 -0500
--- pyodbc-2.1.12v/src/virtuoso.cpp 2011-12-19 12:58:09.000000000 -0500
***************
*** 0 ****
--- 1,34 ----
+ #include "pyodbc.h"
+ #include "virtuoso.h"
+
+ bool
+ isVirtuoso(HDBC hdbc)
+ {
+ char buf[0x1000];
+ SQLSMALLINT len;
+ SQLRETURN ret;
+
+ ret = SQLGetInfo(hdbc, (SQLUSMALLINT)SQL_DBMS_NAME, buf, sizeof(buf), &len);
+ if (!SQL_SUCCEEDED(ret))
+ return false;
+ if (!strncasecmp(buf, "OpenLink Virtuoso", sizeof(buf))) {
+ return true;
+ }
+
+ return false;
+ }
+
+ bool
+ isSPASQL(PyObject *pSql)
+ {
+ char *query = PyString_AS_STRING(pSql);
+
+ if (!query)
+ return false;
+ while (*query && isspace(*query))
+ query++;
+
+ if (!strncasecmp(query, "SPARQL", 6))
+ return true;
+ return false;
+ }
diff -c -N -r pyodbc-2.1.12/src/virtuoso.h pyodbc-2.1.12v/src/virtuoso.h
*** pyodbc-2.1.12/src/virtuoso.h 1969-12-31 19:00:00.000000000 -0500
--- pyodbc-2.1.12v/src/virtuoso.h 2012-05-16 10:20:04.000000000 -0400
***************
*** 0 ****
--- 1,53 ----
+ #ifndef VIRTUOSO_H
+ #define VIRTUOSO_H
+
+ #ifdef HAVE_IODBC
+ #include <iodbcext.h>
+ #endif
+
+ /*
+ * Include Virtuoso ODBC extensions for SPASQL result set
+ */
+ #if !defined (SQL_DESC_COL_DV_TYPE)
+
+ /*
+ * ODBC extensions for SQLGetDescField
+ */
+ # define SQL_DESC_COL_DV_TYPE 1057L
+ # define SQL_DESC_COL_DT_DT_TYPE 1058L
+ # define SQL_DESC_COL_LITERAL_ATTR 1059L
+ # define SQL_DESC_COL_BOX_FLAGS 1060L
+ # define SQL_DESC_COL_LITERAL_LANG 1061L
+ # define SQL_DESC_COL_LITERAL_TYPE 1062L
+
+ /*
+ * Virtuoso - ODBC SQL_DESC_COL_DV_TYPE
+ */
+
+ # define VIRTUOSO_DV_ANY 242
+ # define VIRTUOSO_DV_DATE 129
+ # define VIRTUOSO_DV_DATETIME 211
+ # define VIRTUOSO_DV_DB_NULL 204
+ # define VIRTUOSO_DV_DOUBLE_FLOAT 191
+ # define VIRTUOSO_DV_IRI_ID 243
+ # define VIRTUOSO_DV_LONG_INT 189
+ # define VIRTUOSO_DV_NUMERIC 219
+ # define VIRTUOSO_DV_RDF 246
+ # define VIRTUOSO_DV_SINGLE_FLOAT 190
+ # define VIRTUOSO_DV_STRING 182
+ # define VIRTUOSO_DV_TIME 210
+ # define VIRTUOSO_DV_TIMESTAMP 128
+
+ /*
+ * Virtuoso - ODBC SQL_DESC_COL_DT_DT_TYPE
+ */
+ # define VIRTUOSO_DT_TYPE_DATETIME 1
+ # define VIRTUOSO_DT_TYPE_DATE 2
+ # define VIRTUOSO_DT_TYPE_TIME 3
+
+ #endif /* SQL_DESC_COL_DV_TYPE */
+
+ bool isVirtuoso(HDBC);
+ bool isSPASQL(PyObject *);
+
+ #endif /* VIRTUOSO_H */
diff -c -N -r pyodbc-2.1.12/tests/mysqltests.py pyodbc-2.1.12v/tests/mysqltests.py
*** pyodbc-2.1.12/tests/mysqltests.py 2011-10-17 08:45:30.000000000 -0400
--- pyodbc-2.1.12v/tests/mysqltests.py 2011-12-19 15:08:39.000000000 -0500
***************
*** 430,436 ****
self.assertEquals(result, value)
def test_negative_float(self):
! value = -200
self.cursor.execute("create table t1(n float)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
--- 430,436 ----
self.assertEquals(result, value)
def test_negative_float(self):
! value = -200.0
self.cursor.execute("create table t1(n float)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
diff -c -N -r pyodbc-2.1.12/tests/setup.cfg pyodbc-2.1.12v/tests/setup.cfg