Support quoted column-names in COPY logic

pull/1402/head
Marco Slot 2017-06-19 12:05:55 +02:00
parent 155db4d913
commit 2cd358ad1a
1 changed files with 5 additions and 1 deletions

View File

@ -1676,6 +1676,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
Relation distributedRelation = NULL; Relation distributedRelation = NULL;
int columnIndex = 0; int columnIndex = 0;
List *columnNameList = copyDest->columnNameList; List *columnNameList = copyDest->columnNameList;
List *quotedColumnNameList = NIL;
ListCell *columnNameCell = NULL; ListCell *columnNameCell = NULL;
@ -1769,6 +1770,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
foreach(columnNameCell, columnNameList) foreach(columnNameCell, columnNameList)
{ {
char *columnName = (char *) lfirst(columnNameCell); char *columnName = (char *) lfirst(columnNameCell);
char *quotedColumnName = (char *) quote_identifier(columnName);
/* load the column information from pg_attribute */ /* load the column information from pg_attribute */
AttrNumber attrNumber = get_attnum(tableId, columnName); AttrNumber attrNumber = get_attnum(tableId, columnName);
@ -1782,6 +1784,8 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
} }
columnIndex++; columnIndex++;
quotedColumnNameList = lappend(quotedColumnNameList, quotedColumnName);
} }
if (partitionMethod != DISTRIBUTE_BY_NONE && partitionColumnIndex == -1) if (partitionMethod != DISTRIBUTE_BY_NONE && partitionColumnIndex == -1)
@ -1797,7 +1801,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
copyStatement = makeNode(CopyStmt); copyStatement = makeNode(CopyStmt);
copyStatement->relation = makeRangeVar(schemaName, relationName, -1); copyStatement->relation = makeRangeVar(schemaName, relationName, -1);
copyStatement->query = NULL; copyStatement->query = NULL;
copyStatement->attlist = columnNameList; copyStatement->attlist = quotedColumnNameList;
copyStatement->is_from = true; copyStatement->is_from = true;
copyStatement->is_program = false; copyStatement->is_program = false;
copyStatement->filename = NULL; copyStatement->filename = NULL;