1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Return SQLITE_MISUSE if an application attempts to register a virtual table module with the same name as an existing module.

FossilOrigin-Name: ea2cd55e098b21cd8997fd6c1978131d3ef2fab4
This commit is contained in:
dan
2012-05-16 14:29:11 +00:00
parent 5efb314525
commit ca8b9bac3b
5 changed files with 62 additions and 38 deletions

View File

@@ -1300,6 +1300,7 @@ static sqlite3_module echoModuleV2 = {
** Decode a pointer to an sqlite3 object.
*/
extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
extern const char *sqlite3TestErrorName(int rc);
static void moduleDestroy(void *p){
sqlite3_free(p);
@@ -1314,6 +1315,7 @@ static int register_echo_module(
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
int rc;
sqlite3 *db;
EchoModule *pMod;
if( objc!=2 ){
@@ -1325,14 +1327,20 @@ static int register_echo_module(
/* Virtual table module "echo" */
pMod = sqlite3_malloc(sizeof(EchoModule));
pMod->interp = interp;
sqlite3_create_module_v2(db, "echo", &echoModule, (void*)pMod, moduleDestroy);
rc = sqlite3_create_module_v2(
db, "echo", &echoModule, (void*)pMod, moduleDestroy
);
/* Virtual table module "echo_v2" */
pMod = sqlite3_malloc(sizeof(EchoModule));
pMod->interp = interp;
sqlite3_create_module_v2(db, "echo_v2",
&echoModuleV2, (void*)pMod, moduleDestroy
);
if( rc==SQLITE_OK ){
pMod = sqlite3_malloc(sizeof(EchoModule));
pMod->interp = interp;
rc = sqlite3_create_module_v2(db, "echo_v2",
&echoModuleV2, (void*)pMod, moduleDestroy
);
}
Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
return TCL_OK;
}