Changeset: 4fc8055d5850 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4fc8055d5850
Modified Files:
        dump.sql
        dump_output.sql
Branch: monetdbe-proxy
Log Message:

Dump triggers.


diffs (67 lines):

diff --git a/dump.sql b/dump.sql
--- a/dump.sql
+++ b/dump.sql
@@ -430,6 +430,18 @@ RETURN
        FROM describe_tables() t;
 END;
 
+CREATE FUNCTION describe_triggers() RETURNS TABLE (sch STRING, tab STRING, tri 
STRING, def STRING) BEGIN
+       RETURN
+               SELECT s.name, t.name, tr.name, tr.statement
+               FROM sys.schemas s, sys.tables t, sys.triggers tr
+               WHERE s.id = t.schema_id AND t.id = tr.table_id AND NOT 
t.system;
+END;
+
+CREATE FUNCTION dump_triggers() RETURNS TABLE (stmt STRING) BEGIN
+       RETURN
+               SELECT schema_guard(sch, tab, def) FROM describe_triggers();
+END;
+
 --The dump statement should normally have an auto-incremented column 
representing the creation order.
 --But in cases of db objects that can be interdependent, i.e. functions and 
table-likes, we need access to the underlying sequence of the AUTO_INCREMENT 
property.
 --Because we need to explicitly overwrite the creation order column "o" in 
those cases. After inserting the dump statements for functions and table-likes,
@@ -519,6 +531,7 @@ BEGIN
        INSERT INTO dump_statements(s) SELECT * FROM dump_indices();
        INSERT INTO dump_statements(s) SELECT * FROM dump_foreign_keys();
        INSERT INTO dump_statements(s) SELECT * FROM dump_partition_tables();
+       INSERT INTO dump_statements(s) SELECT * from dump_triggers();
 
        INSERT INTO dump_statements(s) --dump_create_comments_on_indices
         SELECT comment_on('INDEX', DQ(i.name), rem.remark)
@@ -528,7 +541,6 @@ BEGIN
         SELECT comment_on('COLUMN', DQ(s.name) || '.' || DQ(t.name) || '.' || 
DQ(c.name), rem.remark)
                FROM sys.columns c JOIN sys.comments rem ON c.id = rem.id, 
sys.tables t, sys.schemas s WHERE c.table_id = t.id AND t.schema_id = s.id AND 
NOT t.system;
 
-       --TODO Triggers
        --TODO COMMENTS ON TABLE and add schema to commented objects identifier
        --TODO TABLE level grants
        --TODO COLUMN level grants
diff --git a/dump_output.sql b/dump_output.sql
--- a/dump_output.sql
+++ b/dump_output.sql
@@ -25,13 +25,14 @@ CREATE TABLE "sys"."yoyo" ("tsz" CHARACT
 CREATE TABLE "sys"."bolo" ("s" CHARACTER LARGE OBJECT NOT NULL, "v" CHARACTER 
LARGE OBJECT NOT NULL);
 CREATE TABLE "sys"."rolo" ("v" CHARACTER LARGE OBJECT NOT NULL);
 CREATE TABLE "sys"."ungolo" ("x" INTEGER, "y" INTEGER, "z" INTEGER);
-CREATE TABLE "sfoo"."tfoo" ("i" INTEGER);
+CREATE TABLE "sfoo"."tfoo1" ("i" INTEGER);
+CREATE TABLE "sfoo"."tfoo2" ("i" INTEGER);
 CREATE TABLE "sfoo"."test" ("s" CHARACTER LARGE OBJECT);
 CREATE TABLE "sys"."pfoo1" ("i" INTEGER);
 CREATE TABLE "sys"."pfoo2" ("i" INTEGER);
 create function "sfoo"."func1" (x int, y int) returns int begin return x + y; 
end;
 create view "sfoo"."baz" (i) as select func1(t.x, t.y) from (values (10, 1), 
(20, 2)) as t(x,y);
-create function "sfoo"."func2" () RETURNS TABLE(i INTEGER) BEGIN RETURN SELECT 
* FROM "sfoo"."baz"; END;
+create function "sfoo"."func2" () returns table(i integer) begin return select 
* from "sfoo"."baz"; end;
 CREATE TABLE "sys"."lower_scorers" ("name" CHARACTER LARGE OBJECT, 
"first_score" INTEGER, "second_score" INTEGER);
 CREATE TABLE "sys"."higher_scorers" ("name" CHARACTER LARGE OBJECT, 
"first_score" INTEGER, "second_score" INTEGER);
 CREATE TABLE "sys"."unknown_scorers" ("name" CHARACTER LARGE OBJECT, 
"first_score" INTEGER, "second_score" INTEGER);
@@ -63,6 +64,7 @@ ALTER TABLE "sys"."scorers"  ADD TABLE "
 ALTER TABLE "sys"."splitted"  ADD TABLE "sys"."first_decade" AS PARTITION FROM 
RANGE MINVALUE TO  '2010-01-01 00:00:00.000000'  WITH NULL VALUES;
 ALTER TABLE "sys"."splitted"  ADD TABLE "sys"."second_decade" AS PARTITION 
FROM  '2010-01-01 00:00:00.000000'  TO  '2020-01-01 00:00:00.000000' ;
 ALTER TABLE "sys"."m1"  ADD TABLE "sys"."p1";
+create trigger extra_insert after insert on "sfoo"."tfoo1" referencing new row 
as new_row for each statement insert into tfoo2(i) values (new_row.i);
 COMMENT ON INDEX "ind3" IS  'This is a comment on an index.' ;
-COMMENT ON COLUMN "sfoo"."tfoo"."i" IS  'This is a comment on a column.' ;
+COMMENT ON COLUMN "sfoo"."tfoo1"."i" IS  'This is a comment on a column.' ;
 COMMIT;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to