Skip to content

PARTITION OF create path: support child-specific column elements #499

Description

@tianzhou

Context

PR #498 (issue #496) changed the create path for partition children from standalone CREATE TABLE to CREATE TABLE ... PARTITION OF ... FOR VALUES .... This correctly attaches children to their parent and handles child-specific constraints (via conparentid = 0 filtering).

Gap

PostgreSQL's PARTITION OF grammar accepts a full OptTypedTableElementList, which includes column-level elements beyond table constraints:

CREATE TABLE child PARTITION OF parent (
    col1 WITH OPTIONS DEFAULT 42,     -- per-child default override
    col2 WITH OPTIONS NOT NULL        -- per-child NOT NULL override
) FOR VALUES IN ('value');

The current PARTITION OF branch in generateTableSQL only serializes child-specific table constraints. It does not emit per-child column-level overrides (defaults, identity, generated expressions, storage parameters).

Impact

Low — per-child column overrides on partition children are uncommon in practice. The parent's column definitions are inherited automatically, and most schemas don't override them per-child.

Proposed fix

If the IR shows a child column with a different default/identity/generated expression than the parent column, emit it as a WITH OPTIONS element in the PARTITION OF statement.

Related: #496, PR #498

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions