diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/insert.c | 13 | ||||
-rw-r--r-- | src/pragma.c | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/insert.c b/src/insert.c index 20b5d9a91..1c628c670 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1009,6 +1009,7 @@ void sqlite3Insert( iRegStore = regRowid+1; for(i=0; i<pTab->nCol; i++, iRegStore++){ int k; + u32 colFlags; assert( i>=nHidden ); assert( iRegStore==sqlite3ColumnOfTable(pTab,i)+regRowid+1 ); if( i==pTab->iPKey ){ @@ -1020,16 +1021,18 @@ void sqlite3Insert( sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore); continue; } - if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ){ + if( ((colFlags = pTab->aCol[i].colFlags) & COLFLAG_NOINSERT)!=0 ){ nHidden++; - if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){ + if( (colFlags & COLFLAG_VIRTUAL)!=0 ){ /* Virtual columns are no stored */ iRegStore--; - }else{ - /* Hidden and stored columns get the default value */ + continue; + }else if( (colFlags & COLFLAG_STORED)!=0 || pColumn==0 ){ + /* Stored columns get the default value. Also hidden columns + ** that are not explicitly named in the INSERT */ sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); + continue; } - continue; } if( pColumn ){ for(j=0; j<pColumn->nId && pColumn->a[j].idx!=i; j++){} diff --git a/src/pragma.c b/src/pragma.c index 551cc7aa0..d9f249d13 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1102,8 +1102,10 @@ void sqlite3Pragma( for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ int isHidden = 0; if( pCol->colFlags & COLFLAG_NOINSERT ){ - nHidden++; - if( pPragma->iArg==0 ) continue; + if( pPragma->iArg==0 ){ + nHidden++; + continue; + } if( pCol->colFlags & COLFLAG_VIRTUAL ){ isHidden = 2; /* GENERATED ALWAYS AS ... VIRTUAL */ }else if( pCol->colFlags & COLFLAG_VIRTUAL ){ |