Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/sqlite/src/src/test_init.c

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/src/test_hexio.c ('k') | third_party/sqlite/src/src/test_intarray.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2009 August 17 2 ** 2009 August 17
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
11 ************************************************************************* 11 *************************************************************************
12 ** 12 **
13 ** The code in this file is used for testing SQLite. It is not part of 13 ** The code in this file is used for testing SQLite. It is not part of
14 ** the source code used in production systems. 14 ** the source code used in production systems.
15 ** 15 **
16 ** Specifically, this file tests the effect of errors while initializing 16 ** Specifically, this file tests the effect of errors while initializing
17 ** the various pluggable sub-systems from within sqlite3_initialize(). 17 ** the various pluggable sub-systems from within sqlite3_initialize().
18 ** If an error occurs in sqlite3_initialize() the following should be 18 ** If an error occurs in sqlite3_initialize() the following should be
19 ** true: 19 ** true:
20 ** 20 **
21 ** 1) An error code is returned to the user, and 21 ** 1) An error code is returned to the user, and
22 ** 2) A subsequent call to sqlite3_shutdown() calls the shutdown method 22 ** 2) A subsequent call to sqlite3_shutdown() calls the shutdown method
23 ** of those subsystems that were initialized, and 23 ** of those subsystems that were initialized, and
24 ** 3) A subsequent call to sqlite3_initialize() attempts to initialize 24 ** 3) A subsequent call to sqlite3_initialize() attempts to initialize
25 ** the remaining, uninitialized, subsystems. 25 ** the remaining, uninitialized, subsystems.
26 */ 26 */
27 27
28 #include "sqliteInt.h" 28 #include "sqliteInt.h"
29 #include <string.h> 29 #include <string.h>
30 #include <tcl.h> 30 #if defined(INCLUDE_SQLITE_TCL_H)
31 # include "sqlite_tcl.h"
32 #else
33 # include "tcl.h"
34 #endif
31 35
32 static struct Wrapped { 36 static struct Wrapped {
33 sqlite3_pcache_methods2 pcache; 37 sqlite3_pcache_methods2 pcache;
34 sqlite3_mem_methods mem; 38 sqlite3_mem_methods mem;
35 sqlite3_mutex_methods mutex; 39 sqlite3_mutex_methods mutex;
36 40
37 int mem_init; /* True if mem subsystem is initalized */ 41 int mem_init; /* True if mem subsystem is initalized */
38 int mem_fail; /* True to fail mem subsystem inialization */ 42 int mem_fail; /* True to fail mem subsystem inialization */
39 int mutex_init; /* True if mutex subsystem is initalized */ 43 int mutex_init; /* True if mutex subsystem is initalized */
40 int mutex_fail; /* True to fail mutex subsystem inialization */ 44 int mutex_fail; /* True to fail mutex subsystem inialization */
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 181
178 sqlite3_shutdown(); 182 sqlite3_shutdown();
179 sqlite3_config(SQLITE_CONFIG_GETMUTEX, &wrapped.mutex); 183 sqlite3_config(SQLITE_CONFIG_GETMUTEX, &wrapped.mutex);
180 sqlite3_config(SQLITE_CONFIG_GETMALLOC, &wrapped.mem); 184 sqlite3_config(SQLITE_CONFIG_GETMALLOC, &wrapped.mem);
181 sqlite3_config(SQLITE_CONFIG_GETPCACHE2, &wrapped.pcache); 185 sqlite3_config(SQLITE_CONFIG_GETPCACHE2, &wrapped.pcache);
182 sqlite3_config(SQLITE_CONFIG_MUTEX, &mutexmethods); 186 sqlite3_config(SQLITE_CONFIG_MUTEX, &mutexmethods);
183 sqlite3_config(SQLITE_CONFIG_MALLOC, &memmethods); 187 sqlite3_config(SQLITE_CONFIG_MALLOC, &memmethods);
184 sqlite3_config(SQLITE_CONFIG_PCACHE2, &pcachemethods); 188 sqlite3_config(SQLITE_CONFIG_PCACHE2, &pcachemethods);
185 } 189 }
186 190
187 static int init_wrapper_install( 191 static int SQLITE_TCLAPI init_wrapper_install(
188 ClientData clientData, /* Unused */ 192 ClientData clientData, /* Unused */
189 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 193 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
190 int objc, /* Number of arguments */ 194 int objc, /* Number of arguments */
191 Tcl_Obj *CONST objv[] /* Command arguments */ 195 Tcl_Obj *CONST objv[] /* Command arguments */
192 ){ 196 ){
193 int i; 197 int i;
194 installInitWrappers(); 198 installInitWrappers();
195 for(i=1; i<objc; i++){ 199 for(i=1; i<objc; i++){
196 char *z = Tcl_GetString(objv[i]); 200 char *z = Tcl_GetString(objv[i]);
197 if( strcmp(z, "mem")==0 ){ 201 if( strcmp(z, "mem")==0 ){
198 wrapped.mem_fail = 1; 202 wrapped.mem_fail = 1;
199 }else if( strcmp(z, "mutex")==0 ){ 203 }else if( strcmp(z, "mutex")==0 ){
200 wrapped.mutex_fail = 1; 204 wrapped.mutex_fail = 1;
201 }else if( strcmp(z, "pcache")==0 ){ 205 }else if( strcmp(z, "pcache")==0 ){
202 wrapped.pcache_fail = 1; 206 wrapped.pcache_fail = 1;
203 }else{ 207 }else{
204 Tcl_AppendResult(interp, "Unknown argument: \"", z, "\""); 208 Tcl_AppendResult(interp, "Unknown argument: \"", z, "\"");
205 return TCL_ERROR; 209 return TCL_ERROR;
206 } 210 }
207 } 211 }
208 return TCL_OK; 212 return TCL_OK;
209 } 213 }
210 214
211 static int init_wrapper_uninstall( 215 static int SQLITE_TCLAPI init_wrapper_uninstall(
212 ClientData clientData, /* Unused */ 216 ClientData clientData, /* Unused */
213 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 217 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
214 int objc, /* Number of arguments */ 218 int objc, /* Number of arguments */
215 Tcl_Obj *CONST objv[] /* Command arguments */ 219 Tcl_Obj *CONST objv[] /* Command arguments */
216 ){ 220 ){
217 if( objc!=1 ){ 221 if( objc!=1 ){
218 Tcl_WrongNumArgs(interp, 1, objv, ""); 222 Tcl_WrongNumArgs(interp, 1, objv, "");
219 return TCL_ERROR; 223 return TCL_ERROR;
220 } 224 }
221 225
222 sqlite3_shutdown(); 226 sqlite3_shutdown();
223 sqlite3_config(SQLITE_CONFIG_MUTEX, &wrapped.mutex); 227 sqlite3_config(SQLITE_CONFIG_MUTEX, &wrapped.mutex);
224 sqlite3_config(SQLITE_CONFIG_MALLOC, &wrapped.mem); 228 sqlite3_config(SQLITE_CONFIG_MALLOC, &wrapped.mem);
225 sqlite3_config(SQLITE_CONFIG_PCACHE2, &wrapped.pcache); 229 sqlite3_config(SQLITE_CONFIG_PCACHE2, &wrapped.pcache);
226 return TCL_OK; 230 return TCL_OK;
227 } 231 }
228 232
229 static int init_wrapper_clear( 233 static int SQLITE_TCLAPI init_wrapper_clear(
230 ClientData clientData, /* Unused */ 234 ClientData clientData, /* Unused */
231 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 235 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
232 int objc, /* Number of arguments */ 236 int objc, /* Number of arguments */
233 Tcl_Obj *CONST objv[] /* Command arguments */ 237 Tcl_Obj *CONST objv[] /* Command arguments */
234 ){ 238 ){
235 if( objc!=1 ){ 239 if( objc!=1 ){
236 Tcl_WrongNumArgs(interp, 1, objv, ""); 240 Tcl_WrongNumArgs(interp, 1, objv, "");
237 return TCL_ERROR; 241 return TCL_ERROR;
238 } 242 }
239 243
240 wrapped.mem_fail = 0; 244 wrapped.mem_fail = 0;
241 wrapped.mutex_fail = 0; 245 wrapped.mutex_fail = 0;
242 wrapped.pcache_fail = 0; 246 wrapped.pcache_fail = 0;
243 return TCL_OK; 247 return TCL_OK;
244 } 248 }
245 249
246 static int init_wrapper_query( 250 static int SQLITE_TCLAPI init_wrapper_query(
247 ClientData clientData, /* Unused */ 251 ClientData clientData, /* Unused */
248 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 252 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
249 int objc, /* Number of arguments */ 253 int objc, /* Number of arguments */
250 Tcl_Obj *CONST objv[] /* Command arguments */ 254 Tcl_Obj *CONST objv[] /* Command arguments */
251 ){ 255 ){
252 Tcl_Obj *pRet; 256 Tcl_Obj *pRet;
253 257
254 if( objc!=1 ){ 258 if( objc!=1 ){
255 Tcl_WrongNumArgs(interp, 1, objv, ""); 259 Tcl_WrongNumArgs(interp, 1, objv, "");
256 return TCL_ERROR; 260 return TCL_ERROR;
(...skipping 25 matching lines...) Expand all
282 {"init_wrapper_clear", init_wrapper_clear} 286 {"init_wrapper_clear", init_wrapper_clear}
283 }; 287 };
284 int i; 288 int i;
285 289
286 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ 290 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
287 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); 291 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
288 } 292 }
289 293
290 return TCL_OK; 294 return TCL_OK;
291 } 295 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/src/test_hexio.c ('k') | third_party/sqlite/src/src/test_intarray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698