File: foreign_key.out

package info (click to toggle)
pglogical 2.4.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,300 kB
  • sloc: ansic: 39,268; sql: 4,466; perl: 693; makefile: 210; sh: 78
file content (84 lines) | stat: -rw-r--r-- 2,234 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--FOREIGN KEY
SELECT * FROM pglogical_regress_variables()
\gset
\c :provider_dsn
SELECT pglogical.replicate_ddl_command($$
CREATE TABLE public.f1k_products (
    product_no integer PRIMARY KEY,
    product_id integer,
    name text,
    price numeric
);

CREATE TABLE public.f1k_orders (
    order_id integer,
    product_no integer REFERENCES public.f1k_products (product_no),
    quantity integer
);
--pass
$$);
 replicate_ddl_command 
-----------------------
 t
(1 row)

SELECT * FROM pglogical.replication_set_add_table('default', 'f1k_products');
 replication_set_add_table 
---------------------------
 t
(1 row)

SELECT * FROM pglogical.replication_set_add_table('default_insert_only', 'f1k_orders');
 replication_set_add_table 
---------------------------
 t
(1 row)

SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

INSERT into public.f1k_products VALUES (1, 1, 'product1', 1.20);
INSERT into public.f1k_products VALUES (2, 2, 'product2', 2.40);
INSERT into public.f1k_orders VALUES (300, 1, 4);
INSERT into public.f1k_orders VALUES (22, 2, 14);
INSERT into public.f1k_orders VALUES (23, 2, 24);
INSERT into public.f1k_orders VALUES (24, 2, 40);
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

\c :subscriber_dsn
SELECT * FROM public.f1k_products;
 product_no | product_id |   name   | price 
------------+------------+----------+-------
          1 |          1 | product1 |  1.20
          2 |          2 | product2 |  2.40
(2 rows)

SELECT * FROM public.f1k_orders;
 order_id | product_no | quantity 
----------+------------+----------
      300 |          1 |        4
       22 |          2 |       14
       23 |          2 |       24
       24 |          2 |       40
(4 rows)

\c :provider_dsn
\set VERBOSITY terse
SELECT pglogical.replicate_ddl_command($$
	DROP TABLE public.f1k_orders CASCADE;
	DROP TABLE public.f1k_products CASCADE;
$$);
NOTICE:  drop cascades to table public.f1k_orders membership in replication set default_insert_only
NOTICE:  drop cascades to table public.f1k_products membership in replication set default
 replicate_ddl_command 
-----------------------
 t
(1 row)