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 compatibility: Adjust print_extension_changes function for extra type outputs in PG17 #7761

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/test/regress/expected/multi_extension.out
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ $definition$ create_function_test_maintenance_worker
CREATE TABLE multi_extension.prev_objects(description text);
CREATE TABLE multi_extension.extension_diff(previous_object text COLLATE "C",
current_object text COLLATE "C");
-- In PG17, Auto-generated array types, multirange types, and relation rowtypes
-- are treated as dependent objects, hence changing the output of the
-- print_extension_changes function.
-- Relevant PG commit: e5bc9454e527b1cba97553531d8d4992892fdeef
-- Here we create a table with only the basic extension types
-- in order to avoid printing extra ones for now
-- This can be removed when we drop PG16 support.
CREATE TABLE multi_extension.extension_basic_types (description text);
INSERT INTO multi_extension.extension_basic_types VALUES ('type citus.distribution_type'),
('type citus.shard_transfer_mode'),
('type citus_copy_format'),
('type noderole'),
('type citus_job_status'),
('type citus_task_status'),
('type replication_slot_info'),
('type split_copy_info'),
('type split_shard_info'),
('type cluster_clock');
CREATE FUNCTION multi_extension.print_extension_changes()
RETURNS TABLE(previous_object text, current_object text)
AS $func$
Expand All @@ -53,7 +71,10 @@ BEGIN
WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
AND refobjid = e.oid
AND deptype = 'e'
AND e.extname='citus';
AND e.extname='citus'
AND (pg_catalog.pg_describe_object(classid, objid, 0) NOT LIKE 'type%'
OR
pg_catalog.pg_describe_object(classid, objid, 0) IN (SELECT * FROM extension_basic_types));

INSERT INTO extension_diff
SELECT p.description previous_object, c.description current_object
Expand Down Expand Up @@ -88,7 +109,8 @@ FROM pg_depend AS pgd,
WHERE pgd.refclassid = 'pg_extension'::regclass AND
pgd.refobjid = pge.oid AND
pge.extname = 'citus' AND
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal')
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal') AND
pgio.type != 'type'
ORDER BY 1, 2;
type | identity
---------------------------------------------------------------------
Expand Down Expand Up @@ -1424,7 +1446,8 @@ FROM pg_depend AS pgd,
WHERE pgd.refclassid = 'pg_extension'::regclass AND
pgd.refobjid = pge.oid AND
pge.extname = 'citus' AND
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal')
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal') AND
pgio.type != 'type'
ORDER BY 1, 2;
type | identity
---------------------------------------------------------------------
Expand Down Expand Up @@ -1914,6 +1937,7 @@ RESET citus.enable_schema_based_sharding;
DROP EXTENSION citus;
CREATE EXTENSION citus;
DROP TABLE version_mismatch_table;
DROP TABLE multi_extension.extension_basic_types;
DROP SCHEMA multi_extension;
ERROR: cannot drop schema multi_extension because other objects depend on it
DETAIL: function multi_extension.print_extension_changes() depends on schema multi_extension
Expand Down
22 changes: 22 additions & 0 deletions src/test/regress/expected/upgrade_list_citus_objects.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
-- In PG17, Auto-generated array types, multirange types, and relation rowtypes
-- are treated as dependent objects, hence changing the output of the
-- print_extension_changes function.
-- Relevant PG commit: e5bc9454e527b1cba97553531d8d4992892fdeef
-- Here we create a table with only the basic extension types
-- in order to avoid printing extra ones for now
-- This can be removed when we drop PG16 support.
CREATE TABLE extension_basic_types (description text);
INSERT INTO extension_basic_types VALUES ('type citus.distribution_type'),
('type citus.shard_transfer_mode'),
('type citus_copy_format'),
('type noderole'),
('type citus_job_status'),
('type citus_task_status'),
('type replication_slot_info'),
('type split_copy_info'),
('type split_shard_info'),
('type cluster_clock');
-- list all postgres objects belonging to the citus extension
SELECT pg_catalog.pg_describe_object(classid, objid, 0) AS description
FROM pg_catalog.pg_depend, pg_catalog.pg_extension e
WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
AND refobjid = e.oid
AND deptype = 'e'
AND e.extname='citus'
AND (pg_catalog.pg_describe_object(classid, objid, 0) NOT LIKE 'type%'
OR
pg_catalog.pg_describe_object(classid, objid, 0) IN (SELECT * FROM extension_basic_types))
AND pg_catalog.pg_describe_object(classid, objid, 0) != 'function any_value(anyelement)'
AND pg_catalog.pg_describe_object(classid, objid, 0) != 'function any_value_agg(anyelement,anyelement)'
ORDER BY 1;
Expand Down Expand Up @@ -345,3 +366,4 @@ ORDER BY 1;
view time_partitions
(333 rows)

DROP TABLE extension_basic_types;
32 changes: 29 additions & 3 deletions src/test/regress/sql/multi_extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ CREATE TABLE multi_extension.prev_objects(description text);
CREATE TABLE multi_extension.extension_diff(previous_object text COLLATE "C",
current_object text COLLATE "C");

-- In PG17, Auto-generated array types, multirange types, and relation rowtypes
-- are treated as dependent objects, hence changing the output of the
-- print_extension_changes function.
-- Relevant PG commit: e5bc9454e527b1cba97553531d8d4992892fdeef
-- Here we create a table with only the basic extension types
-- in order to avoid printing extra ones for now
-- This can be removed when we drop PG16 support.

CREATE TABLE multi_extension.extension_basic_types (description text);
INSERT INTO multi_extension.extension_basic_types VALUES ('type citus.distribution_type'),
('type citus.shard_transfer_mode'),
('type citus_copy_format'),
('type noderole'),
('type citus_job_status'),
('type citus_task_status'),
('type replication_slot_info'),
('type split_copy_info'),
('type split_shard_info'),
('type cluster_clock');

CREATE FUNCTION multi_extension.print_extension_changes()
RETURNS TABLE(previous_object text, current_object text)
AS $func$
Expand All @@ -57,7 +77,10 @@ BEGIN
WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
AND refobjid = e.oid
AND deptype = 'e'
AND e.extname='citus';
AND e.extname='citus'
AND (pg_catalog.pg_describe_object(classid, objid, 0) NOT LIKE 'type%'
OR
pg_catalog.pg_describe_object(classid, objid, 0) IN (SELECT * FROM extension_basic_types));

INSERT INTO extension_diff
SELECT p.description previous_object, c.description current_object
Expand Down Expand Up @@ -90,7 +113,8 @@ FROM pg_depend AS pgd,
WHERE pgd.refclassid = 'pg_extension'::regclass AND
pgd.refobjid = pge.oid AND
pge.extname = 'citus' AND
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal')
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal') AND
pgio.type != 'type'
ORDER BY 1, 2;


Expand Down Expand Up @@ -647,7 +671,8 @@ FROM pg_depend AS pgd,
WHERE pgd.refclassid = 'pg_extension'::regclass AND
pgd.refobjid = pge.oid AND
pge.extname = 'citus' AND
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal')
pgio.schema NOT IN ('pg_catalog', 'citus', 'citus_internal', 'test', 'columnar', 'columnar_internal') AND
pgio.type != 'type'
ORDER BY 1, 2;

-- see incompatible version errors out
Expand Down Expand Up @@ -1015,4 +1040,5 @@ DROP EXTENSION citus;
CREATE EXTENSION citus;

DROP TABLE version_mismatch_table;
DROP TABLE multi_extension.extension_basic_types;
DROP SCHEMA multi_extension;
24 changes: 24 additions & 0 deletions src/test/regress/sql/upgrade_list_citus_objects.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
-- In PG17, Auto-generated array types, multirange types, and relation rowtypes
-- are treated as dependent objects, hence changing the output of the
-- print_extension_changes function.
-- Relevant PG commit: e5bc9454e527b1cba97553531d8d4992892fdeef
-- Here we create a table with only the basic extension types
-- in order to avoid printing extra ones for now
-- This can be removed when we drop PG16 support.
CREATE TABLE extension_basic_types (description text);
INSERT INTO extension_basic_types VALUES ('type citus.distribution_type'),
('type citus.shard_transfer_mode'),
('type citus_copy_format'),
('type noderole'),
('type citus_job_status'),
('type citus_task_status'),
('type replication_slot_info'),
('type split_copy_info'),
('type split_shard_info'),
('type cluster_clock');

-- list all postgres objects belonging to the citus extension
SELECT pg_catalog.pg_describe_object(classid, objid, 0) AS description
FROM pg_catalog.pg_depend, pg_catalog.pg_extension e
WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
AND refobjid = e.oid
AND deptype = 'e'
AND e.extname='citus'
AND (pg_catalog.pg_describe_object(classid, objid, 0) NOT LIKE 'type%'
OR
pg_catalog.pg_describe_object(classid, objid, 0) IN (SELECT * FROM extension_basic_types))
AND pg_catalog.pg_describe_object(classid, objid, 0) != 'function any_value(anyelement)'
AND pg_catalog.pg_describe_object(classid, objid, 0) != 'function any_value_agg(anyelement,anyelement)'
ORDER BY 1;

DROP TABLE extension_basic_types;
Loading