diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/loadext.c | 44 | ||||
-rw-r--r-- | src/sqlite.h.in | 8 | ||||
-rw-r--r-- | src/sqlite3ext.h | 14 | ||||
-rw-r--r-- | src/tclsqlite.c | 20 | ||||
-rw-r--r-- | src/test_autoext.c | 12 | ||||
-rw-r--r-- | src/test_func.c | 18 | ||||
-rw-r--r-- | src/test_multiplex.c | 2 | ||||
-rw-r--r-- | src/test_thread.c | 4 |
8 files changed, 85 insertions, 37 deletions
diff --git a/src/loadext.c b/src/loadext.c index ce1f5317c..525272d7f 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -21,6 +21,14 @@ #include <string.h> #ifndef SQLITE_OMIT_LOAD_EXTENSION +/* +** This is the function signature used for all extension entry points. +*/ +typedef int (*sqlite3_loadext_entry)( + sqlite3 *db, /* Handle to the database. */ + char **pzErrMsg, /* Used to set error string on failure. */ + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ +); /* ** Some API routines are omitted when various features are @@ -111,6 +119,10 @@ #define sqlite3_blob_reopen 0 #endif +#if defined(SQLITE_OMIT_TRACE) +# define sqlite3_trace_v2 0 +#endif + /* ** The following structure contains pointers to all SQLite API routines. ** A pointer to this structure is passed into extensions when they are @@ -416,7 +428,10 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_strlike, sqlite3_db_cacheflush, /* Version 3.12.0 and later */ - sqlite3_system_errno + sqlite3_system_errno, + /* Version 3.14.0 and later */ + sqlite3_trace_v2, + sqlite3_expanded_sql }; /* @@ -439,7 +454,7 @@ static int sqlite3LoadExtension( ){ sqlite3_vfs *pVfs = db->pVfs; void *handle; - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); + sqlite3_loadext_entry xInit; char *zErrmsg = 0; const char *zEntry; char *zAltEntry = 0; @@ -498,8 +513,7 @@ static int sqlite3LoadExtension( } return SQLITE_ERROR; } - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - sqlite3OsDlSym(pVfs, handle, zEntry); + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); /* If no entry point was specified and the default legacy ** entry point name "sqlite3_extension_init" was not found, then @@ -531,8 +545,7 @@ static int sqlite3LoadExtension( } memcpy(zAltEntry+iEntry, "_init", 6); zEntry = zAltEntry; - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - sqlite3OsDlSym(pVfs, handle, zEntry); + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); } if( xInit==0 ){ if( pzErrMsg ){ @@ -662,7 +675,9 @@ static SQLITE_WSD struct sqlite3AutoExtList { ** Register a statically linked extension that is automatically ** loaded by every new database connection. */ -int sqlite3_auto_extension(void (*xInit)(void)){ +int sqlite3_auto_extension( + void (*xInit)(sqlite3 *, char **, const void *) /* Extension entry point */ +){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); @@ -678,7 +693,7 @@ int sqlite3_auto_extension(void (*xInit)(void)){ wsdAutoextInit; sqlite3_mutex_enter(mutex); for(i=0; i<wsdAutoext.nExt; i++){ - if( wsdAutoext.aExt[i]==xInit ) break; + if( wsdAutoext.aExt[i]==(void*)xInit ) break; } if( i==wsdAutoext.nExt ){ u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); @@ -688,7 +703,7 @@ int sqlite3_auto_extension(void (*xInit)(void)){ rc = SQLITE_NOMEM_BKPT; }else{ wsdAutoext.aExt = aNew; - wsdAutoext.aExt[wsdAutoext.nExt] = xInit; + wsdAutoext.aExt[wsdAutoext.nExt] = (void*)xInit; wsdAutoext.nExt++; } } @@ -707,7 +722,9 @@ int sqlite3_auto_extension(void (*xInit)(void)){ ** Return 1 if xInit was found on the list and removed. Return 0 if xInit ** was not on the list. */ -int sqlite3_cancel_auto_extension(void (*xInit)(void)){ +int sqlite3_cancel_auto_extension( + void (*xInit)(sqlite3 *, char **, const void *) /* Extension entry point */ +){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #endif @@ -716,7 +733,7 @@ int sqlite3_cancel_auto_extension(void (*xInit)(void)){ wsdAutoextInit; sqlite3_mutex_enter(mutex); for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ - if( wsdAutoext.aExt[i]==xInit ){ + if( wsdAutoext.aExt[i]==(void*)xInit ){ wsdAutoext.nExt--; wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; n++; @@ -756,7 +773,7 @@ void sqlite3AutoLoadExtensions(sqlite3 *db){ u32 i; int go = 1; int rc; - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); + sqlite3_loadext_entry xInit; wsdAutoextInit; if( wsdAutoext.nExt==0 ){ @@ -773,8 +790,7 @@ void sqlite3AutoLoadExtensions(sqlite3 *db){ xInit = 0; go = 0; }else{ - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - wsdAutoext.aExt[i]; + xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i]; } sqlite3_mutex_leave(mutex); zErrmsg = 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 02ae22c34..104e46546 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5707,7 +5707,9 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ -int sqlite3_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_auto_extension( + void (*xEntryPoint)(sqlite3 *, char **, const void *) +); /* ** CAPI3REF: Cancel Automatic Extension Loading @@ -5719,7 +5721,9 @@ int sqlite3_auto_extension(void (*xEntryPoint)(void)); ** unregistered and it returns 0 if X was not on the list of initialization ** routines. */ -int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_cancel_auto_extension( + void (*xEntryPoint)(sqlite3 *, char **, const void *) +); /* ** CAPI3REF: Reset Automatic Extension Loading diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 338e1becd..d79ca826d 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -251,12 +251,12 @@ struct sqlite3_api_routines { char *(*vsnprintf)(int,char*,const char*,va_list); int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); /* Version 3.8.7 and later */ - int (*auto_extension)(void(*)(void)); + int (*auto_extension)(void(*)(sqlite3*,char**,const void*)); int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, void(*)(void*)); int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, void(*)(void*),unsigned char); - int (*cancel_auto_extension)(void(*)(void)); + int (*cancel_auto_extension)(void(*)(sqlite3*,char**,const void*)); int (*load_extension)(sqlite3*,const char*,const char*,char**); void *(*malloc64)(sqlite3_uint64); sqlite3_uint64 (*msize)(void*); @@ -287,6 +287,16 @@ struct sqlite3_api_routines { }; /* +** This is the function signature used for all extension entry points. It +** is also defined in the file "loadext.c". +*/ +typedef int (*sqlite3_loadext_entry)( + sqlite3 *db, /* Handle to the database. */ + char **pzErrMsg, /* Used to set error string on failure. */ + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ +); + +/* ** The following macros redefine the API routines so that they are ** redirected through the global sqlite3_api structure. ** diff --git a/src/tclsqlite.c b/src/tclsqlite.c index bc94a5ff7..dd4e42e8a 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3806,7 +3806,12 @@ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ ** A TCL command for md5. The argument is the text to be hashed. The ** Result is the hash in base64. */ -static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ +static int SQLITE_TCLAPI md5_cmd( + void*cd, + Tcl_Interp *interp, + int argc, + const char **argv +){ MD5Context ctx; unsigned char digest[16]; char zBuf[50]; @@ -3830,7 +3835,12 @@ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ ** A TCL command to take the md5 hash of a file. The argument is the ** name of the file. */ -static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){ +static int SQLITE_TCLAPI md5file_cmd( + void*cd, + Tcl_Interp *interp, + int argc, + const char **argv +){ FILE *in; MD5Context ctx; void (*converter)(unsigned char*, char*); @@ -3910,7 +3920,11 @@ static void md5finalize(sqlite3_context *context){ MD5DigestToBase16(digest, zBuf); sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } -int Md5_Register(sqlite3 *db){ +int Md5_Register( + sqlite3 *db, + char **pzErrMsg, + const void *pThunk +){ int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize); sqlite3_overload_function(db, "md5sum", -1); /* To exercise this API */ diff --git a/src/test_autoext.c b/src/test_autoext.c index 94a3223e6..f962a51d6 100644 --- a/src/test_autoext.c +++ b/src/test_autoext.c @@ -100,7 +100,7 @@ static int SQLITE_TCLAPI autoExtSqrObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)sqr_init); + int rc = sqlite3_auto_extension(sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -116,7 +116,7 @@ static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)sqr_init); + int rc = sqlite3_cancel_auto_extension(sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -132,7 +132,7 @@ static int SQLITE_TCLAPI autoExtCubeObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)cube_init); + int rc = sqlite3_auto_extension(cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -148,7 +148,7 @@ static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)cube_init); + int rc = sqlite3_cancel_auto_extension(cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -164,7 +164,7 @@ static int SQLITE_TCLAPI autoExtBrokenObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)broken_init); + int rc = sqlite3_auto_extension(broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -180,7 +180,7 @@ static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)broken_init); + int rc = sqlite3_cancel_auto_extension(broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } diff --git a/src/test_func.c b/src/test_func.c index 6a714ef3e..fff199012 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -644,7 +644,11 @@ static void test_setsubtype( sqlite3_result_subtype(context, (unsigned int)sqlite3_value_int(argv[1])); } -static int registerTestFunctions(sqlite3 *db){ +static int registerTestFunctions( + sqlite3 *db, + char **pzErrMsg, + const void *pThunk +){ static const struct { char *zName; signed char nArg; @@ -699,10 +703,10 @@ static int SQLITE_TCLAPI autoinstall_test_funcs( int objc, Tcl_Obj *CONST objv[] ){ - extern int Md5_Register(sqlite3*); - int rc = sqlite3_auto_extension((void*)registerTestFunctions); + extern int Md5_Register(sqlite3 *, char **, const void *); + int rc = sqlite3_auto_extension(registerTestFunctions); if( rc==SQLITE_OK ){ - rc = sqlite3_auto_extension((void*)Md5_Register); + rc = sqlite3_auto_extension(Md5_Register); } Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_OK; @@ -799,13 +803,13 @@ int Sqlitetest_func_Init(Tcl_Interp *interp){ { "abuse_create_function", abuse_create_function }, }; int i; - extern int Md5_Register(sqlite3*); + extern int Md5_Register(sqlite3 *, char **, const void *); for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); } sqlite3_initialize(); - sqlite3_auto_extension((void*)registerTestFunctions); - sqlite3_auto_extension((void*)Md5_Register); + sqlite3_auto_extension(registerTestFunctions); + sqlite3_auto_extension(Md5_Register); return TCL_OK; } diff --git a/src/test_multiplex.c b/src/test_multiplex.c index e7ffa63a5..a7820975d 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -1197,7 +1197,7 @@ int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault){ gMultiplex.sIoMethodsV2.xShmUnmap = multiplexShmUnmap; sqlite3_vfs_register(&gMultiplex.sThisVfs, makeDefault); - sqlite3_auto_extension((void*)multiplexFuncInit); + sqlite3_auto_extension(multiplexFuncInit); return SQLITE_OK; } diff --git a/src/test_thread.c b/src/test_thread.c index d67b4be10..68452f001 100644 --- a/src/test_thread.c +++ b/src/test_thread.c @@ -280,7 +280,7 @@ static int SQLITE_TCLAPI sqlthread_open( const char *zFilename; sqlite3 *db; char zBuf[100]; - extern void Md5_Register(sqlite3*); + extern int Md5_Register(sqlite3 *, char **, const void *); UNUSED_PARAMETER(clientData); UNUSED_PARAMETER(objc); @@ -303,7 +303,7 @@ static int SQLITE_TCLAPI sqlthread_open( } } #endif - Md5_Register(db); + Md5_Register(db, 0, 0); sqlite3_busy_handler(db, xBusy, 0); if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |