mirror of https://github.com/citusdata/citus.git
Fix mx tests
parent
814e1a95de
commit
cb4e53ad6e
|
@ -58,6 +58,7 @@ CREATE TABLE postgres_local_table(a int, b int);
|
|||
-- We shouldn't use LIMIT in INSERT SELECT queries to make the test faster as
|
||||
-- LIMIT would force planner to wrap SELECT query in an intermediate result and
|
||||
-- this might reduce the coverage of the test cases.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||
BEGIN
|
||||
SET client_min_messages to ERROR;
|
||||
|
@ -74,6 +75,7 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
|||
RESET client_min_messages;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
---------------------------------------------------------------------
|
||||
---- SELECT ----
|
||||
---------------------------------------------------------------------
|
||||
|
|
|
@ -523,6 +523,7 @@ BEGIN
|
|||
RETURN trunc(random() * (end_int-start_int) + start_int);
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql' STRICT;
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE coordinator_evaluation.test_procedure(int)
|
||||
LANGUAGE plpgsql
|
||||
AS $procedure$
|
||||
|
@ -532,6 +533,7 @@ BEGIN
|
|||
PERFORM DISTINCT value FROM coordinator_evaluation_table_2 WHERE key = filterKey;
|
||||
END;
|
||||
$procedure$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- we couldn't find a meaningful query to write for this
|
||||
-- however this query fails before https://github.com/citusdata/citus/pull/3454
|
||||
SET client_min_messages TO DEBUG2;
|
||||
|
|
|
@ -62,6 +62,7 @@ SET citus.log_local_commands TO ON;
|
|||
-- returns true of the distribution key filter
|
||||
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
||||
-- placement which is local to this not
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
||||
|
||||
DECLARE shard_is_local BOOLEAN := FALSE;
|
||||
|
@ -84,6 +85,7 @@ CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) R
|
|||
RETURN shard_is_local;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- pick some example values that reside on the shards locally and remote
|
||||
-- distribution key values of 1,6, 500 and 701 are LOCAL to shards,
|
||||
-- we'll use these values in the tests
|
||||
|
|
|
@ -94,6 +94,7 @@ SET search_path TO local_shard_execution;
|
|||
-- returns true of the distribution key filter
|
||||
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
||||
-- placement which is local to this not
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
||||
|
||||
DECLARE shard_is_local BOOLEAN := FALSE;
|
||||
|
@ -116,6 +117,7 @@ CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) R
|
|||
RETURN shard_is_local;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- test case for issue #3556
|
||||
SET citus.log_intermediate_results TO TRUE;
|
||||
SET client_min_messages TO DEBUG1;
|
||||
|
@ -801,6 +803,7 @@ BEGIN;
|
|||
ERROR: VACUUM cannot run inside a transaction block
|
||||
ROLLBACK;
|
||||
-- make sure that functions can use local execution
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE only_local_execution() AS $$
|
||||
DECLARE cnt INT;
|
||||
BEGIN
|
||||
|
@ -896,6 +899,7 @@ CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
|
|||
SELECT count(*) INTO cnt FROM distributed_table;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
CALL local_execution_followed_by_dist();
|
||||
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1, '11'::text, 21) ON CONFLICT(key) DO UPDATE SET value = '29'::text
|
||||
CONTEXT: SQL statement "INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29'"
|
||||
|
|
|
@ -770,6 +770,7 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution_replic
|
|||
ERROR: VACUUM cannot run inside a transaction block
|
||||
ROLLBACK;
|
||||
-- make sure that functions can use local execution
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE only_local_execution() AS $$
|
||||
DECLARE cnt INT;
|
||||
BEGIN
|
||||
|
@ -865,6 +866,7 @@ CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
|
|||
SELECT count(*) INTO cnt FROM distributed_table;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
CALL local_execution_followed_by_dist();
|
||||
NOTICE: executing the command locally: INSERT INTO local_shard_execution_replicated.distributed_table_1500001 AS citus_table_alias (key, value, age) VALUES (1, '11'::text, 21) ON CONFLICT(key) DO UPDATE SET value = '29'::text
|
||||
CONTEXT: SQL statement "INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29'"
|
||||
|
|
|
@ -948,6 +948,7 @@ BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|||
ERROR: Node with group id 123123123 for shard placement xxxxx does not exist
|
||||
ROLLBACK;
|
||||
-- create a volatile function that returns the local node id
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION get_node_id()
|
||||
RETURNS INT AS $$
|
||||
DECLARE localGroupId int;
|
||||
|
@ -960,6 +961,7 @@ BEGIN
|
|||
nodeport = 57637 AND nodename = 'localhost' AND isactive AND nodecluster = 'default';
|
||||
RETURN localGroupId;
|
||||
END; $$ language plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- fails because we ingest more placements for the same shards to the same worker node
|
||||
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
SELECT assign_distributed_transaction_id(0, 8, '2021-07-09 15:41:55.542377+02');
|
||||
|
|
|
@ -140,8 +140,6 @@ BEGIN
|
|||
END;
|
||||
$$;
|
||||
SELECT create_distributed_function('my_group_id()', colocate_with := 'ref');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -402,6 +402,7 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
-- Test that we handle transactional constructs correctly inside a procedure
|
||||
-- that is routed to the workers.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE PROCEDURE mx_call_proc_tx(x int) LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
INSERT INTO multi_mx_call.mx_call_dist_table_1 VALUES (x, -1), (x+1, 4);
|
||||
|
@ -411,12 +412,11 @@ BEGIN
|
|||
-- Now do the final update!
|
||||
UPDATE multi_mx_call.mx_call_dist_table_1 SET val = val-1 WHERE id >= x;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- before distribution ...
|
||||
CALL multi_mx_call.mx_call_proc_tx(10);
|
||||
-- after distribution ...
|
||||
select create_distributed_function('mx_call_proc_tx(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -487,8 +487,6 @@ BEGIN
|
|||
RAISE EXCEPTION 'error';
|
||||
END;$$;
|
||||
select create_distributed_function('mx_call_proc_raise(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -553,8 +551,6 @@ SET client_min_messages TO DEBUG1;
|
|||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -402,6 +402,7 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
-- Test that we handle transactional constructs correctly inside a procedure
|
||||
-- that is routed to the workers.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE PROCEDURE mx_call_proc_tx(x int) LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
INSERT INTO multi_mx_call.mx_call_dist_table_1 VALUES (x, -1), (x+1, 4);
|
||||
|
@ -411,12 +412,11 @@ BEGIN
|
|||
-- Now do the final update!
|
||||
UPDATE multi_mx_call.mx_call_dist_table_1 SET val = val-1 WHERE id >= x;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- before distribution ...
|
||||
CALL multi_mx_call.mx_call_proc_tx(10);
|
||||
-- after distribution ...
|
||||
select create_distributed_function('mx_call_proc_tx(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -487,8 +487,6 @@ BEGIN
|
|||
RAISE EXCEPTION 'error';
|
||||
END;$$;
|
||||
select create_distributed_function('mx_call_proc_raise(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -553,8 +551,6 @@ SET client_min_messages TO DEBUG1;
|
|||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -66,30 +66,7 @@ HINT: Connect to the coordinator and run it again.
|
|||
-- create schema to test schema support
|
||||
CREATE SCHEMA citus_mx_test_schema_join_1;
|
||||
CREATE SCHEMA citus_mx_test_schema_join_2;
|
||||
-- create UDFs in worker node
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction2(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
CREATE FUNCTION public.immutable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ SELECT old_values || new_value $$ LANGUAGE SQL IMMUTABLE;
|
||||
-- create operator
|
||||
CREATE OPERATOR citus_mx_test_schema.=== (
|
||||
LEFTARG = int,
|
||||
|
@ -104,30 +81,7 @@ CREATE OPERATOR citus_mx_test_schema.=== (
|
|||
-- create schema to test schema support
|
||||
CREATE SCHEMA citus_mx_test_schema_join_1;
|
||||
CREATE SCHEMA citus_mx_test_schema_join_2;
|
||||
-- create UDF
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction2(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
CREATE FUNCTION public.immutable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ SELECT old_values || new_value $$ LANGUAGE SQL IMMUTABLE;
|
||||
-- create operator
|
||||
CREATE OPERATOR citus_mx_test_schema.=== (
|
||||
LEFTARG = int,
|
||||
|
|
|
@ -13,6 +13,7 @@ VACUUM ANALYZE customer_mx;
|
|||
VACUUM ANALYZE supplier_mx;
|
||||
\c - - - :worker_1_port
|
||||
-- Function that parses explain output as JSON
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION explain_json(query text)
|
||||
RETURNS jsonb
|
||||
AS $BODY$
|
||||
|
@ -36,6 +37,7 @@ END;
|
|||
$BODY$ LANGUAGE plpgsql;
|
||||
\c - - - :worker_2_port
|
||||
-- Function that parses explain output as JSON
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION explain_json(query text)
|
||||
RETURNS jsonb
|
||||
AS $BODY$
|
||||
|
@ -57,6 +59,7 @@ BEGIN
|
|||
RETURN result;
|
||||
END;
|
||||
$BODY$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- Test Text format
|
||||
EXPLAIN (COSTS FALSE, FORMAT TEXT)
|
||||
SELECT l_quantity, count(*) count_quantity FROM lineitem_mx
|
||||
|
|
|
@ -212,8 +212,6 @@ select colocate_proc_with_table('squares', 'mx_call_dist_table_2'::regclass, 0);
|
|||
|
||||
select create_distributed_function('mx_call_func_bigint(bigint,bigint)', 'x',
|
||||
colocate_with := 'mx_call_dist_table_bigint');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -223,8 +221,6 @@ DETAIL: A distributed function is created. To make sure subsequent commands see
|
|||
select create_distributed_function('mx_call_func_bigint_force(bigint,bigint)', 'x',
|
||||
colocate_with := 'mx_call_dist_table_2',
|
||||
force_delegation := true);
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -396,6 +392,7 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass
|
|||
(1 row)
|
||||
|
||||
-- Test table returning functions.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION mx_call_func_tbl(x int)
|
||||
RETURNS TABLE (p0 int, p1 int)
|
||||
LANGUAGE plpgsql AS $$
|
||||
|
@ -409,6 +406,7 @@ BEGIN
|
|||
WHERE id >= x
|
||||
ORDER BY 1, 2;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- before distribution ...
|
||||
select mx_call_func_tbl(10);
|
||||
mx_call_func_tbl
|
||||
|
@ -419,8 +417,6 @@ select mx_call_func_tbl(10);
|
|||
|
||||
-- after distribution ...
|
||||
select create_distributed_function('mx_call_func_tbl(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -442,8 +438,6 @@ BEGIN
|
|||
RAISE EXCEPTION 'error';
|
||||
END;$$;
|
||||
select create_distributed_function('mx_call_func_raise(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -594,8 +588,6 @@ SET citus.shard_replication_factor = 1;
|
|||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)', '$1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -212,8 +212,6 @@ select colocate_proc_with_table('squares', 'mx_call_dist_table_2'::regclass, 0);
|
|||
|
||||
select create_distributed_function('mx_call_func_bigint(bigint,bigint)', 'x',
|
||||
colocate_with := 'mx_call_dist_table_bigint');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -223,8 +221,6 @@ DETAIL: A distributed function is created. To make sure subsequent commands see
|
|||
select create_distributed_function('mx_call_func_bigint_force(bigint,bigint)', 'x',
|
||||
colocate_with := 'mx_call_dist_table_2',
|
||||
force_delegation := true);
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -396,6 +392,7 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass
|
|||
(1 row)
|
||||
|
||||
-- Test table returning functions.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION mx_call_func_tbl(x int)
|
||||
RETURNS TABLE (p0 int, p1 int)
|
||||
LANGUAGE plpgsql AS $$
|
||||
|
@ -409,6 +406,7 @@ BEGIN
|
|||
WHERE id >= x
|
||||
ORDER BY 1, 2;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- before distribution ...
|
||||
select mx_call_func_tbl(10);
|
||||
mx_call_func_tbl
|
||||
|
@ -419,8 +417,6 @@ select mx_call_func_tbl(10);
|
|||
|
||||
-- after distribution ...
|
||||
select create_distributed_function('mx_call_func_tbl(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -442,8 +438,6 @@ BEGIN
|
|||
RAISE EXCEPTION 'error';
|
||||
END;$$;
|
||||
select create_distributed_function('mx_call_func_raise(int)', '$1', 'mx_call_dist_table_1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -594,8 +588,6 @@ SET citus.shard_replication_factor = 1;
|
|||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)', '$1');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -344,16 +344,6 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx
|
|||
(3 rows)
|
||||
|
||||
\c - no_access_mx - :worker_1_port
|
||||
-- see the comment in the top of the file
|
||||
CREATE OR REPLACE FUNCTION raise_failed_aclcheck(query text) RETURNS void AS $$
|
||||
BEGIN
|
||||
EXECUTE query;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
IF SQLERRM LIKE 'must be owner of%' THEN
|
||||
RAISE 'must be owner of the object';
|
||||
END IF;
|
||||
END;
|
||||
$$LANGUAGE plpgsql;
|
||||
SELECT raise_failed_aclcheck($$
|
||||
DROP TABLE distributed_mx_table;
|
||||
$$);
|
||||
|
|
|
@ -266,6 +266,7 @@ UPDATE limit_orders_mx SET array_of_values = 1 || array_of_values WHERE id = 246
|
|||
-- immutable function calls with vars are also allowed
|
||||
UPDATE limit_orders_mx
|
||||
SET array_of_values = immutable_append_mx(array_of_values, 2) WHERE id = 246;
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION stable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ BEGIN RETURN old_values || new_value; END; $$
|
||||
LANGUAGE plpgsql STABLE;
|
||||
|
@ -282,6 +283,7 @@ SELECT array_of_values FROM limit_orders_mx WHERE id = 246;
|
|||
-- STRICT functions work as expected
|
||||
CREATE FUNCTION temp_strict_func(integer,integer) RETURNS integer AS
|
||||
'SELECT COALESCE($1, 2) + COALESCE($1, 3);' LANGUAGE SQL STABLE STRICT;
|
||||
RESET citus.enable_metadata_sync;
|
||||
UPDATE limit_orders_mx SET bidder_id = temp_strict_func(1, null) WHERE id = 246;
|
||||
ERROR: null value in column "bidder_id" violates not-null constraint
|
||||
SELECT array_of_values FROM limit_orders_mx WHERE id = 246;
|
||||
|
|
|
@ -227,6 +227,7 @@ SELECT * FROM objects_mx WHERE id = 1;
|
|||
|
||||
-- create trigger on one worker to reject certain values
|
||||
\c - - - :worker_1_port
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION reject_bad_mx() RETURNS trigger AS $rb$
|
||||
BEGIN
|
||||
IF (NEW.name = 'BAD') THEN
|
||||
|
@ -236,6 +237,7 @@ CREATE FUNCTION reject_bad_mx() RETURNS trigger AS $rb$
|
|||
RETURN NEW;
|
||||
END;
|
||||
$rb$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
CREATE CONSTRAINT TRIGGER reject_bad_mx
|
||||
AFTER INSERT ON objects_mx_1220103
|
||||
DEFERRABLE INITIALLY IMMEDIATE
|
||||
|
|
|
@ -829,10 +829,12 @@ SELECT master_update_node(nodeid, 'localhost', 12345) FROM pg_dist_node;
|
|||
|
||||
(1 row)
|
||||
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION trigger_metadata_sync()
|
||||
RETURNS void
|
||||
LANGUAGE C STRICT
|
||||
AS 'citus';
|
||||
RESET citus.enable_metadata_sync;
|
||||
SELECT trigger_metadata_sync();
|
||||
trigger_metadata_sync
|
||||
---------------------------------------------------------------------
|
||||
|
|
|
@ -52,13 +52,7 @@ CREATE TABLE repartition_udt_other (
|
|||
-- so that the OID is off.
|
||||
\c - - - :worker_1_port
|
||||
-- START type creation
|
||||
-- ... as well as a function to use as its comparator...
|
||||
CREATE FUNCTION equal_test_udt_function(test_udt, test_udt) RETURNS boolean
|
||||
AS 'select $1.i = $2.i AND $1.i2 = $2.i2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
-- ... use that function to create a custom equality operator...
|
||||
-- Use function to create a custom equality operator...
|
||||
CREATE OPERATOR = (
|
||||
LEFTARG = test_udt,
|
||||
RIGHTARG = test_udt,
|
||||
|
@ -68,13 +62,6 @@ CREATE OPERATOR = (
|
|||
);
|
||||
-- ... and create a custom operator family for hash indexes...
|
||||
CREATE OPERATOR FAMILY tudt_op_fam USING hash;
|
||||
-- ... create a test HASH function. Though it is a poor hash function,
|
||||
-- it is acceptable for our tests
|
||||
CREATE FUNCTION test_udt_hash(test_udt) RETURNS int
|
||||
AS 'SELECT hashtext( ($1.i + $1.i2)::text);'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
-- We need to define two different operator classes for the composite types
|
||||
-- One uses BTREE the other uses HASH
|
||||
CREATE OPERATOR CLASS tudt_op_fam_clas3
|
||||
|
@ -87,13 +74,7 @@ FUNCTION 1 test_udt_hash(test_udt);
|
|||
-- END type creation
|
||||
\c - - - :worker_2_port
|
||||
-- START type creation
|
||||
-- ... as well as a function to use as its comparator...
|
||||
CREATE FUNCTION equal_test_udt_function(test_udt, test_udt) RETURNS boolean
|
||||
AS 'select $1.i = $2.i AND $1.i2 = $2.i2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
-- ... use that function to create a custom equality operator...
|
||||
-- Use function to create a custom equality operator...
|
||||
CREATE OPERATOR = (
|
||||
LEFTARG = test_udt,
|
||||
RIGHTARG = test_udt,
|
||||
|
@ -103,13 +84,6 @@ CREATE OPERATOR = (
|
|||
);
|
||||
-- ... and create a custom operator family for hash indexes...
|
||||
CREATE OPERATOR FAMILY tudt_op_fam USING hash;
|
||||
-- ... create a test HASH function. Though it is a poor hash function,
|
||||
-- it is acceptable for our tests
|
||||
CREATE FUNCTION test_udt_hash(test_udt) RETURNS int
|
||||
AS 'SELECT hashtext( ($1.i + $1.i2)::text);'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
-- We need to define two different operator classes for the composite types
|
||||
-- One uses BTREE the other uses HASH
|
||||
CREATE OPERATOR CLASS tudt_op_fam_clas3
|
||||
|
|
|
@ -1363,6 +1363,7 @@ DEBUG: query has a single distribution column value: 1
|
|||
(5 rows)
|
||||
|
||||
-- queries inside plpgsql functions could be router plannable
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION author_articles_max_id() RETURNS int AS $$
|
||||
DECLARE
|
||||
max_id integer;
|
||||
|
@ -1418,6 +1419,7 @@ PL/pgSQL function author_articles_id_word_count() line XX at RETURN QUERY
|
|||
41 | 11814
|
||||
(5 rows)
|
||||
|
||||
RESET citus.enable_metadata_sync;
|
||||
-- materialized views can be created for router plannable queries
|
||||
CREATE MATERIALIZED VIEW mv_articles_hash_mx AS
|
||||
SELECT * FROM articles_hash_mx WHERE author_id = 1;
|
||||
|
|
|
@ -43,6 +43,7 @@ CREATE TABLE postgres_local_table(a int, b int);
|
|||
-- We shouldn't use LIMIT in INSERT SELECT queries to make the test faster as
|
||||
-- LIMIT would force planner to wrap SELECT query in an intermediate result and
|
||||
-- this might reduce the coverage of the test cases.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
||||
BEGIN
|
||||
SET client_min_messages to ERROR;
|
||||
|
@ -59,6 +60,7 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$
|
|||
RESET client_min_messages;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
----------------
|
||||
---- SELECT ----
|
||||
|
|
|
@ -165,6 +165,7 @@ BEGIN
|
|||
END;
|
||||
$$ LANGUAGE 'plpgsql' STRICT;
|
||||
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE coordinator_evaluation.test_procedure(int)
|
||||
LANGUAGE plpgsql
|
||||
AS $procedure$
|
||||
|
@ -174,6 +175,7 @@ BEGIN
|
|||
PERFORM DISTINCT value FROM coordinator_evaluation_table_2 WHERE key = filterKey;
|
||||
END;
|
||||
$procedure$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- we couldn't find a meaningful query to write for this
|
||||
-- however this query fails before https://github.com/citusdata/citus/pull/3454
|
||||
|
|
|
@ -48,6 +48,7 @@ SET citus.log_local_commands TO ON;
|
|||
-- returns true of the distribution key filter
|
||||
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
||||
-- placement which is local to this not
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
||||
|
||||
DECLARE shard_is_local BOOLEAN := FALSE;
|
||||
|
@ -70,6 +71,7 @@ CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) R
|
|||
RETURN shard_is_local;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- pick some example values that reside on the shards locally and remote
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ SET search_path TO local_shard_execution;
|
|||
-- returns true of the distribution key filter
|
||||
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
||||
-- placement which is local to this not
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
||||
|
||||
DECLARE shard_is_local BOOLEAN := FALSE;
|
||||
|
@ -93,6 +94,7 @@ CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) R
|
|||
RETURN shard_is_local;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- test case for issue #3556
|
||||
SET citus.log_intermediate_results TO TRUE;
|
||||
|
@ -418,6 +420,7 @@ BEGIN;
|
|||
ROLLBACK;
|
||||
|
||||
-- make sure that functions can use local execution
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE only_local_execution() AS $$
|
||||
DECLARE cnt INT;
|
||||
BEGIN
|
||||
|
@ -491,6 +494,7 @@ CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
|
|||
SELECT count(*) INTO cnt FROM distributed_table;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
CALL local_execution_followed_by_dist();
|
||||
|
||||
|
|
|
@ -384,6 +384,7 @@ BEGIN;
|
|||
ROLLBACK;
|
||||
|
||||
-- make sure that functions can use local execution
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE PROCEDURE only_local_execution() AS $$
|
||||
DECLARE cnt INT;
|
||||
BEGIN
|
||||
|
@ -457,6 +458,7 @@ CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
|
|||
SELECT count(*) INTO cnt FROM distributed_table;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
CALL local_execution_followed_by_dist();
|
||||
|
||||
|
|
|
@ -609,6 +609,7 @@ BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|||
ROLLBACK;
|
||||
|
||||
-- create a volatile function that returns the local node id
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION get_node_id()
|
||||
RETURNS INT AS $$
|
||||
DECLARE localGroupId int;
|
||||
|
@ -621,6 +622,7 @@ BEGIN
|
|||
nodeport = 57637 AND nodename = 'localhost' AND isactive AND nodecluster = 'default';
|
||||
RETURN localGroupId;
|
||||
END; $$ language plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- fails because we ingest more placements for the same shards to the same worker node
|
||||
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
|
|
|
@ -180,6 +180,7 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
-- Test that we handle transactional constructs correctly inside a procedure
|
||||
-- that is routed to the workers.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE PROCEDURE mx_call_proc_tx(x int) LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
INSERT INTO multi_mx_call.mx_call_dist_table_1 VALUES (x, -1), (x+1, 4);
|
||||
|
@ -189,6 +190,7 @@ BEGIN
|
|||
-- Now do the final update!
|
||||
UPDATE multi_mx_call.mx_call_dist_table_1 SET val = val-1 WHERE id >= x;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- before distribution ...
|
||||
CALL multi_mx_call.mx_call_proc_tx(10);
|
||||
|
|
|
@ -67,33 +67,7 @@ SELECT citus_add_local_table_to_metadata('citus_local_table');
|
|||
CREATE SCHEMA citus_mx_test_schema_join_1;
|
||||
CREATE SCHEMA citus_mx_test_schema_join_2;
|
||||
|
||||
-- create UDFs in worker node
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction2(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION public.immutable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ SELECT old_values || new_value $$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
-- create operator
|
||||
CREATE OPERATOR citus_mx_test_schema.=== (
|
||||
LEFTARG = int,
|
||||
|
@ -111,33 +85,7 @@ CREATE OPERATOR citus_mx_test_schema.=== (
|
|||
CREATE SCHEMA citus_mx_test_schema_join_1;
|
||||
CREATE SCHEMA citus_mx_test_schema_join_2;
|
||||
|
||||
|
||||
-- create UDF
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
CREATE OR REPLACE FUNCTION simpleTestFunction2(theValue integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
DECLARE
|
||||
strresult text;
|
||||
BEGIN
|
||||
RETURN theValue * 3 / 2 + 1;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION public.immutable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ SELECT old_values || new_value $$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
-- create operator
|
||||
CREATE OPERATOR citus_mx_test_schema.=== (
|
||||
|
|
|
@ -18,6 +18,7 @@ VACUUM ANALYZE supplier_mx;
|
|||
|
||||
\c - - - :worker_1_port
|
||||
-- Function that parses explain output as JSON
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION explain_json(query text)
|
||||
RETURNS jsonb
|
||||
AS $BODY$
|
||||
|
@ -43,6 +44,7 @@ $BODY$ LANGUAGE plpgsql;
|
|||
|
||||
\c - - - :worker_2_port
|
||||
-- Function that parses explain output as JSON
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION explain_json(query text)
|
||||
RETURNS jsonb
|
||||
AS $BODY$
|
||||
|
@ -65,6 +67,7 @@ BEGIN
|
|||
RETURN result;
|
||||
END;
|
||||
$BODY$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
|
||||
-- Test Text format
|
||||
|
|
|
@ -166,6 +166,7 @@ SET client_min_messages TO DEBUG1;
|
|||
select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass, 1);
|
||||
|
||||
-- Test table returning functions.
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION mx_call_func_tbl(x int)
|
||||
RETURNS TABLE (p0 int, p1 int)
|
||||
LANGUAGE plpgsql AS $$
|
||||
|
@ -179,6 +180,7 @@ BEGIN
|
|||
WHERE id >= x
|
||||
ORDER BY 1, 2;
|
||||
END;$$;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- before distribution ...
|
||||
select mx_call_func_tbl(10);
|
||||
|
|
|
@ -218,17 +218,6 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx
|
|||
|
||||
\c - no_access_mx - :worker_1_port
|
||||
|
||||
-- see the comment in the top of the file
|
||||
CREATE OR REPLACE FUNCTION raise_failed_aclcheck(query text) RETURNS void AS $$
|
||||
BEGIN
|
||||
EXECUTE query;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
IF SQLERRM LIKE 'must be owner of%' THEN
|
||||
RAISE 'must be owner of the object';
|
||||
END IF;
|
||||
END;
|
||||
$$LANGUAGE plpgsql;
|
||||
|
||||
SELECT raise_failed_aclcheck($$
|
||||
DROP TABLE distributed_mx_table;
|
||||
$$);
|
||||
|
|
|
@ -202,6 +202,7 @@ UPDATE limit_orders_mx SET array_of_values = 1 || array_of_values WHERE id = 246
|
|||
UPDATE limit_orders_mx
|
||||
SET array_of_values = immutable_append_mx(array_of_values, 2) WHERE id = 246;
|
||||
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION stable_append_mx(old_values int[], new_value int)
|
||||
RETURNS int[] AS $$ BEGIN RETURN old_values || new_value; END; $$
|
||||
LANGUAGE plpgsql STABLE;
|
||||
|
@ -215,6 +216,8 @@ SELECT array_of_values FROM limit_orders_mx WHERE id = 246;
|
|||
-- STRICT functions work as expected
|
||||
CREATE FUNCTION temp_strict_func(integer,integer) RETURNS integer AS
|
||||
'SELECT COALESCE($1, 2) + COALESCE($1, 3);' LANGUAGE SQL STABLE STRICT;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
UPDATE limit_orders_mx SET bidder_id = temp_strict_func(1, null) WHERE id = 246;
|
||||
|
||||
SELECT array_of_values FROM limit_orders_mx WHERE id = 246;
|
||||
|
|
|
@ -195,6 +195,7 @@ SELECT * FROM objects_mx WHERE id = 1;
|
|||
-- create trigger on one worker to reject certain values
|
||||
\c - - - :worker_1_port
|
||||
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE FUNCTION reject_bad_mx() RETURNS trigger AS $rb$
|
||||
BEGIN
|
||||
IF (NEW.name = 'BAD') THEN
|
||||
|
@ -204,6 +205,7 @@ CREATE FUNCTION reject_bad_mx() RETURNS trigger AS $rb$
|
|||
RETURN NEW;
|
||||
END;
|
||||
$rb$ LANGUAGE plpgsql;
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
CREATE CONSTRAINT TRIGGER reject_bad_mx
|
||||
AFTER INSERT ON objects_mx_1220103
|
||||
|
|
|
@ -367,10 +367,12 @@ UPDATE pg_dist_node SET hasmetadata = true;
|
|||
|
||||
SELECT master_update_node(nodeid, 'localhost', 12345) FROM pg_dist_node;
|
||||
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION trigger_metadata_sync()
|
||||
RETURNS void
|
||||
LANGUAGE C STRICT
|
||||
AS 'citus';
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
SELECT trigger_metadata_sync();
|
||||
|
||||
|
|
|
@ -68,14 +68,7 @@ CREATE TABLE repartition_udt_other (
|
|||
\c - - - :worker_1_port
|
||||
|
||||
-- START type creation
|
||||
-- ... as well as a function to use as its comparator...
|
||||
CREATE FUNCTION equal_test_udt_function(test_udt, test_udt) RETURNS boolean
|
||||
AS 'select $1.i = $2.i AND $1.i2 = $2.i2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
|
||||
-- ... use that function to create a custom equality operator...
|
||||
-- Use function to create a custom equality operator...
|
||||
CREATE OPERATOR = (
|
||||
LEFTARG = test_udt,
|
||||
RIGHTARG = test_udt,
|
||||
|
@ -87,15 +80,6 @@ CREATE OPERATOR = (
|
|||
-- ... and create a custom operator family for hash indexes...
|
||||
CREATE OPERATOR FAMILY tudt_op_fam USING hash;
|
||||
|
||||
-- ... create a test HASH function. Though it is a poor hash function,
|
||||
-- it is acceptable for our tests
|
||||
CREATE FUNCTION test_udt_hash(test_udt) RETURNS int
|
||||
AS 'SELECT hashtext( ($1.i + $1.i2)::text);'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
|
||||
|
||||
-- We need to define two different operator classes for the composite types
|
||||
-- One uses BTREE the other uses HASH
|
||||
CREATE OPERATOR CLASS tudt_op_fam_clas3
|
||||
|
@ -112,14 +96,7 @@ FUNCTION 1 test_udt_hash(test_udt);
|
|||
\c - - - :worker_2_port
|
||||
|
||||
-- START type creation
|
||||
-- ... as well as a function to use as its comparator...
|
||||
CREATE FUNCTION equal_test_udt_function(test_udt, test_udt) RETURNS boolean
|
||||
AS 'select $1.i = $2.i AND $1.i2 = $2.i2;'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
|
||||
-- ... use that function to create a custom equality operator...
|
||||
-- Use function to create a custom equality operator...
|
||||
CREATE OPERATOR = (
|
||||
LEFTARG = test_udt,
|
||||
RIGHTARG = test_udt,
|
||||
|
@ -131,15 +108,6 @@ CREATE OPERATOR = (
|
|||
-- ... and create a custom operator family for hash indexes...
|
||||
CREATE OPERATOR FAMILY tudt_op_fam USING hash;
|
||||
|
||||
-- ... create a test HASH function. Though it is a poor hash function,
|
||||
-- it is acceptable for our tests
|
||||
CREATE FUNCTION test_udt_hash(test_udt) RETURNS int
|
||||
AS 'SELECT hashtext( ($1.i + $1.i2)::text);'
|
||||
LANGUAGE SQL
|
||||
IMMUTABLE
|
||||
RETURNS NULL ON NULL INPUT;
|
||||
|
||||
|
||||
-- We need to define two different operator classes for the composite types
|
||||
-- One uses BTREE the other uses HASH
|
||||
CREATE OPERATOR CLASS tudt_op_fam_clas3
|
||||
|
|
|
@ -609,6 +609,7 @@ PREPARE author_articles(int) as
|
|||
EXECUTE author_articles(1);
|
||||
|
||||
-- queries inside plpgsql functions could be router plannable
|
||||
SET citus.enable_metadata_sync TO OFF;
|
||||
CREATE OR REPLACE FUNCTION author_articles_max_id() RETURNS int AS $$
|
||||
DECLARE
|
||||
max_id integer;
|
||||
|
@ -635,6 +636,7 @@ END;
|
|||
$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT * FROM author_articles_id_word_count();
|
||||
RESET citus.enable_metadata_sync;
|
||||
|
||||
-- materialized views can be created for router plannable queries
|
||||
CREATE MATERIALIZED VIEW mv_articles_hash_mx AS
|
||||
|
|
Loading…
Reference in New Issue