]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
A proof-of-concept for running sqlite3_blob_open() without using OP_Column kv-access-opt-demo
authordrh <drh@noemail.net>
Sat, 21 Jan 2017 15:30:20 +0000 (15:30 +0000)
committerdrh <drh@noemail.net>
Sat, 21 Jan 2017 15:30:20 +0000 (15:30 +0000)
when operating on a pure key/value table.  This demo does not include any
corrupt database checking.  Uses about 3% fewer CPU cycles on a key/value
performance test.

FossilOrigin-Name: 4cda3b305bd1ca893e40d49d90481f4d403ca50a

manifest
manifest.uuid
src/vdbeblob.c

index f0f41d4642f6dbc95d491e664b6a0dde04a4f200..54bf89037b80b1c28776d6279a5c584fb3e725f9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sunnecessary\ssqlite3_bind_int64()\scall\sfrom\ssqlite3_blob_open().\nAlso\sother\sminor\srefactoring\sof\sthe\ssqlite3_blob\simplementation.
-D 2017-01-21T14:11:28.343
+C A\sproof-of-concept\sfor\srunning\ssqlite3_blob_open()\swithout\susing\sOP_Column\nwhen\soperating\son\sa\spure\skey/value\stable.\s\sThis\sdemo\sdoes\snot\sinclude\sany\ncorrupt\sdatabase\schecking.\s\sUses\sabout\s3%\sfewer\sCPU\scycles\son\sa\skey/value\nperformance\stest.
+D 2017-01-21T15:30:20.343
 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -462,7 +462,7 @@ F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b
 F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e
 F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24
 F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147
-F src/vdbeblob.c 824f360105b8cd43c2ec8c4611fd3b162a3a3eed
+F src/vdbeblob.c d6e8d827a3c72447b6b5bbde69080f021fb2fc9a
 F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
 F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
@@ -1547,7 +1547,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 264e5c10d7144910b3223b64546567fa20e4bc65
-R 8ac11845f3680b4a63ed584c4ec0c997
+P 9d197a532349f4b1caf66bbed70ca46df86cb86f
+R 74005762b8c6f4cdf8d383a7684f6381
+T *branch * kv-access-opt-demo
+T *sym-kv-access-opt-demo *
+T -sym-trunk *
 U drh
-Z e8ceb26091bad5772496cc1502eaca7e
+Z 398f1069108acd007f88e9b5a9ec3940
index ca6ba2e6ad990b52fcd11c1c8ca8e02e5718bdd6..a74b0f790a769d2ec921ae518ec8a6fcf6acbf30 100644 (file)
@@ -1 +1 @@
-9d197a532349f4b1caf66bbed70ca46df86cb86f
\ No newline at end of file
+4cda3b305bd1ca893e40d49d90481f4d403ca50a
\ No newline at end of file
index 70a68b4015b071a425dfaae0bf5b091c717469c1..cbb0822cedd9ea6395ae5ab011735b19edbda3f9 100644 (file)
@@ -72,7 +72,22 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
   rc = sqlite3_step(p->pStmt);
   if( rc==SQLITE_ROW ){
     VdbeCursor *pC = v->apCsr[0];
-    u32 type = pC->aType[p->iCol];
+    u32 type;
+    if( p->isPureKV ){
+      u32 avail;
+      const u8 *a;
+      BtCursor *pCrsr = pC->uc.pCursor;
+      sqlite3BtreeEnterCursor(pCrsr);
+      (void)sqlite3BtreePayloadSize(pCrsr);
+      a = (const u8*)sqlite3BtreePayloadFetch(pCrsr, &avail);
+      assert( p->iCol==1 );
+      getVarint32(a+2, type);
+      sqlite3BtreeLeaveCursor(pCrsr);
+      p->iOffset = a[0];
+    }else{
+      type = pC->aType[p->iCol];
+      p->iOffset = pC->aType[p->iCol + pC->nField];
+    }
     if( type<12 ){
       zErr = sqlite3MPrintf(p->db, "cannot open value of type %s",
           type==0?"null": type==7?"real": "integer"
@@ -81,7 +96,6 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
       sqlite3_finalize(p->pStmt);
       p->pStmt = 0;
     }else{
-      p->iOffset = pC->aType[p->iCol + pC->nField];
       p->nByte = sqlite3VdbeSerialTypeLen(type);
       p->pCsr =  pC->uc.pCursor;
       sqlite3BtreeIncrblobCursor(p->pCsr);
@@ -311,14 +325,19 @@ int sqlite3_blob_open(
         aOp[1].p4.i = pTab->nCol+1;
         aOp[3].p2 = pTab->nCol;
 
+   
+        if( pTab->nCol==2 && pTab->iPKey==0 && iCol==1 ){
+          pBlob->isPureKV = 1;
+          aOp[3].opcode = OP_Noop;
+        }
+
         pParse->nVar = 0;
         pParse->nMem = 1;
         pParse->nTab = 1;
         sqlite3VdbeMakeReady(v, pParse);
       }
     }
-   
-    pBlob->isPureKV = (pTab->nCol==2 && pTab->iPKey==0);
+      
     pBlob->iCol = iCol;
     pBlob->db = db;
     sqlite3BtreeLeaveAll(db);