File: huge_tx.sql

package info (click to toggle)
pglogical 2.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,236 kB
  • sloc: ansic: 39,239; sql: 4,466; perl: 693; makefile: 210; sh: 77
file content (62 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
-- test huge transactions
SELECT * FROM pglogical_regress_variables()
\gset

\c :provider_dsn
-- lots of small rows replication with DDL outside transaction
SELECT pglogical.replicate_ddl_command($$
	CREATE TABLE public.a_huge (
		id integer primary key,
                id1 integer,
		data text default 'data',
		data1 text default 'data1'
	);
$$);
SELECT * FROM pglogical.replication_set_add_table('default', 'a_huge');
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);

BEGIN;

INSERT INTO public.a_huge VALUES (generate_series(1, 20000000), generate_series(1, 20000000));

COMMIT;

SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);

\c :subscriber_dsn
SELECT count(*) FROM a_huge;
\dtS+ a_huge;

\c :provider_dsn
-- lots of small rows replication with DDL within transaction
BEGIN;
SELECT pglogical.replicate_ddl_command($$
	CREATE TABLE public.b_huge (
		id integer primary key,
                id1 integer,
		data text default 'data',
		data1 text default 'data1'
	);
$$);

SELECT * FROM pglogical.replication_set_add_table('default', 'b_huge');

INSERT INTO public.b_huge VALUES (generate_series(1,20000000), generate_series(1,20000000));

COMMIT;

SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);

\c :subscriber_dsn
SELECT count(*) FROM b_huge;
\dtS+ b_huge;

\c :provider_dsn
\set VERBOSITY terse
SELECT pglogical.replicate_ddl_command($$
	DROP TABLE public.a_huge CASCADE;
	DROP TABLE public.b_huge CASCADE;
$$);


SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);