Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b3e7cbd

Browse files
committed
add sql regression tests
1 parent 531cf70 commit b3e7cbd

File tree

4 files changed

+112
-19
lines changed

4 files changed

+112
-19
lines changed

Cluster.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ sub init
3030
{
3131
$node->init(allows_streaming => 'logical');
3232
$node->append_conf('postgresql.conf', q{
33+
unix_socket_directories = ''
3334
listen_addresses = '127.0.0.1'
3435
max_connections = 50
3536

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ src/pglogical_relid_map.o src/ddd.o src/bkb.o src/spill.o src/state.o \
77
src/resolver.o src/ddl.o src/syncpoint.o
88
MODULE_big = multimaster
99

10-
ifdef USE_PGXS
11-
PG_CPPFLAGS += -I$(CURDIR)/src/include
12-
else
13-
PG_CPPFLAGS += -I$(top_srcdir)/$(subdir)/src/include
14-
endif
15-
1610
PG_CPPFLAGS += -I$(libpq_srcdir)
1711
SHLIB_LINK = $(libpq)
1812

1913
ifdef USE_PGXS
14+
PG_CPPFLAGS += -I$(CURDIR)/src/include
2015
PG_CONFIG = pg_config
2116
PGXS := $(shell $(PG_CONFIG) --pgxs)
2217
include $(PGXS)
2318
else
19+
PG_CPPFLAGS += -I$(top_srcdir)/$(subdir)/src/include
2420
subdir = contrib/mmts
2521
top_builddir = ../..
2622
include $(top_builddir)/src/Makefile.global
@@ -54,7 +50,7 @@ stop:
5450
PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
5551
perl run.pl --stop
5652

57-
regress: submake-regress
53+
regress-pg: submake-regress
5854
cd $(CURDIR)/$(top_builddir)/src/test/regress && \
5955
$(with_temp_install) \
6056
PGPORT='6$(DEF_PGPORT)' \
@@ -64,4 +60,15 @@ regress: submake-regress
6460
--bindir='' \
6561
--use-existing \
6662
--schedule=serial_schedule \
67-
--dlpath=$(CURDIR)/$(top_builddir)/src/test/regress
63+
--dlpath=$(CURDIR)/$(top_builddir)/src/test/regress
64+
65+
run-regress:
66+
$(with_temp_install) \
67+
PGPORT='6$(DEF_PGPORT)' \
68+
PGHOST='127.0.0.1' \
69+
$(top_builddir)/src/test/regress/pg_regress \
70+
--use-existing \
71+
--bindir= \
72+
$(pg_regress_locale_flags) multimaster
73+
74+
regress: | start run-regress stop

run.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
if ($action eq "--start")
1111
{
1212
$PostgresNode::last_port_assigned = 65431;
13+
$PostgresNode::test_pghost = "127.0.0.1";
1314

1415
my $cluster = new Cluster($n_nodes);
1516
$cluster->init();

sql/multimaster.sql

Lines changed: 95 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
16

27
-- check that implicit empty transactions works fine
38
create table t (a int, b text);
@@ -10,35 +15,114 @@ copy t from stdout;
1015

1116

1217
-- test mixed temp table and persistent write
13-
1418
create table t_tempddl_mix(id int primary key);
1519
insert into t_tempddl_mix values(1);
1620
begin;
1721
insert into t_tempddl_mix values(42);
1822
create temp table tempddl(id int);
1923
commit;
20-
table t;
2124

22-
\c "dbname=regression port=64717 host=127.0.0.1"
2325
table t;
2426

27+
\c :node2
28+
table t;
2529

2630
-- test CTA replication inside explain
27-
2831
EXPLAIN ANALYZE create table explain_cta as select 42;
2932

30-
31-
32-
--- xx?
33-
33+
--- test schemas
3434
create user user1;
3535
create schema user1;
3636
alter schema user1 owner to user1;
3737

38-
\c "user=user1 dbname=regression"
38+
\c :node1
3939
create table user1.test(i int primary key);
4040
create table user1.test2(i int primary key);
4141

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
44126

127+
table aaa;
128+
table aaa_copy;

0 commit comments

Comments
 (0)