Add pg_get_publication_ddl function

First seen: 2026-01-11 11:20:40+00:00 · Messages: 10 · Participants: 7

Latest Update

2026-06-04 · claude-opus-4-6

Monthly Summary: Add pg_get_publication_ddl Function — May 2026

Overview

This thread progressed significantly in May 2026, moving from an initial v1 patch with multiple bugs to a substantially reworked v2 patch that adopts patterns from already-committed pg_get_tablespace_def and pg_get_database_def functions. The v2 patch then received a comprehensive 32-comment review from Peter Smith, identifying structural, style, and testing concerns.

Problem Statement

PostgreSQL lacks a built-in function to reconstruct DDL for PUBLICATION objects. Publications have grown increasingly complex (column lists, row filters, schema-level inclusion, partition handling, generated column behavior), making manual reconstruction from catalog queries error-prone. The function fills a gap analogous to existing pg_get_viewdef(), pg_get_indexdef(), etc.

v2 Patch Architecture

The implementation adds pg_get_publication_ddl(publication_name text) (with OID variant) in ruleutils.c:

  1. Looks up the publication via GetPublicationByName() or OID
  2. Retrieves published relations via GetPublicationRelations() with PUBLICATION_PART_ALL
  3. Reconstructs the FOR clause (ALL TABLES, ALL SEQUENCES, per-table with columns/row-filters, FOR TABLES IN SCHEMA, EXCEPT)
  4. Reconstructs WITH options (publish, publish_generated_columns, publish_via_partition_root)
  5. Adds owner reconstruction via ALTER PUBLICATION ... OWNER TO
  6. Includes pretty-print option

Key v2 improvements over v1:

Critical Review Findings (Peter Smith, 32 Comments)

Architectural Issues

Code Style (6 occurrences)

Other Technical Points

Open Design Questions

Status

The v2 patch needs revision to address Peter Smith's review feedback, particularly the structural issues (EXCEPT clause placement, schema ordering), pervasive style concerns (comma handling pattern × 6), testing approach overhaul, and the StringInfoData stack allocation fix.

History (1 prior analysis)
2026-06-04 · claude-opus-4-6

Incremental Analysis: Solai V's Testing Confirmation and Design Questions

This round contains a single message from Solai V (solai.cdac@gmail.com) on 2026-06-02, which is essentially a forwarding/endorsement of Jonathan Gonzalez V.'s earlier testing report with no new technical content beyond what Jonathan already raised.

Substantive Content

Solai V quotes Jonathan Gonzalez V.'s review in its entirety and adds only "Looking forward to more feedback" — no new technical arguments, no new bugs, no code suggestions, and no patch submission.

The points raised are already covered in prior analysis:

  1. SETOF text return type / multi-statement output — This was a deliberate v2 design choice (owner reconstruction via ALTER PUBLICATION ... OWNER TO) already discussed.

  2. Quoted boolean/enum values — Peter Smith already raised this exact issue in his v2 review (comments #20 and #25), suggesting that 'true'/'false' don't need quoting. Jonathan/Solai extend this observation to publish_generated_columns enum values as well (e.g., none vs 'none'), which is a minor additional data point but the same underlying concern.

Assessment

No substantive technical progress in this round. This is a "+1 / tested successfully" acknowledgment that re-raises already-identified issues without new analysis.