Skip to content

[BUG] 5.4-SNAPSHOT: PostgreSQL ATTACH/DETACH PARTITION is only UNSPECIFIC #2523

Description

@minleejae

Failing SQL feature

PostgreSQL ALTER TABLE ... ATTACH PARTITION and DETACH PARTITION are accepted only by the generic fallback. The resulting AlterExpression has AlterOperation.UNSPECIFIC, getParameters() is null, and none of the partition name, bound, CONCURRENTLY, or FINALIZE data is available structurally.

SQL examples

ALTER TABLE pg_attach_parent
    ATTACH PARTITION pg_attach_child
    FOR VALUES FROM ('2026-09-01') TO ('2026-10-01');

ALTER TABLE pg_attach_parent
    DETACH PARTITION pg_attach_child;

ALTER TABLE pg_attach_parent
    DETACH PARTITION pg_attach_child CONCURRENTLY;

ALTER TABLE pg_attach_parent
    DETACH PARTITION pg_attach_child FINALIZE;

Actual behavior

On JSqlParser 5.4-SNAPSHOT at 9a32ff568f580178d9a27b101596aa43eb45d0b7, all forms return an Alter, but the first AlterExpression reports:

operation = UNSPECIFIC
parameters = null

The original text happens to deparse through captureRest, but callers cannot inspect or modify the operation safely.

Expected behavior

Use dedicated alter operations and structured fields for the partition table name, RANGE/LIST/HASH/DEFAULT bound, and DETACH mode. Parsing and both deparsing paths should retain all tokens.

Software information and server validation

  • JSqlParser: 5.4-SNAPSHOT
  • Database: PostgreSQL 18.6 (postgres:18)
  • A standalone table was successfully attached to a RANGE-partitioned parent, detached, reattached, and detached with CONCURRENTLY using ON_ERROR_STOP=1.
  • Grammar reference: https://www.postgresql.org/docs/18/sql-altertable.html

AI assistance

OpenAI Codex was used to assemble and execute the parser/server comparison. The cases were checked against the PostgreSQL 18 documentation and an actual PostgreSQL 18.6 server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions