1
+ -- set connection strings to nodes
2
+ select conninfo as node1 from mtm .nodes () where id = 1 \gset
3
+ select conninfo as node2 from mtm .nodes () where id = 2 \gset
4
+ select conninfo as node3 from mtm .nodes () where id = 3 \gset
5
+
1
6
2
7
-- check that implicit empty transactions works fine
3
8
create table t (a int , b text );
@@ -10,35 +15,114 @@ copy t from stdout;
10
15
11
16
12
17
-- test mixed temp table and persistent write
13
-
14
18
create table t_tempddl_mix (id int primary key );
15
19
insert into t_tempddl_mix values (1 );
16
20
begin ;
17
21
insert into t_tempddl_mix values (42 );
18
22
create temp table tempddl(id int );
19
23
commit ;
20
- table t;
21
24
22
- \c " dbname=regression port=64717 host=127.0.0.1"
23
25
table t;
24
26
27
+ \c :node2
28
+ table t;
25
29
26
30
-- test CTA replication inside explain
27
-
28
31
EXPLAIN ANALYZE create table explain_cta as select 42 ;
29
32
30
-
31
-
32
- -- - xx?
33
-
33
+ -- - test schemas
34
34
create user user1 ;
35
35
create schema user1 ;
36
36
alter schema user1 owner to user1;
37
37
38
- \c " user=user1 dbname=regression "
38
+ \c :node1
39
39
create table user1 .test(i int primary key );
40
40
create table user1 .test2(i int primary key );
41
41
42
- \c " user=user1 dbname=regression port=5433"
43
- select * from test;
42
+ \c :node3
43
+ table test;
44
+
45
+ \c :node1
46
+
47
+
48
+ -- - scheduler example with secdefs and triggers
49
+ CREATE TABLE aaa (
50
+ id int primary key ,
51
+ text text
52
+ );
53
+ CREATE TABLE aaa_copy (LIKE aaa);
54
+ ALTER TABLE aaa_copy ADD submit_time timestamp NOT NULL DEFAULT now();
55
+ ALTER TABLE aaa_copy ADD submitter text NOT NULL DEFAULT session_user ;
56
+ ALTER TABLE aaa_copy ADD version_id SERIAL NOT NULL ;
57
+ ALTER TABLE aaa_copy ADD PRIMARY KEY (id, version_id);
58
+
59
+ CREATE FUNCTION add_aaa (
60
+ aid integer
61
+ ) RETURNS integer AS
62
+ $BODY$
63
+ DECLARE
64
+ nid integer ;
65
+ BEGIN
66
+ INSERT INTO aaa (id, text ) VALUES (aid, ' zzz' ) RETURNING id INTO nid;
67
+ RETURN nid;
68
+ END
69
+ $BODY$
70
+ LANGUAGE plpgsql SECURITY DEFINER;
71
+
72
+ CREATE FUNCTION drop_aaa (
73
+ aid integer
74
+ ) RETURNS integer AS
75
+ $BODY$
76
+ BEGIN
77
+ DELETE FROM aaa WHERE id = aid;
78
+ RETURN aid;
79
+ END
80
+ $BODY$
81
+ LANGUAGE plpgsql SECURITY DEFINER;
82
+
83
+ CREATE OR REPLACE FUNCTION on_aaa_update () RETURNS TRIGGER
84
+ AS $BODY$
85
+ DECLARE
86
+ aaa_id integer ;
87
+ BEGIN
88
+ aaa_id := NEW .id ;
89
+ INSERT INTO aaa_copy VALUES (NEW.* );
90
+ IF TG_OP = ' UPDATE' THEN
91
+ INSERT INTO aaa_copy VALUES (NEW.* );
92
+ END IF;
93
+ RETURN OLD;
94
+ END
95
+ $BODY$ LANGUAGE plpgsql;
96
+
97
+ CREATE OR REPLACE FUNCTION on_aaa_delete () RETURNS TRIGGER
98
+ AS $BODY$
99
+ DECLARE
100
+ aaa_id INTEGER ;
101
+ BEGIN
102
+ aaa_id := OLD .id ;
103
+ DELETE FROM aaa_copy WHERE id = aaa_id;
104
+ RETURN OLD;
105
+ END
106
+ $BODY$ LANGUAGE plpgsql;
107
+
108
+ CREATE TRIGGER aaa_update_trigger
109
+ AFTER UPDATE OR INSERT ON aaa
110
+ FOR EACH ROW EXECUTE PROCEDURE on_aaa_update();
111
+
112
+ CREATE TRIGGER aaa_delete_trigger
113
+ BEFORE DELETE ON aaa
114
+ FOR EACH ROW EXECUTE PROCEDURE on_aaa_delete();
115
+
116
+ select add_aaa(58 );
117
+ select add_aaa(5833 );
118
+ select add_aaa(582 );
119
+
120
+ delete from aaa;
121
+
122
+ table aaa;
123
+ table aaa_copy;
124
+
125
+ \c :node3
44
126
127
+ table aaa;
128
+ table aaa_copy;
0 commit comments