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
#if SQLITE_VERSION_NUMBER >= 3014000
47
37
#define HAVE_TRACE_V2
48
38
#endif
@@ -61,18 +51,6 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
61
51
static void _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self );
62
52
63
53
64
- static void _sqlite3_result_error (sqlite3_context * ctx , const char * errmsg , int len )
65
- {
66
- /* in older SQLite versions, calling sqlite3_result_error in callbacks
67
- * triggers a bug in SQLite that leads either to irritating results or
68
- * segfaults, depending on the SQLite version */
69
- #if SQLITE_VERSION_NUMBER >= 3003003
70
- sqlite3_result_error (ctx , errmsg , len );
71
- #else
72
- PyErr_SetString (pysqlite_OperationalError , errmsg );
73
- #endif
74
- }
75
-
76
54
int pysqlite_connection_init (pysqlite_Connection * self , PyObject * args , PyObject * kwargs )
77
55
{
78
56
static char * kwlist [] = {
@@ -182,10 +160,6 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
182
160
self -> timeout = timeout ;
183
161
(void )sqlite3_busy_timeout (self -> db , (int )(timeout * 1000 ));
184
162
self -> thread_ident = PyThread_get_thread_ident ();
185
- if (!check_same_thread && sqlite3_libversion_number () < 3003001 ) {
186
- PyErr_SetString (pysqlite_NotSupportedError , "shared connections not available" );
187
- return -1 ;
188
- }
189
163
self -> check_same_thread = check_same_thread ;
190
164
191
165
self -> function_pinboard_trace_callback = NULL ;
@@ -620,7 +594,7 @@ void _pysqlite_func_callback(sqlite3_context* context, int argc, sqlite3_value**
620
594
} else {
621
595
PyErr_Clear ();
622
596
}
623
- _sqlite3_result_error (context , "user-defined function raised exception" , -1 );
597
+ sqlite3_result_error (context , "user-defined function raised exception" , -1 );
624
598
}
625
599
626
600
PyGILState_Release (threadstate );
@@ -652,7 +626,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
652
626
} else {
653
627
PyErr_Clear ();
654
628
}
655
- _sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
629
+ sqlite3_result_error (context , "user-defined aggregate's '__init__' method raised error" , -1 );
656
630
goto error ;
657
631
}
658
632
}
@@ -676,7 +650,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
676
650
} else {
677
651
PyErr_Clear ();
678
652
}
679
- _sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
653
+ sqlite3_result_error (context , "user-defined aggregate's 'step' method raised error" , -1 );
680
654
}
681
655
682
656
error :
@@ -693,7 +667,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
693
667
_Py_IDENTIFIER (finalize );
694
668
int ok ;
695
669
PyObject * exception , * value , * tb ;
696
- int restore ;
697
670
698
671
PyGILState_STATE threadstate ;
699
672
@@ -709,7 +682,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
709
682
710
683
/* Keep the exception (if any) of the last call to step() */
711
684
PyErr_Fetch (& exception , & value , & tb );
712
- restore = 1 ;
713
685
714
686
function_result = _PyObject_CallMethodIdNoArgs (* aggregate_instance , & PyId_finalize );
715
687
@@ -726,19 +698,12 @@ void _pysqlite_final_callback(sqlite3_context* context)
726
698
} else {
727
699
PyErr_Clear ();
728
700
}
729
- _sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
730
- #if SQLITE_VERSION_NUMBER < 3003003
731
- /* with old SQLite versions, _sqlite3_result_error() sets a new Python
732
- exception, so don't restore the previous exception */
733
- restore = 0 ;
734
- #endif
701
+ sqlite3_result_error (context , "user-defined aggregate's 'finalize' method raised error" , -1 );
735
702
}
736
703
737
- if (restore ) {
738
- /* Restore the exception (if any) of the last call to step(),
739
- but clear also the current exception if finalize() failed */
740
- PyErr_Restore (exception , value , tb );
741
- }
704
+ /* Restore the exception (if any) of the last call to step(),
705
+ but clear also the current exception if finalize() failed */
706
+ PyErr_Restore (exception , value , tb );
742
707
743
708
error :
744
709
PyGILState_Release (threadstate );
@@ -1110,7 +1075,7 @@ static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* sel
1110
1075
Py_RETURN_NONE ;
1111
1076
}
1112
1077
1113
- #ifdef HAVE_LOAD_EXTENSION
1078
+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
1114
1079
static PyObject * pysqlite_enable_load_extension (pysqlite_Connection * self , PyObject * args )
1115
1080
{
1116
1081
int rc ;
@@ -1513,7 +1478,6 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args)
1513
1478
return retval ;
1514
1479
}
1515
1480
1516
- #ifdef HAVE_BACKUP_API
1517
1481
static PyObject *
1518
1482
pysqlite_connection_backup (pysqlite_Connection * self , PyObject * args , PyObject * kwds )
1519
1483
{
@@ -1664,7 +1628,6 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject *
1664
1628
return NULL ;
1665
1629
}
1666
1630
}
1667
- #endif
1668
1631
1669
1632
static PyObject *
1670
1633
pysqlite_connection_create_collation (pysqlite_Connection * self , PyObject * args )
@@ -1816,7 +1779,7 @@ static PyMethodDef connection_methods[] = {
1816
1779
PyDoc_STR ("Creates a new aggregate. Non-standard." )},
1817
1780
{"set_authorizer" , (PyCFunction )(void (* )(void ))pysqlite_connection_set_authorizer , METH_VARARGS |METH_KEYWORDS ,
1818
1781
PyDoc_STR ("Sets authorizer callback. Non-standard." )},
1819
- #ifdef HAVE_LOAD_EXTENSION
1782
+ #ifndef SQLITE_OMIT_LOAD_EXTENSION
1820
1783
{"enable_load_extension" , (PyCFunction )pysqlite_enable_load_extension , METH_VARARGS ,
1821
1784
PyDoc_STR ("Enable dynamic loading of SQLite extension modules. Non-standard." )},
1822
1785
{"load_extension" , (PyCFunction )pysqlite_load_extension , METH_VARARGS ,
@@ -1838,10 +1801,8 @@ static PyMethodDef connection_methods[] = {
1838
1801
PyDoc_STR ("Abort any pending database operation. Non-standard." )},
1839
1802
{"iterdump" , (PyCFunction )pysqlite_connection_iterdump , METH_NOARGS ,
1840
1803
PyDoc_STR ("Returns iterator to the dump of the database in an SQL text format. Non-standard." )},
1841
- #ifdef HAVE_BACKUP_API
1842
1804
{"backup" , (PyCFunction )(void (* )(void ))pysqlite_connection_backup , METH_VARARGS | METH_KEYWORDS ,
1843
1805
PyDoc_STR ("Makes a backup of the database. Non-standard." )},
1844
- #endif
1845
1806
{"__enter__" , (PyCFunction )pysqlite_connection_enter , METH_NOARGS ,
1846
1807
PyDoc_STR ("For context manager. Non-standard." )},
1847
1808
{"__exit__" , (PyCFunction )pysqlite_connection_exit , METH_VARARGS ,
0 commit comments