mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Merge the latest trunk changes into the begin-concurrent branch.
FossilOrigin-Name: 94838f16baf810054926196f277be4688359c502cb7e6872e3e3273a9c67e56d
This commit is contained in:
@@ -553,8 +553,9 @@ do_execsql_test 13.1.3 {
|
||||
|
||||
sqlite3_db_config db DEFENSIVE 0
|
||||
do_execsql_test 13.1.4 {
|
||||
PRAGMA writable_schema = 1;
|
||||
PRAGMA writable_schema = ON;
|
||||
UPDATE sqlite_master SET sql = 'CREATE INDEX x1i ON x1(j)' WHERE name='x1i';
|
||||
PRAGMA writable_schema = OFF;
|
||||
} {}
|
||||
|
||||
do_catchsql_test 13.1.5 {
|
||||
@@ -562,7 +563,9 @@ do_catchsql_test 13.1.5 {
|
||||
} {1 {error in index x1i: no such column: j}}
|
||||
|
||||
do_execsql_test 13.1.6 {
|
||||
PRAGMA writable_schema = ON;
|
||||
UPDATE sqlite_master SET sql = '' WHERE name='x1i';
|
||||
PRAGMA writable_schema = OFF;
|
||||
} {}
|
||||
|
||||
do_catchsql_test 13.1.7 {
|
||||
@@ -570,7 +573,9 @@ do_catchsql_test 13.1.7 {
|
||||
} {1 {error in index x1i: }}
|
||||
|
||||
do_execsql_test 13.1.8 {
|
||||
PRAGMA writable_schema = ON;
|
||||
DELETE FROM sqlite_master WHERE name = 'x1i';
|
||||
PRAGMA writable_schema = OFF;
|
||||
}
|
||||
|
||||
do_execsql_test 13.2.0 {
|
||||
@@ -861,5 +866,69 @@ do_execsql_test 23.0 {
|
||||
|
||||
} {ok {CREATE TABLE t1("x" "b",c)}}
|
||||
|
||||
# 2022-02-04
|
||||
# Do not complain about syntax errors in the schema if
|
||||
# in PRAGMA writable_schema=ON mode.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 23.0 {
|
||||
CREATE TABLE t1(a INT, b REAL, c TEXT, d BLOB, e ANY);
|
||||
CREATE INDEX t1abx ON t1(a, b, a+b) WHERE c IS NOT NULL;
|
||||
CREATE VIEW t2 AS SELECT a+10, b*5.0, xyz FROM t1; -- unknown column "xyz"
|
||||
CREATE TABLE schema_copy(name TEXT, sql TEXT);
|
||||
INSERT INTO schema_copy(name,sql) SELECT name, sql FROM sqlite_schema WHERE sql IS NOT NULL;
|
||||
} {}
|
||||
do_catchsql_test 23.1 {
|
||||
ALTER TABLE t1 RENAME COLUMN e TO eeee;
|
||||
} {1 {error in view t2: no such column: xyz}}
|
||||
do_execsql_test 23.2 {
|
||||
SELECT name, sql FROM sqlite_master
|
||||
EXCEPT SELECT name, sql FROM schema_copy;
|
||||
} {}
|
||||
do_execsql_test 23.3 {
|
||||
BEGIN;
|
||||
PRAGMA writable_schema=ON;
|
||||
ALTER TABLE t1 RENAME COLUMN e TO eeee;
|
||||
PRAGMA writable_schema=OFF;
|
||||
SELECT name FROM sqlite_master
|
||||
WHERE (name, sql) NOT IN (SELECT name, sql FROM schema_copy);
|
||||
ROLLBACK;
|
||||
} {t1}
|
||||
do_execsql_test 23.10 {
|
||||
DROP VIEW t2;
|
||||
CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
|
||||
INSERT INTO t3(x,y) VALUES(new.a, new.b);
|
||||
INSERT INTO t4(p) VALUES(new.c); -- no such table "t4"
|
||||
END;
|
||||
DELETE FROM schema_copy;
|
||||
INSERT INTO schema_copy(name,sql) SELECT name, sql FROM sqlite_schema WHERE sql IS NOT NULL;
|
||||
} {}
|
||||
do_catchsql_test 23.11 {
|
||||
ALTER TABLE t1 RENAME COLUMN e TO eeee;
|
||||
} {1 {error in trigger r3: no such table: main.t3}}
|
||||
do_execsql_test 23.12 {
|
||||
SELECT name, sql FROM sqlite_master
|
||||
EXCEPT SELECT name, sql FROM schema_copy;
|
||||
} {}
|
||||
do_execsql_test 23.13 {
|
||||
BEGIN;
|
||||
PRAGMA writable_schema=ON;
|
||||
ALTER TABLE t1 RENAME COLUMN e TO eeee;
|
||||
PRAGMA writable_schema=OFF;
|
||||
SELECT name FROM sqlite_master
|
||||
WHERE (name, sql) NOT IN (SELECT name, sql FROM schema_copy);
|
||||
ROLLBACK;
|
||||
} {t1}
|
||||
do_execsql_test 23.20 {
|
||||
CREATE TABLE t4(id INTEGER PRIMARY KEY, c1 INT, c2 INT);
|
||||
CREATE VIEW t4v1 AS SELECT id, c1, c99 FROM t4;
|
||||
DELETE FROM schema_copy;
|
||||
INSERT INTO schema_copy SELECT name, sql FROM sqlite_schema;
|
||||
BEGIN;
|
||||
PRAGMA writable_schema=ON;
|
||||
ALTER TABLE t4 RENAME to t4new;
|
||||
SELECT name FROM sqlite_schema WHERE (name,sql) NOT IN (SELECT * FROM schema_copy);
|
||||
ROLLBACK;
|
||||
} {t4new}
|
||||
|
||||
finish_test
|
||||
|
@@ -26,6 +26,11 @@ do_execsql_test 1.0 {
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
|
||||
|
||||
do_faultsim_test 1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
@@ -33,7 +38,7 @@ do_faultsim_test 1 -prep {
|
||||
ALTER TABLE t1 RENAME abcd TO dcba
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
catch {db close}
|
||||
@@ -52,7 +57,7 @@ do_faultsim_test 2 -prep {
|
||||
ALTER TABLE t1 RENAME abcd TO dcba
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +75,7 @@ do_faultsim_test 3 -prep {
|
||||
ALTER TABLE t1 RENAME abcd TO dcba
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
reset_db
|
||||
@@ -95,7 +100,7 @@ do_faultsim_test 4 -faults oom-* -prep {
|
||||
ALTER TABLE rr RENAME a TO c;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
reset_db
|
||||
@@ -116,7 +121,7 @@ do_faultsim_test 5 -faults oom-* -prep {
|
||||
ALTER TABLE rr RENAME TO c;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
@@ -21,6 +21,10 @@ ifcapable !altertable {
|
||||
return
|
||||
}
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE x1(
|
||||
one, two, three, PRIMARY KEY(one),
|
||||
@@ -40,7 +44,7 @@ do_faultsim_test 1 -prep {
|
||||
} -body {
|
||||
execsql { ALTER TABLE t1 DROP COLUMN c }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -72,7 +76,7 @@ do_faultsim_test 2.2 -prep {
|
||||
ALTER TABLE t2 RENAME TO t2x;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
@@ -355,7 +355,7 @@ do_execsql_test 8.5 {
|
||||
reset_db
|
||||
do_catchsql_test 8.6 {
|
||||
CREATE TABLE t0(c0);
|
||||
CREATE INDEX i0 ON t0(LIKELIHOOD(1,2) AND 0);
|
||||
CREATE INDEX i0 ON t0(likelihood(1,2) AND 0);
|
||||
ALTER TABLE t0 RENAME TO t1;
|
||||
SELECT sql FROM sqlite_master WHERE name='i0';
|
||||
} {1 {error in index i0: second argument to likelihood() must be a constant between 0.0 and 1.0}}
|
||||
|
63
test/bind2.test
Normal file
63
test/bind2.test
Normal file
@@ -0,0 +1,63 @@
|
||||
# 2022 Feb 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix bind2
|
||||
|
||||
|
||||
# Test that using bind_value() on a REAL sqlite3_value that was stored
|
||||
# as an INTEGER works properly.
|
||||
#
|
||||
# 1.1: An IntReal value read from a table,
|
||||
# 1.2: IntReal values obtained via the sqlite3_preupdate_old|new()
|
||||
# interfaces.
|
||||
#
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a REAL);
|
||||
INSERT INTO t1 VALUES(42.0);
|
||||
SELECT * FROM t1;
|
||||
} {42.0}
|
||||
|
||||
do_test 1.1 {
|
||||
set stmt [sqlite3_prepare db "SELECT ?" -1 tail]
|
||||
sqlite3_bind_value_from_select $stmt 1 "SELECT a FROM t1"
|
||||
sqlite3_step $stmt
|
||||
sqlite3_column_text $stmt 0
|
||||
} {42.0}
|
||||
sqlite3_finalize $stmt
|
||||
|
||||
ifcapable !preupdate {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
proc preup {args} {
|
||||
set stmt [sqlite3_prepare db "SELECT ?" -1 tail]
|
||||
sqlite3_bind_value_from_preupdate $stmt 1 old 0
|
||||
sqlite3_step $stmt
|
||||
lappend ::reslist [sqlite3_column_text $stmt 0]
|
||||
sqlite3_reset $stmt
|
||||
sqlite3_bind_value_from_preupdate $stmt 1 new 0
|
||||
sqlite3_step $stmt
|
||||
lappend ::reslist [sqlite3_column_text $stmt 0]
|
||||
sqlite3_finalize $stmt
|
||||
}
|
||||
db preupdate hook preup
|
||||
|
||||
do_test 1.2 {
|
||||
set ::reslist [list]
|
||||
execsql { UPDATE t1 SET a=43; }
|
||||
set ::reslist
|
||||
} {42.0 43.0}
|
||||
|
||||
finish_test
|
180
test/date.test
180
test/date.test
@@ -239,138 +239,70 @@ datetest 5.13 {datetime('1994-04-16 14:00:00Zulu')} NULL
|
||||
datetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL
|
||||
datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL
|
||||
|
||||
# localtime->utc and utc->localtime conversions. These tests only work
|
||||
# if the localtime is in the US Eastern Time (the time in Charlotte, NC
|
||||
# and in New York.)
|
||||
# localtime->utc and utc->localtime conversions.
|
||||
#
|
||||
# On non-Vista Windows platform, '2006-03-31' is treated incorrectly as being
|
||||
# in DST giving a 4 hour offset instead of 5. In 2007, DST was extended to
|
||||
# start three weeks earlier (second Sunday in March) and end one week
|
||||
# later (first Sunday in November). Older Windows systems apply this
|
||||
# new rule incorrectly to dates prior to 2007.
|
||||
# Use SQLITE_TESTCTRL_LOCALTIME_FAULT=2 to set an alternative localtime_r()
|
||||
# implementation that is not locale-dependent. This testing localtime_r()
|
||||
# operates as follows:
|
||||
#
|
||||
# It might be argued that this is masking a problem on non-Vista Windows
|
||||
# platform. A ticket has already been opened for this issue
|
||||
# (http://www.sqlite.org/cvstrac/tktview?tn=2322). This is just to prevent
|
||||
# more confusion/reports of the issue.
|
||||
# (1) Localtime is 30 minutes earlier than (west of) UTC on
|
||||
# even days (counting from 1970-01-01)
|
||||
#
|
||||
|
||||
# $tzoffset_old should be 5 if DST is working correctly.
|
||||
set tzoffset_old [db one {
|
||||
SELECT CAST(24*(julianday('2006-03-31') -
|
||||
julianday('2006-03-31','localtime'))+0.5
|
||||
AS INT)
|
||||
}]
|
||||
|
||||
# $tzoffset_new should be 4 if DST is working correctly.
|
||||
set tzoffset_new [db one {
|
||||
SELECT CAST(24*(julianday('2007-03-31') -
|
||||
julianday('2007-03-31','localtime'))+0.5
|
||||
AS INT)
|
||||
}]
|
||||
|
||||
# Warn about possibly broken Windows DST implementations.
|
||||
if {$::tcl_platform(platform)=="windows" && $tzoffset_new==4 && $tzoffset_old==4} {
|
||||
puts "******************************************************************"
|
||||
puts "N.B.: The DST support provided by your current O/S seems to be"
|
||||
puts "suspect in that it is reporting incorrect DST values for dates"
|
||||
puts "prior to 2007. This is the known case for most (all?) non-Vista"
|
||||
puts "Windows versions. Please see ticket #2322 for more information."
|
||||
puts "******************************************************************"
|
||||
# (2) Localtime is 30 minutes later than (east of) UTC on odd days.
|
||||
#
|
||||
# (3) The function fails for the specific date/time value
|
||||
# of 2000-05-29 14:16:00 in order to test the ability of
|
||||
# SQLite to deal with localtime_r() failures.
|
||||
#
|
||||
proc local_to_utc {tn utc local} {
|
||||
do_execsql_test date-$tn "SELECT datetime('$utc','localtime')" [list $local]
|
||||
}
|
||||
proc utc_to_local {tn local utc} {
|
||||
do_execsql_test date-$tn "SELECT datetime('$local','utc')" [list $utc]
|
||||
}
|
||||
|
||||
if {$tzoffset_new==4} {
|
||||
datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
|
||||
{2000-10-29 01:59:00}
|
||||
datetest 6.1.1 {datetime('2006-10-29 05:59:00','localtime')}\
|
||||
{2006-10-29 01:59:00}
|
||||
datetest 6.1.2 {datetime('2007-11-04 05:59:00','localtime')}\
|
||||
{2007-11-04 01:59:00}
|
||||
sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 2
|
||||
local_to_utc 6.1 {2000-10-29 12:00:00} {2000-10-29 12:30:00}
|
||||
utc_to_local 6.2 {2000-10-29 12:30:00} {2000-10-29 12:00:00}
|
||||
local_to_utc 6.3 {2000-10-30 12:00:00} {2000-10-30 11:30:00}
|
||||
utc_to_local 6.4 {2000-10-30 11:30:00} {2000-10-30 12:00:00}
|
||||
|
||||
# If the new and old DST rules seem to be working correctly...
|
||||
if {$tzoffset_new==4 && $tzoffset_old==5} {
|
||||
datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
|
||||
{2000-10-29 01:00:00}
|
||||
datetest 6.2.1 {datetime('2006-10-29 06:00:00','localtime')}\
|
||||
{2006-10-29 01:00:00}
|
||||
}
|
||||
datetest 6.2.2 {datetime('2007-11-04 06:00:00','localtime')}\
|
||||
{2007-11-04 01:00:00}
|
||||
local_to_utc 6.5 {2000-10-28 23:59:59} {2000-10-28 23:29:59}
|
||||
local_to_utc 6.6 {2000-10-29 00:00:00} {2000-10-29 00:30:00}
|
||||
|
||||
# If the new and old DST rules seem to be working correctly...
|
||||
if {$tzoffset_new==4 && $tzoffset_old==5} {
|
||||
datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
|
||||
{2000-04-02 01:59:00}
|
||||
datetest 6.3.1 {datetime('2006-04-02 06:59:00','localtime')}\
|
||||
{2006-04-02 01:59:00}
|
||||
}
|
||||
datetest 6.3.2 {datetime('2007-03-11 07:00:00','localtime')}\
|
||||
{2007-03-11 03:00:00}
|
||||
|
||||
datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
|
||||
{2000-04-02 03:00:00}
|
||||
datetest 6.4.1 {datetime('2006-04-02 07:00:00','localtime')}\
|
||||
{2006-04-02 03:00:00}
|
||||
datetest 6.4.2 {datetime('2007-03-11 07:00:00','localtime')}\
|
||||
{2007-03-11 03:00:00}
|
||||
|
||||
datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}
|
||||
datetest 6.5.1 {datetime('2006-10-29 01:59:00','utc')} {2006-10-29 05:59:00}
|
||||
datetest 6.5.2 {datetime('2007-11-04 01:59:00','utc')} {2007-11-04 05:59:00}
|
||||
|
||||
# If the new and old DST rules seem to be working correctly...
|
||||
if {$tzoffset_new==4 && $tzoffset_old==5} {
|
||||
datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}
|
||||
datetest 6.6.1 {datetime('2006-10-29 02:00:00','utc')} {2006-10-29 07:00:00}
|
||||
}
|
||||
datetest 6.6.2 {datetime('2007-11-04 02:00:00','utc')} {2007-11-04 07:00:00}
|
||||
|
||||
# If the new and old DST rules seem to be working correctly...
|
||||
if {$tzoffset_new==4 && $tzoffset_old==5} {
|
||||
datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}
|
||||
datetest 6.7.1 {datetime('2006-04-02 01:59:00','utc')} {2006-04-02 06:59:00}
|
||||
}
|
||||
datetest 6.7.2 {datetime('2007-03-11 01:59:00','utc')} {2007-03-11 06:59:00}
|
||||
|
||||
datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}
|
||||
datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}
|
||||
datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}
|
||||
|
||||
# The 'utc' modifier is a no-op if the LHS is known to already be in UTC
|
||||
datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00}
|
||||
datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00}
|
||||
datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \
|
||||
{2015-12-23 15:00:00}
|
||||
datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \
|
||||
{2015-12-23 17:00:00}
|
||||
|
||||
|
||||
datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
|
||||
{2000-01-01 07:00:00}
|
||||
datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
|
||||
{1969-01-01 07:00:00}
|
||||
datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
|
||||
{2039-01-01 07:00:00}
|
||||
datetest 6.13 {datetime('2000-07-01 12:00:00','localtime')} \
|
||||
{2000-07-01 08:00:00}
|
||||
datetest 6.14 {datetime('1969-07-01 12:00:00','localtime')} \
|
||||
{1969-07-01 07:00:00}
|
||||
datetest 6.15 {datetime('2039-07-01 12:00:00','localtime')} \
|
||||
{2039-07-01 07:00:00}
|
||||
set sqlite_current_time \
|
||||
[db eval {SELECT strftime('%s','2000-07-01 12:34:56')}]
|
||||
datetest 6.16 {datetime('now','localtime')} {2000-07-01 08:34:56}
|
||||
datetest 6.17 {datetime('now','localtimex')} NULL
|
||||
datetest 6.18 {datetime('now','localtim')} NULL
|
||||
set sqlite_current_time 0
|
||||
}
|
||||
|
||||
# These two are a bit of a scam. They are added to ensure that 100% of
|
||||
# the date.c file is covered by testing, even when the time-zone
|
||||
# is not -0400 (the condition for running of the block of tests above).
|
||||
# The previous two cases establish that no such localtime as
|
||||
# 2000-10-29 00:10:00 exists. Verify that we get a reasonable
|
||||
# answer if we try to convert this non-existant localtime to utc?
|
||||
#
|
||||
datetest 6.19 {datetime('2039-07-01 12:00:00','localtime',null)} NULL
|
||||
datetest 6.20 {datetime('2039-07-01 12:00:00','utc',null)} NULL
|
||||
utc_to_local 6.7 {2000-10-29 00:10:00} {2000-10-28 23:40:00}
|
||||
|
||||
local_to_utc 6.8 {2022-02-10 23:59:59} {2022-02-11 00:29:59}
|
||||
local_to_utc 6.9 {2022-02-11 00:00:00} {2022-02-10 23:30:00}
|
||||
local_to_utc 6.10 {2022-02-10 23:45:00} {2022-02-11 00:15:00}
|
||||
local_to_utc 6.11 {2022-02-11 00:45:00} {2022-02-11 00:15:00}
|
||||
|
||||
# The previous two cases show that two different UTC values give
|
||||
# the same localtime of 2022-02-11 00:15:00. When converting from
|
||||
# that localtime back to UTC, we should get one or the other of
|
||||
# the two UTC values.
|
||||
#
|
||||
utc_to_local 6.12 {2022-02-11 00:15:00} {2022-02-11 00:45:00}
|
||||
|
||||
# If localtime_r() fails, the datetime() SQL function should raise an error
|
||||
#
|
||||
do_catchsql_test date-6.20 {
|
||||
SELECT datetime('2000-05-29 14:16:00','localtime');
|
||||
} {1 {local time unavailable}}
|
||||
|
||||
# Modifiers work for dates that are way out of band for localtime_r()
|
||||
#
|
||||
local_to_utc 6.21 {1800-10-29 12:00:00} {1800-10-29 12:30:00}
|
||||
utc_to_local 6.22 {1800-10-29 12:30:00} {1800-10-29 12:00:00}
|
||||
local_to_utc 6.23 {3000-10-30 12:00:00} {3000-10-30 11:30:00}
|
||||
utc_to_local 6.24 {3000-10-30 11:30:00} {3000-10-30 12:00:00}
|
||||
|
||||
# Restore the use of the OS localtime_r() before going on...
|
||||
sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0
|
||||
|
||||
# Date-time functions that contain NULL arguments return a NULL
|
||||
# result.
|
||||
|
@@ -493,10 +493,10 @@ do_execsql_test e_createtable-1.7.0 {
|
||||
do_createtable_tests 1.7.1 -error { %s } {
|
||||
1 "CREATE TABLE t1(a, b)" {{table t1 already exists}}
|
||||
2 "CREATE TABLE i1(a, b)" {{there is already an index named i1}}
|
||||
3 "CREATE TABLE v1(a, b)" {{table v1 already exists}}
|
||||
3 "CREATE TABLE v1(a, b)" {{view v1 already exists}}
|
||||
4 "CREATE TABLE auxa.tbl1(a, b)" {{table tbl1 already exists}}
|
||||
5 "CREATE TABLE auxa.idx1(a, b)" {{there is already an index named idx1}}
|
||||
6 "CREATE TABLE auxa.view1(a, b)" {{table view1 already exists}}
|
||||
6 "CREATE TABLE auxa.view1(a, b)" {{view view1 already exists}}
|
||||
}
|
||||
do_createtable_tests 1.7.2 {
|
||||
1 "CREATE TABLE auxa.t1(a, b)" {}
|
||||
|
@@ -372,7 +372,7 @@ integrity_check fuzz-7.5.integrity
|
||||
#----------------------------------------------------------------
|
||||
# Many CREATE and DROP TABLE statements:
|
||||
#
|
||||
set E [list table duplicate {no such col} {ambiguous column name} {use DROP}]
|
||||
set E [list table view duplicate {no such col} {ambiguous column name} {use DROP}]
|
||||
do_fuzzy_test fuzz-8.1 -template {[CreateOrDropTableOrView]} -errorlist $E
|
||||
|
||||
close $::log
|
||||
|
@@ -156,6 +156,14 @@ static struct GlobalVars {
|
||||
char zTestName[100]; /* Name of current test */
|
||||
} g;
|
||||
|
||||
/*
|
||||
** Include the external vt02.c module, if requested by compile-time
|
||||
** options.
|
||||
*/
|
||||
#ifdef VT02_SOURCES
|
||||
# include "vt02.c"
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Print an error message and quit.
|
||||
*/
|
||||
@@ -1052,6 +1060,10 @@ int runCombinedDbSqlInput(
|
||||
** deserialize to do this because deserialize depends on ATTACH */
|
||||
sqlite3_set_authorizer(cx.db, block_troublesome_sql, 0);
|
||||
|
||||
#ifdef VT02_SOURCES
|
||||
sqlite3_vt02_init(cx.db, 0, 0);
|
||||
#endif
|
||||
|
||||
/* Consistent PRNG seed */
|
||||
#ifdef SQLITE_TESTCTRL_PRNG_SEED
|
||||
sqlite3_table_column_metadata(cx.db, 0, "x", 0, 0, 0, 0, 0, 0);
|
||||
|
Binary file not shown.
@@ -16,6 +16,11 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix merge1
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
load_static_extension db series
|
||||
|
||||
|
||||
|
@@ -53,7 +53,7 @@ do_test shell1-1.1.2 {
|
||||
# error on extra options
|
||||
do_test shell1-1.1.3 {
|
||||
catchcmd "test.db FOO test.db BAD" ".quit"
|
||||
} {/1 .Error: in prepare, near "FOO": syntax error (1)*/}
|
||||
} {/1 .Error: in prepare, near "FOO": syntax error*/}
|
||||
|
||||
# -help
|
||||
do_test shell1-1.2.1 {
|
||||
@@ -78,7 +78,7 @@ do_test shell1-1.3.2 {
|
||||
} {0 {}}
|
||||
do_test shell1-1.3.3 {
|
||||
catchcmd "-init FOO test.db BAD .quit" ""
|
||||
} {/1 .Error: in prepare, near "BAD": syntax error (1)*/}
|
||||
} {/1 .Error: in prepare, near "BAD": syntax error*/}
|
||||
|
||||
# -echo print commands before execution
|
||||
do_test shell1-1.4.1 {
|
||||
@@ -593,7 +593,8 @@ CREATE VIEW v2 AS SELECT x+1 AS y FROM t1
|
||||
/* v2(y) */;
|
||||
CREATE VIEW v1 AS SELECT y+1 FROM v2
|
||||
/* v1("y+1") */;}}
|
||||
db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}
|
||||
|
||||
catch {db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}}
|
||||
}
|
||||
|
||||
# .separator STRING Change column separator used by output and .import
|
||||
|
@@ -63,7 +63,7 @@ do_test shell2-1.3 {
|
||||
|
||||
UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
|
||||
}
|
||||
} {1 {Error: near line 9: stepping, too many levels of trigger recursion (1)}}
|
||||
} {1 {Runtime error near line 9: too many levels of trigger recursion}}
|
||||
|
||||
|
||||
|
||||
|
@@ -68,7 +68,7 @@ do_test shell3-1.6 {
|
||||
} {0 {}}
|
||||
do_test shell3-1.7 {
|
||||
catchcmd "foo.db \"CREATE TABLE\""
|
||||
} {1 {Error: in prepare, incomplete input (1)}}
|
||||
} {1 {Error: in prepare, incomplete input}}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# shell3-2.*: Basic tests for running SQL file from command line.
|
||||
@@ -98,7 +98,7 @@ do_test shell3-2.6 {
|
||||
} {0 {}}
|
||||
do_test shell3-2.7 {
|
||||
catchcmd "foo.db" "CREATE TABLE"
|
||||
} {1 {Error: near line 1: in prepare, incomplete input (1)}}
|
||||
} {1 {Parse error near line 1: incomplete input}}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
@@ -476,4 +476,53 @@ CREATE TABLE t8(a, b, c);
|
||||
db eval { SELECT * FROM t8 }
|
||||
} {1 2 3}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests for the shell automatic column rename.
|
||||
#
|
||||
|
||||
# Import columns containing duplicates
|
||||
do_test shell5-5.1 {
|
||||
set out [open shell5.csv w]
|
||||
fconfigure $out -translation lf
|
||||
puts $out {"","x","x","y","z","z_0","z_5","z"}
|
||||
puts $out {0,"x2","x3","y4","z5","z6","z7","z8"}
|
||||
close $out
|
||||
forcedelete test.db
|
||||
catchcmd test.db {.import -csv shell5.csv t1
|
||||
.mode line
|
||||
SELECT * FROM t1;}
|
||||
} {1 { ? = 0
|
||||
x_02 = x2
|
||||
x_03 = x3
|
||||
y = y4
|
||||
z_05 = z5
|
||||
z_0 = z6
|
||||
z_5 = z7
|
||||
z_08 = z8
|
||||
Columns renamed during .import shell5.csv due to duplicates:
|
||||
"x" to "x_02",
|
||||
"x" to "x_03",
|
||||
"z" to "z_05",
|
||||
"z" to "z_08"}}
|
||||
|
||||
do_test shell5-5.1 {
|
||||
set out [open shell5.csv w]
|
||||
fconfigure $out -translation lf
|
||||
puts $out {"COW","cow","CoW","cOw"}
|
||||
puts $out {"uuu","lll","ulu","lul"}
|
||||
close $out
|
||||
forcedelete test.db
|
||||
catchcmd test.db {.import -csv shell5.csv t1
|
||||
.mode line
|
||||
SELECT * FROM t1;}
|
||||
} {1 {COW_1 = uuu
|
||||
cow_2 = lll
|
||||
CoW_3 = ulu
|
||||
cOw_4 = lul
|
||||
Columns renamed during .import shell5.csv due to duplicates:
|
||||
"COW" to "COW_1",
|
||||
"cow" to "cow_2",
|
||||
"CoW" to "CoW_3",
|
||||
"cOw" to "cOw_4"}}
|
||||
|
||||
finish_test
|
||||
|
@@ -22,13 +22,13 @@ ifcapable !vtab {
|
||||
}
|
||||
load_static_extension db qpvtab
|
||||
|
||||
# EVIDENCE-OF: R-12211-29175 When the sqlite3_vtab_rhs_value(P,J,V)
|
||||
# EVIDENCE-OF: R-60223-49197 When the sqlite3_vtab_rhs_value(P,J,V)
|
||||
# interface is invoked from within the xBestIndex method of a virtual
|
||||
# table implementation, with P being a copy of the sqlite3_index_info
|
||||
# object pointer passed into xBestIndex and J being a 0-based index into
|
||||
# P->aConstraint[], then this routine attempts to set *V to be the
|
||||
# value on the right-hand side of that constraint if the right-hand side
|
||||
# is a known constant.
|
||||
# P->aConstraint[], then this routine attempts to set *V to the value
|
||||
# of the right-hand operand of that constraint if the right-hand operand
|
||||
# is known.
|
||||
#
|
||||
do_execsql_test 1.1 {
|
||||
SELECT rhs FROM qpvtab
|
||||
@@ -56,8 +56,8 @@ do_execsql_test 1.5 {
|
||||
AND a GLOB x'0123'
|
||||
} {x'0123'}
|
||||
|
||||
# EVIDENCE-OF: R-29440-53190 If the right-hand side of the constraint is
|
||||
# not known, then *V is set to a NULL pointer.
|
||||
# EVIDENCE-OF: R-37799-62852 If the right-hand operand is not known,
|
||||
# then *V is set to a NULL pointer.
|
||||
#
|
||||
do_execsql_test 2.1 {
|
||||
SELECT typeof(rhs) FROM qpvtab WHERE cn='a' AND a=format('abc');
|
||||
|
@@ -475,15 +475,16 @@ ifcapable altertable {
|
||||
# Omit an assert() from 2013 that no longer serves any purpose and
|
||||
# is no longer always true.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 15.1 {
|
||||
PRAGMA writable_schema=ON;
|
||||
CREATE TABLE sqlite_sequence (name PRIMARY KEY) WITHOUT ROWID;
|
||||
PRAGMA writable_schema=OFF;
|
||||
CREATE TABLE c1(x);
|
||||
INSERT INTO sqlite_sequence(name) VALUES('c0'),('c1'),('c2');
|
||||
ALTER TABLE c1 RENAME TO a;
|
||||
SELECT name FROM sqlite_sequence ORDER BY +name;
|
||||
} {a c0 c2}
|
||||
|
||||
ifcapable altertable {
|
||||
reset_db
|
||||
do_execsql_test 15.1 {
|
||||
PRAGMA writable_schema=ON;
|
||||
CREATE TABLE sqlite_sequence (name PRIMARY KEY) WITHOUT ROWID;
|
||||
PRAGMA writable_schema=OFF;
|
||||
CREATE TABLE c1(x);
|
||||
INSERT INTO sqlite_sequence(name) VALUES('c0'),('c1'),('c2');
|
||||
ALTER TABLE c1 RENAME TO a;
|
||||
SELECT name FROM sqlite_sequence ORDER BY +name;
|
||||
} {a c0 c2}
|
||||
}
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user