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

Allow CREATE and DROP TRIGGER on attached databases. (CVS 1488)

FossilOrigin-Name: 4060a37d0baaa60c50f2dde4a1ab344133fcabbb
This commit is contained in:
danielk1977
2004-05-29 02:37:19 +00:00
parent 51846b56ed
commit ef2cb63e9e
11 changed files with 211 additions and 398 deletions

View File

@ -12,7 +12,7 @@
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.16 2004/05/11 09:57:35 drh Exp $
# $Id: attach.test,v 1.17 2004/05/29 02:37:20 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@ -488,7 +488,7 @@ do_test attach-5.1 {
SELECT 'no-op';
END;
} db2
} {1 {triggers may not be added to auxiliary database orig}}
} {1 {trigger r1 cannot reference objects in database orig}}
do_test attach-5.2 {
catchsql {
CREATE TABLE t5(x,y);

View File

@ -12,7 +12,7 @@
# focus of this script is testing the ATTACH and DETACH commands
# and schema changes to attached databases.
#
# $Id: attach3.test,v 1.3 2004/05/28 12:33:32 danielk1977 Exp $
# $Id: attach3.test,v 1.4 2004/05/29 02:37:20 danielk1977 Exp $
#
@ -63,7 +63,7 @@ do_test attach3-1.5 {
} {1 2}
# Create an index on the auxilary database table.
do_test attach4-2.1 {
do_test attach3-2.1 {
execsql {
CREATE INDEX aux.i1 on t3(e);
}
@ -71,31 +71,31 @@ do_test attach4-2.1 {
execsql {
pragma vdbe_trace = off;
}
do_test attach4-2.2 {
do_test attach3-2.2 {
execsql {
SELECT * FROM sqlite_master WHERE name = 'i1';
}
} {}
do_test attach4-2.3 {
do_test attach3-2.3 {
execsql {
SELECT * FROM aux.sqlite_master WHERE name = 'i1';
}
} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}}
# Drop the index on the aux database table.
do_test attach4-3.1 {
do_test attach3-3.1 {
execsql {
DROP INDEX aux.i1;
SELECT * FROM aux.sqlite_master WHERE name = 'i1';
}
} {}
do_test attach4-3.2 {
do_test attach3-3.2 {
execsql {
CREATE INDEX aux.i1 on t3(e);
SELECT * FROM aux.sqlite_master WHERE name = 'i1';
}
} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}}
do_test attach4-3.3 {
do_test attach3-3.3 {
execsql {
DROP INDEX i1;
SELECT * FROM aux.sqlite_master WHERE name = 'i1';
@ -103,20 +103,20 @@ do_test attach4-3.3 {
} {}
# Drop tables t1 and t2 in the auxilary database.
do_test attach4-4.1 {
do_test attach3-4.1 {
execsql {
DROP TABLE aux.t1;
SELECT name FROM aux.sqlite_master;
}
} {t2 t3}
do_test attach4-4.2 {
do_test attach3-4.2 {
# This will drop main.t2
execsql {
DROP TABLE t2;
SELECT name FROM aux.sqlite_master;
}
} {t2 t3}
do_test attach4-4.3 {
do_test attach3-4.3 {
execsql {
DROP TABLE t2;
SELECT name FROM aux.sqlite_master;
@ -124,17 +124,17 @@ do_test attach4-4.3 {
} {t3}
# Create a view in the auxilary database.
do_test attach4-5.1 {
do_test attach3-5.1 {
execsql {
CREATE VIEW aux.v1 AS SELECT * FROM t3;
}
} {}
do_test attach4-5.2 {
do_test attach3-5.2 {
execsql {
SELECT * FROM aux.sqlite_master WHERE name = 'v1';
}
} {view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t3}}
do_test attach4-5.3 {
do_test attach3-5.3 {
execsql {
INSERT INTO aux.t3 VALUES('hello', 'world');
SELECT * FROM v1;
@ -142,17 +142,52 @@ do_test attach4-5.3 {
} {1 2 hello world}
# Drop the view
do_test attach4-6.1 {
do_test attach3-6.1 {
execsql {
DROP VIEW aux.v1;
}
} {}
do_test attach4-5.2 {
do_test attach3-6.2 {
execsql {
SELECT * FROM aux.sqlite_master WHERE name = 'v1';
}
} {}
# Create a trigger in the auxilary database.
do_test attach3-7.1 {
execsql {
CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN
INSERT INTO t3 VALUES(new.e*2, new.f*2);
END;
}
} {}
do_test attach3-7.2 {
execsql {
DELETE FROM t3;
INSERT INTO t3 VALUES(10, 20);
SELECT * FROM t3;
}
} {10 20 20 40}
do_test attach3-5.3 {
execsql {
SELECT * FROM aux.sqlite_master WHERE name = 'tr1';
}
} {trigger tr1 t3 0 {CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN
INSERT INTO t3 VALUES(new.e*2, new.f*2);
END}}
# Drop the trigger
do_test attach3-8.1 {
execsql {
DROP TRIGGER aux.tr1;
}
} {}
do_test attach3-8.2 {
execsql {
SELECT * FROM aux.sqlite_master WHERE name = 'tr1';
}
} {}
finish_test

View File

@ -36,7 +36,7 @@ do_test trigger1-1.1.2 {
SELECT * from sqlite_master;
END;
}
} {1 {no such table: no_such_table}}
} {1 {no such table: main.no_such_table}}
do_test trigger1-1.1.2 {
catchsql {
CREATE TEMP TRIGGER trig UPDATE ON no_such_table BEGIN
@ -166,7 +166,7 @@ do_test trigger1-1.12 {
delete from t1 WHERE a=old.a+2;
end;
}
} {1 {cannot create INSTEAD OF trigger on table: t1}}
} {1 {cannot create INSTEAD OF trigger on table: main.t1}}
# Ensure that we cannot create BEFORE triggers on views
do_test trigger1-1.13 {
catchsql {
@ -175,7 +175,7 @@ do_test trigger1-1.13 {
delete from t1 WHERE a=old.a+2;
end;
}
} {1 {cannot create BEFORE trigger on view: v1}}
} {1 {cannot create BEFORE trigger on view: main.v1}}
# Ensure that we cannot create AFTER triggers on views
do_test trigger1-1.14 {
catchsql {
@ -185,7 +185,7 @@ do_test trigger1-1.14 {
delete from t1 WHERE a=old.a+2;
end;
}
} {1 {cannot create AFTER trigger on view: v1}}
} {1 {cannot create AFTER trigger on view: main.v1}}
# Check for memory leaks in the trigger parser
#