mirror of https://github.com/citusdata/citus.git
fix 9.5
parent
93fc34b852
commit
3958bc58e6
|
@ -35,6 +35,7 @@
|
|||
#include "catalog/pg_type.h"
|
||||
#include "distributed/citus_nodefuncs.h"
|
||||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/multi_router_planner.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "commands/extension.h"
|
||||
#include "foreign/foreign.h"
|
||||
|
@ -3144,17 +3145,39 @@ get_update_query_def(Query *query, deparse_context *context)
|
|||
* Start the query with UPDATE relname SET
|
||||
*/
|
||||
rte = rt_fetch(query->resultRelation, query->rtable);
|
||||
Assert(rte->rtekind == RTE_RELATION);
|
||||
Assert(rte->rtekind == RTE_RELATION || UpdateFromQuery(query));
|
||||
if (PRETTY_INDENT(context))
|
||||
{
|
||||
appendStringInfoChar(buf, ' ');
|
||||
context->indentLevel += PRETTYINDENT_STD;
|
||||
}
|
||||
appendStringInfo(buf, "UPDATE %s%s",
|
||||
only_marker(rte),
|
||||
generate_relation_or_shard_name(rte->relid,
|
||||
context->distrelid,
|
||||
context->shardid, NIL));
|
||||
|
||||
/* if it's a shard, do differently */
|
||||
if (GetRangeTblKind(rte) == CITUS_RTE_SHARD)
|
||||
{
|
||||
char *fragmentSchemaName = NULL;
|
||||
char *fragmentTableName = NULL;
|
||||
|
||||
ExtractRangeTblExtraData(rte, NULL, &fragmentSchemaName, &fragmentTableName, NULL);
|
||||
|
||||
/* Use schema and table name from the remote alias */
|
||||
appendStringInfo(buf, "UPDATE %s%s",
|
||||
only_marker(rte),
|
||||
generate_fragment_name(fragmentSchemaName, fragmentTableName));
|
||||
|
||||
if(rte->eref != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfo(buf, "UPDATE %s%s",
|
||||
only_marker(rte),
|
||||
generate_relation_or_shard_name(rte->relid,
|
||||
context->distrelid,
|
||||
context->shardid, NIL));
|
||||
}
|
||||
|
||||
if (rte->alias != NULL)
|
||||
appendStringInfo(buf, " %s",
|
||||
quote_identifier(rte->alias->aliasname));
|
||||
|
|
Loading…
Reference in New Issue