From 43f97587878ed35e14bec9b69879b71f91b45852 Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Mon, 19 Jun 2017 12:05:55 +0200 Subject: [PATCH] Support quoted column-names in COPY logic --- src/backend/distributed/commands/multi_copy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index a0e1f0b65..de8758512 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -1684,6 +1684,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation, Relation distributedRelation = NULL; int columnIndex = 0; List *columnNameList = copyDest->columnNameList; + List *quotedColumnNameList = NIL; ListCell *columnNameCell = NULL; @@ -1777,6 +1778,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation, foreach(columnNameCell, columnNameList) { char *columnName = (char *) lfirst(columnNameCell); + char *quotedColumnName = (char *) quote_identifier(columnName); /* load the column information from pg_attribute */ AttrNumber attrNumber = get_attnum(tableId, columnName); @@ -1790,6 +1792,8 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation, } columnIndex++; + + quotedColumnNameList = lappend(quotedColumnNameList, quotedColumnName); } if (partitionMethod != DISTRIBUTE_BY_NONE && partitionColumnIndex == -1) @@ -1805,7 +1809,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation, copyStatement = makeNode(CopyStmt); copyStatement->relation = makeRangeVar(schemaName, relationName, -1); copyStatement->query = NULL; - copyStatement->attlist = columnNameList; + copyStatement->attlist = quotedColumnNameList; copyStatement->is_from = true; copyStatement->is_program = false; copyStatement->filename = NULL;