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

PG17 Add Regression Test for ALTER TABLE ... SET ACCESS METHOD DEFAULT #7803

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

m3hm3t
Copy link
Contributor

@m3hm3t m3hm3t commented Dec 23, 2024

This PR introduces and enforces an error check preventing ALTER TABLE ... SET ACCESS METHOD DEFAULT on both Citus local tables (added via citus_add_local_table_to_metadata) and distributed/partitioned distributed tables. The regression tests now demonstrate that each table type raises an error advising users to explicitly specify an access method, rather than relying on DEFAULT. This ensures consistent behavior across local and distributed environments in Citus.

postgres/postgres@d61a6cad6

@m3hm3t m3hm3t changed the base branch from naisila/pg17_support to m3hm3t/pg17_support December 23, 2024 21:09
@m3hm3t m3hm3t changed the title M3hm3t/default in alter table PG17 Add Regression Test for ALTER TABLE ... SET ACCESS METHOD DEFAULT Dec 23, 2024
@m3hm3t m3hm3t self-assigned this Dec 23, 2024
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (release-13.0@b4cc721). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff               @@
##             release-13.0    #7803   +/-   ##
===============================================
  Coverage                ?   89.64%           
===============================================
  Files                   ?      274           
  Lines                   ?    59726           
  Branches                ?     7452           
===============================================
  Hits                    ?    53540           
  Misses                  ?     4056           
  Partials                ?     2130           

Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a problem here because default access method may be different in the cluster nodes. Steps to reproduce below:

CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;

CREATE TABLE dist_table (id SERIAL PRIMARY KEY, data TEXT) USING heap;
SELECT create_distributed_table('dist_table', 'id');

SET default_table_access_method = 'heap2';

-- default in coordinator is heap2, default in workers is heap
ALTER TABLE dist_table SET ACCESS METHOD DEFAULT;

SELECT c.relname, am.amname FROM pg_class c, pg_am am
WHERE c.relam = am.oid and c.relname IN ('dist_table', 'ref_table');
  relname   | amname
------------+--------
 dist_table | heap2
(1 row)

\c - - - :worker_1_port
SELECT c.relname, am.amname FROM pg_class c, pg_am am
WHERE c.relam = am.oid and c.relname IN ('dist_table', 'ref_table');
  relname   | amname
------------+--------
 dist_table | heap
(1 row)

The problem is that the alter table command is distributed as it is. One way to fix this is to propagate the alter table command by replacing "default" with the actual access method name. This requires code changes

@m3hm3t m3hm3t force-pushed the m3hm3t/pg17_support branch from d5d31d3 to 15a9e49 Compare December 25, 2024 19:12
@m3hm3t m3hm3t force-pushed the m3hm3t/default_in_alter_table branch from 10759d0 to 8ecfc56 Compare December 25, 2024 19:19
@m3hm3t m3hm3t marked this pull request as ready for review December 26, 2024 07:36
@m3hm3t m3hm3t requested a review from naisila December 26, 2024 07:36
src/test/regress/sql/pg17.sql Outdated Show resolved Hide resolved
src/test/regress/sql/pg17.sql Outdated Show resolved Hide resolved
src/backend/distributed/commands/table.c Outdated Show resolved Hide resolved
@m3hm3t m3hm3t force-pushed the m3hm3t/pg17_support branch from 15a9e49 to b9c5f85 Compare December 26, 2024 13:14
@m3hm3t m3hm3t force-pushed the m3hm3t/default_in_alter_table branch 3 times, most recently from 91e681a to 41cc5c1 Compare December 26, 2024 13:23
@m3hm3t m3hm3t force-pushed the m3hm3t/pg17_support branch from b9c5f85 to 44ddec6 Compare December 26, 2024 14:37
Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Rebase to release-13.0 and merge after all tests have passed (except packaging images tests)

@m3hm3t m3hm3t changed the base branch from m3hm3t/pg17_support to release-13.0 December 27, 2024 10:06
@m3hm3t m3hm3t force-pushed the m3hm3t/default_in_alter_table branch from d26091d to efacf92 Compare December 27, 2024 10:07
update

update

Update src/test/regress/sql/pg17.sql

Co-authored-by: Naisila Puka <37271756+naisila@users.noreply.github.com>

Update src/backend/distributed/commands/table.c

Co-authored-by: Naisila Puka <37271756+naisila@users.noreply.github.com>

update

remove citus tools

update

update

indent
@m3hm3t m3hm3t force-pushed the m3hm3t/default_in_alter_table branch from efacf92 to 2f3262c Compare December 27, 2024 10:13
@naisila naisila merged commit 62a00b1 into release-13.0 Dec 27, 2024
150 of 159 checks passed
@naisila naisila deleted the m3hm3t/default_in_alter_table branch December 27, 2024 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants