Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5alter.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5alter.test
diff --git a/third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5alter.test b/third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5alter.test
new file mode 100644
index 0000000000000000000000000000000000000000..eae01b7386099fdd0e8f647f360c1599f7469ee8
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5alter.test
@@ -0,0 +1,103 @@
+# 2015 Jun 10
+#
+# 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.
+#
+#***********************************************************************
+#
+# The tests in this file focus on renaming FTS5 tables using the
+# "ALTER TABLE ... RENAME TO ..." command
+#
+
+source [file join [file dirname [info script]] fts5_common.tcl]
+set testprefix fts5alter
+
+# If SQLITE_ENABLE_FTS5 is defined, omit this file.
+ifcapable !fts5 {
+ finish_test
+ return
+}
+
+#-------------------------------------------------------------------------
+# Test renaming regular, contentless and columnsize=0 FTS5 tables.
+#
+do_execsql_test 1.1.0 {
+ CREATE VIRTUAL TABLE "a x" USING fts5(a, x);
+ INSERT INTO "a x" VALUES('a a a', 'x x x');
+ ALTER TABLE "a x" RENAME TO "x y";
+}
+do_execsql_test 1.1.1 {
+ SELECT * FROM "x y";
+ SELECT rowid FROM "x y" WHERE "x y" MATCH 'a'
+} {{a a a} {x x x} 1}
+
+do_execsql_test 1.2.0 {
+ CREATE VIRTUAL TABLE "one/two" USING fts5(one, columnsize=0);
+ INSERT INTO "one/two"(rowid, one) VALUES(456, 'd d d');
+ ALTER TABLE "one/two" RENAME TO "three/four";
+}
+do_execsql_test 1.2.1 {
+ SELECT * FROM "three/four";
+ SELECT rowid FROM "three/four" WHERE "three/four" MATCH 'd'
+} {{d d d} 456}
+
+do_execsql_test 1.3.0 {
+ CREATE VIRTUAL TABLE t1 USING fts5(val, content='');
+ INSERT INTO t1(rowid, val) VALUES(-1, 'drop table');
+ INSERT INTO t1(rowid, val) VALUES(-2, 'drop view');
+ ALTER TABLE t1 RENAME TO t2;
+}
+do_execsql_test 1.3.1 {
+ SELECT rowid, * FROM t2;
+ SELECT rowid FROM t2 WHERE t2 MATCH 'table'
+} {-2 {} -1 {} -1}
+
+#-------------------------------------------------------------------------
+# Test renaming an FTS5 table within a transaction.
+#
+do_execsql_test 2.1 {
+ CREATE VIRTUAL TABLE zz USING fts5(a);
+ INSERT INTO zz(rowid, a) VALUES(-56, 'a b c');
+ BEGIN;
+ INSERT INTO zz(rowid, a) VALUES(-22, 'a b c');
+ ALTER TABLE zz RENAME TO yy;
+ SELECT rowid FROM yy WHERE yy MATCH 'a + b + c';
+ COMMIT;
+} {-56 -22}
+
+do_execsql_test 2.2 {
+ BEGIN;
+ ALTER TABLE yy RENAME TO ww;
+ INSERT INTO ww(rowid, a) VALUES(-11, 'a b c');
+ SELECT rowid FROM ww WHERE ww MATCH 'a + b + c';
+} {-56 -22 -11}
+
+do_execsql_test 2.3 {
+ ROLLBACK;
+ SELECT rowid FROM yy WHERE yy MATCH 'a + b + c';
+} {-56 -22}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE abc USING fts5(a);
+ INSERT INTO abc(rowid, a) VALUES(1, 'a');
+ BEGIN;
+ INSERT INTO abc(rowid, a) VALUES(2, 'a');
+}
+breakpoint
+do_execsql_test 3.2 {
+ SELECT rowid FROM abc WHERE abc MATCH 'a';
+} {1 2}
+
+do_execsql_test 3.3 {
+ COMMIT;
+ SELECT rowid FROM abc WHERE abc MATCH 'a';
+} {1 2}
+
+finish_test
+

Powered by Google App Engine
This is Rietveld 408576698