1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Correctly handle an "INTEGER PRIMARY KEY UNIQUE" column in a WITHOUT ROWID

table.  This is a fix for ticket [bc115541132dad136], a problem discovered
by OSSFuzz.

FossilOrigin-Name: 5216bfb73f1a49bdd879d470de139bf46a212474eaf6f38ad2390536d66a2afd
This commit is contained in:
drh
2017-07-30 18:40:52 +00:00
parent 7751deb3e2
commit df94966c8b
4 changed files with 32 additions and 18 deletions

View File

@@ -1739,15 +1739,6 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
}else{
pPk = sqlite3PrimaryKeyIndex(pTab);
/* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
** table entry. This is only required if currently generating VDBE
** code for a CREATE TABLE (not when parsing one as part of reading
** a database schema). */
if( v ){
assert( db->init.busy==0 );
sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);
}
/*
** Remove all redundant columns from the PRIMARY KEY. For example, change
** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later
@@ -1767,6 +1758,15 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
nPk = pPk->nKeyCol;
/* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
** table entry. This is only required if currently generating VDBE
** code for a CREATE TABLE (not when parsing one as part of reading
** a database schema). */
if( v && pPk->tnum>0 ){
assert( db->init.busy==0 );
sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);
}
/* The root page of the PRIMARY KEY is the table root page */
pPk->tnum = pTab->tnum;