]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Refactor names of column index transformation functions, for clarity.
authordrh <drh@noemail.net>
Sat, 19 Oct 2019 13:29:10 +0000 (13:29 +0000)
committerdrh <drh@noemail.net>
Sat, 19 Oct 2019 13:29:10 +0000 (13:29 +0000)
Get generated columns working with ALTER TABLE RENAME COLUMN.

FossilOrigin-Name: 27ab41c9102e7801ff829488fc123a8040da008bef373d6704efbe2f93e1da90

12 files changed:
manifest
manifest.uuid
src/alter.c
src/analyze.c
src/build.c
src/expr.c
src/insert.c
src/sqliteInt.h
src/upsert.c
src/vdbeapi.c
src/where.c
src/wherecode.c

index 74c780e22f7624aa19a906d6c265d5e38b8c9d12..8ebde088c2a4b653661243afa91a45714db6f706 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fixes\sfor\sWITHOUT\sROWID\stables\swith\sVIRTUAL\scolumns\sand\san\sINTEGER\sPRIMARY\sKEY.
-D 2019-10-18T18:33:25.975
+C Refactor\snames\sof\scolumn\sindex\stransformation\sfunctions,\sfor\sclarity.\nGet\sgenerated\scolumns\sworking\swith\sALTER\sTABLE\sRENAME\sCOLUMN.
+D 2019-10-19T13:29:10.933
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -459,8 +459,8 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
 F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
 F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
-F src/alter.c 8a4317e2b322d4da9489cf2aa1d513a3a6f3e4863552dd5e59d08cdaca73c487
-F src/analyze.c 481d9cf34a3c70631ef5c416be70033e8d4cd85eb5ad1b37286aed8b0e29e889
+F src/alter.c fa7486bfd12be8c8a0d4425767fa42203ca9e946c9613bb37924643c622706bf
+F src/analyze.c fd70b9c7a683230a7f7936af64dd25308e93d7c9819a3168493a7c7703481f80
 F src/attach.c 3ca19504849c2d9be10fc5899d6811f9d6e848665d1a41ffb53df0cd6e7c13ed
 F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06
 F src/backup.c f70077d40c08b7787bfe934e4d1da8030cb0cc57d46b345fba2294b7d1be23ab
@@ -469,7 +469,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
 F src/btree.c a8a9c2ce62bdf54c8cf9795143d7cb10b7473a1230a0572f702d061ffcceefe5
 F src/btree.h f27a33c49280209a93385e218306c4ee5f46ba8d7649d2f81a7166b282232484
 F src/btreeInt.h 91806f01fd1145a9a86ba3042f25c38d8faf6002701bf5e780742cf88bcff437
-F src/build.c c38f1b8942572cecf2b9e4abb6984be73ebb6c5c0fdd91c776734d73460fcaf8
+F src/build.c fb6464e8ae5364a7a31915432f349d209a1a3fd287edbce651600bf46ccacd34
 F src/callback.c 25dda5e1c2334a367b94a64077b1d06b2553369f616261ca6783c48bcb6bda73
 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
 F src/ctime.c 1b0724e66f95f33b160b1af85caaf9cceb325d22abf39bd24df4f54a73982251
@@ -477,7 +477,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
 F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
 F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
 F src/delete.c d08c9e01a2664afd12edcfa3a9c6578517e8ff8735f35509582693adbe0edeaf
-F src/expr.c e2c2f78c9f63de2bedabf34f8f25968c6b2317313d1ef15a37c8aa9bd29dcf75
+F src/expr.c 8caa6f07be582979dec421beda6b77033f9b50f97bb1844e189f920a41b781ee
 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
 F src/fkey.c 6271fda51794b569d736eba4097d28f13080cd0c9eb66d5fcecb4b77336fae50
 F src/func.c ed33e38cd642058182a31a3f518f2e34f4bbe53aa483335705c153c4d3e50b12
@@ -486,7 +486,7 @@ F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
 F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
-F src/insert.c 1e565be06343e9d24a6c4f82023e5b0ffb0358c41fb4fb28f95fe50c9f9727b4
+F src/insert.c 66662a52c4e205dbaeb318591bf2aaf1b957920003d1911c6a0dce6dfaad1eed
 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
 F src/loadext.c 4ddc65ae13c0d93db0ceedc8b14a28c8c260513448b0eb8c5a2ac375e3b6a85d
 F src/main.c 3e01f6a1c96643381b5f9d79e4ff7f2520bc5712197746fb0852283e78cccf66
@@ -530,7 +530,7 @@ F src/shell.c.in 3093bdf5eedd91da08f0268f1442aa510a60798c9441868149ddbecdf8bcaa7
 F src/sqlite.h.in 5725a6b20190a1e8d662077a1c1c8ea889ad7be90dd803f914c2de226f5fe6ab
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h cef696ce3293242c67b2339763608427bf72ee66f1f3a05389ac2a7b46001c31
-F src/sqliteInt.h 9ccea3812a75ad6781fb113a4a5273ad0975ada4ed0e140542cc166b0edc34ca
+F src/sqliteInt.h 7fa9357635e6c32c61d103054a4d4040392d81a798cfe982c09d4ed5568aa724
 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
 F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@@ -593,14 +593,14 @@ F src/tokenize.c 7b17f6e2f20f6cbcb0b215025a86b7457c38451fc7622f705e553d7a488c572
 F src/treeview.c fddeb413159c3eeeaea3f496172f121cf3695606c461dc4e6dcee51417952df5
 F src/trigger.c 845ccc08f60716c58aa28fe6470385c18ef8c4e1d88c93dcf449bc13d464eb2e
 F src/update.c ca754bbcb5662184bf5face4b67686bed8f53a36cf3def87cbb238deb1086b9b
-F src/upsert.c 710c91bb13e3c3fed5b6fe17cb13e09560bdd003ad8b8c51e6b16c80cfc48b10
+F src/upsert.c b445315c8958d8f17ec3297d06842e61dacaad0633ccaec1e4e160de7e562212
 F src/utf.c 2f0fac345c7660d5c5bd3df9e9d8d33d4c27f366bcfb09e07443064d751a0507
 F src/util.c 10d910e04a4f3842042485e0df01a484f57f912c10b60b3a09ccddd5019bd138
 F src/vacuum.c 82dcec9e7b1afa980288718ad11bc499651c722d7b9f32933c4d694d91cb6ebf
 F src/vdbe.c 9a3f4c2ec6c45e4bd5db465e77e79dfdf5bdc5cf3a8c0bfe9549da209b9c18bc
 F src/vdbe.h b02904e1bd45c26fdf00c04844b9cfa825763aa5150b6d89ce88b8ab03581d0a
 F src/vdbeInt.h bd589b8b7273286858950717e0e1ec5c88b18af45079a3366dc1371865cea704
-F src/vdbeapi.c 95001d0f84ee3cda344fed98ca0d7961deb4fc836b83495630d0af1f7cc4789e
+F src/vdbeapi.c 1252d80c548711e47a6d84dae88ed4e95d3fbb4e7bd0eaa1347299af7efddf02
 F src/vdbeaux.c a669f412027b6820cace9bf42e280c28304fc72bfc3475283ef33a5cce80e2e8
 F src/vdbeblob.c 253ed82894924c362a7fa3079551d3554cd1cdace39aa833da77d3bc67e7c1b1
 F src/vdbemem.c d8e10d1773806105e62094c4ede0a4684f46caaf07667a45e6d461e94306b530
@@ -611,9 +611,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c bbd6838bd79c0a32144d482fb0b6a9d2d1a252fb3b16d5005ec30f2f80413b0d
 F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
 F src/walker.c d5a94907dcac990e31976be9dc769d17f6a806782593d6aec9d760ee01ec22cd
-F src/where.c b7c662afaad3894b4a1ab60fe048b741705b5b4f6fa6dddbaa2fd7230404a4e8
+F src/where.c 7b2d928b70ac885fb63c871e97d3502f3e0fbe14ec605ba05675d03f20aa6c5e
 F src/whereInt.h 2c6bae136a7c0be6ff75dc36950d1968c67d005c8e51d7a9d77cb996bb4843d9
-F src/wherecode.c b9bb13fce68edf2eee56154a53adb923df7c0cf410fb319d0b2c4001c58a2c73
+F src/wherecode.c d96190c0b536339375846048ad3c41758b4bd6baaf8f8f350da5911d42bc4a61
 F src/whereexpr.c 05c283d26aa9c3f5d1bf13a5f6a573b43295b9db280eff18e26f97d7d7f119b4
 F src/window.c 064f251451c8e2a1c76b6269229d911a651e119c6a5f522b6eaebf8dc8714041
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@@ -1847,7 +1847,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 85bc4524d76999080faa4474e8880d2b6a2ac3a7f6a76239af4de1a42f8138c8
-R 0af80221f2d400634eaa464ec81f7f65
+P 86074da0fd2949e231898ef0bc672d90fd89cefa49fb0eb50ff398fbdd91d1ad
+R 72d8383f6985e8f8ce5ac07723f6738a
 U drh
-Z f141c57ae5a92a7a4189b1c5f348b449
+Z 25261f5626aab97bfd8acba5a24fa871
index d0d7b9d0aefcc0f71cf8315d2b406c402985fada..9b4c67a7fe1b103c8f8bcc18575d46814d9d517b 100644 (file)
@@ -1 +1 @@
-86074da0fd2949e231898ef0bc672d90fd89cefa49fb0eb50ff398fbdd91d1ad
\ No newline at end of file
+27ab41c9102e7801ff829488fc123a8040da008bef373d6704efbe2f93e1da90
\ No newline at end of file
index f8cada0e34d391f09c180eca4bfe0882129f24b4..b7389bf9cbfa8dedb624ad4557ea57186e6feda4 100644 (file)
@@ -1334,6 +1334,11 @@ static void renameColumnFunc(
           sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
         }
       }
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
+      for(i=0; i<sParse.pNewTable->nCol; i++){
+        sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt);
+      }
+#endif
 
       for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
         for(i=0; i<pFKey->nCol; i++){
index 8f73853c85f0f33210da2b63fc25316737bb582e..6df6e7a6ecc0f8396440db1b53b300e29b5dd391 100644 (file)
@@ -1182,7 +1182,7 @@ static void analyzeOneTable(
       int j, k, regKey;
       regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);
       for(j=0; j<pPk->nKeyCol; j++){
-        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
+        k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
         assert( k>=0 && k<pIdx->nColumn );
         sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);
         VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName));
index f00dc32ad080f0f4073a6072c0004d9b8cf225c4..48f3a1c1ea0833f0d9811881021a6d9cd732d87e 100644 (file)
@@ -877,10 +877,12 @@ Index *sqlite3PrimaryKeyIndex(Table *pTab){
 }
 
 /*
-** Return the true column number of index pIdx that corresponds to table
-** true column iCol.  Return -1 if not found.
+** Convert an table column number into a index column number.  That is,
+** for the column iCol in the table (as defined by the CREATE TABLE statement)
+** find the (first) offset of that column in index pIdx.  Or return -1
+** if column iCol is not used in index pIdx.
 */
-i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
+i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){
   int i;
   for(i=0; i<pIdx->nColumn; i++){
     if( iCol==pIdx->aiColumn[i] ) return i;
@@ -889,20 +891,20 @@ i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
 }
 
 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
-/* Convert a storage column number into a true column number.
+/* Convert a storage column number into a table 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.
+** The storage column number is less than the table 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().
+** This function is the inverse of sqlite3TableColumnToStorage().
 */
-i16 sqlite3ColumnOfStorage(Table *pTab, i16 iCol){
+i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){
   if( pTab->tabFlags & TF_HasVirtual ){
     int i;
     for(i=0; i<=iCol; i++){
@@ -914,7 +916,7 @@ i16 sqlite3ColumnOfStorage(Table *pTab, i16 iCol){
 #endif
 
 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
-/* Convert a true column number into a storage column number.
+/* Convert a table 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
@@ -922,9 +924,9 @@ i16 sqlite3ColumnOfStorage(Table *pTab, i16 iCol){
 **
 ** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
 **
-** This function is the inverse of sqlite3ColumnOfStorage().
+** This function is the inverse of sqlite3StorageColumnToTable().
 */
-i16 sqlite3ColumnOfTable(Table *pTab, i16 iCol){
+i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
   int i;
   i16 n;
   assert( iCol<pTab->nCol );
@@ -1577,11 +1579,12 @@ void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
   u8 eType = COLFLAG_VIRTUAL;
   Table *pTab = pParse->pNewTable;
   Column *pCol;
-  if( IN_RENAME_OBJECT ){
-    sqlite3RenameExprUnmap(pParse, pExpr);
-  }
   if( pTab==0 ) goto generated_done;
   pCol = &(pTab->aCol[pTab->nCol-1]);
+  if( IN_DECLARE_VTAB ){
+    sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
+    goto generated_done;
+  }
   if( pCol->pDflt ) goto generated_error;
   if( pType ){
     if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){
@@ -1597,7 +1600,8 @@ void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
   assert( TF_HasVirtual==COLFLAG_VIRTUAL );
   assert( TF_HasStored==COLFLAG_STORED );
   pTab->tabFlags |= eType;
-  pCol->pDflt = sqlite3ExprDup(pParse->db, pExpr, 0);
+  pCol->pDflt = pExpr;
+  pExpr = 0;
   goto generated_done;
 
 generated_error:
@@ -3651,13 +3655,13 @@ void sqlite3CreateIndex(
   /* If this index contains every column of its table, then mark
   ** it as a covering index */
   assert( HasRowid(pTab) 
-      || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );
+      || pTab->iPKey<0 || sqlite3TableColumnToIndex(pIndex, pTab->iPKey)>=0 );
   recomputeColumnsNotIndexed(pIndex);
   if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
     pIndex->isCovering = 1;
     for(j=0; j<pTab->nCol; j++){
       if( j==pTab->iPKey ) continue;
-      if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
+      if( sqlite3TableColumnToIndex(pIndex,j)>=0 ) continue;
       pIndex->isCovering = 0;
       break;
     }
index 41ffe716eacaf4d089a50bac2fed92239e6ddb2c..c57a0000d53c98174ba6ddee23dd18f2e15165f8 100644 (file)
@@ -3410,10 +3410,10 @@ void sqlite3ExprCodeGetColumnOfTable(
       return;
 #endif
     }else if( !HasRowid(pTab) ){
-      x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
+      x = sqlite3TableColumnToIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
       op = OP_Column;
     }else{
-      x = sqlite3ColumnOfTable(pTab,iCol);
+      x = sqlite3TableColumnToStorage(pTab,iCol);
       op = OP_Column;
     }
     sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
@@ -3591,7 +3591,8 @@ expr_code_doover:
             return -1-pParse->iSelfTab;
           }
           pCol = pTab->aCol + pExpr->iColumn;
-          iSrc = sqlite3ColumnOfTable(pTab, pExpr->iColumn) - pParse->iSelfTab;
+          iSrc = sqlite3TableColumnToStorage(pTab, pExpr->iColumn)
+                      - pParse->iSelfTab;
 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
           if( pCol->colFlags & COLFLAG_GENERATED ){
             if( pCol->colFlags & COLFLAG_BUSY ){
@@ -5320,7 +5321,7 @@ struct IdxCover {
 static int exprIdxCover(Walker *pWalker, Expr *pExpr){
   if( pExpr->op==TK_COLUMN
    && pExpr->iTable==pWalker->u.pIdxCover->iCur
-   && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
+   && sqlite3TableColumnToIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
   ){
     pWalker->eCode = 1;
     return WRC_Abort;
index fe275d5a015cc52c326d60778ebd87f02154d90f..88b8e6ad26b808168b8370a3527359cfdf2282f3 100644 (file)
@@ -1055,7 +1055,7 @@ void sqlite3Insert(
       int k;
       u32 colFlags;
       assert( i>=nHidden );
-      assert( iRegStore==sqlite3ColumnOfTable(pTab,i)+regRowid+1 );
+      assert( iRegStore==sqlite3TableColumnToStorage(pTab,i)+regRowid+1 );
       if( i==pTab->iPKey ){
         /* The value of the INTEGER PRIMARY KEY column is always a NULL.
         ** Whenever this column is read, the rowid will be substituted
@@ -1464,7 +1464,7 @@ void sqlite3GenerateConstraintChecks(
       pParse->iSelfTab = 0;
       if( onError==OE_Replace ) onError = OE_Abort;
     }else{
-      iReg = sqlite3ColumnOfTable(pTab, i) + regNewData + 1;
+      iReg = sqlite3TableColumnToStorage(pTab, i) + regNewData + 1;
     }
     switch( onError ){
       case OE_Replace: {
@@ -1782,7 +1782,7 @@ void sqlite3GenerateConstraintChecks(
         VdbeComment((v, "%s column %d", pIdx->zName, i));
 #endif
       }else{
-        x = sqlite3ColumnOfTable(pTab, iField) + regNewData + 1;
+        x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1;
         sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i);
         VdbeComment((v, "%s", pTab->aCol[iField].zName));
       }
@@ -1873,7 +1873,7 @@ void sqlite3GenerateConstraintChecks(
         if( pIdx!=pPk ){
           for(i=0; i<pPk->nKeyCol; i++){
             assert( pPk->aiColumn[i]>=0 );
-            x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
+            x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
             sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
             VdbeComment((v, "%s.%s", pTab->zName,
                          pTab->aCol[pPk->aiColumn[i]].zName));
index a1e6e175bba0fd3c9497facb48289a1539f41c6e..10b2eeaf3f5f1e4fcbfc20dec6a8d7f70f181c37 100644 (file)
@@ -1818,8 +1818,21 @@ struct Module {
 };
 
 /*
-** information about each column of an SQL table is held in an instance
-** of this structure.
+** Information about each column of an SQL table is held in an instance
+** of the Column structure, in the Table.aCol[] array.
+**
+** Definitions:
+**
+**   "table column index"     This is the index of the column in the
+**                            Table.aCol[] array, and also the index of
+**                            the column in the original CREATE TABLE stmt.
+**
+**   "storage column index"   This is the index of the column in the
+**                            record BLOB generated by the OP_MakeRecord
+**                            opcode.  The storage column index is less than
+**                            or equal to the table column index.  It is
+**                            equal if and only if there are no VIRTUAL
+**                            columns to the left.
 */
 struct Column {
   char *zName;     /* Name of this column, \000, then the type */
@@ -3952,13 +3965,13 @@ void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*,char);
 Table *sqlite3ResultSetOfSelect(Parse*,Select*,char);
 void sqlite3OpenMasterTable(Parse *, int);
 Index *sqlite3PrimaryKeyIndex(Table*);
-i16 sqlite3ColumnOfIndex(Index*, i16);
+i16 sqlite3TableColumnToIndex(Index*, i16);
 #ifdef SQLITE_OMIT_GENERATED_COLUMNS
-# define sqlite3ColumnOfTable(T,X)   (X)  /* No-op pass-through */
-# define sqlite3ColumnOfStorage(T,X) (X)  /* No-op pass-through */
+# define sqlite3TableColumnToStorage(T,X) (X)  /* No-op pass-through */
+# define sqlite3StorageColumnToTable(T,X) (X)  /* No-op pass-through */
 #else
-  i16 sqlite3ColumnOfTable(Table*, i16);
-  i16 sqlite3ColumnOfStorage(Table*, i16);
+  i16 sqlite3TableColumnToStorage(Table*, i16);
+  i16 sqlite3StorageColumnToTable(Table*, i16);
 #endif
 void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
 #if SQLITE_ENABLE_HIDDEN_COLUMNS
index 7beb9ffaecf9bd4f452bbbd8fde7bdfe959a7524..5db4f5fc903e4069046c9873a64ae42a5d60300b 100644 (file)
@@ -226,7 +226,7 @@ void sqlite3UpsertDoUpdate(
       for(i=0; i<nPk; i++){
         int k;
         assert( pPk->aiColumn[i]>=0 );
-        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
+        k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
         sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
         VdbeComment((v, "%s.%s", pIdx->zName,
                     pTab->aCol[pPk->aiColumn[i]].zName));
index c7968ee60d46d8a26905278e999917ad53265059..074d4588154ca54dacf9057d5d995f99279ecd49 100644 (file)
@@ -1831,7 +1831,7 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
     goto preupdate_old_out;
   }
   if( p->pPk ){
-    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
+    iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
   }
   if( iIdx>=p->pCsr->nField || iIdx<0 ){
     rc = SQLITE_RANGE;
@@ -1921,7 +1921,7 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
     goto preupdate_new_out;
   }
   if( p->pPk && p->op!=SQLITE_UPDATE ){
-    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);
+    iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
   }
   if( iIdx>=p->pCsr->nField || iIdx<0 ){
     rc = SQLITE_RANGE;
index 252e90665c2dad8541f895b655a9069e8c389cdf..ec2d3847b798fa9331eb72ea89b2c7b8349e3efb 100644 (file)
@@ -5379,9 +5379,9 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
             x = pPk->aiColumn[x];
             assert( x>=0 );
           }else{
-            x = sqlite3ColumnOfStorage(pTab,x);
+            x = sqlite3StorageColumnToTable(pTab,x);
           }
-          x = sqlite3ColumnOfIndex(pIdx, x);
+          x = sqlite3TableColumnToIndex(pIdx, x);
           if( x>=0 ){
             pOp->p2 = x;
             pOp->p1 = pLevel->iIdxCur;
index af395a32669fa09bb15a64e21c7c1e1e43b9b3ec..686a8d6f9a0b84c1b2911871d290325b4a3aac35 100644 (file)
@@ -823,7 +823,7 @@ static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){
   assert( pHint->pIdx!=0 );
   if( pExpr->op==TK_COLUMN
    && pExpr->iTable==pHint->iTabCur
-   && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
+   && sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn)<0
   ){
     pWalker->eCode = 1;
   }
@@ -891,7 +891,7 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
       pExpr->iTable = reg;
     }else if( pHint->pIdx!=0 ){
       pExpr->iTable = pHint->iIdxCur;
-      pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
+      pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
       assert( pExpr->iColumn>=0 );
     }
   }else if( pExpr->op==TK_AGG_FUNCTION ){
@@ -1826,7 +1826,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
       Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
       iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);
       for(j=0; j<pPk->nKeyCol; j++){
-        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
+        k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
         sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);
       }
       sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,