mirror of https://github.com/citusdata/citus.git
Fix master_update_table_statistics scripts for 9.5
parent
b46f8874d3
commit
c84d1d9e70
|
@ -0,0 +1,7 @@
|
||||||
|
-- 9.5-2--9.5-3 was added later as a patch to improve master_update_table_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';
|
|
@ -0,0 +1,22 @@
|
||||||
|
-- citus--9.5-3--9.5-2
|
||||||
|
-- This is a downgrade path that will revert the changes made in citus--9.5-2--9.5-3.sql
|
||||||
|
-- 9.5-2--9.5-3 was added later as a patch to improve master_update_table_statistics.
|
||||||
|
-- We have this downgrade script so that we can continue from the main upgrade path
|
||||||
|
-- when upgrading to later versions.
|
||||||
|
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';
|
|
@ -556,6 +556,82 @@ SELECT * FROM multi_extension.print_extension_changes();
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
-- Test upgrade paths for backported improvement of master_update_table_statistics function
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
citus_update_table_statistics
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-2';
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
+
|
||||||
|
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; +
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
citus_update_table_statistics
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- Snapshot of state at 9.5-1
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-1';
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
+
|
||||||
|
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; +
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
||||||
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
||||||
-- Test downgrade to 9.5-1 from 10.0-4
|
-- Test downgrade to 9.5-1 from 10.0-4
|
||||||
|
|
|
@ -556,6 +556,82 @@ SELECT * FROM multi_extension.print_extension_changes();
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
-- Test upgrade paths for backported improvement of master_update_table_statistics function
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
citus_update_table_statistics
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-2';
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
+
|
||||||
|
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; +
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
citus_update_table_statistics
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
-- Snapshot of state at 9.5-1
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-1';
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
prosrc
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
+
|
||||||
|
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; +
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
previous_object | current_object
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
||||||
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
||||||
-- Test downgrade to 9.5-1 from 10.0-4
|
-- Test downgrade to 9.5-1 from 10.0-4
|
||||||
|
|
|
@ -242,6 +242,30 @@ SELECT * FROM multi_extension.print_extension_changes();
|
||||||
ALTER EXTENSION citus UPDATE TO '9.5-1';
|
ALTER EXTENSION citus UPDATE TO '9.5-1';
|
||||||
SELECT * FROM multi_extension.print_extension_changes();
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
|
||||||
|
-- Test upgrade paths for backported improvement of master_update_table_statistics function
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-2';
|
||||||
|
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-3';
|
||||||
|
-- should see the new source code with internal function citus_update_table_statistics
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
|
||||||
|
-- Snapshot of state at 9.5-1
|
||||||
|
ALTER EXTENSION citus UPDATE TO '9.5-1';
|
||||||
|
-- should see the old source code
|
||||||
|
SELECT prosrc FROM pg_proc WHERE proname = 'master_update_table_statistics' ORDER BY 1;
|
||||||
|
-- Should be empty result
|
||||||
|
SELECT * FROM multi_extension.print_extension_changes();
|
||||||
|
|
||||||
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
-- We removed the upgrade paths to 10.0-1, 10.0-2 and 10.0-3 due to a bug that blocked
|
||||||
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
-- upgrades to 10.0, Therefore we test upgrades to 10.0-4 instead
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue