/ Check-in [740d5ff6]
Login

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

Overview
Comment:Improved header comment and precondition checking for the new isDupColumn() function.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-3182d38790
Files: files | file ages | folders
SHA3-256: 740d5ff6cc9bf7b151dfb8b27409e5923cfb2789b5398fe13d89563aff8ffc07
User & Date: drh 2019-04-29 13:30:16
Context
2019-04-29
13:48
Do not de-duplicate columns index columns associated with a WITHOUT ROWID table if the columns have different collating sequences. This is the fix for ticket [3182d3879020ef3b2]. There is one test case added, but most of the tests are done in TH3. check-in: 1b1dd4d4 user: drh tags: trunk
13:30
Improved header comment and precondition checking for the new isDupColumn() function. Closed-Leaf check-in: 740d5ff6 user: drh tags: tkt-3182d38790
2019-04-28
19:27
Take collating sequence into account when removing redundant columns from indexes on WITHOUT ROWID tables. This is the first proof-of-concept fix for ticket [3182d3879020ef3]. More testing needed. check-in: b34fa5bf user: drh tags: tkt-3182d38790
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  1737   1737         return 1;
  1738   1738       }
  1739   1739     }
  1740   1740     return 0;
  1741   1741   }
  1742   1742   
  1743   1743   /*
  1744         -** Return true if any of the first nKey entries of index pIdx1 exactly
  1745         -** match the iCol-th entry of pIdx2.
         1744  +** Return true if any of the first nKey entries of index pIdx exactly
         1745  +** match the iCol-th entry of pPk.  pPk is always a WITHOUT ROWID
         1746  +** PRIMARY KEY index.  pIdx is an index on the same table.  pIdx may
         1747  +** or may not be the same index as pPk.
  1746   1748   **
  1747         -** The first nKey entries of pIdx1 are guaranteed to be ordinary columns,
         1749  +** The first nKey entries of pIdx are guaranteed to be ordinary columns,
  1748   1750   ** not a rowid or expression.
  1749   1751   **
  1750   1752   ** This routine differs from hasColumn() in that both the column and the
  1751   1753   ** collating sequence must match for this routine, but for hasColumn() only
  1752   1754   ** the column name must match.
  1753   1755   */
  1754         -static int isDupColumn(Index *pIdx1, int nKey, Index *pIdx2, int iCol){
         1756  +static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){
  1755   1757     int i, j;
  1756         -  assert( nKey<=pIdx1->nColumn );
  1757         -  assert( iCol<MAX(pIdx2->nColumn,pIdx2->nKeyCol) );
  1758         -  j = pIdx2->aiColumn[iCol];
  1759         -  testcase( j==XN_EXPR );
  1760         -  assert( j!=XN_ROWID );
         1758  +  assert( nKey<=pIdx->nColumn );
         1759  +  assert( iCol<MAX(pPk->nColumn,pPk->nKeyCol) );
         1760  +  assert( pPk->idxType==SQLITE_IDXTYPE_PRIMARYKEY );
         1761  +  assert( pPk->pTable->tabFlags & TF_WithoutRowid );
         1762  +  assert( pPk->pTable==pIdx->pTable );
         1763  +  testcase( pPk==pIdx );
         1764  +  j = pPk->aiColumn[iCol];
         1765  +  assert( j!=XN_ROWID && j!=XN_EXPR );
  1761   1766     for(i=0; i<nKey; i++){
  1762         -    assert( pIdx1->aiColumn[i]>=0 || j>=0 );
  1763         -    if( pIdx1->aiColumn[i]==j 
  1764         -     && sqlite3StrICmp(pIdx1->azColl[i],pIdx2->azColl[iCol])==0
         1767  +    assert( pIdx->aiColumn[i]>=0 || j>=0 );
         1768  +    if( pIdx->aiColumn[i]==j 
         1769  +     && sqlite3StrICmp(pIdx->azColl[i], pPk->azColl[iCol])==0
  1765   1770       ){
  1766   1771         return 1;
  1767   1772       }
  1768   1773     }
  1769   1774     return 0;
  1770   1775   }
  1771   1776