aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2021-05-17 13:11:24 +0000
committerdrh <>2021-05-17 13:11:24 +0000
commitba39ca40588dfef1a07f172c20fac0197c01c0a2 (patch)
tree4ae3c5ac470ab103028e0f966685a394700261e9 /src
parent9430506df07923d22a4bd03973ff5671e76dfed4 (diff)
downloadsqlite-ba39ca40588dfef1a07f172c20fac0197c01c0a2.tar.gz
sqlite-ba39ca40588dfef1a07f172c20fac0197c01c0a2.zip
When deleting an SQL function that does not exist, return without doing
anything at all rather than creating a tombstone function. In this way, function deletes that happen inside virtual-table destructors that are run when a database connection is closing do not create new tombstones in the function table after the function table has already been purged. [forum:/forumpost/726219164b|forum post 726219164b]. FossilOrigin-Name: 391c73132c80df944fb49a17d8fe78203c54ac48f968ee9dd9dd8c769c0b4b10
Diffstat (limited to 'src')
-rw-r--r--src/main.c4
-rw-r--r--src/test8.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 785b646d2..bd92f7661 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1884,6 +1884,10 @@ int sqlite3CreateFunc(
}else{
sqlite3ExpirePreparedStatements(db, 0);
}
+ }else if( xSFunc==0 && xFinal==0 ){
+ /* Trying to delete a function that does not exist. This is a no-op.
+ ** https://sqlite.org/forum/forumpost/726219164b */
+ return SQLITE_OK;
}
p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);
diff --git a/src/test8.c b/src/test8.c
index f984c2e5f..7a532346e 100644
--- a/src/test8.c
+++ b/src/test8.c
@@ -389,6 +389,7 @@ static int echoDestructor(sqlite3_vtab *pVtab){
typedef struct EchoModule EchoModule;
struct EchoModule {
Tcl_Interp *interp;
+ sqlite3 *db;
};
/*
@@ -1352,6 +1353,9 @@ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
extern const char *sqlite3ErrName(int);
static void moduleDestroy(void *p){
+ EchoModule *pMod = (EchoModule*)p;
+ sqlite3_create_function(pMod->db, "function_that_does_not_exist_0982ma98",
+ SQLITE_ANY, 1, 0, 0, 0, 0);
sqlite3_free(p);
}
@@ -1376,6 +1380,7 @@ static int SQLITE_TCLAPI register_echo_module(
/* Virtual table module "echo" */
pMod = sqlite3_malloc(sizeof(EchoModule));
pMod->interp = interp;
+ pMod->db = db;
rc = sqlite3_create_module_v2(
db, "echo", &echoModule, (void*)pMod, moduleDestroy
);
@@ -1384,6 +1389,7 @@ static int SQLITE_TCLAPI register_echo_module(
if( rc==SQLITE_OK ){
pMod = sqlite3_malloc(sizeof(EchoModule));
pMod->interp = interp;
+ pMod->db = db;
rc = sqlite3_create_module_v2(db, "echo_v2",
&echoModuleV2, (void*)pMod, moduleDestroy
);