aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-07-30 18:40:52 +0000
committerdrh <drh@noemail.net>2017-07-30 18:40:52 +0000
commitdf94966c8b98abfa36fc76174b8cb5683a1921fc (patch)
tree719e8bbb3b6af5b1d822f8d6514fcf6575fe5e58 /src
parent7751deb3e278eb75358455ebb3568416906e7042 (diff)
downloadsqlite-df94966c8b98abfa36fc76174b8cb5683a1921fc.tar.gz
sqlite-df94966c8b98abfa36fc76174b8cb5683a1921fc.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/build.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/build.c b/src/build.c
index 35f5f5c36..8eab3823c 100644
--- a/src/build.c
+++ b/src/build.c
@@ -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;