-C Claw\sback\ssome\sperformance\sfrom\sthe\ssqlite3ExprGetColumnOfTable()\sroutine.
-D 2019-10-18T12:52:08.655
+C Get\sgenerated\scolumns\sworking\sfor\sWITHOUT\sROWID\stables.
+D 2019-10-18T17:42:47.815
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/btree.c a8a9c2ce62bdf54c8cf9795143d7cb10b7473a1230a0572f702d061ffcceefe5
F src/btree.h f27a33c49280209a93385e218306c4ee5f46ba8d7649d2f81a7166b282232484
F src/btreeInt.h 91806f01fd1145a9a86ba3042f25c38d8faf6002701bf5e780742cf88bcff437
-F src/build.c 5e5fc50bda07b83d8f602218dae3099c9b7ee7b71d6d59dfa642dc074877ec35
+F src/build.c 1872ee2d0e09df69081ed25402b3e381d20df49981084d441e99e4dfe4d553fd
F src/callback.c 25dda5e1c2334a367b94a64077b1d06b2553369f616261ca6783c48bcb6bda73
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 1b0724e66f95f33b160b1af85caaf9cceb325d22abf39bd24df4f54a73982251
F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
-F src/insert.c 689b21b415d4bfe2a0ea2cf0066974d2a93899fa51af12453664214fa0d534e6
+F src/insert.c 6a9f9899469e3da1c2e50677fe34597c8315c7daa14f1b907872e598f40b7f13
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 4ddc65ae13c0d93db0ceedc8b14a28c8c260513448b0eb8c5a2ac375e3b6a85d
F src/main.c 3e01f6a1c96643381b5f9d79e4ff7f2520bc5712197746fb0852283e78cccf66
F src/sqlite.h.in 5725a6b20190a1e8d662077a1c1c8ea889ad7be90dd803f914c2de226f5fe6ab
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h cef696ce3293242c67b2339763608427bf72ee66f1f3a05389ac2a7b46001c31
-F src/sqliteInt.h 769a3d9f244fe08c219aadc8474d180e3adca2c26cb5b13603adef4910b6ccf1
+F src/sqliteInt.h 9ccea3812a75ad6781fb113a4a5273ad0975ada4ed0e140542cc166b0edc34ca
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
F src/wal.c bbd6838bd79c0a32144d482fb0b6a9d2d1a252fb3b16d5005ec30f2f80413b0d
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
F src/walker.c d5a94907dcac990e31976be9dc769d17f6a806782593d6aec9d760ee01ec22cd
-F src/where.c 9f3f23efc45934e7b7ea6c0c1042420b73053e7c3264feef6faf9ce6fbd5df61
+F src/where.c b7c662afaad3894b4a1ab60fe048b741705b5b4f6fa6dddbaa2fd7230404a4e8
F src/whereInt.h 2c6bae136a7c0be6ff75dc36950d1968c67d005c8e51d7a9d77cb996bb4843d9
F src/wherecode.c b9bb13fce68edf2eee56154a53adb923df7c0cf410fb319d0b2c4001c58a2c73
F src/whereexpr.c 05c283d26aa9c3f5d1bf13a5f6a573b43295b9db280eff18e26f97d7d7f119b4
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 447271123e3b467d9271a4c0cf27f47af2f865c9298b8c355d9e766411a1f422
-R e46b1fe53b3eb28b7fe52d4e742c44d4
+P e8426acb94179ff49549aced6ea3c26c49ba4761c2f414fa1772d6a031edc79d
+R a1d17655d7716207219f9bae89301b1f
U drh
-Z 941773dbc3af30d7e5e82c7718d2d1bf
+Z 8a3f73b128c9189e66135d5ce5fb6bf2
-e8426acb94179ff49549aced6ea3c26c49ba4761c2f414fa1772d6a031edc79d
\ No newline at end of file
+9f409649ec4282a47f0a8b079b419f1922e0c24779b297f477ced168d5b7910d
\ No newline at end of file
}
/*
-** Return the column of index pIdx that corresponds to table
-** column iCol. Return -1 if not found.
+** Return the true column number of index pIdx that corresponds to table
+** true column iCol. Return -1 if not found.
*/
i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
int i;
+ for(i=0; i<pIdx->nColumn; i++){
+ if( iCol==pIdx->aiColumn[i] ) return i;
+ }
+ return -1;
+}
+
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
- Table *pTab = pIdx->pTable;
+/* Convert a storage column number into a true column number.
+**
+** The storage column number (0,1,2,....) is the index of the value
+** as it appears in the record on disk. The true column number
+** is the index (0,1,2,...) of the column in the CREATE TABLE statement.
+**
+** The storage column number is less than the true column number if
+** and only there are virtual columns to the left.
+**
+** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
+**
+** This function is the inverse of sqlite3ColumnOfTable().
+*/
+i16 sqlite3ColumnOfStorage(Table *pTab, i16 iCol){
if( pTab->tabFlags & TF_HasVirtual ){
+ int i;
for(i=0; i<=iCol; i++){
if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) iCol++;
}
}
-#endif
- for(i=0; i<pIdx->nColumn; i++){
- if( iCol==pIdx->aiColumn[i] ) return i;
- }
- return -1;
+ return iCol;
}
+#endif
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
-/*
-** Of the iCol-th column in table pTab, return the index of that column
-** as stored on disk. Usually the return value is the same as the iCol
-** input, however the return value may be less there are prior VIRTUAL
-** columns.
+/* Convert a true column number into a storage column number.
+**
+** The storage column number (0,1,2,....) is the index of the value
+** as it appears in the record on disk. The true column number
+** is the index (0,1,2,...) of the column in the CREATE TABLE statement.
**
-** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro
+** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
+**
+** This function is the inverse of sqlite3ColumnOfStorage().
*/
i16 sqlite3ColumnOfTable(Table *pTab, i16 iCol){
int i;
*/
nExtra = 0;
for(i=0; i<pTab->nCol; i++){
- if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++;
+ if( !hasColumn(pPk->aiColumn, nPk, i)
+ && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) nExtra++;
}
if( resizeIndexObject(db, pPk, nPk+nExtra) ) return;
for(i=0, j=nPk; i<pTab->nCol; i++){
- if( !hasColumn(pPk->aiColumn, j, i) ){
+ if( !hasColumn(pPk->aiColumn, j, i)
+ && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0
+ ){
assert( j<pPk->nColumn );
pPk->aiColumn[j] = i;
pPk->azColl[j] = sqlite3StrBINARY;
}
}
assert( pPk->nColumn==j );
- assert( pTab->nCol<=j );
+ assert( pTab->nNVCol<=j );
recomputeColumnsNotIndexed(pPk);
}
}
if( (p->tabFlags & TF_HasPrimaryKey)==0 ){
sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);
- }else{
- p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
- convertToWithoutRowidTable(pParse, p);
+ return;
}
+ p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;
}
- iDb = sqlite3SchemaToIndex(db, p->pSchema);
-
#ifndef SQLITE_OMIT_CHECK
/* Resolve names in all CHECK constraint expressions.
*/
}
#endif
+ /* Special processing for WITHOUT ROWID Tables */
+ if( (tabOpts & TF_WithoutRowid)!=0 ){
+ convertToWithoutRowidTable(pParse, p);
+ }
+
+ iDb = sqlite3SchemaToIndex(db, p->pSchema);
+
+
/* Estimate the average row size for the table and for all implied indices */
estimateTableWidth(p);
for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
/* Test all NOT NULL constraints.
*/
for(i=0; i<nCol; i++){
+ int iReg;
if( i==pTab->iPKey ){
continue; /* ROWID is never NULL */
}
assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
|| onError==OE_Ignore || onError==OE_Replace );
addr1 = 0;
+ if( (pTab->tabFlags & TF_HasVirtual)==0 ){
+ iReg = regNewData+1+i;
+ }else if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
+ iReg = ++pParse->nMem;
+ assert( pParse->iSelfTab==0 );
+ pParse->iSelfTab = -regNewData;
+ sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iReg);
+ pParse->iSelfTab = 0;
+ if( onError==OE_Replace ) onError = OE_Abort;
+ }else{
+ iReg = sqlite3ColumnOfTable(pTab, i) + regNewData + 1;
+ }
switch( onError ){
case OE_Replace: {
assert( onError==OE_Replace );
addr1 = sqlite3VdbeMakeLabel(pParse);
- sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
VdbeCoverage(v);
sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
- sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ sqlite3VdbeAddOp2(v, OP_NotNull, iReg, addr1);
VdbeCoverage(v);
onError = OE_Abort;
/* Fall through into the OE_Abort case to generate code that runs
char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName,
pTab->aCol[i].zName);
sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,
- regNewData+1+i);
+ iReg);
sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
VdbeCoverage(v);
}
default: {
assert( onError==OE_Ignore );
- sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
+ sqlite3VdbeAddOp2(v, OP_IsNull, iReg, ignoreDest);
VdbeCoverage(v);
break;
}
Index *sqlite3PrimaryKeyIndex(Table*);
i16 sqlite3ColumnOfIndex(Index*, i16);
#ifdef SQLITE_OMIT_GENERATED_COLUMNS
-# define sqlite3ColumnOfTable(T,X) (X) /* No-op pass-through */
+# define sqlite3ColumnOfTable(T,X) (X) /* No-op pass-through */
+# define sqlite3ColumnOfStorage(T,X) (X) /* No-op pass-through */
#else
i16 sqlite3ColumnOfTable(Table*, i16);
+ i16 sqlite3ColumnOfStorage(Table*, i16);
#endif
void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
#if SQLITE_ENABLE_HIDDEN_COLUMNS
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
x = pPk->aiColumn[x];
assert( x>=0 );
+ }else{
+ x = sqlite3ColumnOfStorage(pTab,x);
}
x = sqlite3ColumnOfIndex(pIdx, x);
if( x>=0 ){