|
| 1 | +--FOREIGN KEY |
| 2 | +\c regression |
| 3 | +SELECT pglogical.replicate_ddl_command($$ |
| 4 | +CREATE TABLE public.f1k_products ( |
| 5 | + product_no integer PRIMARY KEY, |
| 6 | + product_id integer, |
| 7 | + name text, |
| 8 | + price numeric |
| 9 | +); |
| 10 | + |
| 11 | +CREATE TABLE public.f1k_orders ( |
| 12 | + order_id integer, |
| 13 | + product_no integer REFERENCES public.f1k_products (product_no), |
| 14 | + quantity integer |
| 15 | +); |
| 16 | +--pass |
| 17 | +$$); |
| 18 | + replicate_ddl_command |
| 19 | +----------------------- |
| 20 | + t |
| 21 | +(1 row) |
| 22 | + |
| 23 | +SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; |
| 24 | + pg_xlog_wait_remote_apply |
| 25 | +--------------------------- |
| 26 | + |
| 27 | +(1 row) |
| 28 | + |
| 29 | +INSERT into public.f1k_products VALUES (1, 1, 'product1', 1.20); |
| 30 | +INSERT into public.f1k_products VALUES (2, 2, 'product2', 2.40); |
| 31 | +INSERT into public.f1k_orders VALUES (300, 1, 4); |
| 32 | +INSERT into public.f1k_orders VALUES (22, 2, 14); |
| 33 | +INSERT into public.f1k_orders VALUES (23, 2, 24); |
| 34 | +INSERT into public.f1k_orders VALUES (24, 2, 40); |
| 35 | +SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; |
| 36 | + pg_xlog_wait_remote_apply |
| 37 | +--------------------------- |
| 38 | + |
| 39 | +(1 row) |
| 40 | + |
| 41 | +\c postgres |
| 42 | +SELECT * FROM public.f1k_products; |
| 43 | + product_no | product_id | name | price |
| 44 | +------------+------------+----------+------- |
| 45 | + 1 | 1 | product1 | 1.20 |
| 46 | + 2 | 2 | product2 | 2.40 |
| 47 | +(2 rows) |
| 48 | + |
| 49 | +SELECT * FROM public.f1k_orders; |
| 50 | + order_id | product_no | quantity |
| 51 | +----------+------------+---------- |
| 52 | + 300 | 1 | 4 |
| 53 | + 22 | 2 | 14 |
| 54 | + 23 | 2 | 24 |
| 55 | + 24 | 2 | 40 |
| 56 | +(4 rows) |
| 57 | + |
| 58 | +\c regression |
| 59 | +SELECT pglogical.replicate_ddl_command($$ |
| 60 | +DROP TABLE public.f1k_orders; |
| 61 | +DROP TABLE public.f1k_products; |
| 62 | +$$); |
| 63 | + replicate_ddl_command |
| 64 | +----------------------- |
| 65 | + t |
| 66 | +(1 row) |
| 67 | + |
0 commit comments