fix(publication): ensure PostgreSQL 13+ compatibility for multi-table publications by armru · Pull Request #8888 · cloudnative-pg/cloudnative-pg

@dosubot dosubot bot added the size:L

This PR changes 100-499 lines, ignoring generated files.

label

Oct 20, 2025

leonardoce

@dosubot dosubot bot added the lgtm

This PR has been approved by a maintainer

label

Oct 30, 2025

@armru @gbartolini

… publications

Fix SQL generation for publications with multiple tables to support
PostgreSQL 13+. The previous implementation generated SQL that only
worked on PostgreSQL 15+:
  CREATE PUBLICATION "pub" FOR TABLE "t1", TABLE "t2"

While this syntax is valid in PostgreSQL 15+, it fails in PostgreSQL 13+
with a syntax error. The fix now generates backward-compatible SQL:
  CREATE PUBLICATION "pub" FOR TABLE "t1", "t2"

The implementation groups consecutive tables under a single TABLE keyword
and properly handles mixed scenarios with TABLES IN SCHEMA, ensuring full
compatibility across all supported PostgreSQL versions (13+).

Fixes #8588

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>

@gbartolini

Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>

@gbartolini

Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>

gbartolini

cnpg-bot pushed a commit that referenced this pull request

Nov 1, 2025
…table publications (#8888)

The previous implementation generated SQL valid only in PostgreSQL 15+, for
example:

    CREATE PUBLICATION "pub" FOR TABLE "t1", TABLE "t2";

This syntax causes a syntax error in PostgreSQL 13 and 14. The fix updates the
SQL generation to produce backward-compatible statements such as:

    CREATE PUBLICATION "pub" FOR TABLE "t1", "t2";

The new implementation groups consecutive tables under a single `TABLE` keyword
and correctly handles mixed cases involving `TABLES IN SCHEMA`, ensuring full
compatibility across all supported PostgreSQL versions (13+).

Fixes #8588.

Signed-off-by: Armando Ruocco [armando.ruocco@enterprisedb.com](mailto:armando.ruocco@enterprisedb.com)
Signed-off-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
Co-authored-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
(cherry picked from commit 514a43d)

cnpg-bot pushed a commit that referenced this pull request

Nov 1, 2025
…table publications (#8888)

The previous implementation generated SQL valid only in PostgreSQL 15+, for
example:

    CREATE PUBLICATION "pub" FOR TABLE "t1", TABLE "t2";

This syntax causes a syntax error in PostgreSQL 13 and 14. The fix updates the
SQL generation to produce backward-compatible statements such as:

    CREATE PUBLICATION "pub" FOR TABLE "t1", "t2";

The new implementation groups consecutive tables under a single `TABLE` keyword
and correctly handles mixed cases involving `TABLES IN SCHEMA`, ensuring full
compatibility across all supported PostgreSQL versions (13+).

Fixes #8588.

Signed-off-by: Armando Ruocco [armando.ruocco@enterprisedb.com](mailto:armando.ruocco@enterprisedb.com)
Signed-off-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
Co-authored-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
(cherry picked from commit 514a43d)

cnpg-bot pushed a commit that referenced this pull request

Nov 1, 2025
…table publications (#8888)

The previous implementation generated SQL valid only in PostgreSQL 15+, for
example:

    CREATE PUBLICATION "pub" FOR TABLE "t1", TABLE "t2";

This syntax causes a syntax error in PostgreSQL 13 and 14. The fix updates the
SQL generation to produce backward-compatible statements such as:

    CREATE PUBLICATION "pub" FOR TABLE "t1", "t2";

The new implementation groups consecutive tables under a single `TABLE` keyword
and correctly handles mixed cases involving `TABLES IN SCHEMA`, ensuring full
compatibility across all supported PostgreSQL versions (13+).

Fixes #8588.

Signed-off-by: Armando Ruocco [armando.ruocco@enterprisedb.com](mailto:armando.ruocco@enterprisedb.com)
Signed-off-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
Co-authored-by: Gabriele Bartolini [gabriele.bartolini@enterprisedb.com](mailto:gabriele.bartolini@enterprisedb.com)
(cherry picked from commit 514a43d)