| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2006 June 10 | 2 ** 2006 June 10 |
| 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 ** Code for testing the virtual table interfaces. This code | 12 ** Code for testing the virtual table interfaces. This code |
| 13 ** is not included in the SQLite library. It is used for automated | 13 ** is not included in the SQLite library. It is used for automated |
| 14 ** testing of the SQLite library. | 14 ** testing of the SQLite library. |
| 15 */ | 15 */ |
| 16 #include "sqliteInt.h" | 16 #include "sqliteInt.h" |
| 17 #include "tcl.h" | 17 #if defined(INCLUDE_SQLITE_TCL_H) |
| 18 # include "sqlite_tcl.h" |
| 19 #else |
| 20 # include "tcl.h" |
| 21 #endif |
| 18 #include <stdlib.h> | 22 #include <stdlib.h> |
| 19 #include <string.h> | 23 #include <string.h> |
| 20 | 24 |
| 21 #ifndef SQLITE_OMIT_VIRTUALTABLE | 25 #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 22 | 26 |
| 23 typedef struct echo_vtab echo_vtab; | 27 typedef struct echo_vtab echo_vtab; |
| 24 typedef struct echo_cursor echo_cursor; | 28 typedef struct echo_cursor echo_cursor; |
| 25 | 29 |
| 26 /* | 30 /* |
| 27 ** The test module defined in this file uses four global Tcl variables to | 31 ** The test module defined in this file uses four global Tcl variables to |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); | 1350 extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); |
| 1347 extern const char *sqlite3ErrName(int); | 1351 extern const char *sqlite3ErrName(int); |
| 1348 | 1352 |
| 1349 static void moduleDestroy(void *p){ | 1353 static void moduleDestroy(void *p){ |
| 1350 sqlite3_free(p); | 1354 sqlite3_free(p); |
| 1351 } | 1355 } |
| 1352 | 1356 |
| 1353 /* | 1357 /* |
| 1354 ** Register the echo virtual table module. | 1358 ** Register the echo virtual table module. |
| 1355 */ | 1359 */ |
| 1356 static int register_echo_module( | 1360 static int SQLITE_TCLAPI register_echo_module( |
| 1357 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1361 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1358 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1362 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1359 int objc, /* Number of arguments */ | 1363 int objc, /* Number of arguments */ |
| 1360 Tcl_Obj *CONST objv[] /* Command arguments */ | 1364 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1361 ){ | 1365 ){ |
| 1362 int rc; | 1366 int rc; |
| 1363 sqlite3 *db; | 1367 sqlite3 *db; |
| 1364 EchoModule *pMod; | 1368 EchoModule *pMod; |
| 1365 if( objc!=2 ){ | 1369 if( objc!=2 ){ |
| 1366 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 1370 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1386 | 1390 |
| 1387 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); | 1391 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
| 1388 return TCL_OK; | 1392 return TCL_OK; |
| 1389 } | 1393 } |
| 1390 | 1394 |
| 1391 /* | 1395 /* |
| 1392 ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: | 1396 ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: |
| 1393 ** | 1397 ** |
| 1394 ** sqlite3_declare_vtab DB SQL | 1398 ** sqlite3_declare_vtab DB SQL |
| 1395 */ | 1399 */ |
| 1396 static int declare_vtab( | 1400 static int SQLITE_TCLAPI declare_vtab( |
| 1397 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1401 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1398 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1402 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1399 int objc, /* Number of arguments */ | 1403 int objc, /* Number of arguments */ |
| 1400 Tcl_Obj *CONST objv[] /* Command arguments */ | 1404 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1401 ){ | 1405 ){ |
| 1402 sqlite3 *db; | 1406 sqlite3 *db; |
| 1403 int rc; | 1407 int rc; |
| 1404 if( objc!=3 ){ | 1408 if( objc!=3 ){ |
| 1405 Tcl_WrongNumArgs(interp, 1, objv, "DB SQL"); | 1409 Tcl_WrongNumArgs(interp, 1, objv, "DB SQL"); |
| 1406 return TCL_ERROR; | 1410 return TCL_ERROR; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1430 { "sqlite3_declare_vtab", declare_vtab, 0 }, | 1434 { "sqlite3_declare_vtab", declare_vtab, 0 }, |
| 1431 }; | 1435 }; |
| 1432 int i; | 1436 int i; |
| 1433 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ | 1437 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
| 1434 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, | 1438 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, |
| 1435 aObjCmd[i].xProc, aObjCmd[i].clientData, 0); | 1439 aObjCmd[i].xProc, aObjCmd[i].clientData, 0); |
| 1436 } | 1440 } |
| 1437 #endif | 1441 #endif |
| 1438 return TCL_OK; | 1442 return TCL_OK; |
| 1439 } | 1443 } |
| OLD | NEW |