Move citus_internal_delete_placement_metadata and citus_internal_delete_partition_metadata

pull/7473/head
eaydingol 2024-01-31 12:43:53 +00:00
parent 81ac98ab40
commit f9b61cd973
10 changed files with 68 additions and 10 deletions

View File

@ -34,3 +34,5 @@ REVOKE ALL ON FUNCTION citus_internal.start_management_transaction FROM PUBLIC;
#include "udfs/citus_internal_add_tenant_schema/12.2-1.sql" #include "udfs/citus_internal_add_tenant_schema/12.2-1.sql"
#include "udfs/citus_internal_adjust_local_clock_to_remote/12.2-1.sql" #include "udfs/citus_internal_adjust_local_clock_to_remote/12.2-1.sql"
#include "udfs/citus_internal_delete_colocation_metadata/12.2-1.sql" #include "udfs/citus_internal_delete_colocation_metadata/12.2-1.sql"
#include "udfs/citus_internal_delete_partition_metadata/12.2-1.sql"
#include "udfs/citus_internal_delete_placement_metadata/12.2-1.sql"

View File

@ -30,4 +30,6 @@ DROP FUNCTION citus_internal.add_placement_metadata(bigint, bigint, integer, big
DROP FUNCTION citus_internal.add_shard_metadata(regclass, bigint, "char", text, text); DROP FUNCTION citus_internal.add_shard_metadata(regclass, bigint, "char", text, text);
DROP FUNCTION citus_internal.add_tenant_schema(oid, integer); DROP FUNCTION citus_internal.add_tenant_schema(oid, integer);
DROP FUNCTION citus_internal.adjust_local_clock_to_remote(pg_catalog.cluster_clock); DROP FUNCTION citus_internal.adjust_local_clock_to_remote(pg_catalog.cluster_clock);
DROP FUNCTION citus_internal.delete_colocation_metadata(int); DROP FUNCTION citus_internal.delete_colocation_metadata(int);
DROP FUNCTION citus_internal.delete_partition_metadata(regclass);
DROP FUNCTION citus_internal.delete_placement_metadata(bigint);

View File

@ -0,0 +1,14 @@
CREATE OR REPLACE FUNCTION citus_internal.delete_partition_metadata(table_name regclass)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_internal_delete_partition_metadata$$;
COMMENT ON FUNCTION citus_internal.delete_partition_metadata(regclass) IS
'Deletes a row from pg_dist_partition with table ownership checks';
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_partition_metadata(table_name regclass)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME';
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_partition_metadata(regclass) IS
'Deletes a row from pg_dist_partition with table ownership checks';

View File

@ -1,3 +1,10 @@
CREATE OR REPLACE FUNCTION citus_internal.delete_partition_metadata(table_name regclass)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_internal_delete_partition_metadata$$;
COMMENT ON FUNCTION citus_internal.delete_partition_metadata(regclass) IS
'Deletes a row from pg_dist_partition with table ownership checks';
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_partition_metadata(table_name regclass) CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_partition_metadata(table_name regclass)
RETURNS void RETURNS void
LANGUAGE C STRICT LANGUAGE C STRICT

View File

@ -0,0 +1,19 @@
CREATE OR REPLACE FUNCTION citus_internal.delete_placement_metadata(
placement_id bigint)
RETURNS void
LANGUAGE C
VOLATILE
AS 'MODULE_PATHNAME',
$$citus_internal_delete_placement_metadata$$;
COMMENT ON FUNCTION citus_internal.delete_placement_metadata(bigint)
IS 'Delete placement with given id from pg_dist_placement metadata table.';
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_placement_metadata(
placement_id bigint)
RETURNS void
LANGUAGE C
VOLATILE
AS 'MODULE_PATHNAME',
$$citus_internal_delete_placement_metadata$$;
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_placement_metadata(bigint)
IS 'Delete placement with given id from pg_dist_placement metadata table.';

View File

@ -1,3 +1,13 @@
CREATE OR REPLACE FUNCTION citus_internal.delete_placement_metadata(
placement_id bigint)
RETURNS void
LANGUAGE C
VOLATILE
AS 'MODULE_PATHNAME',
$$citus_internal_delete_placement_metadata$$;
COMMENT ON FUNCTION citus_internal.delete_placement_metadata(bigint)
IS 'Delete placement with given id from pg_dist_placement metadata table.';
CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_placement_metadata( CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_placement_metadata(
placement_id bigint) placement_id bigint)
RETURNS void RETURNS void

View File

@ -371,7 +371,7 @@ ROLLBACK;
-- reference tables. -- reference tables.
SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, true); SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, true);
ERROR: This is an internal Citus function can only be used in a distributed transaction ERROR: This is an internal Citus function can only be used in a distributed transaction
SELECT pg_catalog.citus_internal_delete_placement_metadata(1); SELECT citus_internal.delete_placement_metadata(1);
ERROR: This is an internal Citus function can only be used in a distributed transaction ERROR: This is an internal Citus function can only be used in a distributed transaction
CREATE ROLE test_user_create_ref_dist WITH LOGIN; CREATE ROLE test_user_create_ref_dist WITH LOGIN;
GRANT ALL ON SCHEMA create_ref_dist_from_citus_local TO test_user_create_ref_dist; GRANT ALL ON SCHEMA create_ref_dist_from_citus_local TO test_user_create_ref_dist;
@ -401,7 +401,7 @@ SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', null, t
ERROR: colocation_id cannot be NULL ERROR: colocation_id cannot be NULL
SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, null); SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, null);
ERROR: auto_converted cannot be NULL ERROR: auto_converted cannot be NULL
SELECT pg_catalog.citus_internal_delete_placement_metadata(null); SELECT citus_internal.delete_placement_metadata(null);
ERROR: placement_id cannot be NULL ERROR: placement_id cannot be NULL
CREATE TABLE udf_test (col_1 int); CREATE TABLE udf_test (col_1 int);
SELECT citus_add_local_table_to_metadata('udf_test'); SELECT citus_add_local_table_to_metadata('udf_test');
@ -426,8 +426,8 @@ BEGIN;
SELECT placementid AS udf_test_placementid FROM pg_dist_shard_placement SELECT placementid AS udf_test_placementid FROM pg_dist_shard_placement
WHERE shardid = get_shard_id_for_distribution_column('create_ref_dist_from_citus_local.udf_test') \gset WHERE shardid = get_shard_id_for_distribution_column('create_ref_dist_from_citus_local.udf_test') \gset
SELECT pg_catalog.citus_internal_delete_placement_metadata(:udf_test_placementid); SELECT citus_internal.delete_placement_metadata(:udf_test_placementid);
citus_internal_delete_placement_metadata delete_placement_metadata
--------------------------------------------------------------------- ---------------------------------------------------------------------
(1 row) (1 row)

View File

@ -1433,10 +1433,12 @@ SELECT * FROM multi_extension.print_extension_changes();
| function citus_internal.commit_management_command_2pc() void | function citus_internal.commit_management_command_2pc() void
| function citus_internal.database_command(text) void | function citus_internal.database_command(text) void
| function citus_internal.delete_colocation_metadata(integer) void | function citus_internal.delete_colocation_metadata(integer) void
| function citus_internal.delete_partition_metadata(regclass) void
| function citus_internal.delete_placement_metadata(bigint) void
| function citus_internal.execute_command_on_remote_nodes_as_user(text,text) void | function citus_internal.execute_command_on_remote_nodes_as_user(text,text) void
| function citus_internal.mark_object_distributed(oid,text,oid,text) void | function citus_internal.mark_object_distributed(oid,text,oid,text) void
| function citus_internal.start_management_transaction(xid8) void | function citus_internal.start_management_transaction(xid8) void
(14 rows) (16 rows)
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff; DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
-- show running version -- show running version

View File

@ -67,6 +67,8 @@ ORDER BY 1;
function citus_internal.commit_management_command_2pc() function citus_internal.commit_management_command_2pc()
function citus_internal.database_command(text) function citus_internal.database_command(text)
function citus_internal.delete_colocation_metadata(integer) function citus_internal.delete_colocation_metadata(integer)
function citus_internal.delete_partition_metadata(regclass)
function citus_internal.delete_placement_metadata(bigint)
function citus_internal.execute_command_on_remote_nodes_as_user(text,text) function citus_internal.execute_command_on_remote_nodes_as_user(text,text)
function citus_internal.find_groupid_for_node(text,integer) function citus_internal.find_groupid_for_node(text,integer)
function citus_internal.mark_object_distributed(oid,text,oid,text) function citus_internal.mark_object_distributed(oid,text,oid,text)
@ -357,5 +359,5 @@ ORDER BY 1;
view citus_stat_tenants_local view citus_stat_tenants_local
view pg_dist_shard_placement view pg_dist_shard_placement
view time_partitions view time_partitions
(347 rows) (349 rows)

View File

@ -220,7 +220,7 @@ ROLLBACK;
-- reference tables. -- reference tables.
SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, true); SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, true);
SELECT pg_catalog.citus_internal_delete_placement_metadata(1); SELECT citus_internal.delete_placement_metadata(1);
CREATE ROLE test_user_create_ref_dist WITH LOGIN; CREATE ROLE test_user_create_ref_dist WITH LOGIN;
GRANT ALL ON SCHEMA create_ref_dist_from_citus_local TO test_user_create_ref_dist; GRANT ALL ON SCHEMA create_ref_dist_from_citus_local TO test_user_create_ref_dist;
@ -239,7 +239,7 @@ SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, null, 1, tru
SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', null, true); SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', null, true);
SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, null); SELECT pg_catalog.citus_internal_update_none_dist_table_metadata(1, 't', 1, null);
SELECT pg_catalog.citus_internal_delete_placement_metadata(null); SELECT citus_internal.delete_placement_metadata(null);
CREATE TABLE udf_test (col_1 int); CREATE TABLE udf_test (col_1 int);
SELECT citus_add_local_table_to_metadata('udf_test'); SELECT citus_add_local_table_to_metadata('udf_test');
@ -253,7 +253,7 @@ BEGIN;
SELECT placementid AS udf_test_placementid FROM pg_dist_shard_placement SELECT placementid AS udf_test_placementid FROM pg_dist_shard_placement
WHERE shardid = get_shard_id_for_distribution_column('create_ref_dist_from_citus_local.udf_test') \gset WHERE shardid = get_shard_id_for_distribution_column('create_ref_dist_from_citus_local.udf_test') \gset
SELECT pg_catalog.citus_internal_delete_placement_metadata(:udf_test_placementid); SELECT citus_internal.delete_placement_metadata(:udf_test_placementid);
SELECT COUNT(*)=0 FROM pg_dist_placement WHERE placementid = :udf_test_placementid; SELECT COUNT(*)=0 FROM pg_dist_placement WHERE placementid = :udf_test_placementid;
ROLLBACK; ROLLBACK;