Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:2ndQuadrant Pglogical Create Node

From Leeroopedia
Knowledge Sources
Domains Database, Replication
Last Updated 2026-10-13 00:00 GMT

Overview

SQL-callable function that creates a pglogical node with a unique name and DSN, bootstrapping default replication sets and marking the database as a replication participant.

Description

The pglogical.create_node() function creates a new node identity in the pglogical catalog. It inserts a row into pglogical.node, creates a pglogical.node_interface with the provided DSN, creates three default replication sets (default, insert_only, ddl_sql), and records the node as the local node in pglogical.local_node. This function must be called on every database that participates in replication, whether as provider, subscriber, or both.

Usage

Call this function when:

  • Setting up a new provider node
  • Setting up a new subscriber node
  • Establishing any database as a participant in the pglogical replication topology

Code Reference

Source Location

  • Repository: pglogical
  • File: pglogical_functions.c (SQL wrapper), pglogical_node.c (catalog CRUD)
  • Lines: pglogical_functions.c:L173-223; pglogical_node.c:L141-184 (create_node), L321-393 (create_local_node), L461-508 (create_node_interface)

Signature

pglogical.create_node(
    node_name name,
    dsn text
) RETURNS oid

Import

-- Available after CREATE EXTENSION pglogical;
-- Called as: SELECT pglogical.create_node(...);

I/O Contract

Inputs

Name Type Required Description
node_name name Yes Unique node identifier within the replication topology
dsn text Yes Connection string (DSN) for the node's interface

Outputs

Name Type Description
return value oid Hash-generated OID for the new node
pglogical.node catalog row New node record inserted
pglogical.node_interface catalog row New interface record with DSN
default replication sets 3 catalog rows default (I/U/D/T), insert_only (I/T), ddl_sql (I only)
pglogical.local_node catalog row Marks this database as the local node

Usage Examples

Create Provider Node

-- Create the provider node
SELECT pglogical.create_node(
    node_name := 'provider1',
    dsn := 'host=provider.example.com port=5432 dbname=mydb'
);

Create Subscriber Node

-- On the subscriber database
SELECT pglogical.create_node(
    node_name := 'subscriber1',
    dsn := 'host=subscriber.example.com port=5432 dbname=mydb'
);

Verify Node Creation

-- Check local node
SELECT * FROM pglogical.local_node;

-- Check replication sets
SELECT * FROM pglogical.replication_set;

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment