mirror of https://github.com/citusdata/citus.git
Fix empty FROM clauses in PG12
parent
9fa4a20148
commit
bd416ef68f
|
@ -156,24 +156,45 @@ TryToDelegateFunctionCall(Query *query, bool *hasExternParam)
|
||||||
|
|
||||||
if (joinTree->fromlist != NIL)
|
if (joinTree->fromlist != NIL)
|
||||||
{
|
{
|
||||||
/* query has a FROM section */
|
|
||||||
#if PG_VERSION_NUM >= 120000
|
#if PG_VERSION_NUM >= 120000
|
||||||
|
|
||||||
/* in pg12 empty FROMs are represented with an RTE_RESULT */
|
/*
|
||||||
|
* In pg12's planning phase empty FROMs are represented with an RTE_RESULT.
|
||||||
|
* When we arrive here, standard_planner has already been called which calls
|
||||||
|
* replace_empty_jointree() which replaces empty fromlist with a list of
|
||||||
|
* single RTE_RESULT RangleTableRef node.
|
||||||
|
*/
|
||||||
if (list_length(joinTree->fromlist) == 1)
|
if (list_length(joinTree->fromlist) == 1)
|
||||||
{
|
{
|
||||||
RangeTblRef *reference = linitial(joinTree->fromlist);
|
RangeTblRef *reference = linitial(joinTree->fromlist);
|
||||||
|
|
||||||
|
if (IsA(reference, RangeTblRef))
|
||||||
|
{
|
||||||
RangeTblEntry *rtentry = rt_fetch(reference->rtindex, query->rtable);
|
RangeTblEntry *rtentry = rt_fetch(reference->rtindex, query->rtable);
|
||||||
if (rtentry->rtekind != RTE_RESULT)
|
if (rtentry->rtekind != RTE_RESULT)
|
||||||
{
|
{
|
||||||
|
/* e.g. SELECT f() FROM rel */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* e.g. IsA(reference, JoinExpr). This is explicit join expressions
|
||||||
|
* like INNER JOIN, NATURAL JOIN, ...
|
||||||
|
*/
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* e.g. SELECT ... FROM rel1, rel2. */
|
||||||
|
Assert(list_length(joinTree->fromlist) > 1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/* query has a FROM section */
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,13 +342,12 @@ DETAIL: A distributed function is created. To make sure subsequent commands see
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
\set VERBOSITY terse
|
||||||
call multi_mx_call.mx_call_proc_raise(2);
|
call multi_mx_call.mx_call_proc_raise(2);
|
||||||
DEBUG: pushing down the procedure
|
DEBUG: pushing down the procedure
|
||||||
DEBUG: warning
|
DEBUG: warning
|
||||||
DETAIL: WARNING from localhost:57638
|
|
||||||
ERROR: error
|
ERROR: error
|
||||||
CONTEXT: while executing command on localhost:57638
|
\set VERBOSITY default
|
||||||
PL/pgSQL function multi_mx_call.mx_call_proc_raise(integer) line 4 at RAISE
|
|
||||||
-- Test that we don't propagate to non-metadata worker nodes
|
-- Test that we don't propagate to non-metadata worker nodes
|
||||||
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
stop_metadata_sync_to_node
|
stop_metadata_sync_to_node
|
||||||
|
|
|
@ -263,10 +263,10 @@ select create_distributed_function('mx_call_proc_raise(int)', '$1', 'mx_call_dis
|
||||||
ERROR: function "mx_call_proc_raise(int)" does not exist
|
ERROR: function "mx_call_proc_raise(int)" does not exist
|
||||||
LINE 1: select create_distributed_function('mx_call_proc_raise(int)'...
|
LINE 1: select create_distributed_function('mx_call_proc_raise(int)'...
|
||||||
^
|
^
|
||||||
|
\set VERBOSITY terse
|
||||||
call multi_mx_call.mx_call_proc_raise(2);
|
call multi_mx_call.mx_call_proc_raise(2);
|
||||||
ERROR: syntax error at or near "call"
|
ERROR: syntax error at or near "call" at character 1
|
||||||
LINE 1: call multi_mx_call.mx_call_proc_raise(2);
|
\set VERBOSITY default
|
||||||
^
|
|
||||||
-- Test that we don't propagate to non-metadata worker nodes
|
-- Test that we don't propagate to non-metadata worker nodes
|
||||||
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
stop_metadata_sync_to_node
|
stop_metadata_sync_to_node
|
||||||
|
|
|
@ -265,11 +265,11 @@ SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_
|
||||||
DELETE FROM pg_dist_node;
|
DELETE FROM pg_dist_node;
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
-- DROP TABLE
|
-- DROP TABLE
|
||||||
|
-- terse verbosity because pg10 has slightly different output
|
||||||
|
\set VERBOSITY terse
|
||||||
DROP TABLE mx_table;
|
DROP TABLE mx_table;
|
||||||
ERROR: operation is not allowed on this node
|
ERROR: operation is not allowed on this node
|
||||||
HINT: Connect to the coordinator and run it again.
|
\set VERBOSITY default
|
||||||
CONTEXT: SQL statement "SELECT master_remove_distributed_table_metadata_from_workers(v_obj.objid, v_obj.schema_name, v_obj.object_name)"
|
|
||||||
PL/pgSQL function citus_drop_trigger() line 18 at PERFORM
|
|
||||||
SELECT count(*) FROM mx_table;
|
SELECT count(*) FROM mx_table;
|
||||||
count
|
count
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -143,8 +143,9 @@ BEGIN
|
||||||
RAISE EXCEPTION 'error';
|
RAISE EXCEPTION 'error';
|
||||||
END;$$;
|
END;$$;
|
||||||
select create_distributed_function('mx_call_proc_raise(int)', '$1', 'mx_call_dist_table_1');
|
select create_distributed_function('mx_call_proc_raise(int)', '$1', 'mx_call_dist_table_1');
|
||||||
|
\set VERBOSITY terse
|
||||||
call multi_mx_call.mx_call_proc_raise(2);
|
call multi_mx_call.mx_call_proc_raise(2);
|
||||||
|
\set VERBOSITY default
|
||||||
|
|
||||||
-- Test that we don't propagate to non-metadata worker nodes
|
-- Test that we don't propagate to non-metadata worker nodes
|
||||||
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
select stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
|
|
|
@ -154,7 +154,10 @@ DELETE FROM pg_dist_node;
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
|
|
||||||
-- DROP TABLE
|
-- DROP TABLE
|
||||||
|
-- terse verbosity because pg10 has slightly different output
|
||||||
|
\set VERBOSITY terse
|
||||||
DROP TABLE mx_table;
|
DROP TABLE mx_table;
|
||||||
|
\set VERBOSITY default
|
||||||
SELECT count(*) FROM mx_table;
|
SELECT count(*) FROM mx_table;
|
||||||
|
|
||||||
-- master_drop_distributed_table_metadata
|
-- master_drop_distributed_table_metadata
|
||||||
|
|
Loading…
Reference in New Issue