1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open().

Also other minor refactoring of the sqlite3_blob implementation.

FossilOrigin-Name: 9d197a532349f4b1caf66bbed70ca46df86cb86f
This commit is contained in:
drh
2017-01-21 14:11:28 +00:00
parent cd64553015
commit 36cae856ee
3 changed files with 17 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
C Minor\sperformance\soptimization\sand\ssize\sreduction\sto\sthe\saccessPayload()\nroutine\sin\sbtree.c. C Remove\san\sunnecessary\ssqlite3_bind_int64()\scall\sfrom\ssqlite3_blob_open().\nAlso\sother\sminor\srefactoring\sof\sthe\ssqlite3_blob\simplementation.
D 2017-01-20T20:43:14.971 D 2017-01-21T14:11:28.343
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -462,7 +462,7 @@ F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b
F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e
F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24 F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24
F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147 F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147
F src/vdbeblob.c fe3694fcc3cf2cad395416f5289bd0e935c2659d F src/vdbeblob.c 824f360105b8cd43c2ec8c4611fd3b162a3a3eed
F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
@@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8971d98f25a4f5fb060db8ed6a4b06f083122a50 P 264e5c10d7144910b3223b64546567fa20e4bc65
R 6803846831f043d39b9c85f99ff10309 R 8ac11845f3680b4a63ed584c4ec0c997
U drh U drh
Z 62cd4db9c45f8ac36491823fd1143808 Z e8ceb26091bad5772496cc1502eaca7e

View File

@@ -1 +1 @@
264e5c10d7144910b3223b64546567fa20e4bc65 9d197a532349f4b1caf66bbed70ca46df86cb86f

View File

@@ -23,10 +23,10 @@
*/ */
typedef struct Incrblob Incrblob; typedef struct Incrblob Incrblob;
struct Incrblob { struct Incrblob {
int flags; /* Copy of "flags" passed to sqlite3_blob_open() */
int nByte; /* Size of open blob, in bytes */ int nByte; /* Size of open blob, in bytes */
int iOffset; /* Byte offset of blob in cursor data */ 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 */ BtCursor *pCsr; /* Cursor pointing at blob row */
sqlite3_stmt *pStmt; /* Statement holding cursor open */ sqlite3_stmt *pStmt; /* Statement holding cursor open */
sqlite3 *db; /* The associated database */ sqlite3 *db; /* The associated database */
@@ -117,7 +117,7 @@ int sqlite3_blob_open(
const char *zTable, /* The table containing the blob */ const char *zTable, /* The table containing the blob */
const char *zColumn, /* The column containing the blob */ const char *zColumn, /* The column containing the blob */
sqlite_int64 iRow, /* The row containing the glob */ 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 */ sqlite3_blob **ppBlob /* Handle for accessing the blob returned here */
){ ){
int nAttempt = 0; int nAttempt = 0;
@@ -139,7 +139,7 @@ int sqlite3_blob_open(
return SQLITE_MISUSE_BKPT; return SQLITE_MISUSE_BKPT;
} }
#endif #endif
flags = !!flags; /* flags = (flags ? 1 : 0); */ wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
@@ -199,9 +199,8 @@ int sqlite3_blob_open(
/* If the value is being opened for writing, check that the /* 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. ** 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( wrFlag ){
if( flags ){
const char *zFault = 0; const char *zFault = 0;
Index *pIdx; Index *pIdx;
#ifndef SQLITE_OMIT_FOREIGN_KEY #ifndef SQLITE_OMIT_FOREIGN_KEY
@@ -272,7 +271,7 @@ int sqlite3_blob_open(
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
VdbeOp *aOp; VdbeOp *aOp;
sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags, sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag,
pTab->pSchema->schema_cookie, pTab->pSchema->schema_cookie,
pTab->pSchema->iGeneration); pTab->pSchema->iGeneration);
sqlite3VdbeChangeP5(v, 1); sqlite3VdbeChangeP5(v, 1);
@@ -289,7 +288,7 @@ int sqlite3_blob_open(
#else #else
aOp[0].p1 = iDb; aOp[0].p1 = iDb;
aOp[0].p2 = pTab->tnum; aOp[0].p2 = pTab->tnum;
aOp[0].p3 = flags; aOp[0].p3 = wrFlag;
sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT); sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
} }
if( db->mallocFailed==0 ){ if( db->mallocFailed==0 ){
@@ -297,7 +296,7 @@ int sqlite3_blob_open(
/* Remove either the OP_OpenWrite or OpenRead. Set the P2 /* Remove either the OP_OpenWrite or OpenRead. Set the P2
** parameter of the other to pTab->tnum. */ ** 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].p2 = pTab->tnum;
aOp[1].p3 = iDb; 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->iCol = iCol;
pBlob->db = db; pBlob->db = db;
sqlite3BtreeLeaveAll(db); sqlite3BtreeLeaveAll(db);
if( db->mallocFailed ){ if( db->mallocFailed ){
goto blob_open_out; goto blob_open_out;
} }
sqlite3_bind_int64(pBlob->pStmt, 1, iRow);
rc = blobSeekToRow(pBlob, iRow, &zErr); rc = blobSeekToRow(pBlob, iRow, &zErr);
} while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA ); } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );