Skip to content

Commit 484e3d8

Browse files
committed
Support local COPY ultility
1 parent 075798f commit 484e3d8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

contrib/mmts/multimaster.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5441,6 +5441,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
54415441
CopyStmt *copyStatement = (CopyStmt *) parsetree;
54425442
skipCommand = true;
54435443
if (copyStatement->is_from) {
5444+
ListCell *opt;
54445445
RangeVar *relation = copyStatement->relation;
54455446

54465447
if (relation != NULL)
@@ -5455,6 +5456,17 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
54555456
heap_close(rel, ShareLock);
54565457
}
54575458
}
5459+
5460+
foreach(opt, copyStatement->options)
5461+
{
5462+
DefElem *elem = lfirst(opt);
5463+
if (strcmp("local", elem->defname) == 0) {
5464+
MtmTx.isDistributed = false; /* Skip */
5465+
MtmTx.snapshot = INVALID_CSN;
5466+
MtmTx.containsDML = false;
5467+
break;
5468+
}
5469+
}
54585470
}
54595471
case T_CreateFunctionStmt:
54605472
{

src/backend/commands/copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ ProcessCopyOptions(CopyState cstate,
11911191
errmsg("argument to option \"%s\" must be a valid encoding name",
11921192
defel->defname)));
11931193
}
1194-
else
1194+
else if (strcmp(defel->defname, "local") != 0)
11951195
ereport(ERROR,
11961196
(errcode(ERRCODE_SYNTAX_ERROR),
11971197
errmsg("option \"%s\" not recognized",

src/backend/parser/gram.y

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,6 +2856,10 @@ copy_opt_item:
28562856
{
28572857
$$ = makeDefElem("format", (Node *)makeString("csv"));
28582858
}
2859+
| LOCAL
2860+
{
2861+
$$ = makeDefElem("local", (Node *)makeInteger(TRUE));
2862+
}
28592863
| HEADER_P
28602864
{
28612865
$$ = makeDefElem("header", (Node *)makeInteger(TRUE));

0 commit comments

Comments
 (0)