1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Ensure that a WITHOUT ROWID table does not have the .iPKey field set, even if

an OOM error occurs while parsing a schema in PRAGMA writable_schema=ON mode.
Add extra assert() statements to triple-check that this never happens.
dbsqlfuzz 803bb1f63d6f3bd6c14db568494d6e96be8f1ec9.

FossilOrigin-Name: 41228350a620a7de1ee748a4e19a96749c4d39418853fe8b68c43cf401dbd7cd
This commit is contained in:
drh
2021-04-19 18:03:52 +00:00
parent 6a4f7f0225
commit 1bb89e9cc8
3 changed files with 15 additions and 9 deletions

View File

@@ -461,6 +461,8 @@ Table *sqlite3LocateTable(
}else{
sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
}
}else{
assert( HasRowid(p) || p->iPKey<0 );
}
return p;
@@ -2179,7 +2181,10 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
pList = sqlite3ExprListAppend(pParse, 0,
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
if( pList==0 ) return;
if( pList==0 ){
pTab->tabFlags &= ~TF_WithoutRowid;
return;
}
if( IN_RENAME_OBJECT ){
sqlite3RenameTokenRemap(pParse, pList->a[0].pExpr, &pTab->iPKey);
}
@@ -2642,6 +2647,7 @@ void sqlite3EndTable(
Table *pOld;
Schema *pSchema = p->pSchema;
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
assert( HasRowid(p) || p->iPKey<0 );
pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);
if( pOld ){
assert( p==pOld ); /* Malloc must have failed inside HashInsert() */