Skip to content

Fold ALTER TABLE ATTACH PARTITION into the partition hierarchy - #172

Merged
LucaCappelletti94 merged 4 commits into
mainfrom
upstream/attach-partition-of
Oct 28, 2026
Merged

LucaCappelletti94 merged 4 commits into
mainfrom
upstream/attach-partition-of

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

sqlparser main now parses PostgreSQL's ALTER TABLE root ATTACH PARTITION part FOR VALUES ... as AlterTableOperation::AttachPartitionOf (apache/datafusion-sqlparser-rs#2749), and the exhaustive ALTER TABLE match in sql-traits stopped compiling against it. Every crate following both on main fails to build until this lands.

The operation is applied to the catalog. pg_dump writes every partition as a plain CREATE TABLE followed by ALTER TABLE ONLY root ATTACH PARTITION, so skipping it would read every dumped partitioned schema back with no partitions at all. The attached table gets the same edge CREATE TABLE ... PARTITION OF records, so later changes to the root reach it through the existing walks. What it receives follows PostgreSQL 18.6 for this statement. It keeps its own column order and defaults, takes the root's keys, foreign keys and identity, keeps a key or foreign key it already holds under its own name, and a partitioned table passes the root's keys on to its own partitions.

PostgreSQL refuses a mismatched table at attach time, and those refusals are modelled with a new Error::PartitionNotAttachable carrying an UnattachablePartition reason, next to the existing type, collation, check and temporary storage errors. The lockfiles move sqlparser to 5989f9ce in a commit of their own.

@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant