SQLite

Check-in [61b4459ae6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fix with INSERT using an explicit column list on a table with a non-final STORED column.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | generated-columns
Files: files | file ages | folders
SHA3-256: 61b4459ae6a6cc182c11abbc8b1dd629f77beb088d7ccad5e563d8d4769056df
User & Date: drh 2019-10-17 18:07:22.142
Context
2019-10-17
18:35
In the Table object, change the nVCol field to nNVCol - the number of non-virtual columns, as that is the quantity that we need most. (check-in: 4ad66af04a user: drh tags: generated-columns)
18:07
Bug fix with INSERT using an explicit column list on a table with a non-final STORED column. (check-in: 61b4459ae6 user: drh tags: generated-columns)
17:54
Some (but not all) INSERT and UPDATE statements now work for STORED columns. (check-in: fe7517bf4d user: drh tags: generated-columns)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  Table *pTab       /* The table */
){
  int i;
  pParse->iSelfTab = -iRegStore;
  for(i=0; i<pTab->nCol; i++, iRegStore++){
    u32 colFlags = pTab->aCol[i].colFlags;
    if( (colFlags & COLFLAG_VIRTUAL)!=0 ){
      /* Virtual columns are no stored */
      iRegStore--;
    }else if( (colFlags & COLFLAG_STORED)!=0 ){
      /* Stored columns are handled on the second pass */
      sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iRegStore);
    }
  }
  pParse->iSelfTab = 0;







|







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  Table *pTab       /* The table */
){
  int i;
  pParse->iSelfTab = -iRegStore;
  for(i=0; i<pTab->nCol; i++, iRegStore++){
    u32 colFlags = pTab->aCol[i].colFlags;
    if( (colFlags & COLFLAG_VIRTUAL)!=0 ){
      /* Virtual columns are not stored */
      iRegStore--;
    }else if( (colFlags & COLFLAG_STORED)!=0 ){
      /* Stored columns are handled on the second pass */
      sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iRegStore);
    }
  }
  pParse->iSelfTab = 0;
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
  ** If the table has an INTEGER PRIMARY KEY column and that column
  ** is named in the IDLIST, then record in the ipkColumn variable
  ** the index into IDLIST of the primary key column.  ipkColumn is
  ** the index of the primary key as it appears in IDLIST, not as
  ** is appears in the original table.  (The index of the INTEGER
  ** PRIMARY KEY in the original table is pTab->iPKey.)
  */
  bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;
  if( pColumn ){
    for(i=0; i<pColumn->nId; i++){
      pColumn->a[i].idx = -1;
    }
    for(i=0; i<pColumn->nId; i++){
      for(j=0; j<pTab->nCol; j++){
        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){







|







690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
  ** If the table has an INTEGER PRIMARY KEY column and that column
  ** is named in the IDLIST, then record in the ipkColumn variable
  ** the index into IDLIST of the primary key column.  ipkColumn is
  ** the index of the primary key as it appears in IDLIST, not as
  ** is appears in the original table.  (The index of the INTEGER
  ** PRIMARY KEY in the original table is pTab->iPKey.)
  */
  bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
  if( pColumn ){
    for(i=0; i<pColumn->nId; i++){
      pColumn->a[i].idx = -1;
    }
    for(i=0; i<pColumn->nId; i++){
      for(j=0; j<pTab->nCol; j++){
        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){