Many new test cases added, that mostly work. Currently 18 errors in

without_rowid3.test.  Also there is a hack marked by a /*FIXME*/ comment 
on at fkey.c:547 that needs fixing.

FossilOrigin-Name: 39e32187b66405e00dbd44685f6cdd269c90f5e5
This commit is contained in:
drh 2013-11-02 22:09:48 +00:00
parent ce95d11921
commit 63f0eedf10
9 changed files with 2155 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Change\sthe\s"idx"\sname\sof\sthe\sprimary\skey\sindex\sfor\sWITHOUT\sROWID\stables\sin\nsqlite_statN\sstatistics\stables\sto\sbe\sthe\sname\sof\sthe\stable\srather\sthan\sthe\nfabricated\sindex\sname\s(ex:\ssqlite_autoindex_xyz_1).\s\sThis\smakes\sit\sconsistent\nwith\ssqlite_master\stable.
D 2013-11-02T19:34:38.297
C Many\snew\stest\scases\sadded,\sthat\smostly\swork.\s\sCurrently\s18\serrors\sin\s\nwithout_rowid3.test.\s\sAlso\sthere\sis\sa\shack\smarked\sby\sa\s/*FIXME*/\scomment\s\non\sat\sfkey.c:547\sthat\sneeds\sfixing.
D 2013-11-02T22:09:48.508
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -168,15 +168,15 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 509722ce305471b626d3401c0631a808fd33237b
F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf
F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
F src/build.c 38d6d7396213a5320ce6e822145b671e3e2653eb
F src/build.c 113a23bc6f8cf81dd03c984ef0460cca89c48f2e
F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c
F src/date.c 593c744b2623971e45affd0bde347631bdfa4625
F src/delete.c c58e07fb07878c4b4c4b106cee7f2799a48351f8
F src/delete.c 605be39dc72a56768a55ee7245d92774ed7ae343
F src/expr.c ecc2b98eb75fe5533cfdfcca6b04cfe5f0c6001f
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 628f81177299660a86e40359b3689b81f517e125
F src/fkey.c 8dc2b14dd93cd991629ce98e02bc4a5a181f7146
F src/func.c 2c47b65e6e00e3e9374942f28254faf8adafe398
F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
@ -284,7 +284,7 @@ F src/vdbe.h c18a2dd91c838601b867a214e43c5f66d5d001ba
F src/vdbeInt.h f2fa3ceccceeb757773921fb08af7c6e9f3caa1c
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
F src/vdbeaux.c cf6d0bc68fd1783747909cd14387bc06ac10a4e2
F src/vdbeblob.c ef973d8d9f8170015343dd8824f795da675caa87
F src/vdbeblob.c ff60adf2953e0ffc1d59541b3101c9886b03a3de
F src/vdbemem.c e62206af9efa102c5bae58269955cae1965ad728
F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147
F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc
@ -1076,7 +1076,9 @@ 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 e9e88261688e0a220040d5230efa4dd4fc835351
F test/without_rowid1.test de6f9e6ea36a7e4b087e44084abed3c0456f7dfe
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
F test/without_rowid3.test a755f3eef1e0d20e1bb9c9da00ebfa889d7b0bd7
F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
F test/zerodamage.test 209d7ed441f44cc5299e4ebffbef06fd5aabfefd
F tool/build-all-msvc.bat 1bac6adc3fdb4d9204f21d17b14be25778370e48 x
@ -1128,7 +1130,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 9075770e4030b35677fbbe291f3c3c4946937a9a
R 43f61ca2b6fde01b1a8ef610aae771fc
P 4ee4d3106308508a58b80e54e0afb4afb42f510b
R ff4bdc6a5b118bf4488ef2d4ca905162
U drh
Z 769817a600daabafe89044f55c04373b
Z a4403bd962894f91a2a08b106e00735c

View File

@ -1 +1 @@
4ee4d3106308508a58b80e54e0afb4afb42f510b
39e32187b66405e00dbd44685f6cdd269c90f5e5

View File

@ -1653,6 +1653,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
assert( pParse->pNewTable==pTab );
pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0);
if( pPk==0 ) return;
pPk->autoIndex = 2;
pTab->iPKey = -1;
}else{
pPk = sqlite3PrimaryKeyIndex(pTab);

View File

@ -399,8 +399,6 @@ void sqlite3DeleteFrom(
*/
sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite,
iTabCur, &iDataCur, &iIdxCur);
assert( iDataCur!=iTabCur );
assert( iDataCur>=iIdxCur );
/* Loop over the primary keys to be deleted. */
addr = sqlite3VdbeAddOp1(v, OP_Rewind, iEph);

View File

@ -544,7 +544,7 @@ static void fkScanChildren(
** is taking place as part of a DELETE operation (operation D.2), omit the
** row being deleted from the scan by adding ($rowid != rowid) to the WHERE
** clause, where $rowid is the rowid of the row being deleted. */
if( pTab==pFKey->pFrom && nIncr>0 ){
if( pTab==pFKey->pFrom && nIncr>0 && HasRowid(pTab) /*FIXME*/ ){
Expr *pEq; /* Expression (pLeft = pRight) */
Expr *pLeft; /* Value from parent table row */
Expr *pRight; /* Column ref to child table */

View File

@ -178,6 +178,10 @@ int sqlite3_blob_open(
pTab = 0;
sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable);
}
if( pTab && !HasRowid(pTab) ){
pTab = 0;
sqlite3ErrorMsg(pParse, "cannot open table without rowid: %s", zTable);
}
#ifndef SQLITE_OMIT_VIEW
if( pTab && pTab->pSelect ){
pTab = 0;

View File

@ -91,10 +91,21 @@ do_execsql_test without_rowid1-1.40 {
} {1250 phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}
integrity_check without_rowid1-1.41
# Verify that ANALYZE works
#
do_execsql_test without_rowid1-1.50 {
ANALYZE;
SELECT * FROM sqlite_stat1 ORDER BY idx;
} {t1 t1 {4 2 1} t1 t1bd {4 2 2}}
ifcapable stat3 {
do_execsql_test without_rowid1-1.51 {
SELECT DISTINCT tbl, idx FROM sqlite_stat3 ORDER BY idx;
} {t1 t1 t1 t1bd}
}
ifcapable stat4 {
do_execsql_test without_rowid1-1.52 {
SELECT DISTINCT tbl, idx FROM sqlite_stat4 ORDER BY idx;
} {t1 t1 t1 t1bd}
}
finish_test

125
test/without_rowid2.test Normal file
View File

@ -0,0 +1,125 @@
# 2013-11-02
#
# 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.
#
#***********************************************************************
#
# This file implements regression tests for SQLite library. The
# focus of this file is testing WITHOUT ROWID tables, and especially
# FOREIGN KEY constraints.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {!foreignkey} {
finish_test
return
}
# Create a table and some data to work with.
#
do_test without_rowid2-1.0 {
execsql {
CREATE TABLE t1(
a INT PRIMARY KEY,
b INT
REFERENCES t1 ON DELETE CASCADE
REFERENCES t2,
c TEXT,
FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
) WITHOUT rowid;
}
} {}
do_test without_rowid2-1.1 {
execsql {
CREATE TABLE t2(
x INT PRIMARY KEY,
y TEXT
) WITHOUT rowid;
}
} {}
do_test without_rowid2-1.2 {
execsql {
CREATE TABLE t3(
a INT REFERENCES t2,
b INT REFERENCES t1,
FOREIGN KEY (a,b) REFERENCES t2(x,y)
);
}
} {}
do_test without_rowid2-2.1 {
execsql {
CREATE TABLE t4(a int primary key) WITHOUT rowid;
CREATE TABLE t5(x references t4);
CREATE TABLE t6(x references t4);
CREATE TABLE t7(x references t4);
CREATE TABLE t8(x references t4);
CREATE TABLE t9(x references t4);
CREATE TABLE t10(x references t4);
DROP TABLE t7;
DROP TABLE t9;
DROP TABLE t5;
DROP TABLE t8;
DROP TABLE t6;
DROP TABLE t10;
}
} {}
do_test without_rowid2-3.1 {
execsql {
CREATE TABLE t5(a PRIMARY KEY, b, c) WITHOUT rowid;
CREATE TABLE t6(
d REFERENCES t5,
e REFERENCES t5(c)
);
PRAGMA foreign_key_list(t6);
}
} [concat \
{0 0 t5 e c {NO ACTION} {NO ACTION} NONE} \
{1 0 t5 d {} {NO ACTION} {NO ACTION} NONE} \
]
do_test without_rowid2-3.2 {
execsql {
CREATE TABLE t7(d, e, f,
FOREIGN KEY (d, e) REFERENCES t5(a, b)
);
PRAGMA foreign_key_list(t7);
}
} [concat \
{0 0 t5 d a {NO ACTION} {NO ACTION} NONE} \
{0 1 t5 e b {NO ACTION} {NO ACTION} NONE} \
]
do_test without_rowid2-3.3 {
execsql {
CREATE TABLE t8(d, e, f,
FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET NULL
);
PRAGMA foreign_key_list(t8);
}
} [concat \
{0 0 t5 d {} {SET NULL} CASCADE NONE} \
{0 1 t5 e {} {SET NULL} CASCADE NONE} \
]
do_test without_rowid2-3.4 {
execsql {
CREATE TABLE t9(d, e, f,
FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET DEFAULT
);
PRAGMA foreign_key_list(t9);
}
} [concat \
{0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \
{0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \
]
do_test without_rowid2-3.5 {
sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
} {0 0 0}
finish_test

1999
test/without_rowid3.test Normal file

File diff suppressed because it is too large Load Diff