Skip to content
Open

mods #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contrib/pgxc_ctl/do_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,13 @@ int do_singleLine(char *buf, char *wkline)
do_stop_command(line);
return 0;
}
#ifdef XZ
else if (TestToken("restart")) {
do_stop_command(line);
do_start_command(line);
return 0;
}
#endif
else if (TestToken("monitor"))
{
do_monitor_command(line);
Expand Down
63 changes: 62 additions & 1 deletion src/backend/access/common/reloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,15 +972,34 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace,
* Convert the text-array format of reloptions into a List of DefElem.
* This is the inverse of transformRelOptions().
*/
#ifdef XZ
List *
untransformRelOptions(Datum options)
{
#ifdef XZ_DEBUG
elog(NOTICE, "[DEBUG](untransformRelOptions) called");
#endif
return untransformRelOptionsForNode(options, IS_PGXC_DATANODE, true);
}

List *
untransformRelOptionsForNode(Datum options, bool node_only, bool strip_all)
#else
List *
untransformRelOptions(Datum options)
#endif
{
#ifdef XZ_DEBUG
elog(NOTICE, "[DEBUG](untransformRelOptionsForNode) called");
#endif
List *result = NIL;
ArrayType *array;
Datum *optiondatums;
int noptions;
int i;

#ifdef XZ
ListCell *cell;
#endif
/* Nothing to do if no options */
if (!PointerIsValid(DatumGetPointer(options)))
return result;
Expand All @@ -997,12 +1016,54 @@ untransformRelOptions(Datum options)
Node *val = NULL;

s = TextDatumGetCString(optiondatums[i]);
#ifdef XZ
if (node_only || strip_all)
{
/*
* Ignore any node options not intended for our node
* Options are in node:option=value format
*/
p = strchr(s, ':');
if (p)
{
*p++ = '\0';
if (node_only && (strcasecmp(s, PGXCNodeName) != 0) )
continue;
s = p;
}
}
#endif
p = strchr(s, '=');
if (p)
{
*p++ = '\0';
val = (Node *) makeString(pstrdup(p));
}
#ifdef XZ
if (strip_all)
{
/*
* Make sure list is unique, otherwise validation checks will fail.
* If strip_all is true, we just take the first one to pass
* coordinator validation checks.
*/
bool is_dupe = false;

foreach(cell, result)
{
DefElem *def = (DefElem *) lfirst(cell);

/* If a duplicate, skip */
if (pg_strcasecmp(def->defname, s) == 0)
{
is_dupe = true;
break;
}
}
if (is_dupe)
continue;
}
#endif
result = lappend(result, makeDefElem(pstrdup(s), val, -1));
}

Expand Down
12 changes: 12 additions & 0 deletions src/backend/commands/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,10 @@ limit_printout_length(const char *str)
uint64
CopyFrom(CopyState cstate)
{// #lizard forgives
#ifdef XZ_DEBUG
elog(NOTICE, "[DEBUG](COPY) called");
#endif

HeapTuple tuple;
TupleDesc tupDesc;
Datum *values;
Expand Down Expand Up @@ -2986,6 +2990,10 @@ CopyFrom(CopyState cstate)
*/
if (cstate->rel->rd_rel->relkind != RELKIND_RELATION &&
cstate->rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE &&
#ifdef XZ
/* Allow on coordinator */
! (cstate->rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE && IS_PGXC_COORDINATOR) &&
#endif
!(cstate->rel->trigdesc &&
cstate->rel->trigdesc->trig_insert_instead_row))
{
Expand All @@ -3000,11 +3008,15 @@ CopyFrom(CopyState cstate)
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot copy to materialized view \"%s\"",
RelationGetRelationName(cstate->rel))));
#ifdef XZ
/* Allow this, so coordinator can forward to data nodes to load */
#else
else if (cstate->rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot copy to foreign table \"%s\"",
RelationGetRelationName(cstate->rel))));
#endif
else if (cstate->rel->rd_rel->relkind == RELKIND_SEQUENCE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
Expand Down
Loading