Support quoted column-names in COPY logic

pull/1492/head
Marco Slot 2017-06-19 12:05:55 +02:00
parent 5bd4583935
commit 43f9758787
1 changed files with 5 additions and 1 deletions

View File

@ -1684,6 +1684,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;
@ -1777,6 +1778,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);
@ -1790,6 +1792,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)
@ -1805,7 +1809,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;