mirror of https://github.com/citusdata/citus.git
Adds SQL-standard function body support to ruleutils_14.c
Relevant PG commit: e717a9a18b2e34c9c40e5259ad4d31cd7e420750pg14_support_3
parent
0d0fbe518c
commit
d07a6129e3
|
@ -182,6 +182,10 @@ typedef struct
|
|||
List *outer_tlist; /* referent for OUTER_VAR Vars */
|
||||
List *inner_tlist; /* referent for INNER_VAR Vars */
|
||||
List *index_tlist; /* referent for INDEX_VAR Vars */
|
||||
/* Special namespace representing a function signature: */
|
||||
char *funcname;
|
||||
int numargs;
|
||||
char **argnames;
|
||||
} deparse_namespace;
|
||||
|
||||
/* Callback signature for resolve_special_varno() */
|
||||
|
@ -2358,7 +2362,10 @@ get_basic_select_query(Query *query, deparse_context *context,
|
|||
/*
|
||||
* Build up the query string - first we say SELECT
|
||||
*/
|
||||
appendStringInfoString(buf, "SELECT");
|
||||
if (query->isReturn)
|
||||
appendStringInfoString(buf, "RETURN");
|
||||
else
|
||||
appendStringInfoString(buf, "SELECT");
|
||||
|
||||
/* Add the DISTINCT clause if given */
|
||||
if (query->distinctClause != NIL)
|
||||
|
@ -4594,6 +4601,50 @@ get_parameter(Param *param, deparse_context *context)
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it's an external parameter, see if the outermost namespace provides
|
||||
* function argument names.
|
||||
*/
|
||||
if (param->paramkind == PARAM_EXTERN)
|
||||
{
|
||||
dpns = lfirst(list_tail(context->namespaces));
|
||||
if (dpns->argnames)
|
||||
{
|
||||
char *argname = dpns->argnames[param->paramid - 1];
|
||||
|
||||
if (argname)
|
||||
{
|
||||
bool should_qualify = false;
|
||||
ListCell *lc;
|
||||
|
||||
/*
|
||||
* Qualify the parameter name if there are any other deparse
|
||||
* namespaces with range tables. This avoids qualifying in
|
||||
* trivial cases like "RETURN a + b", but makes it safe in all
|
||||
* other cases.
|
||||
*/
|
||||
foreach(lc, context->namespaces)
|
||||
{
|
||||
deparse_namespace *dpns = lfirst(lc);
|
||||
|
||||
if (list_length(dpns->rtable_names) > 0)
|
||||
{
|
||||
should_qualify = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (should_qualify)
|
||||
{
|
||||
appendStringInfoString(context->buf, quote_identifier(dpns->funcname));
|
||||
appendStringInfoChar(context->buf, '.');
|
||||
}
|
||||
|
||||
appendStringInfoString(context->buf, quote_identifier(argname));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Not PARAM_EXEC, or couldn't find referent: for base types just print $N.
|
||||
* For composite types, add cast to the parameter to ease remote node detect
|
||||
|
|
Loading…
Reference in New Issue