Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the sqlite3_cancel_auto_extension(X) interface which will undo a prior call to sqlite3_auto_extension(X). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
cdce87eb889a43dafcc560d5f97ab517 |
User & Date: | drh 2013-07-15 17:02:28.816 |
Context
2013-07-16
| ||
21:31 | Enhance the query planner so that it looks at multiple solutions to OR expressions in the WHERE clause. (check-in: 5e19d05410 user: drh tags: trunk) | |
2013-07-15
| ||
17:02 | Add the sqlite3_cancel_auto_extension(X) interface which will undo a prior call to sqlite3_auto_extension(X). (check-in: cdce87eb88 user: drh tags: trunk) | |
2013-07-12
| ||
21:09 | Make sure the shell does not try to put a zero terminator on the end of an unallocated zero-length string when running ".import" on an empty file. (check-in: 92adaee5bd user: drh tags: trunk) | |
Changes
Changes to src/loadext.c.
︙ | ︙ | |||
663 664 665 666 667 668 669 670 671 672 673 674 675 676 | } } sqlite3_mutex_leave(mutex); assert( (rc&0xff)==rc ); return rc; } } /* ** Reset the automatic extension loading mechanism. */ void sqlite3_reset_auto_extension(void){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize()==SQLITE_OK ) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | } } sqlite3_mutex_leave(mutex); assert( (rc&0xff)==rc ); return rc; } } /* ** Cancel a prior call to sqlite3_auto_extension. Remove xInit from the ** set of routines that is invoked for each new database connection, if it ** is currently on the list. If xInit is not on the list, then this ** routine is a no-op. ** ** 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)){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); #endif int i; int n = 0; wsdAutoextInit; sqlite3_mutex_enter(mutex); for(i=wsdAutoext.nExt-1; i>=0; i--){ if( wsdAutoext.aExt[i]==xInit ){ wsdAutoext.nExt--; wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; n++; break; } } sqlite3_mutex_leave(mutex); return n; } /* ** Reset the automatic extension loading mechanism. */ void sqlite3_reset_auto_extension(void){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize()==SQLITE_OK ) |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
5119 5120 5121 5122 5123 5124 5125 | ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. ** ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already ** on the list of automatic extensions is a harmless no-op. ^No entry point ** will be called more than once for each database connection that is opened. ** | | > > > > > > > > > > > > > | 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 | ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. ** ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already ** on the list of automatic extensions is a harmless no-op. ^No entry point ** will be called more than once for each database connection that is opened. ** ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ int sqlite3_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Cancel Automatic Extension Loading ** ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the ** initialization routine X that was registered using a prior call to ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] ** routine returns 1 if initialization routine X was successfully ** unregistered and it returns 0 if X was not on the list of initialization ** routines. */ int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Reset Automatic Extension Loading ** ** ^This interface disables all automatic extensions previously ** registered using [sqlite3_auto_extension()]. */ void sqlite3_reset_auto_extension(void); |
︙ | ︙ |
Changes to src/test_autoext.c.
︙ | ︙ | |||
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 | int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_auto_extension_cube ** ** Register the "cube" extension to be loaded automatically. */ static int autoExtCubeObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_auto_extension_broken ** ** Register the broken extension to be loaded automatically. */ static int autoExtBrokenObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } #endif /* SQLITE_OMIT_LOAD_EXTENSION */ /* ** tclcmd: sqlite3_reset_auto_extension ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_cancel_auto_extension_sqr ** ** Unregister the "sqr" extension. */ static int cancelAutoExtSqrObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_cancel_auto_extension((void*)sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_auto_extension_cube ** ** Register the "cube" extension to be loaded automatically. */ static int autoExtCubeObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_cancel_auto_extension_cube ** ** Unregister the "cube" extension. */ static int cancelAutoExtCubeObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_cancel_auto_extension((void*)cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_auto_extension_broken ** ** Register the broken extension to be loaded automatically. */ static int autoExtBrokenObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_auto_extension((void*)broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } /* ** tclcmd: sqlite3_cancel_auto_extension_broken ** ** Unregister the broken extension. */ static int cancelAutoExtBrokenObjCmd( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int rc = sqlite3_cancel_auto_extension((void*)broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } #endif /* SQLITE_OMIT_LOAD_EXTENSION */ /* ** tclcmd: sqlite3_reset_auto_extension ** |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 | Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_sqr", autoExtSqrObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_cube", autoExtCubeObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_broken", autoExtBrokenObjCmd, 0, 0); #endif Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension", resetAutoExtObjCmd, 0, 0); return TCL_OK; } | > > > > > > | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_sqr", autoExtSqrObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_cube", autoExtCubeObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_broken", autoExtBrokenObjCmd, 0, 0); #endif Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_sqr", cancelAutoExtSqrObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_cube", cancelAutoExtCubeObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_cancel_auto_extension_broken", cancelAutoExtBrokenObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension", resetAutoExtObjCmd, 0, 0); return TCL_OK; } |
Changes to test/loadext2.test.
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | } } {1 {no such function: sqr}} do_test loadext2-1.2 { catchsql { SELECT cube(2) } } {1 {no such function: cube}} # Register auto-loaders. Still functions do not exist. # do_test loadext2-1.3 { sqlite3_auto_extension_sqr sqlite3_auto_extension_cube catchsql { | > > > > > > > > > > > > > | 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 | } } {1 {no such function: sqr}} do_test loadext2-1.2 { catchsql { SELECT cube(2) } } {1 {no such function: cube}} # Extensions loaders not currently registered # do_test loadext2-1.2.1 { sqlite3_cancel_auto_extension_sqr } {0} do_test loadext2-1.2.2 { sqlite3_cancel_auto_extension_sqr } {0} do_test loadext2-1.2.3 { sqlite3_cancel_auto_extension_sqr } {0} # Register auto-loaders. Still functions do not exist. # do_test loadext2-1.3 { sqlite3_auto_extension_sqr sqlite3_auto_extension_cube catchsql { |
︙ | ︙ | |||
72 73 74 75 76 77 78 | SELECT cube(2) } } {0 8.0} # Reset extension auto loading. Existing extensions still exist. # | | | > > > > > > > > > > > | 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 | SELECT cube(2) } } {0 8.0} # Reset extension auto loading. Existing extensions still exist. # do_test loadext2-1.7.1 { sqlite3_cancel_auto_extension_sqr } {1} do_test loadext2-1.7.2 { sqlite3_cancel_auto_extension_sqr } {0} do_test loadext2-1.7.3 { sqlite3_cancel_auto_extension_cube } {1} do_test loadext2-1.7.4 { sqlite3_cancel_auto_extension_cube } {0} do_test loadext2-1.7.5 { catchsql { SELECT sqr(2) } } {0 4.0} do_test loadext2-1.8 { catchsql { SELECT cube(2) |
︙ | ︙ |