bdr: Make parameters for group_create/group_join/subscribe more consistent.
authorAndres Freund <andres@anarazel.de>
Wed, 11 Feb 2015 16:14:13 +0000 (17:14 +0100)
committerAndres Freund <andres@anarazel.de>
Thu, 12 Feb 2015 09:16:59 +0000 (10:16 +0100)
expected/init_bdr.out
expected/init_udr.out
expected/isolation/init.out
extsql/bdr--0.9.0.0--0.9.0.1.sql
specs/isolation/init.spec
sql/init_bdr.sql
sql/init_udr.sql

index 9af82aaeeea69b09c7a3d06aa4efe2ada41b40c3..b482b328b70439a86ac2f918db211942ce75cc7e 100644 (file)
@@ -1,7 +1,7 @@
 \c postgres
 SELECT bdr.bdr_group_create(
    local_node_name := 'node-pg',
-   dsn := 'dbname=postgres',
+   node_external_dsn := 'dbname=postgres',
    replication_sets := ARRAY['default', 'important', 'for-node-1']
    );
  bdr_group_create 
@@ -18,9 +18,9 @@ SELECT bdr.bdr_node_join_wait_for_ready();
 \c regression
 SELECT bdr.bdr_group_join(
    local_node_name := 'node-regression',
-   dsn := 'dbname=regression',
-   init_from_dsn := 'dbname=postgres',
-   local_dsn := 'dbname=regression',
+   node_external_dsn := 'dbname=regression',
+   join_using_dsn := 'dbname=postgres',
+   node_local_dsn := 'dbname=regression',
    replication_sets := ARRAY['default', 'important', 'for-node-2', 'for-node-2-insert', 'for-node-2-update', 'for-node-2-delete']
    );
  bdr_group_join 
index 3460fb213a7ed020a0511bdee69b8934cd234c35..75dbd1e2cb82f10acdab2a7f14b3e317334e02a6 100644 (file)
@@ -1,8 +1,8 @@
 \c postgres
 SELECT bdr.bdr_subscribe(
    local_node_name := 'postgres',
-   remote_dsn := 'dbname=regression',
-   local_dsn := 'dbname=postgres',
+   subscribe_to_dsn := 'dbname=regression',
+   node_local_dsn := 'dbname=postgres',
    replication_sets := ARRAY['default', 'important', 'for-node-2', 'for-node-2-insert', 'for-node-2-update', 'for-node-2-delete']
    );
  bdr_subscribe 
index 81156e44fc81af62d47ce7f01937981f7defec65..f8c77fcbc8f4a3d92e0c3276dd3ddc1310b0e599 100644 (file)
@@ -16,7 +16,7 @@ step setup3:
 step join_root: 
    SELECT bdr.bdr_group_create(
            local_node_name := 'node1',
-       dsn := 'dbname=node1'
+       node_external_dsn := 'dbname=node1'
        );
 
 bdr_group_create
@@ -25,8 +25,8 @@ bdr_group_create
 step join_2: 
    SELECT bdr.bdr_group_join(
            local_node_name := 'node2',
-       dsn := 'dbname=node2',
-       init_from_dsn := 'dbname=node1'
+       node_external_dsn := 'dbname=node2',
+       join_using_dsn := 'dbname=node1'
        );
 
 bdr_group_join 
@@ -66,9 +66,9 @@ r              dbname=node2   dbname=node1
 step join_3: 
    SELECT bdr.bdr_group_join(
            local_node_name := 'node3',
-       dsn := 'dbname=node3',
-       init_from_dsn := 'dbname=node1',
-       local_dsn := 'dbname=node3'
+       node_external_dsn := 'dbname=node3',
+       join_using_dsn := 'dbname=node1',
+       node_local_dsn := 'dbname=node3'
        );
 
 bdr_group_join 
index 8d011cbebb89a1e36bf91717c8573904864f297d..3da7422e09480bb16068023032927c83220e0a11 100644 (file)
@@ -90,7 +90,7 @@ COMMENT ON FUNCTION bdr_connections_changed() IS 'Internal BDR function, do not
 --
 CREATE FUNCTION bdr.internal_node_join(
     sysid text, timeline oid, dboid oid,
-    dsn text,
+    node_external_dsn text,
     apply_delay integer,
     replication_sets text[]
     )
@@ -144,12 +144,12 @@ BEGIN
         VALUES
         (sysid, timeline, dboid,
          '0', 0, 0,
-         dsn,
+         node_external_dsn,
          CASE WHEN apply_delay = -1 THEN NULL ELSE apply_delay END,
          replication_sets, false);
     EXCEPTION WHEN unique_violation THEN
         UPDATE bdr.bdr_connections
-        SET conn_dsn = dsn,
+        SET conn_dsn = node_external_dsn,
             conn_apply_delay = CASE WHEN apply_delay = -1 THEN NULL ELSE apply_delay END,
             conn_replication_sets = replication_sets,
             conn_is_unidirectional = false
@@ -216,7 +216,7 @@ $body$;
 
 -- Setup that's common to BDR and UDR joins
 CREATE FUNCTION bdr.internal_begin_join(
-    caller text, local_node_name text, local_dsn text, remote_dsn text,
+    caller text, local_node_name text, node_local_dsn text, remote_dsn text,
     remote_sysid OUT text, remote_timeline OUT oid, remote_dboid OUT oid
 )
 RETURNS record LANGUAGE plpgsql VOLATILE
@@ -260,12 +260,12 @@ BEGIN
     -- Validate that the local connection is usable and matches
     -- the node identity of the node we're running on.
     --
-    -- For BDR this will NOT check the 'dsn' if 'local_dsn'
+    -- For BDR this will NOT check the 'dsn' if 'node_local_dsn'
     -- gets supplied. We don't know if 'dsn' is even valid
     -- for loopback connections and can't assume it is. That'll
     -- get checked later by BDR specific code.
     SELECT * INTO localid_from_dsn
-    FROM bdr_get_remote_nodeinfo(local_dsn);
+    FROM bdr_get_remote_nodeinfo(node_local_dsn);
 
     IF localid_from_dsn.sysid <> localid.sysid
         OR localid_from_dsn.timeline <> localid.timeline
@@ -274,16 +274,16 @@ BEGIN
         RAISE USING
             MESSAGE = 'node identity for local dsn does not match current node',
             DETAIL = format($$The dsn '%s' connects to a node with identity (%s,%s,%s) but the local node is (%s,%s,%s)$$,
-                local_dsn, localid_from_dsn.sysid, localid_from_dsn.timeline,
+                node_local_dsn, localid_from_dsn.sysid, localid_from_dsn.timeline,
                 localid_from_dsn.dboid, localid.sysid, localid.timeline, localid.dboid),
-            HINT = 'The local_dsn (or, for bdr, dsn if local_dsn is null) parameter must refer to the node you''re running this function from',
+            HINT = 'The node_local_dsn (or, for bdr, dsn if node_local_dsn is null) parameter must refer to the node you''re running this function from',
             ERRCODE = 'object_not_in_prerequisite_state';
     END IF;
 
     IF NOT localid_from_dsn.is_superuser THEN
         RAISE USING
             MESSAGE = 'local dsn does not have superuser rights',
-            DETAIL = format($$The dsn '%s' connects successfully but does not grant superuser rights$$, local_dsn),
+            DETAIL = format($$The dsn '%s' connects successfully but does not grant superuser rights$$, node_local_dsn),
             ERRCODE = 'object_not_in_prerequisite_state';
     END IF;
 
@@ -342,7 +342,7 @@ BEGIN
         ) VALUES (
             local_node_name,
             localid.sysid, localid.timeline, localid.dboid,
-            'b', local_dsn, remote_dsn
+            'b', node_local_dsn, remote_dsn
         );
     END IF;
 
@@ -356,9 +356,9 @@ $body$;
 --
 CREATE FUNCTION bdr.bdr_group_join(
     local_node_name text,
-    dsn text,
-    init_from_dsn text,
-    local_dsn text DEFAULT NULL,
+    node_external_dsn text,
+    join_using_dsn text,
+    node_local_dsn text DEFAULT NULL,
     apply_delay integer DEFAULT NULL,
     replication_sets text[] DEFAULT ARRAY['default']
     )
@@ -373,7 +373,7 @@ DECLARE
     connectback_nodeinfo record;
     remoteinfo record;
 BEGIN
-    IF dsn IS NULL THEN
+    IF node_external_dsn IS NULL THEN
         RAISE USING
             MESSAGE = 'dsn may not be null',
             ERRCODE = 'invalid_parameter_value';
@@ -390,8 +390,8 @@ BEGIN
     PERFORM bdr.internal_begin_join(
         'bdr_group_join',
         local_node_name,
-        CASE WHEN local_dsn IS NULL THEN dsn ELSE local_dsn END,
-        init_from_dsn);
+        CASE WHEN node_local_dsn IS NULL THEN node_external_dsn ELSE node_local_dsn END,
+        join_using_dsn);
 
     SELECT sysid, timeline, dboid INTO localid
     FROM bdr.bdr_get_local_nodeid();
@@ -403,16 +403,16 @@ BEGIN
     --
     -- This cannot be checked for the first node since there's no peer
     -- to ask for help.
-    IF init_from_dsn IS NOT NULL THEN
+    IF join_using_dsn IS NOT NULL THEN
 
         SELECT * INTO connectback_nodeinfo
-        FROM bdr.bdr_test_remote_connectback(init_from_dsn, dsn);
+        FROM bdr.bdr_test_remote_connectback(join_using_dsn, node_external_dsn);
 
         -- The connectback must actually match our local node identity
         -- and must provide a superuser connection.
         IF NOT connectback_nodeinfo.is_superuser THEN
             RAISE USING
-                MESSAGE = 'dsn does not have superuser rights when connecting via remote node',
+                MESSAGE = 'node_external_dsn does not have superuser rights when connecting via remote node',
                 DETAIL = format($$The dsn '%s' connects successfully but does not grant superuser rights$$, dsn),
                 ERRCODE = 'object_not_in_prerequisite_state';
         END IF;
@@ -422,11 +422,11 @@ BEGIN
            OR connectback_nodeinfo.dboid <> localid.dboid
         THEN
             RAISE USING
-                MESSAGE = 'node identity for dsn does not match current node when connecting back via remote',
+                MESSAGE = 'node identity for node_external_dsn does not match current node when connecting back via remote',
                 DETAIL = format($$The dsn '%s' connects to a node with identity (%s,%s,%s) but the local node is (%s,%s,%s)$$,
-                    local_dsn, connectback_nodeinfo.sysid, connectback_nodeinfo.timeline,
+                    node_local_dsn, connectback_nodeinfo.sysid, connectback_nodeinfo.timeline,
                     connectback_nodeinfo.dboid, localid.sysid, localid.timeline, localid.dboid),
-                HINT = 'The ''dsn'' parameter must refer to the node you''re running this function from, from the perspective of the node pointed to by init_from_dsn',
+                HINT = 'The ''node_external_dsn'' parameter must refer to the node you''re running this function from, from the perspective of the node pointed to by join_using_dsn',
                 ERRCODE = 'object_not_in_prerequisite_state';
         END IF;
     END IF;
@@ -441,7 +441,7 @@ BEGIN
     ) VALUES (
         localid.sysid, localid.timeline, localid.dboid,
         '0', 0, 0,
-        dsn, apply_delay, replication_sets, false
+        node_external_dsn, apply_delay, replication_sets, false
     );
 
     -- Now ensure the per-db worker is started if it's not already running.
@@ -456,8 +456,8 @@ IS 'Join an existing BDR group by connecting to a member node and copying its co
 
 CREATE FUNCTION bdr.bdr_group_create(
     local_node_name text,
-    dsn text,
-    local_dsn text DEFAULT NULL,
+    node_external_dsn text,
+    node_local_dsn text DEFAULT NULL,
     apply_delay integer DEFAULT NULL,
     replication_sets text[] DEFAULT ARRAY['default']
     )
@@ -470,7 +470,9 @@ AS $body$
 BEGIN
     PERFORM bdr.bdr_group_join(
         local_node_name := local_node_name,
-        dsn := dsn, init_from_dsn := null, local_dsn := local_dsn,
+        node_external_dsn := node_external_dsn,
+        join_using_dsn := null,
+        node_local_dsn := node_local_dsn,
         apply_delay := apply_delay,
         replication_sets := replication_sets);
 END;
@@ -484,8 +486,8 @@ IS 'Create a BDR group, turning a stand-alone database into the first node in a
 --
 CREATE FUNCTION bdr.bdr_subscribe(
     local_node_name text,
-    remote_dsn text,
-    local_dsn text,
+    subscribe_to_dsn text,
+    node_local_dsn text,
     apply_delay integer DEFAULT NULL,
     replication_sets text[] DEFAULT ARRAY['default']
     )
@@ -499,13 +501,13 @@ DECLARE
     localid record;
     remoteid record;
 BEGIN
-    IF local_dsn IS NULL THEN
+    IF node_local_dsn IS NULL THEN
         RAISE USING
-            MESSAGE = 'local_dsn may not be null',
+            MESSAGE = 'node_local_dsn may not be null',
             ERRCODE = 'invalid_parameter_value';
     END IF;
 
-    IF remote_dsn IS NULL THEN
+    IF subscribe_to_dsn IS NULL THEN
         RAISE USING
             MESSAGE = 'remote may not be null',
             ERRCODE = 'invalid_parameter_value';
@@ -515,7 +517,7 @@ BEGIN
            remote_dboid AS dboid INTO remoteid
     FROM bdr.internal_begin_join('bdr_subscribe',
          local_node_name || '-subscriber',
-         local_dsn, remote_dsn);
+         node_local_dsn, subscribe_to_dsn);
 
     SELECT sysid, timeline, dboid INTO localid
     FROM bdr.bdr_get_local_nodeid();
@@ -563,7 +565,7 @@ BEGIN
     ) VALUES (
         remoteid.sysid, remoteid.timeline, remoteid.dboid,
         localid.sysid, localid.timeline, localid.dboid,
-        remote_dsn, apply_delay, replication_sets, true
+        subscribe_to_dsn, apply_delay, replication_sets, true
     );
 
     -- Now ensure the per-db worker is started if it's not already running.
index a76a5da964182bb6220090021af7b87992cc3630..f8ef4904100cbdcd170b291efe2f0b0d6be644f4 100644 (file)
@@ -27,7 +27,7 @@ step "join_root"
 {
    SELECT bdr.bdr_group_create(
            local_node_name := 'node1',
-       dsn := 'dbname=node1'
+       node_external_dsn := 'dbname=node1'
        );
 }
 
@@ -74,8 +74,8 @@ step "join_2"
 {
    SELECT bdr.bdr_group_join(
            local_node_name := 'node2',
-       dsn := 'dbname=node2',
-       init_from_dsn := 'dbname=node1'
+       node_external_dsn := 'dbname=node2',
+       join_using_dsn := 'dbname=node1'
        );
 }
 
@@ -107,9 +107,9 @@ step "join_3"
 {
    SELECT bdr.bdr_group_join(
            local_node_name := 'node3',
-       dsn := 'dbname=node3',
-       init_from_dsn := 'dbname=node1',
-       local_dsn := 'dbname=node3'
+       node_external_dsn := 'dbname=node3',
+       join_using_dsn := 'dbname=node1',
+       node_local_dsn := 'dbname=node3'
        );
 }
 
index b7ea81b626b00d7cca683e8649dc0bd68406730f..16b8dc4f07b9e8fc97f2de545cec1f9621ef8ed4 100644 (file)
@@ -1,7 +1,7 @@
 \c postgres
 SELECT bdr.bdr_group_create(
    local_node_name := 'node-pg',
-   dsn := 'dbname=postgres',
+   node_external_dsn := 'dbname=postgres',
    replication_sets := ARRAY['default', 'important', 'for-node-1']
    );
 
@@ -10,9 +10,9 @@ SELECT bdr.bdr_node_join_wait_for_ready();
 \c regression
 SELECT bdr.bdr_group_join(
    local_node_name := 'node-regression',
-   dsn := 'dbname=regression',
-   init_from_dsn := 'dbname=postgres',
-   local_dsn := 'dbname=regression',
+   node_external_dsn := 'dbname=regression',
+   join_using_dsn := 'dbname=postgres',
+   node_local_dsn := 'dbname=regression',
    replication_sets := ARRAY['default', 'important', 'for-node-2', 'for-node-2-insert', 'for-node-2-update', 'for-node-2-delete']
    );
 
index ee84c23b92a64dc9ec8ca0becfc8c70f8f8113c8..eb0b20b2933106436d28e49432bae613c1e5097b 100644 (file)
@@ -1,8 +1,8 @@
 \c postgres
 SELECT bdr.bdr_subscribe(
    local_node_name := 'postgres',
-   remote_dsn := 'dbname=regression',
-   local_dsn := 'dbname=postgres',
+   subscribe_to_dsn := 'dbname=regression',
+   node_local_dsn := 'dbname=postgres',
    replication_sets := ARRAY['default', 'important', 'for-node-2', 'for-node-2-insert', 'for-node-2-update', 'for-node-2-delete']
    );