mirror of https://github.com/citusdata/citus.git
Add ruleutils changes from 3977 and 4011
parent
63ed126ad4
commit
33406598e3
|
@ -984,6 +984,7 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
int ncolumns;
|
||||
char **real_colnames;
|
||||
bool changed_any;
|
||||
bool has_anonymous;
|
||||
int noldcolumns;
|
||||
int i;
|
||||
int j;
|
||||
|
@ -1071,6 +1072,7 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
*/
|
||||
noldcolumns = list_length(rte->eref->colnames);
|
||||
changed_any = false;
|
||||
has_anonymous = false;
|
||||
j = 0;
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
{
|
||||
|
@ -1108,6 +1110,13 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
/* Remember if any assigned aliases differ from "real" name */
|
||||
if (!changed_any && strcmp(colname, real_colname) != 0)
|
||||
changed_any = true;
|
||||
|
||||
/*
|
||||
* Remember if there is a reference to an anonymous column as named by
|
||||
* char * FigureColname(Node *node)
|
||||
*/
|
||||
if (!has_anonymous && strcmp(real_colname, "?column?") == 0)
|
||||
has_anonymous = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1137,7 +1146,7 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
else if (rte->alias && rte->alias->colnames != NIL)
|
||||
colinfo->printaliases = true;
|
||||
else
|
||||
colinfo->printaliases = changed_any;
|
||||
colinfo->printaliases = changed_any || has_anonymous;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2975,7 +2984,7 @@ get_insert_query_def(Query *query, deparse_context *context)
|
|||
/* INSERT requires AS keyword for target alias */
|
||||
if (rte->alias != NULL)
|
||||
appendStringInfo(buf, "AS %s ",
|
||||
quote_identifier(rte->alias->aliasname));
|
||||
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||
|
||||
/*
|
||||
* Add the insert-column-names list. Any indirection decoration needed on
|
||||
|
@ -3174,7 +3183,7 @@ get_update_query_def(Query *query, deparse_context *context)
|
|||
|
||||
if(rte->eref != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3186,7 +3195,7 @@ get_update_query_def(Query *query, deparse_context *context)
|
|||
|
||||
if (rte->alias != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->alias->aliasname));
|
||||
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||
}
|
||||
|
||||
appendStringInfoString(buf, " SET ");
|
||||
|
@ -3406,7 +3415,7 @@ get_delete_query_def(Query *query, deparse_context *context)
|
|||
|
||||
if(rte->eref != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3418,7 +3427,7 @@ get_delete_query_def(Query *query, deparse_context *context)
|
|||
|
||||
if (rte->alias != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->alias->aliasname));
|
||||
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||
}
|
||||
|
||||
/* Add the USING clause if given */
|
||||
|
|
Loading…
Reference in New Issue