SQLite

Check-in [447271123e]
Login

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

Overview
Comment:Fix sqlite3ColumnOfIndex() to account for virtual columns.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | generated-columns
Files: files | file ages | folders
SHA3-256: 447271123e3b467d9271a4c0cf27f47af2f865c9298b8c355d9e766411a1f422
User & Date: drh 2019-10-18 12:14:48.871
Context
2019-10-18
12:52
Claw back some performance from the sqlite3ExprGetColumnOfTable() routine. (check-in: e8426acb94 user: drh tags: generated-columns)
12:14
Fix sqlite3ColumnOfIndex() to account for virtual columns. (check-in: 447271123e user: drh tags: generated-columns)
10:05
Get indexes working on virtual columns. (check-in: 450c48766c user: drh tags: generated-columns)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/build.c.
878
879
880
881
882
883
884








885
886
887
888
889
890
891

/*
** Return the column of index pIdx that corresponds to table
** 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







>
>
>
>
>
>
>
>







878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899

/*
** Return the column of index pIdx that corresponds to table
** column iCol.  Return -1 if not found.
*/
i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
  int i;
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
  Table *pTab = pIdx->pTable;
  if( pTab->tabFlags & TF_HasVirtual ){
    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;
}

#ifndef SQLITE_OMIT_GENERATED_COLUMNS