]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhancements to sqlite3BitvecBuiltinTest() that allow testing code to
authordrh <>
Tue, 10 Jun 2025 17:22:53 +0000 (17:22 +0000)
committerdrh <>
Tue, 10 Jun 2025 17:22:53 +0000 (17:22 +0000)
create very large Bitvec objects that do not use the linear array cross-check.

FossilOrigin-Name: c5680672cae23f65637eebf66f3bb983a2864be03ea70378832034f3c89ef728

manifest
manifest.uuid
src/bitvec.c

index 9a9cb8ba38c3b14dd527f45e7fd14967f9615a0e..04ef150ffcbb61411b0db5353de65d4eb32aa922 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\sdiagnostics\sfor\sBitvec:\s\sAdd\sthe\ssqlite3ShowBitvec()\sroutine\sthat\ncan\sbe\scalled\sfrom\sa\sdebugger\s(only\savailable\swith\sSQLITE_DEBUG).\s\sAdd\snew\noutput\sopcodes\sfor\ssqlite3BitvecBuiltinTest().
-D 2025-06-10T16:02:29.157
+C Enhancements\sto\ssqlite3BitvecBuiltinTest()\sthat\sallow\stesting\scode\sto\ncreate\svery\slarge\sBitvec\sobjects\sthat\sdo\snot\suse\sthe\slinear\sarray\scross-check.
+D 2025-06-10T17:22:53.410
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -724,7 +724,7 @@ F src/analyze.c 03bcfc083fc0cccaa9ded93604e1d4244ea245c17285d463ef6a60425fcb247d
 F src/attach.c 9af61b63b10ee702b1594ecd24fb8cea0839cfdb6addee52fba26fa879f5db9d
 F src/auth.c 54ab9c6c5803b47c0d45b76ce27eff22a03b4b1f767c5945a3a4eb13aa4c78dc
 F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523
-F src/bitvec.c 248cfe775b6a6040615d59116fc7468de3568caf802a8ecb5fdedbe4b336357f
+F src/bitvec.c bf4516e0b64905315e41f6cd98fddf3321e1fa45b4639c58c1e33be3a36762f9
 F src/btmutex.c 30dada73a819a1ef5b7583786370dce1842e12e1ad941e4d05ac29695528daea
 F src/btree.c 53a9c7b243e94c992853d90f1dac0959028433b4b0d27e04409cee04e001b508
 F src/btree.h 18e5e7b2124c23426a283523e5f31a4bff029131b795bb82391f9d2f3136fc50
@@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 96b14a3f1193de8f30e9fa704f87558dab8027a218868d32e47688cd5df497b7
-R 18009ba9dff94b8a020eccfe5001a554
+P dea1e37fa67ada6efc1533b449d9eb22338d9e58eec8f89b48c38319c212c8f4
+R f17be20aba33ae92effa44ccdc334f8f
 U drh
-Z 5261ad27d85df5b5801fdf97adab7f4f
+Z d746dc167462d800e8f34514e232eed7
 # Remove this line to create a well-formed Fossil manifest.
index 440cdd9f26597caae638064f3577472fe062fba2..ba91fb995576150113e2aed28d2e24488013032b 100644 (file)
@@ -1 +1 @@
-dea1e37fa67ada6efc1533b449d9eb22338d9e58eec8f89b48c38319c212c8f4
+c5680672cae23f65637eebf66f3bb983a2864be03ea70378832034f3c89ef728
index 89cf1b30bc32de1aa48faf8467c60bf86d3c0a41..3855ebfc2e990b05032b2123931806f9fc12ce65 100644 (file)
@@ -385,6 +385,9 @@ void sqlite3ShowBitvec(Bitvec *p){
 ** an error is returned.  If they are the same, zero is returned.
 **
 ** If a memory allocation error occurs, return -1.
+**
+** sz is the size of the Bitvec.  Or if sz is negative, make the size
+** 2*(unsigned)(-sz) and disabled the linear vector check.
 */
 int sqlite3BitvecBuiltinTest(int sz, int *aOp){
   Bitvec *pBitvec = 0;
@@ -395,10 +398,15 @@ int sqlite3BitvecBuiltinTest(int sz, int *aOp){
 
   /* Allocate the Bitvec to be tested and a linear array of
   ** bits to act as the reference */
-  pBitvec = sqlite3BitvecCreate( sz );
-  pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 );
+  if( sz<=0 ){
+    pBitvec = sqlite3BitvecCreate( 2*(unsigned)(-sz) );
+    pV = 0;
+  }else{
+    pBitvec = sqlite3BitvecCreate( sz );
+    pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 );
+  }
   pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
-  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;
+  if( pBitvec==0 || pTmpSpace==0  ) goto bitvec_end;
 
   /* NULL pBitvec tests */
   sqlite3BitvecSet(0, 1);
@@ -448,12 +456,12 @@ int sqlite3BitvecBuiltinTest(int sz, int *aOp){
     pc += nx;
     i = (i & 0x7fffffff)%sz;
     if( (op & 1)!=0 ){
-      SETBIT(pV, (i+1));
+      if( pV ) SETBIT(pV, (i+1));
       if( op!=5 ){
         if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;
       }
     }else{
-      CLEARBIT(pV, (i+1));
+      if( pV ) CLEARBIT(pV, (i+1));
       sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);
     }
   }
@@ -463,14 +471,18 @@ int sqlite3BitvecBuiltinTest(int sz, int *aOp){
   ** match (rc==0).  Change rc to non-zero if a discrepancy
   ** is found.
   */
-  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
-          + sqlite3BitvecTest(pBitvec, 0)
-          + (sqlite3BitvecSize(pBitvec) - sz);
-  for(i=1; i<=sz; i++){
-    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
-      rc = i;
-      break;
+  if( pV ){
+    rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
+            + sqlite3BitvecTest(pBitvec, 0)
+            + (sqlite3BitvecSize(pBitvec) - sz);
+    for(i=1; i<=sz; i++){
+      if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
+        rc = i;
+        break;
+      }
     }
+  }else{
+    rc = 0;
   }
 
   /* Free allocated structure */