Improved header comment and precondition checking for the new isDupColumn()

function.

FossilOrigin-Name: 740d5ff6cc9bf7b151dfb8b27409e5923cfb2789b5398fe13d89563aff8ffc07
This commit is contained in:
drh 2019-04-29 13:30:16 +00:00
parent f78d0f426c
commit c19b63c9a3
3 changed files with 24 additions and 22 deletions

View File

@ -1,5 +1,5 @@
C Take\scollating\ssequence\sinto\saccount\swhen\sremoving\sredundant\scolumns\sfrom\nindexes\son\sWITHOUT\sROWID\stables.\s\sThis\sis\sthe\sfirst\sproof-of-concept\sfix\nfor\sticket\s[3182d3879020ef3].\sMore\stesting\sneeded.
D 2019-04-28T19:27:02.781
C Improved\sheader\scomment\sand\sprecondition\schecking\sfor\sthe\snew\sisDupColumn()\nfunction.
D 2019-04-29T13:30:16.066
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -463,7 +463,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
F src/btree.c ffe7101006aee2ab9e9dec2fc001998e57a8e59419c6ea4072d6c3935d3d50fb
F src/btree.h c11446f07ec0e9dc85af8041cb0855c52f5359c8b2a43e47e02a685282504d89
F src/btreeInt.h 6111c15868b90669f79081039d19e7ea8674013f907710baa3c814dc3f8bfd3f
F src/build.c 3fedab95ff7a9b3ed51eceb12aaa61de6bbd063dabd276767494cc448a151b7b
F src/build.c 2d9ddfeaf8e1dafc7e1fcc8a84e7a8b455199dac3b69037fc73af6279aa8447b
F src/callback.c 25dda5e1c2334a367b94a64077b1d06b2553369f616261ca6783c48bcb6bda73
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 109e58d00f62e8e71ee1eb5944ac18b90171c928ab2e082e058056e1137cc20b
@ -1821,10 +1821,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 50fe48458942fa7a6bcc76316c6321f95b23dc34f2f8e0a483826483b2fb16f6
R fa5b9567c2bc0a92e3c8181fab56d7f8
T *branch * tkt-3182d38790
T *sym-tkt-3182d38790 *
T -sym-trunk *
P b34fa5bff40d3d364bd8c80e7de55c606ef3caac47b14b5265ebcb38857eb85e
R 4500a529c2eaff26172712aaa84d5151
U drh
Z dd82847aa38c87860cc4ec05cc3ab230
Z 5d2313cdcb9e1838679491aff8b0ed48

View File

@ -1 +1 @@
b34fa5bff40d3d364bd8c80e7de55c606ef3caac47b14b5265ebcb38857eb85e
740d5ff6cc9bf7b151dfb8b27409e5923cfb2789b5398fe13d89563aff8ffc07

View File

@ -1741,27 +1741,32 @@ static int hasColumn(const i16 *aiCol, int nCol, int x){
}
/*
** Return true if any of the first nKey entries of index pIdx1 exactly
** match the iCol-th entry of pIdx2.
** Return true if any of the first nKey entries of index pIdx exactly
** match the iCol-th entry of pPk. pPk is always a WITHOUT ROWID
** PRIMARY KEY index. pIdx is an index on the same table. pIdx may
** or may not be the same index as pPk.
**
** The first nKey entries of pIdx1 are guaranteed to be ordinary columns,
** The first nKey entries of pIdx are guaranteed to be ordinary columns,
** not a rowid or expression.
**
** This routine differs from hasColumn() in that both the column and the
** collating sequence must match for this routine, but for hasColumn() only
** the column name must match.
*/
static int isDupColumn(Index *pIdx1, int nKey, Index *pIdx2, int iCol){
static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){
int i, j;
assert( nKey<=pIdx1->nColumn );
assert( iCol<MAX(pIdx2->nColumn,pIdx2->nKeyCol) );
j = pIdx2->aiColumn[iCol];
testcase( j==XN_EXPR );
assert( j!=XN_ROWID );
assert( nKey<=pIdx->nColumn );
assert( iCol<MAX(pPk->nColumn,pPk->nKeyCol) );
assert( pPk->idxType==SQLITE_IDXTYPE_PRIMARYKEY );
assert( pPk->pTable->tabFlags & TF_WithoutRowid );
assert( pPk->pTable==pIdx->pTable );
testcase( pPk==pIdx );
j = pPk->aiColumn[iCol];
assert( j!=XN_ROWID && j!=XN_EXPR );
for(i=0; i<nKey; i++){
assert( pIdx1->aiColumn[i]>=0 || j>=0 );
if( pIdx1->aiColumn[i]==j
&& sqlite3StrICmp(pIdx1->azColl[i],pIdx2->azColl[iCol])==0
assert( pIdx->aiColumn[i]>=0 || j>=0 );
if( pIdx->aiColumn[i]==j
&& sqlite3StrICmp(pIdx->azColl[i], pPk->azColl[iCol])==0
){
return 1;
}