]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the parse_create_index() SQL function created by the incremental
authordrh <>
Sun, 5 Jul 2026 18:28:35 +0000 (18:28 +0000)
committerdrh <>
Sun, 5 Jul 2026 18:28:35 +0000 (18:28 +0000)
integrity_check extension so that it works for widely correct CREATE INDEX
statements.
[bugs:/info/2026-07-05T12:00:57Z|Bug 2026-07-05T12:00:57Z].
Also fix the extension so that it removes the parse_create_index() function.
Add the sqlite3_intck_register() API function so that the
parse_create_index() function can be more easily tested.

FossilOrigin-Name: bd28985523b02875b1045652fe29757e5d5519f48e6109ffebc99212314ab69c

ext/intck/sqlite3intck.c
manifest
manifest.uuid
src/shell.c.in
test/intck01.sql
test/shellB.test

index 6e2b5543a7348f40cac960224729a5363fa484a0..74f523affb1746094b0b62bd3b53bd339ea3db75 100644 (file)
@@ -335,6 +335,9 @@ static int intckGetToken(const char *z){
       iRet++;
     }
   }
+  else if( c==0 ){
+    iRet = 0;
+  }
 
   return iRet;
 }
@@ -775,6 +778,23 @@ static char *intckCheckObjectSql(
   return zRet;
 }
 
+/*
+** Register or unregister special SQL functions implemented by intck.
+**
+** Normally the custom SQL functions used by intck are only available
+** in between sqlite3_intck_open() and sqlite3_intck_close().  However,
+** for testing and debugging, it is sometimes useful to make those
+** functions available generally.  This routine provides as a separate
+** interface in order to provide that capability.
+*/
+int sqlite3_intck_register(sqlite3 *db, int bCreate){
+  int rc;
+  rc = sqlite3_create_function(db, "parse_create_index", 
+    2, SQLITE_UTF8, 0, bCreate ? intckParseCreateIndexFunc : 0, 0, 0
+  );
+  return rc;
+}
+
 /*
 ** Open a new integrity-check object.
 */
@@ -796,9 +816,7 @@ int sqlite3_intck_open(
     pNew->db = db;
     pNew->zDb = (const char*)&pNew[1];
     memcpy(&pNew[1], zDb, nDb+1);
-    rc = sqlite3_create_function(db, "parse_create_index", 
-        2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0
-    );
+    rc = sqlite3_intck_register(db, 1);
     if( rc!=SQLITE_OK ){
       sqlite3_intck_close(pNew);
       pNew = 0;
@@ -815,9 +833,7 @@ int sqlite3_intck_open(
 void sqlite3_intck_close(sqlite3_intck *p){
   if( p ){
     sqlite3_finalize(p->pCheck);
-    sqlite3_create_function(
-        p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0
-    );
+    sqlite3_intck_register(p->db, 0);
     sqlite3_free(p->zObj);
     sqlite3_free(p->zKey);
     sqlite3_free(p->zTestSql);
index 68502c615989fd00525fcad5dc7cbb27cc19f155..4a5523e748a8f640eadcb10ff2d678c315b6cf0b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Be\ssure\sto\sinvoke\sthe\sauthorizer\scallback\son\sall\sterms\sof\sthe\sUSING\sclause\nin\sa\sRIGHT\sJOIN.\n[bugs:/info/2026-07-05T08:15:45Z|Bug\s2026-07-05T08:15:45Z]
-D 2026-07-05T16:06:33.418
+C Fix\sthe\sparse_create_index()\sSQL\sfunction\screated\sby\sthe\sincremental\nintegrity_check\sextension\sso\sthat\sit\sworks\sfor\swidely\scorrect\sCREATE\sINDEX\nstatements.\n[bugs:/info/2026-07-05T12:00:57Z|Bug\s2026-07-05T12:00:57Z].\nAlso\sfix\sthe\sextension\sso\sthat\sit\sremoves\sthe\sparse_create_index()\sfunction.\nAdd\sthe\ssqlite3_intck_register()\sAPI\sfunction\sso\sthat\sthe\nparse_create_index()\sfunction\scan\sbe\smore\seasily\stested.
+D 2026-07-05T18:28:35.939
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -290,7 +290,7 @@ F ext/intck/intck_common.tcl a61fd2697ae55b0a3d89847ca0b590c6e0d8ff64bebb70920d9
 F ext/intck/intckbusy.test d5ed4ef85a4b1dc1dee2484bd14a4bb68529659cca743327df0c775f005fa387
 F ext/intck/intckcorrupt.test f6c302792326fb3db9dcfc70b554c55369bc4b52882eaaf039cfe0b74c821029
 F ext/intck/intckfault.test cff3f75dff74abb3edfcb13f6aa53f6436746ab64b09fe5e2028f051e985efab
-F ext/intck/sqlite3intck.c 134e65f5999f1b6a0d82f146f68488cd1bc47391861b497c598bed5198578924
+F ext/intck/sqlite3intck.c c06ae13326e4b5cb4a207d9b82280d12a19ce69d3281196217035e12c3a5af3a
 F ext/intck/sqlite3intck.h 2b40c38e7063ab822c974c0bd4aed97dabb579ccfe2e180a4639bb3bbef0f1c9
 F ext/intck/test_intck.c 4f9eaadaedccb9df1d26ba41116a0a8e5b0c5556dc3098c8ff68633adcccdea8
 F ext/jni/GNUmakefile 8a94e3a1953b88cf117fb2a5380480feada8b4f5316f02572cab425030a720b4
@@ -741,7 +741,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 54395ee97eb710e695202d4112cf2b1c1c7767a57afcea745df71abb1c917768
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c f553420eaf5c72a49cef786621eea79dd8c4411671839fb05250bb49ca74a0a0
-F src/shell.c.in 1bdd1d402ab9e50515010b1f3d1de86f7f98c103fb29f609b068aca513aff995
+F src/shell.c.in cabdf85361fa9ac9c9f6ee900fb7cce012984917583a2302c03ef40829e6a90c
 F src/sqlite.h.in d9ec41feb4cd804e68b174328b43beb3f1f71bba13e1c7a439efb826d301cccc
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 0efd4723bad9124ea1f581d9f1ea0254ac1c6f3e5fb29e4f3dcf36c72485a456
@@ -1324,7 +1324,7 @@ F test/insertfault.test ac63d14ea3b49c573673a572f4014b9117383a03e497c58f308b5c77
 F test/instr.test 67ba309e9697c24a304e98a7c8f372456177dd4e32237d2a305e1e05f7bb79c2
 F test/instrfault.test 95e28efade652e6d51ae11b377088fe523a581a07ec428009e152a4dd0e0f44c
 F test/intarray.test bb976b0b3df0ebb6a2eddfb61768280440e672beba5460ed49679ea984ccf440
-F test/intck01.sql f2d88bf41cdd64f2ed8c3d4f357cf520f017aa2986999ab9a62eb6506ef18106
+F test/intck01.sql cc67c49bb0dbffd8ede29d3e095ba2b758eaa3907eeeca3fd44048a01c4071d3
 F test/interrupt.test ac1ef50ec9ab8e4f0e17c47629f82539d4b22558904e321ed5abea2e6187da7a
 F test/interrupt2.test 7eaa40a975d950826cd56e6c37f0f0629adfa2d1a8d3333aff0ff7cf86069963
 F test/intpkey.test 7d54711acf553cdd641a40e9c6cfc2bf1a76070074940c1b126442517054320f
@@ -1642,7 +1642,7 @@ F test/shell7.test 6b006d296b569a7ec78b8168af77578b3bde8f58b79c32d9f46cff1eaf763
 F test/shell8.test 38c9e4d7e85d2a3ecfacaa9f6cda4f7a81bf4fffb5f3f37f9cd76827c6883192
 F test/shell9.test c0e8871061a92151450b3332279a893b516fa73a6c46d4f51a0998407cbf8c89
 F test/shellA.test 05cdaafa1f79913654487ce3aefa038d4106245d58f52e02faf506140a76d480
-F test/shellB.test 82622da7783c32ce931138bec3d5016e802d70361b9f9364b5d49c1dfc2f5af9
+F test/shellB.test 132ece4f4c50ca0af53dfc70ff5ebfb4d5ee98cd436db1bd4aae22a367877391
 F test/shmlock.test 9f1f729a7fe2c46c88b156af819ac9b72c0714ac6f7246638a73c5752b5fd13c
 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
@@ -2211,8 +2211,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 521a7cf8443d914ae0486aa8a91924ed35a1d5b88082acbe513cef216408c97e
-R c47e3ec58dfc5b3c5721b3f7bceaef2d
+P bbd69ce27462000873af053bfebdd305c53deac85c426b1e7dbd927b5f17d622
+R 0aa071819298f0881d8fe27486a22ba0
 U drh
-Z 83984ac253e20b3c315465f7f95b3ff9
+Z 2dfcd592cea9661faf5853a936cd3c85
 # Remove this line to create a well-formed Fossil manifest.
index 04677670ab8492071fe6d7b0f89d45517280e54d..f92e4f8ffabe2f65c5ef35df988172a5ccfb80cb 100644 (file)
@@ -1 +1 @@
-bbd69ce27462000873af053bfebdd305c53deac85c426b1e7dbd927b5f17d622
+bd28985523b02875b1045652fe29757e5d5519f48e6109ffebc99212314ab69c
index 99d9464948166cc82bfdf14e9f3c18f82a668135..cbc534ce57815e08d39a52b15ce2471c9b45abf9 100644 (file)
@@ -10668,9 +10668,17 @@ static int do_meta_command(const char *zLine, ShellState *p){
 
   if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
     i64 iArg = 0;
+    open_db(p, 0);
     if( nArg==2 ){
       iArg = integerValue(azArg[1]);
-      if( iArg==0 ) iArg = -1;
+      if( iArg==0 ){
+        if( cli_strcmp(azArg[1],"register")==0 ){
+          sqlite3_intck_register(p->db, 1);
+          rc = 0;
+          goto meta_command_exit;
+        }
+        iArg = -1;
+      }
     }
     if( (nArg!=1 && nArg!=2) || iArg<0 ){
       cli_printf(stderr,"%s","Usage: .intck STEPS_PER_UNLOCK\n");
index b1996aeeb9ad18cfc87722bec0ca47ca1274fae9..c451c9fa25de54dcdae081f01265a8307d559ddd 100644 (file)
@@ -15,9 +15,9 @@
 #
 .testcase 100
 .mode quote
-.intck 1
+.intck register
 SELECT parse_create_index('CREATE IDEX i ON t("x',0);
-.check <<END
-1 steps, 0 errors
-NULL
-END
+.check NULL
+.testcase 110
+SELECT parse_create_index(strdup(''),0);
+.check NULL
index baae9f984b537f62958bf6d239ce2bce57ba5d8e..3df4a074a86c534f122624f4195dce236c568aab 100644 (file)
@@ -22,10 +22,10 @@ set CLI [test_cli_invocation]
 # Capture the number of test cases and the number of
 # errors and increment the counts.
 #
-proc do_clitest {name} {
-  set mapping [list <NAME> $::testdir/$name <CLI> $::CLI]
+proc do_clitest {name args} {
+  set mapping [list <NAME> $::testdir/$name <CLI> $::CLI <ARGS> $args]
   set script [string map $mapping {
-    catch {exec <CLI> :memory: ".read <NAME>" 2>@stdout} res
+    catch {exec <CLI> <ARGS> :memory: ".read <NAME>" 2>@stdout} res
     set ntest 0
     set nerr 999
     regexp {(\d+) tests? run with (\d+) errors?} $res all ntest nerr
@@ -46,7 +46,7 @@ do_clitest imposter1.sql
 ifcapable vtab {
   do_clitest dotcmd01.sql
   do_clitest import01.sql
-  do_clitest intck01.sql
+  do_clitest intck01.sql --unsafe-testing
 }
 do_clitest fptest01.sql
 unset -nocomplain ::env(SQLITE_PS1)