diff options
author | drh <> | 2021-04-19 18:03:52 +0000 |
---|---|---|
committer | drh <> | 2021-04-19 18:03:52 +0000 |
commit | 1bb89e9cc88bd9cb18b9d970f41ec28f47913a53 (patch) | |
tree | a2bcdc6749cbc4ead0fa28aae314f9fff2a03dfb /src/build.c | |
parent | 6a4f7f0225cdf62e7b06362d6d691948424d43c1 (diff) | |
download | sqlite-1bb89e9cc88bd9cb18b9d970f41ec28f47913a53.tar.gz sqlite-1bb89e9cc88bd9cb18b9d970f41ec28f47913a53.zip |
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
Diffstat (limited to 'src/build.c')
-rw-r--r-- | src/build.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/build.c b/src/build.c index a6a6edb9b..ecc08f60f 100644 --- a/src/build.c +++ b/src/build.c @@ -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() */ |