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;
|
int ncolumns;
|
||||||
char **real_colnames;
|
char **real_colnames;
|
||||||
bool changed_any;
|
bool changed_any;
|
||||||
|
bool has_anonymous;
|
||||||
int noldcolumns;
|
int noldcolumns;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -1071,6 +1072,7 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
||||||
*/
|
*/
|
||||||
noldcolumns = list_length(rte->eref->colnames);
|
noldcolumns = list_length(rte->eref->colnames);
|
||||||
changed_any = false;
|
changed_any = false;
|
||||||
|
has_anonymous = false;
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < ncolumns; i++)
|
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 */
|
/* Remember if any assigned aliases differ from "real" name */
|
||||||
if (!changed_any && strcmp(colname, real_colname) != 0)
|
if (!changed_any && strcmp(colname, real_colname) != 0)
|
||||||
changed_any = true;
|
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)
|
else if (rte->alias && rte->alias->colnames != NIL)
|
||||||
colinfo->printaliases = true;
|
colinfo->printaliases = true;
|
||||||
else
|
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 */
|
/* INSERT requires AS keyword for target alias */
|
||||||
if (rte->alias != NULL)
|
if (rte->alias != NULL)
|
||||||
appendStringInfo(buf, "AS %s ",
|
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
|
* 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)
|
if(rte->eref != NULL)
|
||||||
appendStringInfo(buf, " %s",
|
appendStringInfo(buf, " %s",
|
||||||
quote_identifier(rte->eref->aliasname));
|
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3186,7 +3195,7 @@ get_update_query_def(Query *query, deparse_context *context)
|
||||||
|
|
||||||
if (rte->alias != NULL)
|
if (rte->alias != NULL)
|
||||||
appendStringInfo(buf, " %s",
|
appendStringInfo(buf, " %s",
|
||||||
quote_identifier(rte->alias->aliasname));
|
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfoString(buf, " SET ");
|
appendStringInfoString(buf, " SET ");
|
||||||
|
@ -3406,7 +3415,7 @@ get_delete_query_def(Query *query, deparse_context *context)
|
||||||
|
|
||||||
if(rte->eref != NULL)
|
if(rte->eref != NULL)
|
||||||
appendStringInfo(buf, " %s",
|
appendStringInfo(buf, " %s",
|
||||||
quote_identifier(rte->eref->aliasname));
|
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3418,7 +3427,7 @@ get_delete_query_def(Query *query, deparse_context *context)
|
||||||
|
|
||||||
if (rte->alias != NULL)
|
if (rte->alias != NULL)
|
||||||
appendStringInfo(buf, " %s",
|
appendStringInfo(buf, " %s",
|
||||||
quote_identifier(rte->alias->aliasname));
|
quote_identifier(get_rtable_name(query->resultRelation, context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the USING clause if given */
|
/* Add the USING clause if given */
|
||||||
|
|
Loading…
Reference in New Issue