mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add tests for updates of without-rowid tables that use non-BINARY collation sequences for the primary key columns. And a minor bugfix to the same.
FossilOrigin-Name: 99b1fa4b1664a79eae1dddce2b9a848384cdb1d7
This commit is contained in:
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Standardize\sthe\serror\smessages\sgenerated\sby\sconstraint\sfailures\sto\sa\sformat\nof\s"$TYPE\sconstraint\sfailed:\s$DETAIL".\s\sThis\sinvolves\smany\schanges\sto\sthe\nexpected\soutput\sof\stest\scases.
|
||||
D 2013-11-05T13:33:55.491
|
||||
C Add\stests\sfor\supdates\sof\swithout-rowid\stables\sthat\suse\snon-BINARY\scollation\ssequences\sfor\sthe\sprimary\skey\scolumns.\sAnd\sa\sminor\sbugfix\sto\sthe\ssame.
|
||||
D 2013-11-05T14:19:22.006
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -182,7 +182,7 @@ F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759
|
||||
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
|
||||
F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
|
||||
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
|
||||
F src/insert.c 63660d2ec840c43c212fbfe3805a162e4e6eafc7
|
||||
F src/insert.c 37bbaf90c077a8a8a6a5831d66c223b66e8272ae
|
||||
F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
|
||||
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
|
||||
@ -831,7 +831,7 @@ F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43
|
||||
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
|
||||
F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
|
||||
F test/temptrigger.test 0a48d94222d50e6e50d72ac103606c4f8e7cbb81
|
||||
F test/tester.tcl 5e97d1fe08f45fa3cc2320cee437e315c75ce995
|
||||
F test/tester.tcl 901258f2825cb712be4093bcd9317082d26a9901
|
||||
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
|
||||
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||
@ -1078,7 +1078,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
|
||||
F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
|
||||
F test/win32lock.test 7a6bd73a5dcdee39b5bb93e92395e1773a194361
|
||||
F test/win32longpath.test e2aafc07e6990fe86c69be22a3d1a0e210cd329b
|
||||
F test/without_rowid1.test 657fde6092752c0f08a8f4b5f92b8b4b11c754ce
|
||||
F test/without_rowid1.test 0b349aa31554afcee213ccabf4d259f4ff13a86a
|
||||
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
|
||||
F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0
|
||||
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
|
||||
@ -1133,7 +1133,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P 294ed33756b06375e56c41f1088d42ee48adbdc8
|
||||
R 130b6461e81d8eeec1daafa19f71d1d2
|
||||
U drh
|
||||
Z ecfd4293f10f89cf27ac30e16c93be55
|
||||
P 54b221929744b1bcdbcc2030fef2e510618afd41
|
||||
R 1aec678b4bfe426b5a77dcb059fca6c2
|
||||
U dan
|
||||
Z 288ff3cb146c8502bea1245ecdd07fe3
|
||||
|
@ -1 +1 @@
|
||||
54b221929744b1bcdbcc2030fef2e510618afd41
|
||||
99b1fa4b1664a79eae1dddce2b9a848384cdb1d7
|
41
src/insert.c
41
src/insert.c
@ -1506,29 +1506,28 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
}
|
||||
if( isUpdate ){
|
||||
if( pIdx->autoIndex==2 ){
|
||||
/* For a PRIMARY KEY index on a WITHOUT ROWID table, always conflict
|
||||
** on an INSERT. On an UPDATE, only conflict if the PRIMARY KEY
|
||||
** has changed. */
|
||||
int addrPkConflict = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
|
||||
for(i=0; i<pPk->nKeyCol-1; i++){
|
||||
/* If currently processing the PRIMARY KEY of a WITHOUT ROWID
|
||||
** table, only conflict if the new PRIMARY KEY values are actually
|
||||
** different from the old.
|
||||
**
|
||||
** For a UNIQUE index, only conflict if the PRIMARY KEY values
|
||||
** of the matched index row are different from the original PRIMARY
|
||||
** KEY values of this row before the update. */
|
||||
char *p4;
|
||||
int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
|
||||
int op = OP_Ne;
|
||||
int regCmp = (pIdx->autoIndex==2 ? regIdx : regR);
|
||||
|
||||
for(i=0; i<pPk->nKeyCol; i++){
|
||||
char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);
|
||||
x = pPk->aiColumn[i];
|
||||
sqlite3VdbeAddOp3(v, OP_Ne, regOldData+1+x,
|
||||
addrPkConflict, regIdx+i);
|
||||
if( i==(pPk->nKeyCol-1) ){
|
||||
addrJump = addrUniqueOk;
|
||||
op = OP_Eq;
|
||||
}
|
||||
x = pPk->aiColumn[i];
|
||||
sqlite3VdbeAddOp3(v, OP_Eq, regOldData+1+x, addrUniqueOk, regIdx+i);
|
||||
}else{
|
||||
/* For a UNIQUE index on a WITHOUT ROWID table, conflict only if the
|
||||
** PRIMARY KEY value of the match is different from the old
|
||||
** PRIMARY KEY value from before the update. */
|
||||
int addrConflict = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
|
||||
for(i=0; i<pPk->nKeyCol-1; i++){
|
||||
sqlite3VdbeAddOp3(v, OP_Ne, regOldData+pPk->aiColumn[i]+1,
|
||||
addrConflict, regR+i);
|
||||
}
|
||||
sqlite3VdbeAddOp3(v, OP_Eq, regOldData+pPk->aiColumn[i]+1,
|
||||
addrUniqueOk, regR+i);
|
||||
sqlite3VdbeAddOp4(v, op,
|
||||
regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1023,6 +1023,50 @@ proc explain {sql {db db}} {
|
||||
}
|
||||
}
|
||||
|
||||
proc explain_i {sql {db db}} {
|
||||
puts ""
|
||||
puts "addr opcode p1 p2 p3 p4 p5 #"
|
||||
puts "---- ------------ ------ ------ ------ ---------------- -- -"
|
||||
|
||||
set addrTail 0
|
||||
|
||||
$db eval "explain $sql" {} {
|
||||
set x($addr) 0
|
||||
set op($addr) $opcode
|
||||
|
||||
if {$opcode == "Goto" && $addrTail==0} {
|
||||
set addrTail $p2
|
||||
}
|
||||
|
||||
if {$opcode == "Next"} {
|
||||
for {set i $p2} {$i<$addr} {incr i} {
|
||||
incr x($i) 2
|
||||
}
|
||||
}
|
||||
|
||||
if {$opcode == "Goto" && $p2<$addr && $op($p2)=="Yield"} {
|
||||
for {set i [expr $p2+1]} {$i<$addr} {incr i} {
|
||||
incr x($i) 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db eval "explain $sql" {} {
|
||||
if {$addr == $addrTail} {
|
||||
puts ""
|
||||
}
|
||||
set I [string repeat " " $x($addr)]
|
||||
puts [format {%-4d %s%-12.12s %-6d %-6d %-6d % -17s %s %s} \
|
||||
$addr $I $opcode $p1 $p2 $p3 $p4 $p5 $comment
|
||||
]
|
||||
|
||||
if {$opcode == "Halt" && $comment == "End of coroutine"} {
|
||||
puts ""
|
||||
}
|
||||
}
|
||||
puts "---- ------------ ------ ------ ------ ---------------- -- -"
|
||||
}
|
||||
|
||||
# Show the VDBE program for an SQL statement but omit the Trace
|
||||
# opcode at the beginning. This procedure can be used to prove
|
||||
# that different SQL statements generate exactly the same VDBE code.
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix without_rowid1
|
||||
|
||||
# Create and query a WITHOUT ROWID table.
|
||||
#
|
||||
@ -108,4 +109,50 @@ ifcapable stat4 {
|
||||
} {t1 t1 t1 t1bd}
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
do_execsql_test 2.1.1 {
|
||||
CREATE TABLE t4 (a COLLATE nocase PRIMARY KEY, b) WITHOUT ROWID;
|
||||
INSERT INTO t4 VALUES('abc', 'def');
|
||||
SELECT * FROM t4;
|
||||
} {abc def}
|
||||
do_execsql_test 2.1.2 {
|
||||
UPDATE t4 SET a = 'ABC';
|
||||
SELECT * FROM t4;
|
||||
} {ABC def}
|
||||
|
||||
do_execsql_test 2.2.1 {
|
||||
DROP TABLE t4;
|
||||
CREATE TABLE t4 (b, a COLLATE nocase PRIMARY KEY) WITHOUT ROWID;
|
||||
INSERT INTO t4(a, b) VALUES('abc', 'def');
|
||||
SELECT * FROM t4;
|
||||
} {def abc}
|
||||
|
||||
do_execsql_test 2.2.2 {
|
||||
UPDATE t4 SET a = 'ABC', b = 'xyz';
|
||||
SELECT * FROM t4;
|
||||
} {xyz ABC}
|
||||
|
||||
do_execsql_test 2.3.1 {
|
||||
CREATE TABLE t5 (a, b, PRIMARY KEY(b, a)) WITHOUT ROWID;
|
||||
INSERT INTO t5(a, b) VALUES('abc', 'def');
|
||||
UPDATE t5 SET a='abc', b='def';
|
||||
} {}
|
||||
|
||||
do_execsql_test 2.4.1 {
|
||||
CREATE TABLE t6 (
|
||||
a COLLATE nocase, b, c UNIQUE, PRIMARY KEY(b, a)
|
||||
) WITHOUT ROWID;
|
||||
|
||||
INSERT INTO t6(a, b, c) VALUES('abc', 'def', 'ghi');
|
||||
UPDATE t6 SET a='ABC', c='ghi';
|
||||
} {}
|
||||
|
||||
do_execsql_test 2.4.2 {
|
||||
SELECT * FROM t6 ORDER BY b, a;
|
||||
SELECT * FROM t6 ORDER BY c;
|
||||
} {ABC def ghi ABC def ghi}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user