From: drh Date: Sat, 21 Jan 2017 14:11:28 +0000 (+0000) Subject: Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open(). X-Git-Tag: version-3.17.0~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36cae856eef6769c83da403bd73247c12474142f;p=thirdparty%2Fsqlite.git Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open(). Also other minor refactoring of the sqlite3_blob implementation. FossilOrigin-Name: 9d197a532349f4b1caf66bbed70ca46df86cb86f --- diff --git a/manifest b/manifest index 9780aa2959..f0f41d4642 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sperformance\soptimization\sand\ssize\sreduction\sto\sthe\saccessPayload()\nroutine\sin\sbtree.c. -D 2017-01-20T20:43:14.971 +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 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 fe3694fcc3cf2cad395416f5289bd0e935c2659d +F src/vdbeblob.c 824f360105b8cd43c2ec8c4611fd3b162a3a3eed F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 @@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8971d98f25a4f5fb060db8ed6a4b06f083122a50 -R 6803846831f043d39b9c85f99ff10309 +P 264e5c10d7144910b3223b64546567fa20e4bc65 +R 8ac11845f3680b4a63ed584c4ec0c997 U drh -Z 62cd4db9c45f8ac36491823fd1143808 +Z e8ceb26091bad5772496cc1502eaca7e diff --git a/manifest.uuid b/manifest.uuid index 6d1f724a7b..ca6ba2e6ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -264e5c10d7144910b3223b64546567fa20e4bc65 \ No newline at end of file +9d197a532349f4b1caf66bbed70ca46df86cb86f \ No newline at end of file diff --git a/src/vdbeblob.c b/src/vdbeblob.c index b2902ba321..70a68b4015 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -23,10 +23,10 @@ */ typedef struct Incrblob Incrblob; struct Incrblob { - int flags; /* Copy of "flags" passed to sqlite3_blob_open() */ int nByte; /* Size of open blob, in bytes */ int iOffset; /* Byte offset of blob in cursor data */ - int iCol; /* Table column this handle is open on */ + u16 iCol; /* Table column this handle is open on */ + u8 isPureKV; /* True if pTab is a pure key/value table */ BtCursor *pCsr; /* Cursor pointing at blob row */ sqlite3_stmt *pStmt; /* Statement holding cursor open */ sqlite3 *db; /* The associated database */ @@ -117,7 +117,7 @@ int sqlite3_blob_open( const char *zTable, /* The table containing the blob */ const char *zColumn, /* The column containing the blob */ sqlite_int64 iRow, /* The row containing the glob */ - int flags, /* True -> read/write access, false -> read-only */ + int wrFlag, /* True -> read/write access, false -> read-only */ sqlite3_blob **ppBlob /* Handle for accessing the blob returned here */ ){ int nAttempt = 0; @@ -139,7 +139,7 @@ int sqlite3_blob_open( return SQLITE_MISUSE_BKPT; } #endif - flags = !!flags; /* flags = (flags ? 1 : 0); */ + wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */ sqlite3_mutex_enter(db->mutex); @@ -199,9 +199,8 @@ int sqlite3_blob_open( /* If the value is being opened for writing, check that the ** column is not indexed, and that it is not part of a foreign key. - ** It is against the rules to open a column to which either of these - ** descriptions applies for writing. */ - if( flags ){ + */ + if( wrFlag ){ const char *zFault = 0; Index *pIdx; #ifndef SQLITE_OMIT_FOREIGN_KEY @@ -272,7 +271,7 @@ int sqlite3_blob_open( int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); VdbeOp *aOp; - sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags, + sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag, pTab->pSchema->schema_cookie, pTab->pSchema->iGeneration); sqlite3VdbeChangeP5(v, 1); @@ -289,7 +288,7 @@ int sqlite3_blob_open( #else aOp[0].p1 = iDb; aOp[0].p2 = pTab->tnum; - aOp[0].p3 = flags; + aOp[0].p3 = wrFlag; sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT); } if( db->mallocFailed==0 ){ @@ -297,7 +296,7 @@ int sqlite3_blob_open( /* Remove either the OP_OpenWrite or OpenRead. Set the P2 ** parameter of the other to pTab->tnum. */ - if( flags ) aOp[1].opcode = OP_OpenWrite; + if( wrFlag ) aOp[1].opcode = OP_OpenWrite; aOp[1].p2 = pTab->tnum; aOp[1].p3 = iDb; @@ -319,14 +318,13 @@ int sqlite3_blob_open( } } - pBlob->flags = flags; + pBlob->isPureKV = (pTab->nCol==2 && pTab->iPKey==0); pBlob->iCol = iCol; pBlob->db = db; sqlite3BtreeLeaveAll(db); if( db->mallocFailed ){ goto blob_open_out; } - sqlite3_bind_int64(pBlob->pStmt, 1, iRow); rc = blobSeekToRow(pBlob, iRow, &zErr); } while( (++nAttempt)