diff --git a/src/test/regress/expected/pg17.out b/src/test/regress/expected/pg17.out index fbe8ebbe1..ca2f7643f 100644 --- a/src/test/regress/expected/pg17.out +++ b/src/test/regress/expected/pg17.out @@ -1117,12 +1117,108 @@ SELECT * FROM pg_constraint WHERE conname = 'local_exclude_named' AND contype = DROP TABLE distributed_partitioned_table CASCADE; DROP TABLE local_partitioned_table CASCADE; -- End of Test for exclusion constraints on partitioned and distributed partitioned tables in Citus environment +-- Propagate SET STATISTICS DEFAULT +-- Relevant PG commit: +-- https://github.com/postgres/postgres/commit/4f622503d +SET citus.next_shard_id TO 25122024; +CREATE TABLE tbl (c1 int, c2 int); +SELECT citus_add_local_table_to_metadata('tbl'); + citus_add_local_table_to_metadata +--------------------------------------------------------------------- + +(1 row) + +CREATE INDEX tbl_idx ON tbl (c1, (c1+0)) INCLUDE (c2); +-- Citus currently doesn't support ALTER TABLE ALTER COLUMN SET STATISTICS anyway +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS 100; +ERROR: alter table command is currently unsupported +DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VALIDATE CONSTRAINT, SET (), RESET (), ENABLE|DISABLE|NO FORCE|FORCE ROW LEVEL SECURITY, ATTACH|DETACH PARTITION and TYPE subcommands are supported. +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS DEFAULT; +ERROR: alter table command is currently unsupported +DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VALIDATE CONSTRAINT, SET (), RESET (), ENABLE|DISABLE|NO FORCE|FORCE ROW LEVEL SECURITY, ATTACH|DETACH PARTITION and TYPE subcommands are supported. +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS -1; +ERROR: alter table command is currently unsupported +DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VALIDATE CONSTRAINT, SET (), RESET (), ENABLE|DISABLE|NO FORCE|FORCE ROW LEVEL SECURITY, ATTACH|DETACH PARTITION and TYPE subcommands are supported. +-- Citus propagates ALTER INDEX ALTER COLUMN SET STATISTICS DEFAULT to the nodes and shards +SET citus.log_remote_commands TO true; +SET citus.grep_remote_commands = '%STATISTICS%'; +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000; +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (25122024, 'pg17', 'ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000;') +\d+ tbl_idx + Index "pg17.tbl_idx" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | 1000 + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl" + +\d+ tbl_idx_25122024 + Index "pg17.tbl_idx_25122024" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | 1000 + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl_25122024" + +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS DEFAULT; +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS DEFAULT; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS DEFAULT; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (25122024, 'pg17', 'ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS DEFAULT;') +\d+ tbl_idx + Index "pg17.tbl_idx" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl" + +\d+ tbl_idx_25122024 + Index "pg17.tbl_idx_25122024" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl_25122024" + +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS -1; +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS -1; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS -1; +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (25122024, 'pg17', 'ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS -1;') +\d+ tbl_idx + Index "pg17.tbl_idx" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl" + +\d+ tbl_idx_25122024 + Index "pg17.tbl_idx_25122024" + Column | Type | Key? | Definition | Storage | Stats target +--------------------------------------------------------------------- + c1 | integer | yes | c1 | plain | + expr | integer | yes | (c1 + 0) | plain | + c2 | integer | no | c2 | plain | +btree, for table "pg17.tbl_25122024" + +-- End of testing SET STATISTICS DEFAULT +\set VERBOSITY terse +SET client_min_messages TO WARNING; DROP SCHEMA pg17 CASCADE; -NOTICE: drop cascades to 5 other objects -DETAIL: drop cascades to function fake_am_handler(internal) -drop cascades to access method fake_am -drop cascades to table dist_test -drop cascades to table postgres_table -drop cascades to table distributed_table +\set VERBOSITY default +RESET client_min_messages; DROP ROLE regress_maintain; DROP ROLE regress_no_maintain; diff --git a/src/test/regress/sql/pg17.sql b/src/test/regress/sql/pg17.sql index f0c6d5b65..aad8445ea 100644 --- a/src/test/regress/sql/pg17.sql +++ b/src/test/regress/sql/pg17.sql @@ -574,6 +574,41 @@ DROP TABLE distributed_partitioned_table CASCADE; DROP TABLE local_partitioned_table CASCADE; -- End of Test for exclusion constraints on partitioned and distributed partitioned tables in Citus environment +-- Propagate SET STATISTICS DEFAULT +-- Relevant PG commit: +-- https://github.com/postgres/postgres/commit/4f622503d +SET citus.next_shard_id TO 25122024; + +CREATE TABLE tbl (c1 int, c2 int); +SELECT citus_add_local_table_to_metadata('tbl'); +CREATE INDEX tbl_idx ON tbl (c1, (c1+0)) INCLUDE (c2); + +-- Citus currently doesn't support ALTER TABLE ALTER COLUMN SET STATISTICS anyway +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS 100; +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS DEFAULT; +ALTER TABLE tbl ALTER COLUMN 1 SET STATISTICS -1; + +-- Citus propagates ALTER INDEX ALTER COLUMN SET STATISTICS DEFAULT to the nodes and shards +SET citus.log_remote_commands TO true; +SET citus.grep_remote_commands = '%STATISTICS%'; + +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000; +\d+ tbl_idx +\d+ tbl_idx_25122024 +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS DEFAULT; +\d+ tbl_idx +\d+ tbl_idx_25122024 +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS -1; +\d+ tbl_idx +\d+ tbl_idx_25122024 + +-- End of testing SET STATISTICS DEFAULT + +\set VERBOSITY terse +SET client_min_messages TO WARNING; DROP SCHEMA pg17 CASCADE; +\set VERBOSITY default +RESET client_min_messages; + DROP ROLE regress_maintain; DROP ROLE regress_no_maintain;