mirror of https://github.com/citusdata/citus.git
Fix upgrade and downgrade paths for master/citus_update_table_statistics (#4805)
(cherry picked from commit 71a9f45513
)
pull/5009/head
parent
f13cf336f2
commit
a6435b7f6b
|
@ -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';
|
|
@ -1394,11 +1394,22 @@ COMMENT ON FUNCTION master_update_node(node_id int, new_node_name text, new_node
|
||||||
|
|
||||||
-- shard statistics
|
-- shard statistics
|
||||||
CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
|
CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
|
||||||
RETURNS VOID
|
RETURNS VOID AS $$
|
||||||
LANGUAGE C STRICT
|
DECLARE
|
||||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
colocated_tables regclass[];
|
||||||
COMMENT ON FUNCTION pg_catalog.master_update_table_statistics(regclass)
|
BEGIN
|
||||||
IS 'updates shard statistics of the given table';
|
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)
|
CREATE OR REPLACE FUNCTION get_colocated_shard_array(bigint)
|
||||||
RETURNS 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,6 +1,17 @@
|
||||||
CREATE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
CREATE FUNCTION pg_catalog.citus_update_table_statistics(relation regclass)
|
||||||
RETURNS VOID
|
RETURNS VOID AS $$
|
||||||
LANGUAGE C STRICT
|
DECLARE
|
||||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
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)
|
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
|
RETURNS VOID
|
||||||
LANGUAGE C STRICT
|
LANGUAGE C STRICT
|
||||||
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$;
|
||||||
|
|
Loading…
Reference in New Issue