mirror of https://github.com/citusdata/citus.git
Fix check_multi tests
parent
8901936e9a
commit
6de2d7f050
|
@ -875,6 +875,7 @@ BEGIN
|
||||||
RETURN $1 * $1;
|
RETURN $1 * $1;
|
||||||
END;
|
END;
|
||||||
$function$;
|
$function$;
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION square_func(int)
|
CREATE OR REPLACE FUNCTION square_func(int)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
|
@ -883,6 +884,7 @@ BEGIN
|
||||||
RETURN $1 * $1;
|
RETURN $1 * $1;
|
||||||
END;
|
END;
|
||||||
$function$;
|
$function$;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT const_function(1), string_agg(a::character, ',') FROM t1;
|
SELECT const_function(1), string_agg(a::character, ',') FROM t1;
|
||||||
NOTICE: stable_fn called
|
NOTICE: stable_fn called
|
||||||
CONTEXT: PL/pgSQL function const_function(integer) line XX at RAISE
|
CONTEXT: PL/pgSQL function const_function(integer) line XX at RAISE
|
||||||
|
|
|
@ -303,16 +303,12 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SELECT create_distributed_function('func_calls_forcepush_func()');
|
SELECT create_distributed_function('func_calls_forcepush_func()');
|
||||||
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT create_distributed_function('inner_force_delegation_function(int)', '$1', colocate_with := 'test_nested', force_delegation := true);
|
SELECT create_distributed_function('inner_force_delegation_function(int)', '$1', colocate_with := 'test_nested', 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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -367,6 +363,7 @@ $$ LANGUAGE plpgsql;
|
||||||
-- select res into var from fn();
|
-- select res into var from fn();
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_infrom()
|
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_infrom()
|
||||||
RETURNS NUMERIC AS $$
|
RETURNS NUMERIC AS $$
|
||||||
DECLARE incremented_val NUMERIC;
|
DECLARE incremented_val NUMERIC;
|
||||||
|
@ -377,6 +374,7 @@ BEGIN
|
||||||
RETURN incremented_val;
|
RETURN incremented_val;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT func_calls_forcepush_func_infrom();
|
SELECT func_calls_forcepush_func_infrom();
|
||||||
DEBUG: pushing down function call in a multi-statement transaction
|
DEBUG: pushing down function call in a multi-statement transaction
|
||||||
CONTEXT: SQL statement "SELECT inner_force_delegation_function FROM inner_force_delegation_function(add_val + 100)"
|
CONTEXT: SQL statement "SELECT inner_force_delegation_function FROM inner_force_delegation_function(add_val + 100)"
|
||||||
|
@ -418,6 +416,7 @@ COMMIT;
|
||||||
-- select fn() into var;
|
-- select fn() into var;
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_intarget()
|
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_intarget()
|
||||||
RETURNS NUMERIC AS $$
|
RETURNS NUMERIC AS $$
|
||||||
DECLARE incremented_val NUMERIC;
|
DECLARE incremented_val NUMERIC;
|
||||||
|
@ -428,6 +427,7 @@ BEGIN
|
||||||
RETURN incremented_val;
|
RETURN incremented_val;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT func_calls_forcepush_func_intarget();
|
SELECT func_calls_forcepush_func_intarget();
|
||||||
DEBUG: pushing down function call in a multi-statement transaction
|
DEBUG: pushing down function call in a multi-statement transaction
|
||||||
CONTEXT: SQL statement "SELECT inner_force_delegation_function(100 + 100) OFFSET 0"
|
CONTEXT: SQL statement "SELECT inner_force_delegation_function(100 + 100) OFFSET 0"
|
||||||
|
@ -474,8 +474,6 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SELECT create_distributed_function('test_recursive(int)', '$1', colocate_with := 'test_nested', force_delegation := true);
|
SELECT create_distributed_function('test_recursive(int)', '$1', colocate_with := 'test_nested', 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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -549,8 +547,6 @@ SELECT create_distributed_function(
|
||||||
'$1',
|
'$1',
|
||||||
colocate_with := 'test_forcepushdown',
|
colocate_with := 'test_forcepushdown',
|
||||||
force_delegation := true);
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -610,6 +606,7 @@ BEGIN
|
||||||
INSERT INTO emp VALUES (empname, 33);
|
INSERT INTO emp VALUES (empname, 33);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION outer_emp()
|
CREATE OR REPLACE FUNCTION outer_emp()
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
|
@ -618,9 +615,8 @@ BEGIN
|
||||||
PERFORM inner_emp('hello');
|
PERFORM inner_emp('hello');
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT create_distributed_function('inner_emp(text)','empname', force_delegation := true);
|
SELECT create_distributed_function('inner_emp(text)','empname', 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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -655,8 +651,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_forcepushdown',
|
colocate_with := 'test_forcepushdown',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -730,8 +724,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_forcepushdown',
|
colocate_with := 'test_forcepushdown',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -808,8 +800,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_forcepushdown_char',
|
colocate_with := 'test_forcepushdown_char',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -826,8 +816,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_forcepushdown_varchar',
|
colocate_with := 'test_forcepushdown_varchar',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -844,8 +832,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_forcepushdown_text',
|
colocate_with := 'test_forcepushdown_text',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -952,8 +938,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_subquery',
|
colocate_with := 'test_subquery',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -974,8 +958,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_subquery',
|
colocate_with := 'test_subquery',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -995,8 +977,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_subquery',
|
colocate_with := 'test_subquery',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1016,8 +996,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_subquery',
|
colocate_with := 'test_subquery',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1038,8 +1016,6 @@ SELECT create_distributed_function(
|
||||||
colocate_with := 'test_subquery',
|
colocate_with := 'test_subquery',
|
||||||
force_delegation := true
|
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1211,8 +1187,6 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SELECT create_distributed_function('test_prepare(int,int)','x',force_delegation :=true, colocate_with := 'table_test_prepare');
|
SELECT create_distributed_function('test_prepare(int,int)','x',force_delegation :=true, colocate_with := 'table_test_prepare');
|
||||||
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1220,6 +1194,7 @@ DETAIL: A distributed function is created. To make sure subsequent commands see
|
||||||
|
|
||||||
DROP FUNCTION outer_test_prepare(int, int);
|
DROP FUNCTION outer_test_prepare(int, int);
|
||||||
ERROR: function outer_test_prepare(integer, integer) does not exist
|
ERROR: function outer_test_prepare(integer, integer) does not exist
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION outer_test_prepare(x int, y int)
|
CREATE OR REPLACE FUNCTION outer_test_prepare(x int, y int)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
|
@ -1230,6 +1205,7 @@ BEGIN
|
||||||
PERFORM 1, 1 + a FROM test_prepare(x + 1, y + 1) a;
|
PERFORM 1, 1 + a FROM test_prepare(x + 1, y + 1) a;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
-- First 5 get delegated and succeeds
|
-- First 5 get delegated and succeeds
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT outer_test_prepare(1,1);
|
SELECT outer_test_prepare(1,1);
|
||||||
|
@ -1406,8 +1382,6 @@ END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SELECT create_distributed_function('test(int)', 'x',
|
SELECT create_distributed_function('test(int)', 'x',
|
||||||
colocate_with := 'test_perform', force_delegation := true);
|
colocate_with := 'test_perform', 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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,6 @@ CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||||
AS 'SELECT $1 + $2;'
|
AS 'SELECT $1 + $2;'
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
SELECT create_distributed_function('add(integer,integer)');
|
SELECT create_distributed_function('add(integer,integer)');
|
||||||
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
|
create_distributed_function
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -198,6 +196,7 @@ SET client_min_messages TO ERROR;
|
||||||
-- function joins in CTE results can create lateral joins that are not supported
|
-- function joins in CTE results can create lateral joins that are not supported
|
||||||
-- we execute the query within a function to consolidate the error messages
|
-- we execute the query within a function to consolidate the error messages
|
||||||
-- between different executors
|
-- between different executors
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
EXECUTE query;
|
EXECUTE query;
|
||||||
|
@ -209,6 +208,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$LANGUAGE plpgsql;
|
$$LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT raise_failed_execution_func_join($$
|
SELECT raise_failed_execution_func_join($$
|
||||||
WITH one_row AS (
|
WITH one_row AS (
|
||||||
SELECT * FROM table1 WHERE id=52
|
SELECT * FROM table1 WHERE id=52
|
||||||
|
|
|
@ -200,6 +200,7 @@ SET client_min_messages TO ERROR;
|
||||||
-- function joins in CTE results can create lateral joins that are not supported
|
-- function joins in CTE results can create lateral joins that are not supported
|
||||||
-- we execute the query within a function to consolidate the error messages
|
-- we execute the query within a function to consolidate the error messages
|
||||||
-- between different executors
|
-- between different executors
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
EXECUTE query;
|
EXECUTE query;
|
||||||
|
@ -211,6 +212,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$LANGUAGE plpgsql;
|
$$LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT raise_failed_execution_func_join($$
|
SELECT raise_failed_execution_func_join($$
|
||||||
WITH one_row AS (
|
WITH one_row AS (
|
||||||
SELECT * FROM table1 WHERE id=52
|
SELECT * FROM table1 WHERE id=52
|
||||||
|
|
|
@ -1132,10 +1132,6 @@ DROP TABLE http_request;
|
||||||
-- (re-)planning, but not when executing.
|
-- (re-)planning, but not when executing.
|
||||||
-- first create helper function
|
-- first create helper function
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
||||||
\c - - - :worker_1_port
|
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
|
||||||
\c - - - :worker_2_port
|
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- test table
|
-- test table
|
||||||
CREATE TABLE test_table (test_id integer NOT NULL, data text);
|
CREATE TABLE test_table (test_id integer NOT NULL, data text);
|
||||||
|
|
|
@ -1563,22 +1563,8 @@ LIMIT 10;
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
-- this is one complex join query derived from a user's production query
|
-- this is one complex join query derived from a user's production query
|
||||||
-- first declare the function on workers on master
|
-- declare the function on workers and master
|
||||||
-- With array_index:
|
-- With array_index:
|
||||||
SELECT * FROM run_command_on_workers('CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
|
||||||
RETURNS INT AS $$
|
|
||||||
SELECT i
|
|
||||||
FROM (SELECT generate_series(array_lower($1, 1), array_upper($1, 1))) g(i)
|
|
||||||
WHERE $1 [i] = $2
|
|
||||||
LIMIT 1;
|
|
||||||
$$ LANGUAGE sql')
|
|
||||||
ORDER BY 1,2;
|
|
||||||
nodename | nodeport | success | result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
localhost | 57637 | t | CREATE FUNCTION
|
|
||||||
localhost | 57638 | t | CREATE FUNCTION
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
||||||
RETURNS INT AS $$
|
RETURNS INT AS $$
|
||||||
SELECT i
|
SELECT i
|
||||||
|
@ -1745,14 +1731,6 @@ LIMIT 10;
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
-- drop created functions
|
-- drop created functions
|
||||||
SELECT * FROM run_command_on_workers('DROP FUNCTION array_index(ANYARRAY, ANYELEMENT)')
|
|
||||||
ORDER BY 1,2;
|
|
||||||
nodename | nodeport | success | result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
localhost | 57637 | t | DROP FUNCTION
|
|
||||||
localhost | 57638 | t | DROP FUNCTION
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
DROP FUNCTION array_index(ANYARRAY, ANYELEMENT);
|
DROP FUNCTION array_index(ANYARRAY, ANYELEMENT);
|
||||||
-- a query with a constant subquery
|
-- a query with a constant subquery
|
||||||
SELECT count(*) as subquery_count
|
SELECT count(*) as subquery_count
|
||||||
|
@ -1987,21 +1965,6 @@ CREATE FUNCTION test_join_function_2(integer, integer) RETURNS bool
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
IMMUTABLE
|
IMMUTABLE
|
||||||
RETURNS NULL ON NULL INPUT;
|
RETURNS NULL ON NULL INPUT;
|
||||||
SELECT run_command_on_workers($f$
|
|
||||||
|
|
||||||
CREATE FUNCTION test_join_function_2(integer, integer) RETURNS bool
|
|
||||||
AS 'select $1 > $2;'
|
|
||||||
LANGUAGE SQL
|
|
||||||
IMMUTABLE
|
|
||||||
RETURNS NULL ON NULL INPUT;
|
|
||||||
|
|
||||||
$f$);
|
|
||||||
run_command_on_workers
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
(localhost,57637,t,"CREATE FUNCTION")
|
|
||||||
(localhost,57638,t,"CREATE FUNCTION")
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- we don't support joins via functions
|
-- we don't support joins via functions
|
||||||
SELECT user_id, array_length(events_table, 1)
|
SELECT user_id, array_length(events_table, 1)
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -2285,16 +2248,5 @@ LIMIT 1;
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP FUNCTION test_join_function_2(integer, integer);
|
DROP FUNCTION test_join_function_2(integer, integer);
|
||||||
SELECT run_command_on_workers($f$
|
|
||||||
|
|
||||||
DROP FUNCTION test_join_function_2(integer, integer);
|
|
||||||
|
|
||||||
$f$);
|
|
||||||
run_command_on_workers
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
(localhost,57637,t,"DROP FUNCTION")
|
|
||||||
(localhost,57638,t,"DROP FUNCTION")
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SET citus.enable_router_execution TO TRUE;
|
SET citus.enable_router_execution TO TRUE;
|
||||||
SET citus.subquery_pushdown to OFF;
|
SET citus.subquery_pushdown to OFF;
|
||||||
|
|
|
@ -20,6 +20,7 @@ SET citus.enable_repartition_joins TO ON;
|
||||||
-- copied from multi_explain.sql and had to give
|
-- copied from multi_explain.sql and had to give
|
||||||
-- a different name via postfix to prevent concurrent
|
-- a different name via postfix to prevent concurrent
|
||||||
-- create/drop etc.
|
-- create/drop etc.
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION explain_json_2(query text)
|
CREATE OR REPLACE FUNCTION explain_json_2(query text)
|
||||||
RETURNS jsonb
|
RETURNS jsonb
|
||||||
AS $BODY$
|
AS $BODY$
|
||||||
|
@ -30,6 +31,7 @@ BEGIN
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$BODY$ LANGUAGE plpgsql;
|
$BODY$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
-- leaf queries contain colocated joins
|
-- leaf queries contain colocated joins
|
||||||
-- but not the subquery
|
-- but not the subquery
|
||||||
SELECT true AS valid FROM explain_json_2($$
|
SELECT true AS valid FROM explain_json_2($$
|
||||||
|
|
|
@ -459,6 +459,7 @@ RETURN $1 * $1;
|
||||||
END;
|
END;
|
||||||
$function$;
|
$function$;
|
||||||
|
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION square_func(int)
|
CREATE OR REPLACE FUNCTION square_func(int)
|
||||||
RETURNS int
|
RETURNS int
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
|
@ -467,6 +468,7 @@ BEGIN
|
||||||
RETURN $1 * $1;
|
RETURN $1 * $1;
|
||||||
END;
|
END;
|
||||||
$function$;
|
$function$;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT const_function(1), string_agg(a::character, ',') FROM t1;
|
SELECT const_function(1), string_agg(a::character, ',') FROM t1;
|
||||||
SELECT const_function(1), count(b) FROM t1;
|
SELECT const_function(1), count(b) FROM t1;
|
||||||
|
|
|
@ -203,6 +203,7 @@ $$ LANGUAGE plpgsql;
|
||||||
-- select res into var from fn();
|
-- select res into var from fn();
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_infrom()
|
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_infrom()
|
||||||
RETURNS NUMERIC AS $$
|
RETURNS NUMERIC AS $$
|
||||||
DECLARE incremented_val NUMERIC;
|
DECLARE incremented_val NUMERIC;
|
||||||
|
@ -213,6 +214,7 @@ BEGIN
|
||||||
RETURN incremented_val;
|
RETURN incremented_val;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT func_calls_forcepush_func_infrom();
|
SELECT func_calls_forcepush_func_infrom();
|
||||||
|
|
||||||
|
@ -227,6 +229,7 @@ COMMIT;
|
||||||
-- select fn() into var;
|
-- select fn() into var;
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_intarget()
|
CREATE OR REPLACE FUNCTION func_calls_forcepush_func_intarget()
|
||||||
RETURNS NUMERIC AS $$
|
RETURNS NUMERIC AS $$
|
||||||
DECLARE incremented_val NUMERIC;
|
DECLARE incremented_val NUMERIC;
|
||||||
|
@ -237,6 +240,7 @@ BEGIN
|
||||||
RETURN incremented_val;
|
RETURN incremented_val;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT func_calls_forcepush_func_intarget();
|
SELECT func_calls_forcepush_func_intarget();
|
||||||
|
|
||||||
|
@ -336,6 +340,7 @@ BEGIN
|
||||||
INSERT INTO emp VALUES (empname, 33);
|
INSERT INTO emp VALUES (empname, 33);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION outer_emp()
|
CREATE OR REPLACE FUNCTION outer_emp()
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
|
@ -344,6 +349,7 @@ BEGIN
|
||||||
PERFORM inner_emp('hello');
|
PERFORM inner_emp('hello');
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT create_distributed_function('inner_emp(text)','empname', force_delegation := true);
|
SELECT create_distributed_function('inner_emp(text)','empname', force_delegation := true);
|
||||||
SELECT outer_emp();
|
SELECT outer_emp();
|
||||||
|
@ -631,6 +637,7 @@ $$ LANGUAGE plpgsql;
|
||||||
SELECT create_distributed_function('test_prepare(int,int)','x',force_delegation :=true, colocate_with := 'table_test_prepare');
|
SELECT create_distributed_function('test_prepare(int,int)','x',force_delegation :=true, colocate_with := 'table_test_prepare');
|
||||||
|
|
||||||
DROP FUNCTION outer_test_prepare(int, int);
|
DROP FUNCTION outer_test_prepare(int, int);
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION outer_test_prepare(x int, y int)
|
CREATE OR REPLACE FUNCTION outer_test_prepare(x int, y int)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
|
@ -641,6 +648,7 @@ BEGIN
|
||||||
PERFORM 1, 1 + a FROM test_prepare(x + 1, y + 1) a;
|
PERFORM 1, 1 + a FROM test_prepare(x + 1, y + 1) a;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
-- First 5 get delegated and succeeds
|
-- First 5 get delegated and succeeds
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
|
@ -124,6 +124,7 @@ SET client_min_messages TO ERROR;
|
||||||
-- function joins in CTE results can create lateral joins that are not supported
|
-- function joins in CTE results can create lateral joins that are not supported
|
||||||
-- we execute the query within a function to consolidate the error messages
|
-- we execute the query within a function to consolidate the error messages
|
||||||
-- between different executors
|
-- between different executors
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
CREATE FUNCTION raise_failed_execution_func_join(query text) RETURNS void AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
EXECUTE query;
|
EXECUTE query;
|
||||||
|
@ -135,6 +136,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$LANGUAGE plpgsql;
|
$$LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
SELECT raise_failed_execution_func_join($$
|
SELECT raise_failed_execution_func_join($$
|
||||||
WITH one_row AS (
|
WITH one_row AS (
|
||||||
|
|
|
@ -610,10 +610,6 @@ DROP TABLE http_request;
|
||||||
|
|
||||||
-- first create helper function
|
-- first create helper function
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
||||||
\c - - - :worker_1_port
|
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
|
||||||
\c - - - :worker_2_port
|
|
||||||
CREATE OR REPLACE FUNCTION immutable_bleat(text) RETURNS int LANGUAGE plpgsql IMMUTABLE AS $$BEGIN RAISE NOTICE '%', $1;RETURN 1;END$$;
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
|
||||||
-- test table
|
-- test table
|
||||||
|
|
|
@ -1278,17 +1278,8 @@ ORDER BY
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
|
||||||
-- this is one complex join query derived from a user's production query
|
-- this is one complex join query derived from a user's production query
|
||||||
-- first declare the function on workers on master
|
-- declare the function on workers and master
|
||||||
-- With array_index:
|
-- With array_index:
|
||||||
SELECT * FROM run_command_on_workers('CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
|
||||||
RETURNS INT AS $$
|
|
||||||
SELECT i
|
|
||||||
FROM (SELECT generate_series(array_lower($1, 1), array_upper($1, 1))) g(i)
|
|
||||||
WHERE $1 [i] = $2
|
|
||||||
LIMIT 1;
|
|
||||||
$$ LANGUAGE sql')
|
|
||||||
ORDER BY 1,2;
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
CREATE OR REPLACE FUNCTION array_index(ANYARRAY, ANYELEMENT)
|
||||||
RETURNS INT AS $$
|
RETURNS INT AS $$
|
||||||
SELECT i
|
SELECT i
|
||||||
|
@ -1431,8 +1422,6 @@ LIMIT 10;
|
||||||
|
|
||||||
|
|
||||||
-- drop created functions
|
-- drop created functions
|
||||||
SELECT * FROM run_command_on_workers('DROP FUNCTION array_index(ANYARRAY, ANYELEMENT)')
|
|
||||||
ORDER BY 1,2;
|
|
||||||
DROP FUNCTION array_index(ANYARRAY, ANYELEMENT);
|
DROP FUNCTION array_index(ANYARRAY, ANYELEMENT);
|
||||||
|
|
||||||
-- a query with a constant subquery
|
-- a query with a constant subquery
|
||||||
|
@ -1629,16 +1618,6 @@ CREATE FUNCTION test_join_function_2(integer, integer) RETURNS bool
|
||||||
IMMUTABLE
|
IMMUTABLE
|
||||||
RETURNS NULL ON NULL INPUT;
|
RETURNS NULL ON NULL INPUT;
|
||||||
|
|
||||||
SELECT run_command_on_workers($f$
|
|
||||||
|
|
||||||
CREATE FUNCTION test_join_function_2(integer, integer) RETURNS bool
|
|
||||||
AS 'select $1 > $2;'
|
|
||||||
LANGUAGE SQL
|
|
||||||
IMMUTABLE
|
|
||||||
RETURNS NULL ON NULL INPUT;
|
|
||||||
|
|
||||||
$f$);
|
|
||||||
|
|
||||||
-- we don't support joins via functions
|
-- we don't support joins via functions
|
||||||
SELECT user_id, array_length(events_table, 1)
|
SELECT user_id, array_length(events_table, 1)
|
||||||
FROM (
|
FROM (
|
||||||
|
@ -1869,11 +1848,5 @@ LIMIT 1;
|
||||||
|
|
||||||
DROP FUNCTION test_join_function_2(integer, integer);
|
DROP FUNCTION test_join_function_2(integer, integer);
|
||||||
|
|
||||||
SELECT run_command_on_workers($f$
|
|
||||||
|
|
||||||
DROP FUNCTION test_join_function_2(integer, integer);
|
|
||||||
|
|
||||||
$f$);
|
|
||||||
|
|
||||||
SET citus.enable_router_execution TO TRUE;
|
SET citus.enable_router_execution TO TRUE;
|
||||||
SET citus.subquery_pushdown to OFF;
|
SET citus.subquery_pushdown to OFF;
|
||||||
|
|
|
@ -25,6 +25,7 @@ SET citus.enable_repartition_joins TO ON;
|
||||||
-- copied from multi_explain.sql and had to give
|
-- copied from multi_explain.sql and had to give
|
||||||
-- a different name via postfix to prevent concurrent
|
-- a different name via postfix to prevent concurrent
|
||||||
-- create/drop etc.
|
-- create/drop etc.
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION explain_json_2(query text)
|
CREATE OR REPLACE FUNCTION explain_json_2(query text)
|
||||||
RETURNS jsonb
|
RETURNS jsonb
|
||||||
AS $BODY$
|
AS $BODY$
|
||||||
|
@ -35,6 +36,7 @@ BEGIN
|
||||||
RETURN result;
|
RETURN result;
|
||||||
END;
|
END;
|
||||||
$BODY$ LANGUAGE plpgsql;
|
$BODY$ LANGUAGE plpgsql;
|
||||||
|
RESET citus.enable_metadata_sync;
|
||||||
|
|
||||||
|
|
||||||
-- leaf queries contain colocated joins
|
-- leaf queries contain colocated joins
|
||||||
|
|
Loading…
Reference in New Issue