1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Fix test cases so that they all still work even with -DSQLITE_DQS=0.

FossilOrigin-Name: 4883776669ee2f2310ea82b0d6df4d008eebaa7cb252102539cf21a635402ebb
This commit is contained in:
drh
2022-01-16 19:11:13 +00:00
parent 72e30421c8
commit 7d44b22d45
35 changed files with 117 additions and 97 deletions

View File

@ -838,6 +838,8 @@ do_execsql_test 22.0 {
#-------------------------------------------------------------------------
#
reset_db
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test 22.0 {
CREATE TABLE t1(a, b);
CREATE INDEX x1 on t1("c"=b);

View File

@ -25,6 +25,8 @@ ifcapable !altertable {
sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test 1.0 {
CREATE TABLE t1(a, b, c);
@ -89,6 +91,8 @@ foreach {tn before after} {
#-------------------------------------------------------------------------
reset_db
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test 2.0 {
CREATE TABLE x1(
one, two, three, PRIMARY KEY(one),

View File

@ -21,6 +21,8 @@ ifcapable !check {
finish_test
return
}
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_test check-1.1 {
execsql {
@ -138,6 +140,8 @@ do_test check-2.2 {
} {1 2.2 three}
db close
sqlite3 db test.db
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_test check-2.3 {
execsql {
INSERT INTO t2 VALUES(NULL, NULL, NULL);

View File

@ -338,6 +338,7 @@ do_test collate1-5.3 {
#-------------------------------------------------------------------------
# Fix problems with handling collation sequences named '"""'.
#
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test 6.1 {
SELECT """""""";
} {\"\"\"}

View File

@ -81,6 +81,7 @@ ifcapable threadsafe2 {
# SQLITE_THREADSAFE should pretty much always be defined
# one way or the other, and it must have a value of 0 or 1.
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_test ctime-1.4.1 {
catchsql {
SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');

View File

@ -81,7 +81,7 @@ do_test eval-3.1 {
} {1 {} 102 2 {} 103 3 {} 104 4 {} 105}
do_test eval-4.1 {
execsql { SELECT test_eval('SELECT "abcdefghij"') }
execsql { SELECT test_eval('SELECT ''abcdefghij''') }
} {abcdefghij}
finish_test

View File

@ -970,6 +970,7 @@ do_realnum_test expr-13.7 {
}
} {9.22337203685478e+18}
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test expr-13.8 {
SELECT "" <= '';
} {1}

View File

@ -6,8 +6,6 @@
# This file implements regression tests for SQLite library. This
# tests creating fts3 tables in an attached database.
#
# $Id: fts3aj.test,v 1.1 2007/08/20 17:38:42 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -25,14 +23,14 @@ sqlite3 db2 test2.db
db eval {
CREATE VIRTUAL TABLE t3 USING fts3(content);
INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
INSERT INTO t3 (rowid, content) VALUES(1, 'hello world');
}
db2 eval {
CREATE VIRTUAL TABLE t1 USING fts3(content);
INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
INSERT INTO t1 (rowid, content) VALUES(1, 'hello world');
INSERT INTO t1 (rowid, content) VALUES(2, 'hello there');
INSERT INTO t1 (rowid, content) VALUES(3, 'cruel world');
}
# This has always worked because the t1_* tables used by fts3 will be
@ -56,9 +54,9 @@ do_test fts3aj-1.2 {
execsql {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t2 USING fts3(content);
INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
INSERT INTO t2 (rowid, content) VALUES(1, 'hello world');
INSERT INTO t2 (rowid, content) VALUES(2, 'hello there');
INSERT INTO t2 (rowid, content) VALUES(3, 'cruel world');
SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
DETACH DATABASE two;
}
@ -74,8 +72,8 @@ do_test fts3aj-1.3 {
ATTACH DATABASE 'test2.db' AS two;
CREATE VIRTUAL TABLE two.t3 USING fts3(content);
INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
INSERT INTO two.t3 (rowid, content) VALUES(2, 'hello there');
INSERT INTO two.t3 (rowid, content) VALUES(3, 'cruel world');
SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
DETACH DATABASE two;

View File

@ -21,17 +21,17 @@ ifcapable !fts3 {
db eval {
CREATE VIRTUAL TABLE t1 USING fts3(content);
INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
INSERT INTO t1 (rowid, content) VALUES(1, 'hello world');
INSERT INTO t1 (rowid, content) VALUES(2, 'hello there');
INSERT INTO t1 (rowid, content) VALUES(3, 'cruel world');
}
# Test that possibly-buffered inserts went through after commit.
do_test fts3ak-1.1 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(4, "false world");
INSERT INTO t1 (rowid, content) VALUES(5, "false door");
INSERT INTO t1 (rowid, content) VALUES(4, 'false world');
INSERT INTO t1 (rowid, content) VALUES(5, 'false door');
COMMIT TRANSACTION;
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
}
@ -42,8 +42,8 @@ do_test fts3ak-1.1 {
do_test fts3ak-1.2 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(6, "another world");
INSERT INTO t1 (rowid, content) VALUES(7, "another test");
INSERT INTO t1 (rowid, content) VALUES(6, 'another world');
INSERT INTO t1 (rowid, content) VALUES(7, 'another test');
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
COMMIT TRANSACTION;
}
@ -54,8 +54,8 @@ do_test fts3ak-1.2 {
do_test fts3ak-1.3 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(8, "second world");
INSERT INTO t1 (rowid, content) VALUES(9, "second sight");
INSERT INTO t1 (rowid, content) VALUES(8, 'second world');
INSERT INTO t1 (rowid, content) VALUES(9, 'second sight');
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
ROLLBACK TRANSACTION;
}
@ -73,8 +73,8 @@ do_test fts3ak-1.4 {
do_test fts3ak-1.5 {
execsql {
BEGIN TRANSACTION;
INSERT INTO t1 (rowid, content) VALUES(10, "second world");
INSERT INTO t1 (rowid, content) VALUES(11, "second sight");
INSERT INTO t1 (rowid, content) VALUES(10, 'second world');
INSERT INTO t1 (rowid, content) VALUES(11, 'second sight');
ROLLBACK TRANSACTION;
SELECT rowid FROM t1 WHERE t1 MATCH 'world';
}
@ -84,7 +84,7 @@ do_test fts3ak-1.5 {
do_test fts3ak-1.6 {
execsql {
BEGIN;
INSERT INTO t1 (rowid, content) VALUES(12, "third world");
INSERT INTO t1 (rowid, content) VALUES(12, 'third world');
COMMIT;
SELECT rowid FROM t1 WHERE t1 MATCH 'third';
}
@ -95,7 +95,7 @@ do_test fts3ak-1.6 {
do_test fts3ak-1.7 {
execsql {
BEGIN;
INSERT INTO t1 (rowid, content) VALUES(13, "third dimension");
INSERT INTO t1 (rowid, content) VALUES(13, 'third dimension');
CREATE TABLE x (c);
COMMIT;
SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';

View File

@ -178,7 +178,7 @@ do_catchsql_test 6.10 {
INSERT INTO f_segments (blockid) values (16);
INSERT INTO f_segments values (0, x'');
INSERT INTO f_stat VALUES (1,x'cf0f01');
INSERT INTO f(f) VALUES ("merge=1");
INSERT INTO f(f) VALUES ('merge=1');
} {1 {database disk image is malformed}}
# 2020-03-02 https://bugs.chromium.org/p/chromium/issues/detail?id=1057441

View File

@ -173,7 +173,7 @@ do_execsql_test 6.1.1 {
CREATE VIRTUAL TABLE t1 USING fts4(
poiCategory, poiCategoryId, notindexed=poiCategoryId
);
INSERT INTO t1(poiCategory, poiCategoryId) values ("Restaurant", 6021);
INSERT INTO t1(poiCategory, poiCategoryId) values ('Restaurant', 6021);
}
do_execsql_test 6.1.2 {
@ -194,7 +194,7 @@ do_execsql_test 6.2.1 {
CREATE VIRTUAL TABLE t1 USING fts4(
poiCategory, poiCategoryId, notindexed=poiCategory
);
INSERT INTO t1(poiCategory, poiCategoryId) values ("Restaurant", 6021);
INSERT INTO t1(poiCategory, poiCategoryId) values ('Restaurant', 6021);
}
do_execsql_test 6.2.2 {

View File

@ -1007,32 +1007,32 @@ do_test func-21.2 {
} {1 {wrong number of arguments to function replace()}}
do_test func-21.3 {
execsql {
SELECT typeof(replace("This is the main test string", NULL, "ALT"));
SELECT typeof(replace('This is the main test string', NULL, 'ALT'));
}
} {null}
do_test func-21.4 {
execsql {
SELECT typeof(replace(NULL, "main", "ALT"));
SELECT typeof(replace(NULL, 'main', 'ALT'));
}
} {null}
do_test func-21.5 {
execsql {
SELECT typeof(replace("This is the main test string", "main", NULL));
SELECT typeof(replace('This is the main test string', 'main', NULL));
}
} {null}
do_test func-21.6 {
execsql {
SELECT replace("This is the main test string", "main", "ALT");
SELECT replace('This is the main test string', 'main', 'ALT');
}
} {{This is the ALT test string}}
do_test func-21.7 {
execsql {
SELECT replace("This is the main test string", "main", "larger-main");
SELECT replace('This is the main test string', 'main', 'larger-main');
}
} {{This is the larger-main test string}}
do_test func-21.8 {
execsql {
SELECT replace("aaaaaaa", "a", "0123456789");
SELECT replace('aaaaaaa', 'a', '0123456789');
}
} {0123456789012345678901234567890123456789012345678901234567890123456789}
@ -1315,7 +1315,7 @@ do_test func-29.1 {
CREATE TABLE t29(id INTEGER PRIMARY KEY, x, y);
INSERT INTO t29 VALUES(1, 2, 3), (2, NULL, 4), (3, 4.5, 5);
INSERT INTO t29 VALUES(4, randomblob(1000000), 6);
INSERT INTO t29 VALUES(5, "hello", 7);
INSERT INTO t29 VALUES(5, 'hello', 7);
}
db close
sqlite3 db test.db

View File

@ -329,6 +329,8 @@ ifcapable !fts3 {
db close
forcedelete test.db
sqlite3 db test.db
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_test fuzz-oss1-gnomeshell {
db eval {
CREATE TABLE Resource (ID INTEGER NOT NULL PRIMARY KEY, Uri TEXT NOT

View File

@ -281,12 +281,13 @@ do_test in-7.8.2 {
db status step
} {0}
do_test in-8.1 {
do_test in-8.3 {
execsql {
SELECT b FROM t1 WHERE a IN ('hello','there')
}
} {world}
do_test in-8.2 {
do_test in-8.4 {
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
execsql {
SELECT b FROM t1 WHERE a IN ("hello",'there')
}

View File

@ -428,7 +428,7 @@ do_test index-13.1 {
} {1 2.0 3}
do_test index-13.2 {
set ::idxlist [execsql {
SELECT name FROM sqlite_master WHERE type="index" AND tbl_name="t5";
SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='t5';
}]
llength $::idxlist
} {3}

View File

@ -439,6 +439,7 @@ do_test join-5.1 {
# A test for ticket #247.
#
do_test join-7.1 {
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
execsql {
CREATE TABLE t7 (x, y);
INSERT INTO t7 VALUES ("pa1", 1);

View File

@ -652,7 +652,7 @@ do_catchsql_test misc1-21.2 {
# 2015-04-15
do_execsql_test misc1-22.1 {
SELECT ""+3 FROM (SELECT ""+5);
SELECT ''+3 FROM (SELECT ''+5);
} {3}
# 2015-04-19: NULL pointer dereference on a corrupt schema

View File

@ -173,6 +173,7 @@ ifcapable altertable {
INSERT INTO t1 VALUES(1,2,3),(1,4,5);
ALTER TABLE t1 DROP COLUMN b;
} {1 {error in index x1 after drop column: no such column: b}}
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
do_catchsql_test 3.5 {
DROP TABLE t1;
CREATE TABLE t1(a, b, c);

View File

@ -169,7 +169,6 @@ do_test select6-3.2 {
FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY q) AS a,
(SELECT max(a) as r, b as s FROM t2 GROUP BY s) as b
WHERE a.q=b.s ORDER BY a.q)
ORDER BY "a.q"
}
} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}
do_test select6-3.3 {

View File

@ -477,7 +477,7 @@ do_test subquery-5.1 {
INSERT INTO t5 VALUES(3,33);
INSERT INTO t5 VALUES(4,44);
SELECT b FROM t5 WHERE a IN
(SELECT callcnt(y)+0 FROM t4 WHERE x="two")
(SELECT callcnt(y)+0 FROM t4 WHERE x='two')
}
} {22}
do_test subquery-5.2 {

View File

@ -209,8 +209,8 @@ db func fetch_db fetch_db
do_catchsql_test 3.1 {
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
'VALUES
("test.db1", "t1", 1, 10),
("test.db2", "t1", 11, 20)
(''test.db1'', ''t1'', 1, 10),
(''test.db2'', ''t1'', 11, 20)
', 'fetch_db_no_such_function'
);
} {1 {sql error: no such function: fetch_db_no_such_function}}
@ -218,8 +218,8 @@ do_catchsql_test 3.1 {
do_catchsql_test 3.2 {
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
'VALUES
("test.db1", "t1", 1, 10),
("test.db2", "t1", 11, 20)
(''test.db1'', ''t1'', 1, 10),
(''test.db2'', ''t1'', 11, 20)
', 'fetch_db'
);
} {1 {fetch_db error!}}
@ -233,8 +233,8 @@ do_execsql_test 3.3.1 {
DETACH aux;
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
'VALUES
("test.db1", "t1", 1, 10),
("test.db2", "t1", 11, 20)
(''test.db1'', ''t1'', 1, 10),
(''test.db2'', ''t1'', 11, 20)
', 'fetch_db'
);
} {}

View File

@ -146,7 +146,7 @@ do_execsql_test 2.2 {
} {31 10}
do_execsql_test 2.3 {
SELECT CASE WHEN DeliveredQty=10 THEN "TEST PASSED!" ELSE "TEST FAILED!" END
SELECT CASE WHEN DeliveredQty=10 THEN 'TEST PASSED!' ELSE 'TEST FAILED!' END
FROM InventoryControl WHERE SKU=31;
} {{TEST PASSED!}}

View File

@ -38,6 +38,7 @@ do_test tkt3442-1.1 {
# SELECT referenced in ticket #3442 (both '5000' and "5000")
# and verify that the query plan is the same.
#
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_eqp_test tkt3442-1.2 {
SELECT node FROM listhash WHERE id='5000' LIMIT 1;
} {SEARCH listhash USING INDEX ididx (id=?)}

View File

@ -22,6 +22,7 @@ ifcapable !subquery {
return
}
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_test tkt3841.1 {
execsql {
CREATE TABLE table2 (key TEXT, x TEXT);

View File

@ -627,7 +627,7 @@ ifcapable altertable {
CREATE INDEX t15c ON t15(c);
INSERT INTO t15(a,b)
VALUES(5,'zyx'),(15,'wvu'),(25,'tsr'),(35,'qpo');
UPDATE t15 SET c=printf("y%d",a) WHERE c IS NULL;
UPDATE t15 SET c=printf('y%d',a) WHERE c IS NULL;
SELECT a,b,c,'|' FROM t15 ORDER BY a;
} {5 zyx y5 | 10 abc y10 | 15 wvu y15 | 20 def y20 | 25 tsr y25 | 30 ghi y30 | 35 qpo y35 |}
}

View File

@ -32,6 +32,7 @@ ifcapable !utf16 {
do_test utf16align-1.0 {
set unaligned_string_counter 0
add_alignment_test_collations [sqlite3_connection_pointer db]
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
execsql {
PRAGMA encoding=UTF16;
CREATE TABLE t1(

View File

@ -351,6 +351,7 @@ do_test vtab6-4.10 {
# A test for ticket #247.
#
do_test vtab6-7.1 {
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
execsql {
INSERT INTO t7 VALUES ("pa1", 1);
INSERT INTO t7 VALUES ("pa2", NULL);

View File

@ -148,6 +148,7 @@ do_execsql_test 5.5 {
#
ifcapable !icu {
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
do_execsql_test 6.0 {
SELECT LIKE('!', '', '!') x WHERE x;
} {}