f467744d5f
FossilOrigin-Name: 2d9cd06715092c312c8c0ec392696a0e90ed090b074e2082e0b830f1399aa941
87 lines
2.1 KiB
Plaintext
87 lines
2.1 KiB
Plaintext
# 2019 January 23
|
|
#
|
|
# 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 altertab3
|
|
|
|
# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
|
|
ifcapable !altertable {
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
do_execsql_test 1.0 {
|
|
CREATE TABLE t1(a, b);
|
|
CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
|
|
SELECT sum(b) OVER w FROM t1 WINDOW w AS (ORDER BY a);
|
|
END;
|
|
}
|
|
|
|
do_execsql_test 1.1 {
|
|
ALTER TABLE t1 RENAME a TO aaa;
|
|
}
|
|
|
|
do_execsql_test 1.2 {
|
|
SELECT sql FROM sqlite_master WHERE name='tr1'
|
|
} {{CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
|
|
SELECT sum(b) OVER w FROM t1 WINDOW w AS (ORDER BY aaa);
|
|
END}}
|
|
|
|
do_execsql_test 1.3 {
|
|
INSERT INTO t1 VALUES(1, 2);
|
|
}
|
|
|
|
#-------------------------------------------------------------------------
|
|
reset_db
|
|
do_execsql_test 2.0 {
|
|
CREATE TABLE t1(a,b,c);
|
|
CREATE TABLE t2(a,b,c);
|
|
CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
|
|
SELECT a,b, a name FROM t1
|
|
INTERSECT
|
|
SELECT a,b,c FROM t1 WHERE b>='d' ORDER BY name;
|
|
SELECT new.c;
|
|
END;
|
|
}
|
|
|
|
do_execsql_test 2.1 {
|
|
ALTER TABLE t1 RENAME TO t1x;
|
|
SELECT sql FROM sqlite_master WHERE name = 'r1';
|
|
} {{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
|
|
SELECT a,b, a name FROM "t1x"
|
|
INTERSECT
|
|
SELECT a,b,c FROM "t1x" WHERE b>='d' ORDER BY name;
|
|
SELECT new.c;
|
|
END}}
|
|
|
|
#-------------------------------------------------------------------------
|
|
reset_db
|
|
do_execsql_test 3.0 {
|
|
CREATE TABLE t1(a, b, c, d);
|
|
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (b IN ());
|
|
}
|
|
|
|
do_execsql_test 3.1 {
|
|
ALTER TABLE t1 RENAME b TO bbb;
|
|
}
|
|
|
|
do_execsql_test 3.2 {
|
|
SELECT sql FROM sqlite_master WHERE name = 'v1'
|
|
} {{CREATE VIEW v1 AS SELECT * FROM t1 WHERE a=1 OR (bbb IN ())}}
|
|
|
|
|
|
|
|
finish_test
|
|
|
|
|