mirror of https://github.com/citusdata/citus.git
Fix index name udf scripts for 10.2 and bump use of new sql functions
parent
0a48c0aec7
commit
757446bc61
|
@ -1,6 +1,6 @@
|
|||
# Citus extension
|
||||
comment = 'Citus distributed database'
|
||||
default_version = '10.2-3'
|
||||
default_version = '10.2-4'
|
||||
module_pathname = '$libdir/citus'
|
||||
relocatable = false
|
||||
schema = pg_catalog
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
-- citus--10.2-3--10.2-4
|
||||
|
||||
-- bump version to 10.2-4
|
||||
|
||||
#include "udfs/fix_partition_shard_index_names/10.2-4.sql"
|
||||
#include "udfs/fix_all_partition_shard_index_names/10.2-4.sql"
|
||||
#include "udfs/worker_fix_partition_shard_index_names/10.2-4.sql"
|
|
@ -0,0 +1,5 @@
|
|||
-- citus--10.2-4--10.2-3
|
||||
|
||||
DROP FUNCTION pg_catalog.fix_all_partition_shard_index_names();
|
||||
DROP FUNCTION pg_catalog.fix_partition_shard_index_names(regclass);
|
||||
DROP FUNCTION pg_catalog.worker_fix_partition_shard_index_names(regclass, text, text);
|
21
src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql
generated
Normal file
21
src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql
generated
Normal file
|
@ -0,0 +1,21 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.fix_all_partition_shard_index_names()
|
||||
RETURNS SETOF regclass
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
dist_partitioned_table_name regclass;
|
||||
BEGIN
|
||||
FOR dist_partitioned_table_name IN SELECT p.logicalrelid
|
||||
FROM pg_dist_partition p
|
||||
JOIN pg_class c ON p.logicalrelid = c.oid
|
||||
WHERE c.relkind = 'p'
|
||||
ORDER BY c.relname, c.oid
|
||||
LOOP
|
||||
EXECUTE 'SELECT fix_partition_shard_index_names( ' || quote_literal(dist_partitioned_table_name) || ' )';
|
||||
RETURN NEXT dist_partitioned_table_name;
|
||||
END LOOP;
|
||||
RETURN;
|
||||
END;
|
||||
$$;
|
||||
COMMENT ON FUNCTION pg_catalog.fix_all_partition_shard_index_names()
|
||||
IS 'fix index names on partition shards of all tables';
|
|
@ -0,0 +1,6 @@
|
|||
CREATE FUNCTION pg_catalog.fix_partition_shard_index_names(table_name regclass)
|
||||
RETURNS void
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$fix_partition_shard_index_names$$;
|
||||
COMMENT ON FUNCTION pg_catalog.fix_partition_shard_index_names(table_name regclass)
|
||||
IS 'fix index names on partition shards of given table';
|
10
src/backend/distributed/sql/udfs/worker_fix_partition_shard_index_names/10.2-4.sql
generated
Normal file
10
src/backend/distributed/sql/udfs/worker_fix_partition_shard_index_names/10.2-4.sql
generated
Normal file
|
@ -0,0 +1,10 @@
|
|||
CREATE FUNCTION pg_catalog.worker_fix_partition_shard_index_names(parent_shard_index regclass,
|
||||
partition_shard text,
|
||||
new_partition_shard_index_name text)
|
||||
RETURNS void
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$worker_fix_partition_shard_index_names$$;
|
||||
COMMENT ON FUNCTION pg_catalog.worker_fix_partition_shard_index_names(parent_shard_index regclass,
|
||||
partition_shard text,
|
||||
new_partition_shard_index_name text)
|
||||
IS 'fix the name of the index on given partition shard that is child of given parent_index';
|
|
@ -864,6 +864,41 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Test downgrade to 10.2-2 from 10.2-3
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-2';
|
||||
-- Should be empty result since upgrade+downgrade should be a no-op
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Snapshot of state at 10.2-3
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Test downgrade to 10.2-3 from 10.2-4
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-4';
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
-- Should be empty result since upgrade+downgrade should be a no-op
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Snapshot of state at 10.2-4
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-4';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
| function fix_all_partition_shard_index_names() SETOF regclass
|
||||
| function fix_partition_shard_index_names(regclass) void
|
||||
| function worker_fix_partition_shard_index_names(regclass,text,text) void
|
||||
(3 rows)
|
||||
|
||||
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
||||
-- show running version
|
||||
SHOW citus.version;
|
||||
|
|
|
@ -356,6 +356,26 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
ALTER EXTENSION citus UPDATE TO '10.2-2';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
|
||||
-- Test downgrade to 10.2-2 from 10.2-3
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-2';
|
||||
-- Should be empty result since upgrade+downgrade should be a no-op
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
|
||||
-- Snapshot of state at 10.2-3
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
|
||||
-- Test downgrade to 10.2-3 from 10.2-4
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-4';
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-3';
|
||||
-- Should be empty result since upgrade+downgrade should be a no-op
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
|
||||
-- Snapshot of state at 10.2-4
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-4';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
|
||||
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
||||
|
||||
-- show running version
|
||||
|
|
Loading…
Reference in New Issue