mirror of https://github.com/citusdata/citus.git
Fix upgrade and downgrade paths for master/citus_update_table_statistics (#4805)
parent
69f09556fd
commit
71a9f45513
|
@ -0,0 +1,10 @@
|
|||
-- citus--10.0-2--10.0-3
|
||||
|
||||
#include "udfs/citus_update_table_statistics/10.0-3.sql"
|
||||
|
||||
CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||
COMMENT ON FUNCTION pg_catalog.master_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table';
|
|
@ -1,4 +1,4 @@
|
|||
-- citus--10.0-2--10.1-1
|
||||
-- citus--10.0-3--10.1-1
|
||||
|
||||
-- bump version to 10.1-1
|
||||
|
|
@ -1394,11 +1394,22 @@ COMMENT ON FUNCTION master_update_node(node_id int, new_node_name text, new_node
|
|||
|
||||
-- shard statistics
|
||||
CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||
COMMENT ON FUNCTION pg_catalog.master_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table';
|
||||
RETURNS VOID AS $$
|
||||
DECLARE
|
||||
colocated_tables regclass[];
|
||||
BEGIN
|
||||
SELECT get_colocated_table_array(relation) INTO colocated_tables;
|
||||
|
||||
PERFORM
|
||||
master_update_shard_statistics(shardid)
|
||||
FROM
|
||||
pg_dist_shard
|
||||
WHERE
|
||||
logicalrelid = ANY (colocated_tables);
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
COMMENT ON FUNCTION master_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table and its colocated tables';
|
||||
|
||||
CREATE OR REPLACE FUNCTION get_colocated_shard_array(bigint)
|
||||
RETURNS BIGINT[]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
-- citus--10.0-3--10.0-2
|
||||
-- this is a downgrade path that will revert the changes made in citus--10.0-2--10.0-3.sql
|
||||
|
||||
DROP FUNCTION pg_catalog.citus_update_table_statistics(regclass);
|
||||
|
||||
#include "../udfs/citus_update_table_statistics/10.0-1.sql"
|
||||
|
||||
CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
|
||||
RETURNS VOID AS $$
|
||||
DECLARE
|
||||
colocated_tables regclass[];
|
||||
BEGIN
|
||||
SELECT get_colocated_table_array(relation) INTO colocated_tables;
|
||||
|
||||
PERFORM
|
||||
master_update_shard_statistics(shardid)
|
||||
FROM
|
||||
pg_dist_shard
|
||||
WHERE
|
||||
logicalrelid = ANY (colocated_tables);
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
COMMENT ON FUNCTION master_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table and its colocated tables';
|
|
@ -1,3 +0,0 @@
|
|||
-- citus--10.1-1--10.0-2
|
||||
-- this is an empty downgrade path since citus--10.0-2--10.1-1.sql is empty for now
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
-- citus--10.1-1--10.0-2
|
||||
-- this is an empty downgrade path since citus--10.0-3--10.1-1.sql is empty for now
|
||||
|
|
@ -1,6 +1,17 @@
|
|||
CREATE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||
RETURNS VOID AS $$
|
||||
DECLARE
|
||||
colocated_tables regclass[];
|
||||
BEGIN
|
||||
SELECT get_colocated_table_array(relation) INTO colocated_tables;
|
||||
|
||||
PERFORM
|
||||
master_update_shard_statistics(shardid)
|
||||
FROM
|
||||
pg_dist_shard
|
||||
WHERE
|
||||
logicalrelid = ANY (colocated_tables);
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
COMMENT ON FUNCTION pg_catalog.citus_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table';
|
||||
IS 'updates shard statistics of the given table and its colocated tables';
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||
COMMENT ON FUNCTION pg_catalog.citus_update_table_statistics(regclass)
|
||||
IS 'updates shard statistics of the given table';
|
|
@ -1,4 +1,4 @@
|
|||
CREATE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||
|
|
Loading…
Reference in New Issue