Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a module-destructor to the echo module (test8.c) to improve code coverage. (CVS 4372) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e3dd3651421ee723f9b7550fc333a308 |
User & Date: | danielk1977 2007-09-03 11:51:50.000 |
Context
2007-09-03
| ||
12:34 | Document the fact that xRandomness is only called once from the default VFS. Ticket #2614. (CVS 4373) (check-in: e89d4131a1 user: drh tags: trunk) | |
11:51 | Add a module-destructor to the echo module (test8.c) to improve code coverage. (CVS 4372) (check-in: e3dd365142 user: danielk1977 tags: trunk) | |
11:04 | Handle transient malloc() failures in sqlite3CreateFunc(). (CVS 4371) (check-in: c0ce631964 user: danielk1977 tags: trunk) | |
Changes
Changes to src/test8.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test8.c,v 1.56 2007/09/03 11:51:50 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #ifndef SQLITE_OMIT_VIRTUALTABLE |
︙ | ︙ | |||
345 346 347 348 349 350 351 352 353 354 355 356 357 358 | sqlite3_free(p->zThis); sqlite3_free(p->zTableName); sqlite3_free(p->zLogName); sqlite3_free(p); return 0; } /* ** This function is called to do the work of the xConnect() method - ** to allocate the required in-memory structures for a newly connected ** virtual table. */ static int echoConstructor( sqlite3 *db, | > > > > > | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | sqlite3_free(p->zThis); sqlite3_free(p->zTableName); sqlite3_free(p->zLogName); sqlite3_free(p); return 0; } typedef struct EchoModule EchoModule; struct EchoModule { Tcl_Interp *interp; }; /* ** This function is called to do the work of the xConnect() method - ** to allocate the required in-memory structures for a newly connected ** virtual table. */ static int echoConstructor( sqlite3 *db, |
︙ | ︙ | |||
366 367 368 369 370 371 372 | echo_vtab *pVtab; /* Allocate the sqlite3_vtab/echo_vtab structure itself */ pVtab = sqlite3MallocZero( sizeof(*pVtab) ); if( !pVtab ){ return SQLITE_NOMEM; } | | | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | echo_vtab *pVtab; /* Allocate the sqlite3_vtab/echo_vtab structure itself */ pVtab = sqlite3MallocZero( sizeof(*pVtab) ); if( !pVtab ){ return SQLITE_NOMEM; } pVtab->interp = ((EchoModule *)pAux)->interp; pVtab->db = db; /* Allocate echo_vtab.zThis */ pVtab->zThis = sqlite3MPrintf(0, "%s", argv[2]); if( !pVtab->zThis ){ echoDestructor((sqlite3_vtab *)pVtab); return SQLITE_NOMEM; |
︙ | ︙ | |||
423 424 425 426 427 428 429 | sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ int rc = SQLITE_OK; | | | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ int rc = SQLITE_OK; appendToEchoModule(((EchoModule *)pAux)->interp, "xCreate"); rc = echoConstructor(db, pAux, argc, argv, ppVtab, pzErr); /* If there were two arguments passed to the module at the SQL level ** (i.e. "CREATE VIRTUAL TABLE tbl USING echo(arg1, arg2)"), then ** the second argument is used as a table name. Attempt to create ** such a table with a single column, "logmsg". This table will ** be used to log calls to the xUpdate method. It will be deleted |
︙ | ︙ | |||
458 459 460 461 462 463 464 | static int echoConnect( sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ | | | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | static int echoConnect( sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ appendToEchoModule(((EchoModule *)pAux)->interp, "xConnect"); return echoConstructor(db, pAux, argc, argv, ppVtab, pzErr); } /* ** Echo virtual table module xDisconnect method. */ static int echoDisconnect(sqlite3_vtab *pVtab){ |
︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | /* ** Decode a pointer to an sqlite3 object. */ static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){ *ppDb = (sqlite3*)sqlite3TextToPtr(zA); return TCL_OK; } /* ** Register the echo virtual table module. */ static int register_echo_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ sqlite3 *db; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | > > > > > > > | | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | /* ** Decode a pointer to an sqlite3 object. */ static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){ *ppDb = (sqlite3*)sqlite3TextToPtr(zA); return TCL_OK; } static void moduleDestroy(void *p){ sqlite3_free(p); } /* ** Register the echo virtual table module. */ static int register_echo_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ sqlite3 *db; EchoModule *pMod; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; pMod = sqlite3_malloc(sizeof(EchoModule)); pMod->interp = interp; sqlite3_create_module_v2(db, "echo", &echoModule, (void*)pMod, moduleDestroy); return TCL_OK; } /* ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: ** ** sqlite3_declare_vtab DB SQL |
︙ | ︙ |