Skip to content

Instantly share code, notes, and snippets.

@cabecada
Created September 7, 2023 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabecada/86ab0bb494c27a3a7b793ce677bb3526 to your computer and use it in GitHub Desktop.
Save cabecada/86ab0bb494c27a3a7b793ce677bb3526 to your computer and use it in GitHub Desktop.
bdr pg16 demo
-- port 5432
drop publication db1 ;
drop subscription db12;
drop subscription db13;
drop table t;
create table t(id int primary key);
create publication db1 for all tables WITH ( PUBLISH = 'insert,update,delete,truncate' );
CREATE SUBSCRIPTION db12 connection 'dbname=postgres port=5433 host=localhost user=postgres' publication db2 WITH (origin = none, copy_data =
off);
CREATE SUBSCRIPTION db13 connection 'dbname=postgres port=5434 host=localhost user=postgres' publication db3 WITH (origin = none, copy_data =
off);
-- port 5433
drop publication db2 ;
drop subscription db21;
drop subscription db23;
drop table t;
create table t(id int primary key);
create publication db2 for all tables WITH ( PUBLISH = 'insert,update,delete,truncate' );
CREATE SUBSCRIPTION db21 connection 'dbname=postgres port=5432 host=localhost user=postgres' publication db2 WITH (origin = none, copy_data =
off);
CREATE SUBSCRIPTION db23 connection 'dbname=postgres port=5435 host=localhost user=postgres' publication db3 WITH (origin = none, copy_data =
off);
select inet_server_port();
\dRp
\dRs
-- port 5434
drop publication db3 ;
drop subscription db32;
drop subscription db31;
drop table t;
create table t(id int primary key);
create publication db3 for all tables WITH ( PUBLISH = 'insert,update,delete,truncate' );
CREATE SUBSCRIPTION db31 connection 'dbname=postgres port=5432 host=localhost user=postgres' publication db1 WITH (origin = none, copy_data =
off);
CREATE SUBSCRIPTION db32 connection 'dbname=postgres port=5433 host=localhost user=postgres' publication db2 WITH (origin = none, copy_data =
off);
select inet_server_port();
\dRp
\dRs
\dt
insert into t select inet_server_port();
table t;
alter subscription db12 disable;
alter subscription db13 disable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment