Protect every access to the Table.u union using a nearby assert() or branch.
FossilOrigin-Name: 50e08338aed7ac0cee600098d2ecd4b3b7bfd31a597bb26773badf3d2e2582c8
This commit is contained in:
parent
16a8f28e49
commit
78b2fa8610
24
manifest
24
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\smacro\stypo\sintroduced\sby\s[5da112c02f9e8d0b]\sthat\sprevented\scoverage\ntests\sfrom\sworking.
|
||||
D 2021-10-06T10:36:56.583
|
||||
C Protect\severy\saccess\sto\sthe\sTable.u\sunion\susing\sa\snearby\sassert()\sor\sbranch.
|
||||
D 2021-10-07T12:11:20.389
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -483,7 +483,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c a6afe961ef3544104fa635a0c3161bfe1a34382f32e2a28706993abadedbffed
|
||||
F src/alter.c c3ef7565031b96f70c6d240929052cc2603e54df4a48025e2387104c804b2de6
|
||||
F src/analyze.c 979b6d2cdaca992a9c9f0818de55d08fb9a4e52929a509752b52d9fd23bb86d3
|
||||
F src/attach.c e5f9ab9700d545d49352db4865e9f4ba02085d244485729575b61da9fd3a7218
|
||||
F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
|
||||
@ -493,7 +493,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c 15b8bdbcf4c26ca15ec420e8da440a6d170669ac2f3735deb1668d9f3284129e
|
||||
F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
|
||||
F src/btreeInt.h 7bc15a24a02662409ebcd6aeaa1065522d14b7fda71573a2b0568b458f514ae0
|
||||
F src/build.c ee6941680fa2ab0461d9be145a546f8659f6543af643ace0b44d08abdf85e001
|
||||
F src/build.c 56dd17ca5491f3992095353a569956b435cc669edb330b98b2e2ac8e99b010a1
|
||||
F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 8159d5f706551861c18ec6c8f6bdf105e15ea00367f05d9ab65d31a1077facc1
|
||||
@ -503,14 +503,14 @@ F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
|
||||
F src/delete.c 3ce6af6b64c8b476de51ccc32da0cb3142d42e65754e1d8118addf65b8bcba15
|
||||
F src/expr.c ac2bc8eef596443dfe04c3510eefda5dfdda9dac65cc8fef5a80c69fb4c24815
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 1905af1821b88321e1bb9d6a69e704495b6844a9b6c29398d40117cc251e893c
|
||||
F src/fkey.c 0c57a9cd2a0ecd04dde0c06e41df46959526f52a68c4409591e0f8c41a577042
|
||||
F src/func.c 761a989e9b6a1f03cae05ef274f30881cb8f7ec816af2913b58dc18ac31ffd0e
|
||||
F src/global.c 612ea60c9acbcb45754c2ed659b4a56936a06814718e969636fedc7e3b889808
|
||||
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
|
||||
F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
|
||||
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 16fa4b66709db6db5bb31475f2321d0a839269765aa2461a520c151c385e8b9d
|
||||
F src/insert.c 042ad11fce0792944c6e3111a46c604318abc6fa4e90f5ad380e0c760b5e4e8a
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 0aa9e7f08e168e3874cb54984408e3976dafdf5616d511952c425b5ac088ea3e
|
||||
F src/main.c 819f1e56cb8fc8d2d58cd5bbdbf60da0c48065a96a0d06617a5e5723ae2ddd05
|
||||
@ -542,7 +542,7 @@ F src/parse.y 82bdd593c50bddcc285a173e9788a20296103217f5f5290c9122abf8af71af62
|
||||
F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b
|
||||
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
|
||||
F src/pcache1.c 54881292a9a5db202b2c0ac541c5e3ef9a5e8c4f1c1383adb2601d5499a60e65
|
||||
F src/pragma.c 4a473feae3646063996ce3bfae78032009fa950765908d97424f7578b202813c
|
||||
F src/pragma.c e92c2529978bfc0bbd5a7c48e5a18c35822d23997a7a10edfb94cb869e924666
|
||||
F src/pragma.h 87330ed2fbfa2a1274de93ca0ab850fba336189228cb256089202c3b52766fad
|
||||
F src/prepare.c 8f07616db04337057b8498b72d051ee90f73c54615c2e908c05404cef1e060b7
|
||||
F src/printf.c 5901672228f305f7d493cbc4e7d76a61a5caecdbc1cd06b1f9ec42ea4265cf8d
|
||||
@ -626,12 +626,12 @@ F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
|
||||
F src/vdbeInt.h 38206c8dd6b60ff03d9fd4f626b1b4fd0eef7cdc44f2fc2c1973b0f932a3f26b
|
||||
F src/vdbeapi.c aa5aaf2c37676b83af5724c6cd8207a3064ed46a217fd180957f75ac84f7a2a5
|
||||
F src/vdbeaux.c e7d3d85ac3c64522f5077b18c6f7ae725026727f74d852fef416180060275b15
|
||||
F src/vdbeblob.c 60a7694760e35b2bba166cf49eb6a1eb0b31581102b49de78008ca3032406065
|
||||
F src/vdbeblob.c 292e96c01c4219fca71d74e1002906d43eb232af4bd83f7552a3faec741f3eb8
|
||||
F src/vdbemem.c f4dcedec564688c957c7ac27c5e90a884dd5499cf37eb7cc50e33853e5313c97
|
||||
F src/vdbesort.c cd5130f683706c1a43e165a74187745fb3351cb56052cf9dc91de820634bbde2
|
||||
F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823
|
||||
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
|
||||
F src/vtab.c c289aa504f278f23b64cb33c95d284495c5f405bd363b419d31c92c61c14df1f
|
||||
F src/vtab.c 3a6640d86d5dfae8f69715a1ee7405bb96d8982b39655b91c1f3648baae476a8
|
||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c 2be08331d798237ad5d7ae0b252700ffb2b63189cb18d993496d009a93e2f81c
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
@ -1929,7 +1929,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 79e90a8225b90593e384eab49a8d1d3c93a3deaf2739dcc30f6c88852df80d04
|
||||
R 72dda00bb84c5fb21dc2438379b36ec1
|
||||
P 566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336
|
||||
R d41a9f5eb518b0215c5b2591bb42bca2
|
||||
U drh
|
||||
Z f3fb5f8bb9c0563f6e2634c4bbe3df94
|
||||
Z e3f6ac0c0f243a0e136ac2fe16fdf41d
|
||||
|
@ -1 +1 @@
|
||||
566e6974892ebd3d3de8d77b24655257a5efe14434c553e1a25fc680b201b336
|
||||
50e08338aed7ac0cee600098d2ecd4b3b7bfd31a597bb26773badf3d2e2582c8
|
13
src/alter.c
13
src/alter.c
@ -367,6 +367,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
if( pDflt && pDflt->pLeft->op==TK_NULL ){
|
||||
pDflt = 0;
|
||||
}
|
||||
assert( IsOrdinaryTable(pNew) );
|
||||
if( (db->flags&SQLITE_ForeignKeys) && pNew->u.tab.pFKey && pDflt ){
|
||||
sqlite3ErrorIfNotEmpty(pParse, zDb, zTab,
|
||||
"Cannot add a REFERENCES column with non-NULL default value");
|
||||
@ -409,7 +410,8 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||
}
|
||||
/* substr() operations on characters, but addColOffset is in bytes. So we
|
||||
** have to use printf() to translate between these units: */
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
assert( IsOrdinaryTable(pNew) );
|
||||
sqlite3NestedParse(pParse,
|
||||
"UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET "
|
||||
"sql = printf('%%.%ds, ',sql) || %Q"
|
||||
@ -503,6 +505,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||
}
|
||||
|
||||
sqlite3MayAbort(pParse);
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
assert( pTab->u.tab.addColOffset>0 );
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
|
||||
@ -533,7 +536,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||
pCol->zCnName = sqlite3DbStrDup(db, pCol->zCnName);
|
||||
pCol->hName = sqlite3StrIHash(pCol->zCnName);
|
||||
}
|
||||
assert( !IsVirtual(pNew) );
|
||||
assert( IsOrdinaryTable(pNew) );
|
||||
pNew->u.tab.pDfltList = sqlite3ExprListDup(db, pTab->u.tab.pDfltList, 0);
|
||||
pNew->pSchema = db->aDb[iDb].pSchema;
|
||||
pNew->u.tab.addColOffset = pTab->u.tab.addColOffset;
|
||||
@ -1531,7 +1534,7 @@ static void renameColumnFunc(
|
||||
#endif
|
||||
}
|
||||
|
||||
assert( !IsVirtual(sParse.pNewTable) );
|
||||
assert( IsOrdinaryTable(sParse.pNewTable) );
|
||||
for(pFKey=sParse.pNewTable->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(i=0; i<pFKey->nCol; i++){
|
||||
if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
|
||||
@ -1721,7 +1724,7 @@ static void renameTableFunc(
|
||||
&& !IsVirtual(pTab)
|
||||
){
|
||||
FKey *pFKey;
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
|
||||
@ -2042,7 +2045,7 @@ static void dropColumnFunc(
|
||||
pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zCnName);
|
||||
zEnd = (const char*)pEnd->t.z;
|
||||
}else{
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
zEnd = (const char*)&zSql[pTab->u.tab.addColOffset];
|
||||
while( ALWAYS(pCol->t.z[0]!=0) && pCol->t.z[0]!=',' ) pCol->t.z--;
|
||||
}
|
||||
|
13
src/build.c
13
src/build.c
@ -683,7 +683,7 @@ void sqlite3ColumnSetExpr(
|
||||
Expr *pExpr /* The new default expression */
|
||||
){
|
||||
ExprList *pList;
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
pList = pTab->u.tab.pDfltList;
|
||||
if( pCol->iDflt==0
|
||||
|| NEVER(pList==0)
|
||||
@ -704,7 +704,7 @@ void sqlite3ColumnSetExpr(
|
||||
*/
|
||||
Expr *sqlite3ColumnExpr(Table *pTab, Column *pCol){
|
||||
if( pCol->iDflt==0 ) return 0;
|
||||
if( NEVER(IsVirtual(pTab)) ) return 0;
|
||||
if( NEVER(!IsOrdinaryTable(pTab)) ) return 0;
|
||||
if( NEVER(pTab->u.tab.pDfltList==0) ) return 0;
|
||||
if( NEVER(pTab->u.tab.pDfltList->nExpr<pCol->iDflt) ) return 0;
|
||||
return pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr;
|
||||
@ -763,13 +763,13 @@ void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
|
||||
sqlite3DbFree(db, pCol->zCnName);
|
||||
}
|
||||
sqlite3DbFree(db, pTable->aCol);
|
||||
if( !IsVirtual(pTable) ){
|
||||
if( IsOrdinaryTable(pTable) ){
|
||||
sqlite3ExprListDelete(db, pTable->u.tab.pDfltList);
|
||||
}
|
||||
if( db==0 || db->pnBytesFreed==0 ){
|
||||
pTable->aCol = 0;
|
||||
pTable->nCol = 0;
|
||||
if( !IsVirtual(pTable) ){
|
||||
if( IsOrdinaryTable(pTable) ){
|
||||
pTable->u.tab.pDfltList = 0;
|
||||
}
|
||||
}
|
||||
@ -3549,6 +3549,7 @@ void sqlite3CreateForeignKey(
|
||||
goto fk_end;
|
||||
}
|
||||
pFKey->pFrom = p;
|
||||
assert( IsOrdinaryTable(p) );
|
||||
pFKey->pNextFrom = p->u.tab.pFKey;
|
||||
z = (char*)&pFKey->aCol[nCol];
|
||||
pFKey->zTo = z;
|
||||
@ -3614,7 +3615,7 @@ void sqlite3CreateForeignKey(
|
||||
|
||||
/* Link the foreign key to the table as the last step.
|
||||
*/
|
||||
assert( !IsVirtual(p) );
|
||||
assert( IsOrdinaryTable(p) );
|
||||
p->u.tab.pFKey = pFKey;
|
||||
pFKey = 0;
|
||||
|
||||
@ -3637,7 +3638,7 @@ void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
|
||||
Table *pTab;
|
||||
FKey *pFKey;
|
||||
if( (pTab = pParse->pNewTable)==0 ) return;
|
||||
if( NEVER(IsVirtual(pTab)) ) return;
|
||||
if( NEVER(!IsOrdinaryTable(pTab)) ) return;
|
||||
if( (pFKey = pTab->u.tab.pFKey)==0 ) return;
|
||||
assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */
|
||||
pFKey->isDeferred = (u8)isDeferred;
|
||||
|
14
src/fkey.c
14
src/fkey.c
@ -720,13 +720,12 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
|
||||
*/
|
||||
void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
|
||||
sqlite3 *db = pParse->db;
|
||||
if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) ){
|
||||
if( (db->flags&SQLITE_ForeignKeys) && IsOrdinaryTable(pTab) ){
|
||||
int iSkip = 0;
|
||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||
|
||||
assert( v ); /* VDBE has already been allocated */
|
||||
assert( !IsView(pTab) ); /* Not a view */
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
if( sqlite3FkReferences(pTab)==0 ){
|
||||
/* Search for a deferred foreign key constraint for which this table
|
||||
** is the child table. If one cannot be found, return without
|
||||
@ -890,13 +889,13 @@ void sqlite3FkCheck(
|
||||
|
||||
/* If foreign-keys are disabled, this function is a no-op. */
|
||||
if( (db->flags&SQLITE_ForeignKeys)==0 ) return;
|
||||
if( !IsOrdinaryTable(pTab) ) return;
|
||||
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
zDb = db->aDb[iDb].zDbSName;
|
||||
|
||||
/* Loop through all the foreign key constraints for which pTab is the
|
||||
** child table (the table that the foreign key definition is part of). */
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
Table *pTo; /* Parent table of foreign key pFKey */
|
||||
Index *pIdx = 0; /* Index on key columns in pTo */
|
||||
@ -1079,10 +1078,9 @@ u32 sqlite3FkOldmask(
|
||||
Table *pTab /* Table being modified */
|
||||
){
|
||||
u32 mask = 0;
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys ){
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys && IsOrdinaryTable(pTab) ){
|
||||
FKey *p;
|
||||
int i;
|
||||
assert( !IsVirtual(pTab) );
|
||||
for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){
|
||||
for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);
|
||||
}
|
||||
@ -1133,7 +1131,7 @@ int sqlite3FkRequired(
|
||||
){
|
||||
int eRet = 1; /* Value to return if bHaveFK is true */
|
||||
int bHaveFK = 0; /* If FK processing is required */
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys && !IsVirtual(pTab) ){
|
||||
if( pParse->db->flags&SQLITE_ForeignKeys && IsOrdinaryTable(pTab) ){
|
||||
if( !aChange ){
|
||||
/* A DELETE operation. Foreign key processing is required if the
|
||||
** table in question is either the child or parent table for any
|
||||
@ -1421,7 +1419,7 @@ void sqlite3FkDelete(sqlite3 *db, Table *pTab){
|
||||
FKey *pFKey; /* Iterator variable */
|
||||
FKey *pNext; /* Copy of pFKey->pNextFrom */
|
||||
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pNext){
|
||||
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
|
||||
|
||||
|
@ -2219,7 +2219,8 @@ void sqlite3GenerateConstraintChecks(
|
||||
**
|
||||
** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row
|
||||
** must be explicitly deleted in order to ensure any pre-update hook
|
||||
** is invoked. */
|
||||
** is invoked. */
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
|
||||
&& pPk==pIdx /* Condition 2 */
|
||||
@ -2940,6 +2941,7 @@ static int xferOptimization(
|
||||
** the extra complication to make this rule less restrictive is probably
|
||||
** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
|
||||
*/
|
||||
assert( IsOrdinaryTable(pDest) );
|
||||
if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->u.tab.pFKey!=0 ){
|
||||
return 0;
|
||||
}
|
||||
|
@ -1408,7 +1408,7 @@ void sqlite3Pragma(
|
||||
FKey *pFK;
|
||||
Table *pTab;
|
||||
pTab = sqlite3FindTable(db, zRight, zDb);
|
||||
if( pTab && !IsVirtual(pTab) ){
|
||||
if( pTab && IsOrdinaryTable(pTab) ){
|
||||
pFK = pTab->u.tab.pFKey;
|
||||
if( pFK ){
|
||||
int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
@ -1468,7 +1468,7 @@ void sqlite3Pragma(
|
||||
pTab = (Table*)sqliteHashData(k);
|
||||
k = sqliteHashNext(k);
|
||||
}
|
||||
if( pTab==0 || IsVirtual(pTab) || pTab->u.tab.pFKey==0 ) continue;
|
||||
if( pTab==0 || !IsOrdinaryTable(pTab) || pTab->u.tab.pFKey==0 ) continue;
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
zDb = db->aDb[iDb].zDbSName;
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
@ -1476,7 +1476,7 @@ void sqlite3Pragma(
|
||||
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
|
||||
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
|
||||
sqlite3VdbeLoadString(v, regResult, pTab->zName);
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
pParent = sqlite3FindTable(db, pFK->zTo, zDb);
|
||||
if( pParent==0 ) continue;
|
||||
@ -1499,7 +1499,7 @@ void sqlite3Pragma(
|
||||
if( pFK ) break;
|
||||
if( pParse->nTab<i ) pParse->nTab = i;
|
||||
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v);
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){
|
||||
pParent = sqlite3FindTable(db, pFK->zTo, zDb);
|
||||
pIdx = 0;
|
||||
|
@ -212,7 +212,7 @@ int sqlite3_blob_open(
|
||||
** key columns must be indexed. The check below will pick up this
|
||||
** case. */
|
||||
FKey *pFKey;
|
||||
assert( !IsVirtual(pTab) );
|
||||
assert( IsOrdinaryTable(pTab) );
|
||||
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
int j;
|
||||
for(j=0; j<pFKey->nCol; j++){
|
||||
|
19
src/vtab.c
19
src/vtab.c
@ -228,7 +228,10 @@ void sqlite3VtabUnlock(VTable *pVTab){
|
||||
*/
|
||||
static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
|
||||
VTable *pRet = 0;
|
||||
VTable *pVTable = p->u.vtab.p;
|
||||
VTable *pVTable;
|
||||
|
||||
assert( IsVirtual(p) );
|
||||
pVTable = p->u.vtab.p;
|
||||
p->u.vtab.p = 0;
|
||||
|
||||
/* Assert that the mutex (if any) associated with the BtShared database
|
||||
@ -336,6 +339,7 @@ void sqlite3VtabUnlockList(sqlite3 *db){
|
||||
** database connection.
|
||||
*/
|
||||
void sqlite3VtabClear(sqlite3 *db, Table *p){
|
||||
assert( IsVirtual(p) );
|
||||
if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
|
||||
if( p->u.vtab.azArg ){
|
||||
int i;
|
||||
@ -353,9 +357,12 @@ void sqlite3VtabClear(sqlite3 *db, Table *p){
|
||||
** deleted.
|
||||
*/
|
||||
static void addModuleArgument(Parse *pParse, Table *pTable, char *zArg){
|
||||
sqlite3_int64 nBytes = sizeof(char *)*(2+pTable->u.vtab.nArg);
|
||||
sqlite3_int64 nBytes;
|
||||
char **azModuleArg;
|
||||
sqlite3 *db = pParse->db;
|
||||
|
||||
assert( IsVirtual(pTable) );
|
||||
nBytes = sizeof(char *)*(2+pTable->u.vtab.nArg);
|
||||
if( pTable->u.vtab.nArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){
|
||||
sqlite3ErrorMsg(pParse, "too many columns on %s", pTable->zName);
|
||||
}
|
||||
@ -442,6 +449,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
||||
sqlite3 *db = pParse->db; /* The database connection */
|
||||
|
||||
if( pTab==0 ) return;
|
||||
assert( IsVirtual(pTab) );
|
||||
addArgumentToVtab(pParse);
|
||||
pParse->sArg.z = 0;
|
||||
if( pTab->u.vtab.nArg<1 ) return;
|
||||
@ -559,13 +567,16 @@ static int vtabCallConstructor(
|
||||
VtabCtx sCtx;
|
||||
VTable *pVTable;
|
||||
int rc;
|
||||
const char *const*azArg = (const char *const*)pTab->u.vtab.azArg;
|
||||
const char *const*azArg;
|
||||
int nArg = pTab->u.vtab.nArg;
|
||||
char *zErr = 0;
|
||||
char *zModuleName;
|
||||
int iDb;
|
||||
VtabCtx *pCtx;
|
||||
|
||||
assert( IsVirtual(pTab) );
|
||||
azArg = (const char *const*)pTab->u.vtab.azArg;
|
||||
|
||||
/* Check that the virtual-table is not already being initialized */
|
||||
for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){
|
||||
if( pCtx->pTab==pTab ){
|
||||
@ -893,7 +904,7 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
|
||||
Table *pTab;
|
||||
|
||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
|
||||
if( pTab!=0 && ALWAYS(pTab->u.vtab.p!=0) ){
|
||||
if( pTab!=0 && ALWAYS(IsVirtual(pTab)) && ALWAYS(pTab->u.vtab.p!=0) ){
|
||||
VTable *p;
|
||||
int (*xDestroy)(sqlite3_vtab *);
|
||||
for(p=pTab->u.vtab.p; p; p=p->pNext){
|
||||
|
Loading…
Reference in New Issue
Block a user