mirror of https://github.com/citusdata/citus.git
Merge pull request #5893 from citusdata/velioglu/fix_function_in_tx
Create function in transaction according to create object propagation gucpull/5896/head
commit
31df111ecb
|
@ -1263,12 +1263,7 @@ ShouldPropagateCreateFunction(CreateFunctionStmt *stmt)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (!ShouldPropagateCreateInCoordinatedTransction())
|
||||||
* If the create command is a part of a multi-statement transaction that is not in
|
|
||||||
* sequential mode, don't propagate.
|
|
||||||
*/
|
|
||||||
if (IsMultiStatementTransaction() &&
|
|
||||||
MultiShardConnectionType != SEQUENTIAL_CONNECTION)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,18 @@ NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_comm
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE distributed_table(value int);
|
CREATE TABLE distributed_table(value int);
|
||||||
SELECT create_distributed_table('distributed_table', 'value');
|
|
||||||
create_distributed_table
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE FUNCTION insert_42() RETURNS trigger AS $insert_42$
|
CREATE FUNCTION insert_42() RETURNS trigger AS $insert_42$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO distributed_table VALUES (42);
|
INSERT INTO distributed_table VALUES (42);
|
||||||
RETURN NEW;
|
RETURN NEW;
|
||||||
END;
|
END;
|
||||||
$insert_42$ LANGUAGE plpgsql;
|
$insert_42$ LANGUAGE plpgsql;
|
||||||
|
SELECT create_distributed_table('distributed_table', 'value');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
CREATE TRIGGER insert_42_trigger
|
CREATE TRIGGER insert_42_trigger
|
||||||
AFTER DELETE ON citus_local_table
|
AFTER DELETE ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
||||||
|
|
|
@ -321,6 +321,7 @@ $$;
|
||||||
-- Show that functions are propagated (or not) as a dependency
|
-- Show that functions are propagated (or not) as a dependency
|
||||||
-- Function as a default column
|
-- Function as a default column
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_def()
|
CREATE OR REPLACE FUNCTION func_in_transaction_def()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -329,7 +330,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -360,6 +360,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Multiple functions as a default column
|
-- Multiple functions as a default column
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_1()
|
CREATE OR REPLACE FUNCTION func_in_transaction_1()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -376,7 +377,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_1'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_1'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -434,6 +434,9 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
WARNING: "function func_in_transaction_3(non_dist_table)" has dependency to "table non_dist_table" that is not in Citus' metadata
|
||||||
|
DETAIL: "function func_in_transaction_3(non_dist_table)" will be created only locally
|
||||||
|
HINT: Distribute "table non_dist_table" first to distribute "function func_in_transaction_3(non_dist_table)"
|
||||||
CREATE TABLE table_to_prop_func_3(id int, col_1 int default func_in_transaction_3(NULL::non_dist_table));
|
CREATE TABLE table_to_prop_func_3(id int, col_1 int default func_in_transaction_3(NULL::non_dist_table));
|
||||||
-- It should error out as there is a non-distributed table dependency
|
-- It should error out as there is a non-distributed table dependency
|
||||||
SELECT create_distributed_table('table_to_prop_func_3','id');
|
SELECT create_distributed_table('table_to_prop_func_3','id');
|
||||||
|
@ -443,12 +446,7 @@ COMMIT;
|
||||||
-- Adding a column with default value should propagate the function
|
-- Adding a column with default value should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE table_to_prop_func_4(id int);
|
CREATE TABLE table_to_prop_func_4(id int);
|
||||||
SELECT create_distributed_table('table_to_prop_func_4', 'id');
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
create_distributed_table
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_4()
|
CREATE OR REPLACE FUNCTION func_in_transaction_4()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -457,7 +455,12 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Function shouldn't be propagated within transaction
|
SELECT create_distributed_table('table_to_prop_func_4', 'id');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_4'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_4'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -483,6 +486,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
-- Adding a column with default function depending on non-distributable table should fail
|
-- Adding a column with default function depending on non-distributable table should fail
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE non_dist_table_for_function(id int);
|
CREATE TABLE non_dist_table_for_function(id int);
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_dist_func(col_1 non_dist_table_for_function)
|
CREATE OR REPLACE FUNCTION non_dist_func(col_1 non_dist_table_for_function)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -504,6 +508,7 @@ HINT: Distribute "table non_dist_table_for_function" first to distribute "table
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- Adding multiple columns with default values should propagate the function
|
-- Adding multiple columns with default values should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_5()
|
CREATE OR REPLACE FUNCTION func_in_transaction_5()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -520,7 +525,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_5'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_5'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -569,6 +573,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Adding a constraint with function check should propagate the function
|
-- Adding a constraint with function check should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_7(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_7(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -577,7 +582,6 @@ BEGIN;
|
||||||
return param_1 > 5;
|
return param_1 > 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_7'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_7'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -608,6 +612,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Adding a constraint with multiple functions check should propagate the function
|
-- Adding a constraint with multiple functions check should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_8(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_8(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -624,7 +629,6 @@ BEGIN;
|
||||||
return param_1 > 5;
|
return param_1 > 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_8'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_8'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -680,6 +684,7 @@ BEGIN;
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_10(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_10(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -688,7 +693,6 @@ BEGIN;
|
||||||
return param_1 > 5;
|
return param_1 > 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_10'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_10'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -722,6 +726,9 @@ BEGIN;
|
||||||
return param_1 > 5;
|
return param_1 > 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
WARNING: "function func_in_transaction_11(integer,local_table_for_const)" has dependency to "table local_table_for_const" that is not in Citus' metadata
|
||||||
|
DETAIL: "function func_in_transaction_11(integer,local_table_for_const)" will be created only locally
|
||||||
|
HINT: Distribute "table local_table_for_const" first to distribute "function func_in_transaction_11(integer,local_table_for_const)"
|
||||||
CREATE TABLE table_to_prop_func_9(id int, col_1 int check (func_in_transaction_11(col_1, NULL::local_table_for_const)));
|
CREATE TABLE table_to_prop_func_9(id int, col_1 int check (func_in_transaction_11(col_1, NULL::local_table_for_const)));
|
||||||
-- It should error out since there is non-distributed table dependency exists
|
-- It should error out since there is non-distributed table dependency exists
|
||||||
SELECT create_distributed_table('table_to_prop_func_9', 'id');
|
SELECT create_distributed_table('table_to_prop_func_9', 'id');
|
||||||
|
@ -730,6 +737,7 @@ HINT: Distribute "table local_table_for_const" first to distribute "table table
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- Show that function as a part of generated always is supporte
|
-- Show that function as a part of generated always is supporte
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_sense_func_for_generated_always()
|
CREATE OR REPLACE FUNCTION non_sense_func_for_generated_always()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -738,7 +746,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_generated_always'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_generated_always'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -764,6 +771,7 @@ BEGIN;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- Show that functions depending table via rule are also distributed
|
-- Show that functions depending table via rule are also distributed
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_for_rule()
|
CREATE OR REPLACE FUNCTION func_for_rule()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql STABLE AS
|
LANGUAGE plpgsql STABLE AS
|
||||||
|
@ -772,7 +780,7 @@ BEGIN;
|
||||||
return 4;
|
return 4;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
RESET citus.create_object_propagation;
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_rule'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_rule'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -805,6 +813,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Show that functions as partitioning functions are supported
|
-- Show that functions as partitioning functions are supported
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_sense_func_for_partitioning(int)
|
CREATE OR REPLACE FUNCTION non_sense_func_for_partitioning(int)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -813,7 +822,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_partitioning'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_partitioning'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -844,6 +852,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Test function dependency on citus local table
|
-- Test function dependency on citus local table
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_for_local_table()
|
CREATE OR REPLACE FUNCTION func_in_transaction_for_local_table()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -852,7 +861,6 @@ BEGIN;
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_for_local_table'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_for_local_table'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -882,6 +890,7 @@ NOTICE: localhost:xxxxx is the coordinator and already contains metadata, skipp
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- Show that having a function dependency on exlude also works
|
-- Show that having a function dependency on exlude also works
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION exclude_bool_func()
|
CREATE OR REPLACE FUNCTION exclude_bool_func()
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -890,7 +899,6 @@ BEGIN;
|
||||||
return true;
|
return true;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.exclude_bool_func'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.exclude_bool_func'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -921,6 +929,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Show that having a function dependency for index also works
|
-- Show that having a function dependency for index also works
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_for_index_predicate(col_1 int)
|
CREATE OR REPLACE FUNCTION func_for_index_predicate(col_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -929,7 +938,6 @@ BEGIN;
|
||||||
return col_1 > 5;
|
return col_1 > 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_index_predicate'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_index_predicate'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -978,6 +986,9 @@ BEGIN;
|
||||||
return 5;
|
return 5;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
WARNING: "function func_for_func_dep_2(func_dep_table)" has dependency to "table func_dep_table" that is not in Citus' metadata
|
||||||
|
DETAIL: "function func_for_func_dep_2(func_dep_table)" will be created only locally
|
||||||
|
HINT: Distribute "table func_dep_table" first to distribute "function func_for_func_dep_2(func_dep_table)"
|
||||||
SELECT create_distributed_table('func_dep_table', 'a');
|
SELECT create_distributed_table('func_dep_table', 'a');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1002,6 +1013,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Test function with SQL language and sequence dependency
|
-- Test function with SQL language and sequence dependency
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_def_with_seq(val bigint)
|
CREATE OR REPLACE FUNCTION func_in_transaction_def_with_seq(val bigint)
|
||||||
RETURNS bigint
|
RETURNS bigint
|
||||||
LANGUAGE SQL AS
|
LANGUAGE SQL AS
|
||||||
|
@ -1014,7 +1026,6 @@ BEGIN;
|
||||||
$$
|
$$
|
||||||
SELECT func_in_transaction_def_with_seq(val);
|
SELECT func_in_transaction_def_with_seq(val);
|
||||||
$$;
|
$$;
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def_with_seq'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def_with_seq'::regproc::oid;
|
||||||
pg_identify_object_as_address
|
pg_identify_object_as_address
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -694,6 +694,7 @@ BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||||
|
|
||||||
SET application_name to 'citus_internal gpid=10000000001';
|
SET application_name to 'citus_internal gpid=10000000001';
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
|
SET citus.enable_ddl_propagation TO OFF;
|
||||||
CREATE FUNCTION distribution_test_function(int) RETURNS int
|
CREATE FUNCTION distribution_test_function(int) RETURNS int
|
||||||
AS $$ SELECT $1 $$
|
AS $$ SELECT $1 $$
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
|
|
|
@ -233,22 +233,27 @@ SET search_path TO shard_move_deferred_delete;
|
||||||
SELECT master_move_shard_placement(20000001, 'localhost', :worker_2_port, 'localhost', :worker_1_port);
|
SELECT master_move_shard_placement(20000001, 'localhost', :worker_2_port, 'localhost', :worker_1_port);
|
||||||
ERROR: not enough empty space on node if the shard is moved, actual available space after move will be 108 bytes, desired available space after move is 850 bytes,estimated size increase on node after move is 8192 bytes.
|
ERROR: not enough empty space on node if the shard is moved, actual available space after move will be 108 bytes, desired available space after move is 850 bytes,estimated size increase on node after move is 8192 bytes.
|
||||||
HINT: consider lowering citus.desired_percent_disk_available_after_move.
|
HINT: consider lowering citus.desired_percent_disk_available_after_move.
|
||||||
-- Restore the original function
|
-- Restore the original function on workers
|
||||||
SELECT run_command_on_workers($cmd$
|
\c - - - :worker_1_port
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
OUT available_disk_size bigint,
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
||||||
OUT total_disk_size bigint)
|
OUT available_disk_size bigint,
|
||||||
RETURNS record
|
OUT total_disk_size bigint)
|
||||||
LANGUAGE C STRICT
|
RETURNS record
|
||||||
AS 'citus', $$citus_local_disk_space_stats$$;
|
LANGUAGE C STRICT
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
AS 'citus', $$citus_local_disk_space_stats$$;
|
||||||
IS 'returns statistics on available disk space on the local node';
|
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
||||||
$cmd$);
|
IS 'returns statistics on available disk space on the local node';
|
||||||
run_command_on_workers
|
\c - - - :worker_2_port
|
||||||
---------------------------------------------------------------------
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
(localhost,57637,t,"CREATE FUNCTION")
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
||||||
(localhost,57638,t,"CREATE FUNCTION")
|
OUT available_disk_size bigint,
|
||||||
(2 rows)
|
OUT total_disk_size bigint)
|
||||||
|
RETURNS record
|
||||||
|
LANGUAGE C STRICT
|
||||||
|
AS 'citus', $$citus_local_disk_space_stats$$;
|
||||||
|
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
||||||
|
IS 'returns statistics on available disk space on the local node';
|
||||||
|
\c - - - :master_port
|
||||||
DROP SCHEMA shard_move_deferred_delete CASCADE;
|
DROP SCHEMA shard_move_deferred_delete CASCADE;
|
||||||
NOTICE: drop cascades to table t1
|
NOTICE: drop cascades to table shard_move_deferred_delete.t1
|
||||||
|
|
|
@ -12,6 +12,7 @@ SET citus.shard_count TO 4;
|
||||||
create schema test_tableam;
|
create schema test_tableam;
|
||||||
set search_path to test_tableam;
|
set search_path to test_tableam;
|
||||||
SELECT public.run_command_on_coordinator_and_workers($Q$
|
SELECT public.run_command_on_coordinator_and_workers($Q$
|
||||||
|
SET citus.enable_ddl_propagation TO off;
|
||||||
CREATE FUNCTION fake_am_handler(internal)
|
CREATE FUNCTION fake_am_handler(internal)
|
||||||
RETURNS table_am_handler
|
RETURNS table_am_handler
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
|
@ -26,8 +27,6 @@ $Q$);
|
||||||
-- Since Citus assumes access methods are part of the extension, make fake_am
|
-- Since Citus assumes access methods are part of the extension, make fake_am
|
||||||
-- owned manually to be able to pass checks on Citus while distributing tables.
|
-- owned manually to be able to pass checks on Citus while distributing tables.
|
||||||
ALTER EXTENSION citus ADD ACCESS METHOD fake_am;
|
ALTER EXTENSION citus ADD ACCESS METHOD fake_am;
|
||||||
NOTICE: Citus does not propagate adding/dropping member objects
|
|
||||||
HINT: You can add/drop the member objects on the workers as well.
|
|
||||||
--
|
--
|
||||||
-- Hash distributed table using a non-default table access method
|
-- Hash distributed table using a non-default table access method
|
||||||
--
|
--
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
setup
|
setup
|
||||||
{
|
{
|
||||||
|
SET citus.enable_metadata_sync TO off;
|
||||||
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
|
@ -17,6 +18,7 @@ setup
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
AS 'citus', $$stop_session_level_connection_to_node$$;
|
AS 'citus', $$stop_session_level_connection_to_node$$;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT citus_internal.replace_isolation_tester_func();
|
SELECT citus_internal.replace_isolation_tester_func();
|
||||||
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// so setting the corresponding shard here is useful
|
// so setting the corresponding shard here is useful
|
||||||
setup
|
setup
|
||||||
{
|
{
|
||||||
|
SET citus.enable_ddl_propagation TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
|
@ -16,6 +17,7 @@ setup
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
AS 'citus', $$stop_session_level_connection_to_node$$;
|
AS 'citus', $$stop_session_level_connection_to_node$$;
|
||||||
|
RESET citus.enable_ddl_propagation;
|
||||||
|
|
||||||
SELECT citus_internal.replace_isolation_tester_func();
|
SELECT citus_internal.replace_isolation_tester_func();
|
||||||
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
||||||
|
|
|
@ -6,12 +6,14 @@ setup
|
||||||
SELECT create_distributed_table('distributed_table', 'x');
|
SELECT create_distributed_table('distributed_table', 'x');
|
||||||
INSERT INTO distributed_table VALUES (1,0);
|
INSERT INTO distributed_table VALUES (1,0);
|
||||||
|
|
||||||
|
SET citus.enable_ddl_propagation TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION get_adjacency_list_wait_graph(OUT transactionNumber int, OUT waitingTransactionNumbers cstring)
|
CREATE OR REPLACE FUNCTION get_adjacency_list_wait_graph(OUT transactionNumber int, OUT waitingTransactionNumbers cstring)
|
||||||
RETURNS SETOF RECORD
|
RETURNS SETOF RECORD
|
||||||
LANGUAGE C STRICT
|
LANGUAGE C STRICT
|
||||||
AS 'citus', $$get_adjacency_list_wait_graph$$;
|
AS 'citus', $$get_adjacency_list_wait_graph$$;
|
||||||
COMMENT ON FUNCTION get_adjacency_list_wait_graph(OUT transactionNumber int, OUT waitingTransactionNumbers cstring)
|
COMMENT ON FUNCTION get_adjacency_list_wait_graph(OUT transactionNumber int, OUT waitingTransactionNumbers cstring)
|
||||||
IS 'returns flattened wait graph';
|
IS 'returns flattened wait graph';
|
||||||
|
RESET citus.enable_ddl_propagation;
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown
|
teardown
|
||||||
|
|
|
@ -11,10 +11,12 @@ setup
|
||||||
GRANT USAGE ON SCHEMA public TO my_user;
|
GRANT USAGE ON SCHEMA public TO my_user;
|
||||||
GRANT SELECT ON TABLE my_table TO my_user;
|
GRANT SELECT ON TABLE my_table TO my_user;
|
||||||
|
|
||||||
|
SET citus.enable_ddl_propagation TO OFF;
|
||||||
CREATE FUNCTION make_external_connection_to_node(text,int,text,text)
|
CREATE FUNCTION make_external_connection_to_node(text,int,text,text)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
RESET citus.enable_ddl_propagation;
|
||||||
|
|
||||||
SELECT run_command_on_workers('ALTER SYSTEM SET citus.max_client_connections TO 1');
|
SELECT run_command_on_workers('ALTER SYSTEM SET citus.max_client_connections TO 1');
|
||||||
SELECT run_command_on_workers('SELECT pg_reload_conf()');
|
SELECT run_command_on_workers('SELECT pg_reload_conf()');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// ready for testing MX functionalities.
|
// ready for testing MX functionalities.
|
||||||
setup
|
setup
|
||||||
{
|
{
|
||||||
|
SET citus.enable_metadata_sync TO off;
|
||||||
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
CREATE OR REPLACE FUNCTION start_session_level_connection_to_node(text, integer)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
|
@ -26,6 +27,7 @@ setup
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT VOLATILE
|
LANGUAGE C STRICT VOLATILE
|
||||||
AS 'citus', $$stop_session_level_connection_to_node$$;
|
AS 'citus', $$stop_session_level_connection_to_node$$;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT citus_internal.replace_isolation_tester_func();
|
SELECT citus_internal.replace_isolation_tester_func();
|
||||||
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
SELECT citus_internal.refresh_isolation_tester_prepared_statement();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// so setting the corresponding shard here is useful
|
// so setting the corresponding shard here is useful
|
||||||
setup
|
setup
|
||||||
{
|
{
|
||||||
|
SET citus.enable_metadata_sync TO off;
|
||||||
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
|
CREATE OR REPLACE FUNCTION run_try_drop_marked_shards()
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
|
@ -31,6 +31,7 @@ CREATE OR REPLACE PROCEDURE isolation_cleanup_orphaned_shards()
|
||||||
AS 'citus', $$isolation_cleanup_orphaned_shards$$;
|
AS 'citus', $$isolation_cleanup_orphaned_shards$$;
|
||||||
COMMENT ON PROCEDURE isolation_cleanup_orphaned_shards()
|
COMMENT ON PROCEDURE isolation_cleanup_orphaned_shards()
|
||||||
IS 'cleanup orphaned shards';
|
IS 'cleanup orphaned shards';
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SET citus.next_shard_id to 120000;
|
SET citus.next_shard_id to 120000;
|
||||||
SET citus.shard_count TO 8;
|
SET citus.shard_count TO 8;
|
||||||
|
|
|
@ -27,7 +27,6 @@ ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value)
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE distributed_table(value int);
|
CREATE TABLE distributed_table(value int);
|
||||||
SELECT create_distributed_table('distributed_table', 'value');
|
|
||||||
CREATE FUNCTION insert_42() RETURNS trigger AS $insert_42$
|
CREATE FUNCTION insert_42() RETURNS trigger AS $insert_42$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO distributed_table VALUES (42);
|
INSERT INTO distributed_table VALUES (42);
|
||||||
|
@ -35,6 +34,8 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$insert_42$ LANGUAGE plpgsql;
|
$insert_42$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
SELECT create_distributed_table('distributed_table', 'value');
|
||||||
|
|
||||||
CREATE TRIGGER insert_42_trigger
|
CREATE TRIGGER insert_42_trigger
|
||||||
AFTER DELETE ON citus_local_table
|
AFTER DELETE ON citus_local_table
|
||||||
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
FOR EACH ROW EXECUTE FUNCTION insert_42();
|
||||||
|
|
|
@ -192,6 +192,7 @@ $$;
|
||||||
|
|
||||||
-- Function as a default column
|
-- Function as a default column
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_def()
|
CREATE OR REPLACE FUNCTION func_in_transaction_def()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -201,7 +202,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE table_to_prop_func(id int, col_1 int default func_in_transaction_def());
|
CREATE TABLE table_to_prop_func(id int, col_1 int default func_in_transaction_def());
|
||||||
|
@ -217,6 +217,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Multiple functions as a default column
|
-- Multiple functions as a default column
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_1()
|
CREATE OR REPLACE FUNCTION func_in_transaction_1()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -235,7 +236,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_1'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_1'::regproc::oid;
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_2'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_2'::regproc::oid;
|
||||||
|
|
||||||
|
@ -275,8 +275,8 @@ COMMIT;
|
||||||
-- Adding a column with default value should propagate the function
|
-- Adding a column with default value should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE table_to_prop_func_4(id int);
|
CREATE TABLE table_to_prop_func_4(id int);
|
||||||
SELECT create_distributed_table('table_to_prop_func_4', 'id');
|
|
||||||
|
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_4()
|
CREATE OR REPLACE FUNCTION func_in_transaction_4()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -286,7 +286,8 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Function shouldn't be propagated within transaction
|
SELECT create_distributed_table('table_to_prop_func_4', 'id');
|
||||||
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_4'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_4'::regproc::oid;
|
||||||
|
|
||||||
ALTER TABLE table_to_prop_func_4 ADD COLUMN col_1 int default function_propagation_schema.func_in_transaction_4();
|
ALTER TABLE table_to_prop_func_4 ADD COLUMN col_1 int default function_propagation_schema.func_in_transaction_4();
|
||||||
|
@ -303,6 +304,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE non_dist_table_for_function(id int);
|
CREATE TABLE non_dist_table_for_function(id int);
|
||||||
|
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_dist_func(col_1 non_dist_table_for_function)
|
CREATE OR REPLACE FUNCTION non_dist_func(col_1 non_dist_table_for_function)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -322,6 +324,7 @@ ROLLBACK;
|
||||||
|
|
||||||
-- Adding multiple columns with default values should propagate the function
|
-- Adding multiple columns with default values should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_5()
|
CREATE OR REPLACE FUNCTION func_in_transaction_5()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -340,8 +343,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_5'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_5'::regproc::oid;
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_6'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_6'::regproc::oid;
|
||||||
|
|
||||||
|
@ -359,6 +360,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Adding a constraint with function check should propagate the function
|
-- Adding a constraint with function check should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_7(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_7(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -368,7 +370,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_7'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_7'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE table_to_prop_func_6(id int, col_1 int check (function_propagation_schema.func_in_transaction_7(col_1)));
|
CREATE TABLE table_to_prop_func_6(id int, col_1 int check (function_propagation_schema.func_in_transaction_7(col_1)));
|
||||||
|
@ -384,6 +385,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Adding a constraint with multiple functions check should propagate the function
|
-- Adding a constraint with multiple functions check should propagate the function
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_8(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_8(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -402,7 +404,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_8'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_8'::regproc::oid;
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_9'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_9'::regproc::oid;
|
||||||
|
|
||||||
|
@ -424,6 +425,7 @@ BEGIN;
|
||||||
CREATE TABLE table_to_prop_func_8(id int, col_1 int);
|
CREATE TABLE table_to_prop_func_8(id int, col_1 int);
|
||||||
SELECT create_distributed_table('table_to_prop_func_8', 'id');
|
SELECT create_distributed_table('table_to_prop_func_8', 'id');
|
||||||
|
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_10(param_1 int)
|
CREATE OR REPLACE FUNCTION func_in_transaction_10(param_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -433,7 +435,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_10'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_10'::regproc::oid;
|
||||||
|
|
||||||
ALTER TABLE table_to_prop_func_8 ADD CONSTRAINT col1_check CHECK (function_propagation_schema.func_in_transaction_10(col_1));
|
ALTER TABLE table_to_prop_func_8 ADD CONSTRAINT col1_check CHECK (function_propagation_schema.func_in_transaction_10(col_1));
|
||||||
|
@ -468,7 +469,7 @@ COMMIT;
|
||||||
|
|
||||||
-- Show that function as a part of generated always is supporte
|
-- Show that function as a part of generated always is supporte
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_sense_func_for_generated_always()
|
CREATE OR REPLACE FUNCTION non_sense_func_for_generated_always()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -478,7 +479,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_generated_always'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_generated_always'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE people (
|
CREATE TABLE people (
|
||||||
|
@ -495,6 +495,7 @@ COMMIT;
|
||||||
|
|
||||||
-- Show that functions depending table via rule are also distributed
|
-- Show that functions depending table via rule are also distributed
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_for_rule()
|
CREATE OR REPLACE FUNCTION func_for_rule()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql STABLE AS
|
LANGUAGE plpgsql STABLE AS
|
||||||
|
@ -503,8 +504,8 @@ BEGIN;
|
||||||
return 4;
|
return 4;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
RESET citus.create_object_propagation;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_rule'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_rule'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE table_1_for_rule(id int, col_1 int);
|
CREATE TABLE table_1_for_rule(id int, col_1 int);
|
||||||
|
@ -524,7 +525,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Show that functions as partitioning functions are supported
|
-- Show that functions as partitioning functions are supported
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION non_sense_func_for_partitioning(int)
|
CREATE OR REPLACE FUNCTION non_sense_func_for_partitioning(int)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -534,7 +535,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_partitioning'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.non_sense_func_for_partitioning'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE partitioned_table_to_test_func_prop(id INT, a INT) PARTITION BY RANGE (non_sense_func_for_partitioning(id));
|
CREATE TABLE partitioned_table_to_test_func_prop(id INT, a INT) PARTITION BY RANGE (non_sense_func_for_partitioning(id));
|
||||||
|
@ -551,6 +551,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Test function dependency on citus local table
|
-- Test function dependency on citus local table
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_for_local_table()
|
CREATE OR REPLACE FUNCTION func_in_transaction_for_local_table()
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -560,7 +561,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_for_local_table'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_for_local_table'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE citus_local_table_to_test_func(l1 int DEFAULT func_in_transaction_for_local_table());
|
CREATE TABLE citus_local_table_to_test_func(l1 int DEFAULT func_in_transaction_for_local_table());
|
||||||
|
@ -573,6 +573,7 @@ ROLLBACK;
|
||||||
|
|
||||||
-- Show that having a function dependency on exlude also works
|
-- Show that having a function dependency on exlude also works
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION exclude_bool_func()
|
CREATE OR REPLACE FUNCTION exclude_bool_func()
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -582,7 +583,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.exclude_bool_func'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.exclude_bool_func'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE exclusion_func_prop_table (id int, EXCLUDE USING btree (id WITH =) WHERE (exclude_bool_func()));
|
CREATE TABLE exclusion_func_prop_table (id int, EXCLUDE USING btree (id WITH =) WHERE (exclude_bool_func()));
|
||||||
|
@ -598,6 +598,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Show that having a function dependency for index also works
|
-- Show that having a function dependency for index also works
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_for_index_predicate(col_1 int)
|
CREATE OR REPLACE FUNCTION func_for_index_predicate(col_1 int)
|
||||||
RETURNS boolean
|
RETURNS boolean
|
||||||
LANGUAGE plpgsql IMMUTABLE AS
|
LANGUAGE plpgsql IMMUTABLE AS
|
||||||
|
@ -607,7 +608,6 @@ BEGIN;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Functions shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_index_predicate'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_for_index_predicate'::regproc::oid;
|
||||||
|
|
||||||
CREATE TABLE table_to_check_func_index_dep (id int, col_2 int);
|
CREATE TABLE table_to_check_func_index_dep (id int, col_2 int);
|
||||||
|
@ -657,6 +657,7 @@ SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(clas
|
||||||
|
|
||||||
-- Test function with SQL language and sequence dependency
|
-- Test function with SQL language and sequence dependency
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
SET LOCAL citus.create_object_propagation TO deferred;
|
||||||
CREATE OR REPLACE FUNCTION func_in_transaction_def_with_seq(val bigint)
|
CREATE OR REPLACE FUNCTION func_in_transaction_def_with_seq(val bigint)
|
||||||
RETURNS bigint
|
RETURNS bigint
|
||||||
LANGUAGE SQL AS
|
LANGUAGE SQL AS
|
||||||
|
@ -671,7 +672,6 @@ BEGIN;
|
||||||
SELECT func_in_transaction_def_with_seq(val);
|
SELECT func_in_transaction_def_with_seq(val);
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Function shouldn't be propagated within transaction
|
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def_with_seq'::regproc::oid;
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object where objid = 'function_propagation_schema.func_in_transaction_def_with_seq'::regproc::oid;
|
||||||
|
|
||||||
CREATE SEQUENCE myseq;
|
CREATE SEQUENCE myseq;
|
||||||
|
|
|
@ -424,6 +424,7 @@ BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||||
SET application_name to 'citus_internal gpid=10000000001';
|
SET application_name to 'citus_internal gpid=10000000001';
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
|
|
||||||
|
SET citus.enable_ddl_propagation TO OFF;
|
||||||
CREATE FUNCTION distribution_test_function(int) RETURNS int
|
CREATE FUNCTION distribution_test_function(int) RETURNS int
|
||||||
AS $$ SELECT $1 $$
|
AS $$ SELECT $1 $$
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
|
|
|
@ -167,17 +167,30 @@ SET search_path TO shard_move_deferred_delete;
|
||||||
-- When there would not be enough free space left after the move, the move should fail
|
-- When there would not be enough free space left after the move, the move should fail
|
||||||
SELECT master_move_shard_placement(20000001, 'localhost', :worker_2_port, 'localhost', :worker_1_port);
|
SELECT master_move_shard_placement(20000001, 'localhost', :worker_2_port, 'localhost', :worker_1_port);
|
||||||
|
|
||||||
-- Restore the original function
|
-- Restore the original function on workers
|
||||||
SELECT run_command_on_workers($cmd$
|
\c - - - :worker_1_port
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
OUT available_disk_size bigint,
|
|
||||||
OUT total_disk_size bigint)
|
|
||||||
RETURNS record
|
|
||||||
LANGUAGE C STRICT
|
|
||||||
AS 'citus', $$citus_local_disk_space_stats$$;
|
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
|
||||||
IS 'returns statistics on available disk space on the local node';
|
|
||||||
$cmd$);
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
||||||
|
OUT available_disk_size bigint,
|
||||||
|
OUT total_disk_size bigint)
|
||||||
|
RETURNS record
|
||||||
|
LANGUAGE C STRICT
|
||||||
|
AS 'citus', $$citus_local_disk_space_stats$$;
|
||||||
|
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
||||||
|
IS 'returns statistics on available disk space on the local node';
|
||||||
|
|
||||||
|
\c - - - :worker_2_port
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_local_disk_space_stats(
|
||||||
|
OUT available_disk_size bigint,
|
||||||
|
OUT total_disk_size bigint)
|
||||||
|
RETURNS record
|
||||||
|
LANGUAGE C STRICT
|
||||||
|
AS 'citus', $$citus_local_disk_space_stats$$;
|
||||||
|
COMMENT ON FUNCTION pg_catalog.citus_local_disk_space_stats()
|
||||||
|
IS 'returns statistics on available disk space on the local node';
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
DROP SCHEMA shard_move_deferred_delete CASCADE;
|
DROP SCHEMA shard_move_deferred_delete CASCADE;
|
||||||
|
|
|
@ -15,6 +15,7 @@ create schema test_tableam;
|
||||||
set search_path to test_tableam;
|
set search_path to test_tableam;
|
||||||
|
|
||||||
SELECT public.run_command_on_coordinator_and_workers($Q$
|
SELECT public.run_command_on_coordinator_and_workers($Q$
|
||||||
|
SET citus.enable_ddl_propagation TO off;
|
||||||
CREATE FUNCTION fake_am_handler(internal)
|
CREATE FUNCTION fake_am_handler(internal)
|
||||||
RETURNS table_am_handler
|
RETURNS table_am_handler
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
|
|
Loading…
Reference in New Issue