1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Only preserve rowid values for VACUUM INTO. Keep the legacy behavior of

renumbering rowids for ordinary VACUUM.

FossilOrigin-Name: 13a0ea6466b051ea5281865ed5285b8b5a99ec4307f400c5f7b03692723f1cd1
This commit is contained in:
drh
2019-04-04 14:00:23 +00:00
parent b92d7d264e
commit 4e61e88348
6 changed files with 57 additions and 17 deletions

View File

@@ -232,9 +232,9 @@ do_execsql_test e_vacuum-3.1.1 {
do_execsql_test e_vacuum-3.1.2 {
VACUUM;
SELECT rowid, x FROM t4;
} {1 x 3 z}
# Was: {1 x 2 z}
} {1 x 2 z}
# Rowids are preserved if an INTEGER PRIMARY KEY is used
do_execsql_test e_vacuum-3.1.3 {
CREATE TABLE t5(x, y INTEGER PRIMARY KEY);
INSERT INTO t5(x) VALUES('x');
@@ -248,6 +248,44 @@ do_execsql_test e_vacuum-3.1.4 {
SELECT rowid, x FROM t5;
} {1 x 3 z}
# Rowid is preserved for VACUUM INTO
do_execsql_test e_vacuum-3.1.5 {
DROP TABLE t5;
CREATE TABLE t5(x);
INSERT INTO t5(x) VALUES('x');
INSERT INTO t5(x) VALUES('y');
INSERT INTO t5(x) VALUES('z');
DELETE FROM t5 WHERE x = 'y';
SELECT rowid, x FROM t5;
} {1 x 3 z}
forcedelete test2.db
do_execsql_test e_vacuum-3.1.6 {
VACUUM INTO 'test2.db';
ATTACH 'test2.db' AS aux1;
SELECT rowid, x FROM aux1.t5;
DETACH aux1;
} {1 x 3 z}
# Rowids are renumbered even if the table being vacuumed
# has indexes.
do_execsql_test e_vacuum-3.1.7 {
DROP TABLE t5;
CREATE TABLE t5(x,y,z);
INSERT INTO t5(x) VALUES('x');
INSERT INTO t5(x) VALUES('y');
INSERT INTO t5(x) VALUES('z');
UPDATE t5 SET y=x, z=random();
DELETE FROM t5 WHERE x = 'y';
CREATE INDEX t5x ON t5(x);
CREATE UNIQUE INDEX t5y ON t5(y);
CREATE INDEX t5zxy ON t5(z,x,y);
SELECT rowid, x FROM t5;
} {1 x 3 z}
do_execsql_test e_vacuum-3.1.8 {
VACUUM;
SELECT rowid, x FROM t5;
} {1 x 3 z}
# EVIDENCE-OF: R-49563-33883 A VACUUM will fail if there is an open
# transaction, or if there are one or more active SQL statements when it
# is run.