mirror of https://github.com/citusdata/citus.git
Address reviews
parent
cfac2d7714
commit
4ef18e8737
|
@ -1297,17 +1297,30 @@ PostprocessCreateFunctionStmt(Node *node, const char *queryString)
|
||||||
ObjectAddress *undistributableDependency = GetUndistributableRelationDependency(
|
ObjectAddress *undistributableDependency = GetUndistributableRelationDependency(
|
||||||
&functionAddress);
|
&functionAddress);
|
||||||
if (undistributableDependency != NULL)
|
if (undistributableDependency != NULL)
|
||||||
|
{
|
||||||
|
if (SupportedDependencyByCitus(undistributableDependency))
|
||||||
{
|
{
|
||||||
RangeVar *functionRangeVar = makeRangeVarFromNameList(stmt->funcname);
|
RangeVar *functionRangeVar = makeRangeVarFromNameList(stmt->funcname);
|
||||||
char *functionName = functionRangeVar->relname;
|
char *functionName = functionRangeVar->relname;
|
||||||
char *dependentRelationName = get_rel_name(undistributableDependency->objectId);
|
char *dependentRelationName =
|
||||||
|
get_rel_name(undistributableDependency->objectId);
|
||||||
|
|
||||||
ereport(WARNING, (errmsg("Citus can't distribute function \"%s\" having "
|
ereport(WARNING, (errmsg("Citus can't distribute function \"%s\" having "
|
||||||
"dependency on non-distributed relation \"%s\"",
|
"dependency on non-distributed relation \"%s\"",
|
||||||
functionName, dependentRelationName),
|
functionName, dependentRelationName),
|
||||||
errdetail("Function will be created only locally"),
|
errdetail("Function will be created only locally"),
|
||||||
errhint("To distribute function, distribute dependent relations"
|
errhint("To distribute function, distribute dependent "
|
||||||
" first. Then, re-create the function")));
|
"relations first. Then, re-create the function")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ereport(WARNING, (errmsg("Citus can't distribute functions having "
|
||||||
|
"dependency on unsupported relation with relkind %c",
|
||||||
|
get_rel_relkind(
|
||||||
|
undistributableDependency->objectId)),
|
||||||
|
errdetail("Function will be created only locally")));
|
||||||
|
}
|
||||||
|
|
||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,8 @@ BEGIN
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
WARNING: Citus can't distribute function "func_7" having dependency on non-distributed relation "function_prop_view"
|
WARNING: Citus can't distribute functions having dependency on unsupported relation with relkind v
|
||||||
DETAIL: Function will be created only locally
|
DETAIL: Function will be created only locally
|
||||||
HINT: To distribute function, distribute dependent relations first. Then, re-create the function
|
|
||||||
CREATE OR REPLACE FUNCTION func_8(param_1 int)
|
CREATE OR REPLACE FUNCTION func_8(param_1 int)
|
||||||
RETURNS function_prop_view
|
RETURNS function_prop_view
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -197,9 +196,8 @@ BEGIN
|
||||||
return 1;
|
return 1;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
WARNING: Citus can't distribute function "func_8" having dependency on non-distributed relation "function_prop_view"
|
WARNING: Citus can't distribute functions having dependency on unsupported relation with relkind v
|
||||||
DETAIL: Function will be created only locally
|
DETAIL: Function will be created only locally
|
||||||
HINT: To distribute function, distribute dependent relations first. Then, re-create the function
|
|
||||||
-- Check within transaction
|
-- Check within transaction
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TYPE type_in_transaction AS (a int, b int);
|
CREATE TYPE type_in_transaction AS (a int, b int);
|
||||||
|
|
|
@ -77,9 +77,8 @@ END
|
||||||
$func$ LANGUAGE plpgsql;
|
$func$ LANGUAGE plpgsql;
|
||||||
CREATE SCHEMA test;
|
CREATE SCHEMA test;
|
||||||
:create_function_test_maintenance_worker
|
:create_function_test_maintenance_worker
|
||||||
WARNING: Citus can't distribute function "maintenance_worker" having dependency on non-distributed relation "pg_stat_activity"
|
WARNING: Citus can't distribute functions having dependency on unsupported relation with relkind v
|
||||||
DETAIL: Function will be created only locally
|
DETAIL: Function will be created only locally
|
||||||
HINT: To distribute function, distribute dependent relations first. Then, re-create the function
|
|
||||||
-- check maintenance daemon is started
|
-- check maintenance daemon is started
|
||||||
SELECT datname, current_database(),
|
SELECT datname, current_database(),
|
||||||
usename, (SELECT extowner::regrole::text FROM pg_extension WHERE extname = 'citus')
|
usename, (SELECT extowner::regrole::text FROM pg_extension WHERE extname = 'citus')
|
||||||
|
@ -1200,9 +1199,8 @@ HINT: You can manually create a database and its extensions on workers.
|
||||||
CREATE EXTENSION citus;
|
CREATE EXTENSION citus;
|
||||||
CREATE SCHEMA test;
|
CREATE SCHEMA test;
|
||||||
:create_function_test_maintenance_worker
|
:create_function_test_maintenance_worker
|
||||||
WARNING: Citus can't distribute function "maintenance_worker" having dependency on non-distributed relation "pg_stat_activity"
|
WARNING: Citus can't distribute functions having dependency on unsupported relation with relkind v
|
||||||
DETAIL: Function will be created only locally
|
DETAIL: Function will be created only locally
|
||||||
HINT: To distribute function, distribute dependent relations first. Then, re-create the function
|
|
||||||
-- see that the daemon started
|
-- see that the daemon started
|
||||||
SELECT datname, current_database(),
|
SELECT datname, current_database(),
|
||||||
usename, (SELECT extowner::regrole::text FROM pg_extension WHERE extname = 'citus')
|
usename, (SELECT extowner::regrole::text FROM pg_extension WHERE extname = 'citus')
|
||||||
|
|
|
@ -66,6 +66,8 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, ta
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- a function that returns a set of integers
|
-- a function that returns a set of integers
|
||||||
|
-- Block distributing function as we have tests below to test it locally
|
||||||
|
SET citus.enable_metadata_sync TO OFF;
|
||||||
CREATE OR REPLACE FUNCTION next_k_integers(IN first_value INTEGER,
|
CREATE OR REPLACE FUNCTION next_k_integers(IN first_value INTEGER,
|
||||||
IN k INTEGER DEFAULT 3,
|
IN k INTEGER DEFAULT 3,
|
||||||
OUT result INTEGER)
|
OUT result INTEGER)
|
||||||
|
@ -74,12 +76,10 @@ BEGIN
|
||||||
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
DEBUG: switching to sequential query execution mode
|
RESET citus.enable_metadata_sync;
|
||||||
DETAIL: A command for a distributed function is run. To make sure subsequent commands see the function correctly we need to make sure to use only one connection for all future commands
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
||||||
ORDER BY id ASC;
|
ORDER BY id ASC;
|
||||||
DEBUG: function does not have co-located tables
|
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT result FROM functions_in_joins.next_k_integers(3, 2) next_integers(result)
|
DEBUG: generating subplan XXX_1 for subquery SELECT result FROM functions_in_joins.next_k_integers(3, 2) next_integers(result)
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, next_integers.result FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.result FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(result integer)) next_integers ON ((table1.id OPERATOR(pg_catalog.=) next_integers.result))) ORDER BY table1.id
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, next_integers.result FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.result FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(result integer)) next_integers ON ((table1.id OPERATOR(pg_catalog.=) next_integers.result))) ORDER BY table1.id
|
||||||
id | data | result
|
id | data | result
|
||||||
|
|
|
@ -78,7 +78,7 @@ BEGIN
|
||||||
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SET citus.enable_metadata_sync TO OFF;
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
||||||
ORDER BY id ASC;
|
ORDER BY id ASC;
|
||||||
|
@ -95,7 +95,10 @@ CREATE FUNCTION get_set_of_records() RETURNS SETOF RECORD AS $cmd$
|
||||||
SELECT x, x+1 FROM generate_series(0,4) f(x)
|
SELECT x, x+1 FROM generate_series(0,4) f(x)
|
||||||
$cmd$
|
$cmd$
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
|
DEBUG: switching to sequential query execution mode
|
||||||
|
DETAIL: A command for a distributed function is run. To make sure subsequent commands see the function correctly we need to make sure to use only one connection for all future commands
|
||||||
SELECT * FROM table1 JOIN get_set_of_records() AS t2(x int, y int) ON (id = x) ORDER BY id ASC;
|
SELECT * FROM table1 JOIN get_set_of_records() AS t2(x int, y int) ON (id = x) ORDER BY id ASC;
|
||||||
|
DEBUG: function does not have co-located tables
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT x, y FROM functions_in_joins.get_set_of_records() t2(x integer, y integer)
|
DEBUG: generating subplan XXX_1 for subquery SELECT x, y FROM functions_in_joins.get_set_of_records() t2(x integer, y integer)
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, t2.x, t2.y FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) t2 ON ((table1.id OPERATOR(pg_catalog.=) t2.x))) ORDER BY table1.id
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, t2.x, t2.y FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) t2 ON ((table1.id OPERATOR(pg_catalog.=) t2.x))) ORDER BY table1.id
|
||||||
id | data | x | y
|
id | data | x | y
|
||||||
|
@ -110,7 +113,10 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, ta
|
||||||
CREATE FUNCTION dup(int) RETURNS TABLE(f1 int, f2 text)
|
CREATE FUNCTION dup(int) RETURNS TABLE(f1 int, f2 text)
|
||||||
AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$
|
AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$
|
||||||
LANGUAGE SQL;
|
LANGUAGE SQL;
|
||||||
|
DEBUG: switching to sequential query execution mode
|
||||||
|
DETAIL: A command for a distributed function is run. To make sure subsequent commands see the function correctly we need to make sure to use only one connection for all future commands
|
||||||
SELECT f.* FROM table1 t JOIN dup(32) f ON (f1 = id);
|
SELECT f.* FROM table1 t JOIN dup(32) f ON (f1 = id);
|
||||||
|
DEBUG: function does not have co-located tables
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT f1, f2 FROM functions_in_joins.dup(32) f(f1, f2)
|
DEBUG: generating subplan XXX_1 for subquery SELECT f1, f2 FROM functions_in_joins.dup(32) f(f1, f2)
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT f.f1, f.f2 FROM (functions_in_joins.table1 t JOIN (SELECT intermediate_result.f1, intermediate_result.f2 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(f1 integer, f2 text)) f ON ((f.f1 OPERATOR(pg_catalog.=) t.id)))
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT f.f1, f.f2 FROM (functions_in_joins.table1 t JOIN (SELECT intermediate_result.f1, intermediate_result.f2 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(f1 integer, f2 text)) f ON ((f.f1 OPERATOR(pg_catalog.=) t.id)))
|
||||||
f1 | f2
|
f1 | f2
|
||||||
|
@ -121,7 +127,10 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT f.f1, f.f2 FR
|
||||||
-- a stable function
|
-- a stable function
|
||||||
CREATE OR REPLACE FUNCTION the_minimum_id()
|
CREATE OR REPLACE FUNCTION the_minimum_id()
|
||||||
RETURNS INTEGER STABLE AS 'SELECT min(id) FROM table1' LANGUAGE SQL;
|
RETURNS INTEGER STABLE AS 'SELECT min(id) FROM table1' LANGUAGE SQL;
|
||||||
|
DEBUG: switching to sequential query execution mode
|
||||||
|
DETAIL: A command for a distributed function is run. To make sure subsequent commands see the function correctly we need to make sure to use only one connection for all future commands
|
||||||
SELECT * FROM table1 JOIN the_minimum_id() min_id ON (id = min_id);
|
SELECT * FROM table1 JOIN the_minimum_id() min_id ON (id = min_id);
|
||||||
|
DEBUG: function does not have co-located tables
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT min_id FROM functions_in_joins.the_minimum_id() min_id(min_id)
|
DEBUG: generating subplan XXX_1 for subquery SELECT min_id FROM functions_in_joins.the_minimum_id() min_id(min_id)
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, min_id.min_id FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.min_id FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(min_id integer)) min_id ON ((table1.id OPERATOR(pg_catalog.=) min_id.min_id)))
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, min_id.min_id FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.min_id FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(min_id integer)) min_id ON ((table1.id OPERATOR(pg_catalog.=) min_id.min_id)))
|
||||||
id | data | min_id
|
id | data | min_id
|
||||||
|
@ -182,7 +191,10 @@ begin
|
||||||
return result;
|
return result;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
DEBUG: switching to sequential query execution mode
|
||||||
|
DETAIL: A command for a distributed function is run. To make sure subsequent commands see the function correctly we need to make sure to use only one connection for all future commands
|
||||||
SELECT * FROM table1 JOIN max_and_min() m ON (m.maximum = data OR m.minimum = data) ORDER BY 1,2,3,4;
|
SELECT * FROM table1 JOIN max_and_min() m ON (m.maximum = data OR m.minimum = data) ORDER BY 1,2,3,4;
|
||||||
|
DEBUG: function does not have co-located tables
|
||||||
DEBUG: generating subplan XXX_1 for subquery SELECT minimum, maximum FROM functions_in_joins.max_and_min() m(minimum, maximum)
|
DEBUG: generating subplan XXX_1 for subquery SELECT minimum, maximum FROM functions_in_joins.max_and_min() m(minimum, maximum)
|
||||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, m.minimum, m.maximum FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.minimum, intermediate_result.maximum FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(minimum integer, maximum integer)) m ON (((m.maximum OPERATOR(pg_catalog.=) table1.data) OR (m.minimum OPERATOR(pg_catalog.=) table1.data)))) ORDER BY table1.id, table1.data, m.minimum, m.maximum
|
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT table1.id, table1.data, m.minimum, m.maximum FROM (functions_in_joins.table1 JOIN (SELECT intermediate_result.minimum, intermediate_result.maximum FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(minimum integer, maximum integer)) m ON (((m.maximum OPERATOR(pg_catalog.=) table1.data) OR (m.minimum OPERATOR(pg_catalog.=) table1.data)))) ORDER BY table1.id, table1.data, m.minimum, m.maximum
|
||||||
id | data | minimum | maximum
|
id | data | minimum | maximum
|
||||||
|
|
|
@ -55,7 +55,7 @@ BEGIN
|
||||||
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
RETURN QUERY SELECT x FROM generate_series(first_value, first_value+k-1) f(x);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
SET citus.enable_metadata_sync TO OFF;
|
RESET citus.enable_metadata_sync;
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
FROM table1 JOIN next_k_integers(3,2) next_integers ON (id = next_integers.result)
|
||||||
ORDER BY id ASC;
|
ORDER BY id ASC;
|
||||||
|
|
Loading…
Reference in New Issue