/ Check-in [b6ea2f21]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid making unnecessary changes to the signatures of the sqlite3_auto_extension() and sqlite3_cancel_auto_extension() interfaces.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6
User & Date: drh 2016-08-01 14:35:48
Context
2016-08-01
15:00
Update releasetest.tcl to automatically do one round of tests with USE_STDCALL=1 when running on Windows with MSVC. check-in: a6a112de user: drh tags: trunk
14:35
Avoid making unnecessary changes to the signatures of the sqlite3_auto_extension() and sqlite3_cancel_auto_extension() interfaces. check-in: b6ea2f21 user: drh tags: trunk
2016-07-30
18:54
Fix harmless compiler warning seen with MSVC. check-in: 390a38a1 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/loadext.c.

   672    672   
   673    673   
   674    674   /*
   675    675   ** Register a statically linked extension that is automatically
   676    676   ** loaded by every new database connection.
   677    677   */
   678    678   int sqlite3_auto_extension(
   679         -  int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *)
          679  +  void (*xInit)(void)
   680    680   ){
   681    681     int rc = SQLITE_OK;
   682    682   #ifndef SQLITE_OMIT_AUTOINIT
   683    683     rc = sqlite3_initialize();
   684    684     if( rc ){
   685    685       return rc;
   686    686     }else
................................................................................
   719    719   ** is currently on the list.  If xInit is not on the list, then this
   720    720   ** routine is a no-op.
   721    721   **
   722    722   ** Return 1 if xInit was found on the list and removed.  Return 0 if xInit
   723    723   ** was not on the list.
   724    724   */
   725    725   int sqlite3_cancel_auto_extension(
   726         -  int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *)
          726  +  void (*xInit)(void)
   727    727   ){
   728    728   #if SQLITE_THREADSAFE
   729    729     sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
   730    730   #endif
   731    731     int i;
   732    732     int n = 0;
   733    733     wsdAutoextInit;

Changes to src/sqlite.h.in.

  1041   1041   ** at the internal representation of an [sqlite3_mutex].  It only
  1042   1042   ** deals with pointers to the [sqlite3_mutex] object.
  1043   1043   **
  1044   1044   ** Mutexes are created using [sqlite3_mutex_alloc()].
  1045   1045   */
  1046   1046   typedef struct sqlite3_mutex sqlite3_mutex;
  1047   1047   
         1048  +/*
         1049  +** CAPI3REF: Loadable Extension Thunk
         1050  +**
         1051  +** A pointer to the opaque sqlite3_api_routines structure is passed as
         1052  +** the third parameter to entry points of [loadable extensions].  This
         1053  +** structure must be typedefed in order to work around compiler warnings
         1054  +** on some platforms.
         1055  +*/
         1056  +typedef struct sqlite3_api_routines sqlite3_api_routines;
         1057  +
  1048   1058   /*
  1049   1059   ** CAPI3REF: OS Interface Object
  1050   1060   **
  1051   1061   ** An instance of the sqlite3_vfs object defines the interface between
  1052   1062   ** the SQLite core and the underlying operating system.  The "vfs"
  1053   1063   ** in the name of the object stands for "virtual file system".  See
  1054   1064   ** the [VFS | VFS documentation] for further information.
................................................................................
  2238   2248   ** database connection that invoked the busy handler.  In other words,
  2239   2249   ** the busy handler is not reentrant.  Any such actions
  2240   2250   ** result in undefined behavior.
  2241   2251   ** 
  2242   2252   ** A busy handler must not close the database connection
  2243   2253   ** or [prepared statement] that invoked the busy handler.
  2244   2254   */
  2245         -int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
         2255  +int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
  2246   2256   
  2247   2257   /*
  2248   2258   ** CAPI3REF: Set A Busy Timeout
  2249   2259   ** METHOD: sqlite3
  2250   2260   **
  2251   2261   ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
  2252   2262   ** for a specified amount of time when a table is locked.  ^The handler
................................................................................
  5677   5687   ** ^This interface causes the xEntryPoint() function to be invoked for
  5678   5688   ** each new [database connection] that is created.  The idea here is that
  5679   5689   ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
  5680   5690   ** that is to be automatically loaded into all new database connections.
  5681   5691   **
  5682   5692   ** ^(Even though the function prototype shows that xEntryPoint() takes
  5683   5693   ** no arguments and returns void, SQLite invokes xEntryPoint() with three
  5684         -** arguments and expects and integer result as if the signature of the
         5694  +** arguments and expects an integer result as if the signature of the
  5685   5695   ** entry point where as follows:
  5686   5696   **
  5687   5697   ** <blockquote><pre>
  5688   5698   ** &nbsp;  int xEntryPoint(
  5689   5699   ** &nbsp;    sqlite3 *db,
  5690   5700   ** &nbsp;    const char **pzErrMsg,
  5691   5701   ** &nbsp;    const struct sqlite3_api_routines *pThunk
................................................................................
  5703   5713   ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
  5704   5714   ** on the list of automatic extensions is a harmless no-op. ^No entry point
  5705   5715   ** will be called more than once for each database connection that is opened.
  5706   5716   **
  5707   5717   ** See also: [sqlite3_reset_auto_extension()]
  5708   5718   ** and [sqlite3_cancel_auto_extension()]
  5709   5719   */
  5710         -typedef struct sqlite3_api_routines sqlite3_api_routines;
  5711         -int sqlite3_auto_extension(
  5712         -  int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *)
  5713         -);
         5720  +int sqlite3_auto_extension(void(*xEntryPoint)(void));
  5714   5721   
  5715   5722   /*
  5716   5723   ** CAPI3REF: Cancel Automatic Extension Loading
  5717   5724   **
  5718   5725   ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
  5719   5726   ** initialization routine X that was registered using a prior call to
  5720   5727   ** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]
  5721   5728   ** routine returns 1 if initialization routine X was successfully 
  5722   5729   ** unregistered and it returns 0 if X was not on the list of initialization
  5723   5730   ** routines.
  5724   5731   */
  5725         -int sqlite3_cancel_auto_extension(
  5726         -  int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *)
  5727         -);
         5732  +int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
  5728   5733   
  5729   5734   /*
  5730   5735   ** CAPI3REF: Reset Automatic Extension Loading
  5731   5736   **
  5732   5737   ** ^This interface disables all automatic extensions previously
  5733   5738   ** registered using [sqlite3_auto_extension()].
  5734   5739   */

Changes to src/sqlite3ext.h.

    15     15   ** as extensions by SQLite should #include this file instead of 
    16     16   ** sqlite3.h.
    17     17   */
    18     18   #ifndef SQLITE3EXT_H
    19     19   #define SQLITE3EXT_H
    20     20   #include "sqlite3.h"
    21     21   
    22         -typedef struct sqlite3_api_routines sqlite3_api_routines;
    23         -
    24     22   /*
    25     23   ** The following structure holds pointers to all of the SQLite API
    26     24   ** routines.
    27     25   **
    28     26   ** WARNING:  In order to maintain backwards compatibility, add new
    29     27   ** interfaces to the end of this structure only.  If you insert new
    30     28   ** interfaces in the middle of this structure, then older different
................................................................................
   247    245     int (*stricmp)(const char*,const char*);
   248    246     int (*uri_boolean)(const char*,const char*,int);
   249    247     sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
   250    248     const char *(*uri_parameter)(const char*,const char*);
   251    249     char *(*vsnprintf)(int,char*,const char*,va_list);
   252    250     int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
   253    251     /* Version 3.8.7 and later */
   254         -  int (*auto_extension)(int(*)(sqlite3*,char**,const sqlite3_api_routines*));
          252  +  int (*auto_extension)(void(*)(void));
   255    253     int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
   256    254                        void(*)(void*));
   257    255     int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
   258    256                         void(*)(void*),unsigned char);
   259         -  int (*cancel_auto_extension)(int(*)(sqlite3*,char**,
   260         -                                       const sqlite3_api_routines*));
          257  +  int (*cancel_auto_extension)(void(*)(void));
   261    258     int (*load_extension)(sqlite3*,const char*,const char*,char**);
   262    259     void *(*malloc64)(sqlite3_uint64);
   263    260     sqlite3_uint64 (*msize)(void*);
   264    261     void *(*realloc64)(void*,sqlite3_uint64);
   265    262     void (*reset_auto_extension)(void);
   266    263     void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
   267    264                           void(*)(void*));

Changes to src/test1.c.

  6738   6738       }
  6739   6739       return TCL_ERROR;
  6740   6740     }
  6741   6741     sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask);
  6742   6742     return TCL_OK;
  6743   6743   }
  6744   6744   
  6745         -typedef struct sqlite3_api_routines sqlite3_api_routines;
  6746   6745   /*
  6747   6746   **     load_static_extension DB NAME ...
  6748   6747   **
  6749   6748   ** Load one or more statically linked extensions.
  6750   6749   */
  6751   6750   static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
  6752   6751     void * clientData,

Changes to src/test_autoext.c.

    96     96   */
    97     97   static int SQLITE_TCLAPI autoExtSqrObjCmd(
    98     98     void * clientData,
    99     99     Tcl_Interp *interp,
   100    100     int objc,
   101    101     Tcl_Obj *CONST objv[]
   102    102   ){
   103         -  int rc = sqlite3_auto_extension(sqr_init);
          103  +  int rc = sqlite3_auto_extension((void(*)(void))sqr_init);
   104    104     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   105    105     return SQLITE_OK;
   106    106   }
   107    107   
   108    108   /*
   109    109   ** tclcmd:   sqlite3_cancel_auto_extension_sqr
   110    110   **
................................................................................
   112    112   */
   113    113   static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd(
   114    114     void * clientData,
   115    115     Tcl_Interp *interp,
   116    116     int objc,
   117    117     Tcl_Obj *CONST objv[]
   118    118   ){
   119         -  int rc = sqlite3_cancel_auto_extension(sqr_init);
          119  +  int rc = sqlite3_cancel_auto_extension((void(*)(void))sqr_init);
   120    120     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   121    121     return SQLITE_OK;
   122    122   }
   123    123   
   124    124   /*
   125    125   ** tclcmd:   sqlite3_auto_extension_cube
   126    126   **
................................................................................
   128    128   */
   129    129   static int SQLITE_TCLAPI autoExtCubeObjCmd(
   130    130     void * clientData,
   131    131     Tcl_Interp *interp,
   132    132     int objc,
   133    133     Tcl_Obj *CONST objv[]
   134    134   ){
   135         -  int rc = sqlite3_auto_extension(cube_init);
          135  +  int rc = sqlite3_auto_extension((void(*)(void))cube_init);
   136    136     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   137    137     return SQLITE_OK;
   138    138   }
   139    139   
   140    140   /*
   141    141   ** tclcmd:   sqlite3_cancel_auto_extension_cube
   142    142   **
................................................................................
   144    144   */
   145    145   static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd(
   146    146     void * clientData,
   147    147     Tcl_Interp *interp,
   148    148     int objc,
   149    149     Tcl_Obj *CONST objv[]
   150    150   ){
   151         -  int rc = sqlite3_cancel_auto_extension(cube_init);
          151  +  int rc = sqlite3_cancel_auto_extension((void(*)(void))cube_init);
   152    152     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   153    153     return SQLITE_OK;
   154    154   }
   155    155   
   156    156   /*
   157    157   ** tclcmd:   sqlite3_auto_extension_broken
   158    158   **
................................................................................
   160    160   */
   161    161   static int SQLITE_TCLAPI autoExtBrokenObjCmd(
   162    162     void * clientData,
   163    163     Tcl_Interp *interp,
   164    164     int objc,
   165    165     Tcl_Obj *CONST objv[]
   166    166   ){
   167         -  int rc = sqlite3_auto_extension(broken_init);
          167  +  int rc = sqlite3_auto_extension((void(*)(void))broken_init);
   168    168     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   169    169     return SQLITE_OK;
   170    170   }
   171    171   
   172    172   /*
   173    173   ** tclcmd:   sqlite3_cancel_auto_extension_broken
   174    174   **
................................................................................
   176    176   */
   177    177   static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd(
   178    178     void * clientData,
   179    179     Tcl_Interp *interp,
   180    180     int objc,
   181    181     Tcl_Obj *CONST objv[]
   182    182   ){
   183         -  int rc = sqlite3_cancel_auto_extension(broken_init);
          183  +  int rc = sqlite3_cancel_auto_extension((void(*)(void))broken_init);
   184    184     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   185    185     return SQLITE_OK;
   186    186   }
   187    187   
   188    188   #endif /* SQLITE_OMIT_LOAD_EXTENSION */
   189    189   
   190    190   

Changes to src/test_func.c.

    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   #include <assert.h>
    24     24   
    25     25   #include "sqliteInt.h"
    26     26   #include "vdbeInt.h"
    27     27   
    28         -
    29     28   /*
    30     29   ** Allocate nByte bytes of space using sqlite3_malloc(). If the
    31     30   ** allocation fails, call sqlite3_result_error_nomem() to notify
    32     31   ** the database handle that malloc() has failed.
    33     32   */
    34     33   static void *testContextMalloc(sqlite3_context *context, int nByte){
    35     34     char *z = sqlite3_malloc(nByte);
................................................................................
   700    699   static int SQLITE_TCLAPI autoinstall_test_funcs(
   701    700     void * clientData,
   702    701     Tcl_Interp *interp,
   703    702     int objc,
   704    703     Tcl_Obj *CONST objv[]
   705    704   ){
   706    705     extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);
   707         -  int rc = sqlite3_auto_extension(registerTestFunctions);
          706  +  int rc = sqlite3_auto_extension((void(*)(void))registerTestFunctions);
   708    707     if( rc==SQLITE_OK ){
   709         -    rc = sqlite3_auto_extension(Md5_Register);
          708  +    rc = sqlite3_auto_extension((void(*)(void))Md5_Register);
   710    709     }
   711    710     Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   712    711     return TCL_OK;
   713    712   }
   714    713   
   715    714   /*
   716    715   ** A bogus step function and finalizer function.
................................................................................
   786    785     return TCL_OK;
   787    786   
   788    787   abuse_err:
   789    788     Tcl_AppendResult(interp, "sqlite3_create_function abused test failed", 
   790    789                      (char*)0);
   791    790     return TCL_ERROR;
   792    791   }
          792  +
   793    793   
   794    794   /*
   795    795   ** Register commands with the TCL interpreter.
   796    796   */
   797    797   int Sqlitetest_func_Init(Tcl_Interp *interp){
   798    798     static struct {
   799    799        char *zName;
................................................................................
   805    805     int i;
   806    806     extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);
   807    807   
   808    808     for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
   809    809       Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
   810    810     }
   811    811     sqlite3_initialize();
   812         -  sqlite3_auto_extension(registerTestFunctions);
   813         -  sqlite3_auto_extension(Md5_Register);
          812  +  sqlite3_auto_extension((void(*)(void))registerTestFunctions);
          813  +  sqlite3_auto_extension((void(*)(void))Md5_Register);
   814    814     return TCL_OK;
   815    815   }

Changes to src/test_multiplex.c.

  1193   1193     gMultiplex.sIoMethodsV2.iVersion = 2;
  1194   1194     gMultiplex.sIoMethodsV2.xShmMap = multiplexShmMap;
  1195   1195     gMultiplex.sIoMethodsV2.xShmLock = multiplexShmLock;
  1196   1196     gMultiplex.sIoMethodsV2.xShmBarrier = multiplexShmBarrier;
  1197   1197     gMultiplex.sIoMethodsV2.xShmUnmap = multiplexShmUnmap;
  1198   1198     sqlite3_vfs_register(&gMultiplex.sThisVfs, makeDefault);
  1199   1199   
  1200         -  sqlite3_auto_extension(multiplexFuncInit);
         1200  +  sqlite3_auto_extension((void(*)(void))multiplexFuncInit);
  1201   1201   
  1202   1202     return SQLITE_OK;
  1203   1203   }
  1204   1204   
  1205   1205   /*
  1206   1206   ** CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown()
  1207   1207   **

Changes to src/test_thread.c.

   276    276     Tcl_Obj *CONST objv[]
   277    277   ){
   278    278     int sqlite3TestMakePointerStr(Tcl_Interp *interp, char *zPtr, void *p);
   279    279   
   280    280     const char *zFilename;
   281    281     sqlite3 *db;
   282    282     char zBuf[100];
   283         -  extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);
          283  +  extern int Md5_Register(sqlite3*,char**,const sqlite3_api_routines*);
   284    284   
   285    285     UNUSED_PARAMETER(clientData);
   286    286     UNUSED_PARAMETER(objc);
   287    287   
   288    288     zFilename = Tcl_GetString(objv[2]);
   289    289     sqlite3_open(zFilename, &db);
   290    290   #ifdef SQLITE_HAS_CODEC