33
33
#define ACTION_FINALIZE 1
34
34
#define ACTION_RESET 2
35
35
36
- #if SQLITE_VERSION_NUMBER >= 3003008
37
- #ifndef SQLITE_OMIT_LOAD_EXTENSION
38
- #define HAVE_LOAD_EXTENSION
39
- #endif
40
- #endif
41
-
42
- #if SQLITE_VERSION_NUMBER >= 3006011
43
- #define HAVE_BACKUP_API
44
- #endif
45
-
46
36
_Py_IDENTIFIER (cursor );
47
37
48
38
static const char * const begin_statements [] = {
@@ -57,18 +47,6 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
57
47
static void _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self );
58
48
59
49
60
- static void _sqlite3_result_error (sqlite3_context * ctx , const char * errmsg , int len )
61
- {
62
- /* in older SQLite versions, calling sqlite3_result_error in callbacks
63
- * triggers a bug in SQLite that leads either to irritating results or
64
- * segfaults, depending on the SQLite version */
65
- #if SQLITE_VERSION_NUMBER >= 3003003
66
- sqlite3_result_error (ctx , errmsg , len );
67
- #else
68
- PyErr_SetString (pysqlite_OperationalError , errmsg );
69
- #endif
70
- }
71
-
72
50
int pysqlite_connection_init (pysqlite_Connection * self , PyObject * args , PyObject * kwargs )
73
51
{
74
52
static char * kwlist [] = {
@@ -178,10 +156,6 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
178
156
self -> timeout = timeout ;
179
157
(void )sqlite3_busy_timeout (self -> db , (int )(timeout * 1000 ));
180
158
self -> thread_ident = PyThread_get_thread_ident ();
181
- if (!check_same_thread && sqlite3_libversion_number () < 3003001 ) {
182
- PyErr_SetString (pysqlite_NotSupportedError , "shared connections not available" );
183
- return -1 ;
184
- }
185
159
self -> check_same_thread = check_same_thread ;
186
160
187
161
self -> function_pinboard_trace_callback = NULL ;
@@ -616,7 +590,7 @@ void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value**
616
590
} else {
617
591
PyErr_Clear ();
618
592
}
619
- _sqlite3_result_error (context , "user-defined function raised exception" , -1 );
593
+ sqlite3_result_error (context , "user-defined function raised exception" , -1 );
620
594
}
621
595
622
596
PyGILState_Release (threadstate );
@@ -648,7 +622,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
648
622
} else {
649
623
PyErr_Clear ();
650
624
}
651
- _sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
625
+ sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
652
626
goto error ;
653
627
}
654
628
}
@@ -672,7 +646,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
672
646
} else {
673
647
PyErr_Clear ();
674
648
}
675
- _sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
649
+ sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
676
650
}
677
651
678
652
error :
@@ -689,7 +663,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
689
663
_Py_IDENTIFIER (finalize );
690
664
int ok ;
691
665
PyObject * exception , * value , * tb ;
692
- int restore ;
693
666
694
667
PyGILState_STATE threadstate ;
695
668
@@ -705,7 +678,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
705
678
706
679
/* Keep the exception (if any) of the last call to step() */
707
680
PyErr_Fetch (& exception , & value , & tb );
708
- restore = 1 ;
709
681
710
682
function_result = _PyObject_CallMethodIdNoArgs (* aggregate_instance , & PyId_finalize );
711
683
@@ -722,19 +694,12 @@ void _pysqlite_final_callback(sqlite3_context* context)
722
694
} else {
723
695
PyErr_Clear ();
724
696
}
725
- _sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
726
- #if SQLITE_VERSION_NUMBER < 3003003
727
- /* with old SQLite versions, _sqlite3_result_error() sets a new Python
728
- exception, so don't restore the previous exception */
729
- restore = 0 ;
730
- #endif
697
+ sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
731
698
}
732
699
733
- if (restore ) {
734
- /* Restore the exception (if any) of the last call to step(),
735
- but clear also the current exception if finalize() failed */
736
- PyErr_Restore (exception , value , tb );
737
- }
700
+ /* Restore the exception (if any) of the last call to step(),
701
+ but clear also the current exception if finalize() failed */
702
+ PyErr_Restore (exception , value , tb );
738
703
739
704
error :
740
705
PyGILState_Release (threadstate );
@@ -1074,7 +1039,7 @@ static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* sel
1074
1039
Py_RETURN_NONE ;
1075
1040
}
1076
1041
1077
- #ifdef HAVE_LOAD_EXTENSION
1042
+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
1078
1043
static PyObject * pysqlite_enable_load_extension (pysqlite_Connection * self , PyObject * args )
1079
1044
{
1080
1045
int rc ;
@@ -1477,7 +1442,6 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
1477
1442
return retval ;
1478
1443
}
1479
1444
1480
- #ifdef HAVE_BACKUP_API
1481
1445
static PyObject *
1482
1446
pysqlite_connection_backup (pysqlite_Connection * self , PyObject * args , PyObject * kwds )
1483
1447
{
@@ -1628,7 +1592,6 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
1628
1592
return NULL ;
1629
1593
}
1630
1594
}
1631
- #endif
1632
1595
1633
1596
static PyObject *
1634
1597
pysqlite_connection_create_collation (pysqlite_Connection * self , PyObject * args )
@@ -1780,7 +1743,7 @@ static PyMethodDef connection_methods[] = {
1780
1743
PyDoc_STR ("Creates a new aggregate. Non-standard." )},
1781
1744
{"set_authorizer" , (PyCFunction )(void (* )(void ))pysqlite_connection_set_authorizer , METH_VARARGS |METH_KEYWORDS ,
1782
1745
PyDoc_STR ("Sets authorizer callback. Non-standard." )},
1783
- #ifdef HAVE_LOAD_EXTENSION
1746
+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
1784
1747
{"enable_load_extension" , (PyCFunction )pysqlite_enable_load_extension , METH_VARARGS ,
1785
1748
PyDoc_STR ("Enable dynamic loading of SQLite extension modules. Non-standard." )},
1786
1749
{"load_extension" , (PyCFunction )pysqlite_load_extension , METH_VARARGS ,
@@ -1802,10 +1765,8 @@ static PyMethodDef connection_methods[] = {
1802
1765
PyDoc_STR ("Abort any pending database operation. Non-standard." )},
1803
1766
{"iterdump" , (PyCFunction )pysqlite_connection_iterdump , METH_NOARGS ,
1804
1767
PyDoc_STR ("Returns iterator to the dump of the database in an SQL text format. Non-standard." )},
1805
- #ifdef HAVE_BACKUP_API
1806
1768
{"backup" , (PyCFunction )(void (* )(void ))pysqlite_connection_backup , METH_VARARGS | METH_KEYWORDS ,
1807
1769
PyDoc_STR ("Makes a backup of the database. Non-standard." )},
1808
- #endif
1809
1770
{"__enter__" , (PyCFunction )pysqlite_connection_enter , METH_NOARGS ,
1810
1771
PyDoc_STR ("For context manager. Non-standard." )},
1811
1772
{"__exit__" , (PyCFunction )pysqlite_connection_exit , METH_VARARGS ,
0 commit comments