Fix WITHOUT ROWID tables so that they correctly deal with PRIMARY KEYs that
contain redundant columns. FossilOrigin-Name: 0dfef6757056ef0bdea8f049f7469ccf6960e2cb
This commit is contained in:
parent
0ab0e05c6b
commit
e385d8876e
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C Update\sthe\sSQLITE_CONFIG_PAGECACHE\sdocumentation\sso\sthat\sthe\smaximum\spage\nsize\sis\scorrectly\sstated\sto\sbe\s65536.
|
||||
D 2014-12-25T12:19:56.744
|
||||
C Fix\sWITHOUT\sROWID\stables\sso\sthat\sthey\scorrectly\sdeal\swith\sPRIMARY\sKEYs\sthat\ncontain\sredundant\scolumns.
|
||||
D 2014-12-28T22:10:51.114
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in c20e37499a3d664a3732257ed042352eba777a4d
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -176,7 +176,7 @@ F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
|
||||
F src/btree.c 904d30478685fe0723ad9092fc800a655544c69a
|
||||
F src/btree.h 94277c1d30c0b75705974bcc8b0c05e79c03d474
|
||||
F src/btreeInt.h a3d0ae1d511365e1a2b76ad10960dbe55c286f34
|
||||
F src/build.c 162d84e4833b03f9d07192ef06057b0226f6e543
|
||||
F src/build.c f5cfd7b32216f695b995bbc7c1a395f6d451d11f
|
||||
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
|
||||
F src/complete.c 198a0066ba60ab06fc00fba1998d870a4d575463
|
||||
F src/ctime.c df19848891c8a553c80e6f5a035e768280952d1a
|
||||
@ -1178,6 +1178,7 @@ F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
|
||||
F test/without_rowid3.test 1081aabf60a1e1123b7f9a8f6ae19954351843b0
|
||||
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
|
||||
F test/without_rowid5.test 61256715b686359df48ca1742db50cc7e3e7b862
|
||||
F test/without_rowid6.test deddb78ef539c355bddec00cdfaea6c56efd8b3f
|
||||
F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda
|
||||
F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
|
||||
F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac
|
||||
@ -1233,7 +1234,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 6396f8046242286298fecd1748a6e8e786e6794e
|
||||
R 6fef442856f5d39a46d82b3795b528e7
|
||||
P 3286424b4d30035de69b88ef0b2897365ff848f9
|
||||
R fdb1da8fdb04c896d0536c98941bdfa0
|
||||
U drh
|
||||
Z 07073e8eb87986ae3ece689929973238
|
||||
Z ccbcde8f60a3b3f04760cafd27073216
|
||||
|
@ -1 +1 @@
|
||||
3286424b4d30035de69b88ef0b2897365ff848f9
|
||||
0dfef6757056ef0bdea8f049f7469ccf6960e2cb
|
13
src/build.c
13
src/build.c
@ -1713,6 +1713,19 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
|
||||
pTab->iPKey = -1;
|
||||
}else{
|
||||
pPk = sqlite3PrimaryKeyIndex(pTab);
|
||||
/*
|
||||
** Remove all redundant columns from the PRIMARY KEY. For example, change
|
||||
** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later
|
||||
** code assumes the PRIMARY KEY contains no repeated columns.
|
||||
*/
|
||||
for(i=j=1; i<pPk->nKeyCol; i++){
|
||||
if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){
|
||||
pPk->nColumn--;
|
||||
}else{
|
||||
pPk->aiColumn[j++] = pPk->aiColumn[i];
|
||||
}
|
||||
}
|
||||
pPk->nKeyCol = j;
|
||||
}
|
||||
pPk->isCovering = 1;
|
||||
assert( pPk!=0 );
|
||||
|
41
test/without_rowid6.test
Normal file
41
test/without_rowid6.test
Normal file
@ -0,0 +1,41 @@
|
||||
# 2014-12-28
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Verify that WITHOUT ROWID tables work correctly when the PRIMARY KEY
|
||||
# has redundant columns.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_execsql_test without_rowid6-100 {
|
||||
CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,a,b,c,d,a,b,c)) WITHOUT ROWID;
|
||||
CREATE INDEX t1a ON t1(b, b);
|
||||
WITH RECURSIVE
|
||||
c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<1000)
|
||||
INSERT INTO t1(a,b,c,d,e) SELECT i, i+1000, printf('x%dy',i), 0, 0 FROM c;
|
||||
ANALYZE;
|
||||
} {}
|
||||
do_execsql_test without_rowid6-110 {
|
||||
SELECT c FROM t1 WHERE a=123;
|
||||
} {x123y}
|
||||
do_execsql_test without_rowid6-120 {
|
||||
SELECT c FROM t1 WHERE b=1123;
|
||||
} {x123y}
|
||||
do_execsql_test without_rowid6-130 {
|
||||
SELECT c FROM t1 ORDER BY a DESC LIMIT 5;
|
||||
} {x1000y x999y x998y x997y x996y}
|
||||
do_execsql_test without_rowid6-140 {
|
||||
SELECT c FROM t1 ORDER BY b LIMIT 5;
|
||||
} {x1y x2y x3y x4y x5y}
|
||||
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user