Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix partition handling for recent Postgres versions #52

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

seanlinsley
Copy link
Collaborator

This PR fixes two issues with partition table handling:

  • The attach command for a partition has a comment with Type: TABLE ATTACH which wasn't being matched, leading to a dangling ATTACH in the output, which causes a syntax error.
  • The primary key handling was out of date, both for the comment and the ALTER INDEX command.

Without the implementation changes, the added test fails with:

CleanDumpTest#test_partitions [test/clean_dump_test.rb:29]:
--- expected
+++ actual
@@ -17,6 +17,8 @@
 
 CREATE INDEX index_autovacuum_run_stats_35d_on_server_id_and_occurred_at ON public.autovacuum_run_stats_35d USING btree (server_id, occurred_at);
 
+ ATTACH
+
 -- Name: schema_table_infos_35d; Type: TABLE
 
 CREATE TABLE public.schema_table_infos_35d (
@@ -29,4 +31,10 @@
 ALTER TABLE ONLY public.schema_table_infos_35d
     ADD CONSTRAINT schema_table_infos_35d_pkey PRIMARY KEY (schema_table_id, collected_at);
 
+ ATTACH
+
+-- Name: schema_table_infos_35d_20240920_pkey; Type: INDEX ATTACH
+
+ALTER INDEX public.schema_table_infos_35d_pkey ATTACH PARTITION public.schema_table_infos_35d_20240920_pkey;
+
 "

@seanlinsley seanlinsley merged commit f1f2f58 into lfittl:master Jan 7, 2025
4 checks passed
@seanlinsley seanlinsley deleted the pg-14-partitions branch January 7, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants