Merge pull request #672 from citusdata/drop_pg_94_support

Drop PostgreSQL 9.4 support
pull/647/head
Murat Tuncer 2016-07-26 20:24:15 +03:00 committed by GitHub
commit 512d1791c2
25 changed files with 6 additions and 8895 deletions

View File

@ -9,7 +9,6 @@ env:
secure: degV+qb2xHiea7E2dGk/WLvmYjq4ZsBn6ZPko+YhRcNm2GRXRaU3FqMBIecPtsEEFYaL5GwCQq/CgBf9aQxgDQ+t2CrmtGTtI9AGAbVBl//amNeJOoLe6QvrDpSQX5pUxwDLCng8cvoQK7ZxGlNCzDKiu4Ep4DUWgQVpauJkQ9nHjtSMZvUqCoI9h1lBy9Mxh7YFfHPW2PAXCqpV4VlNiIYF84UKdX3MXKLy9Yt0JBSNTWLZFp/fFw2qNwzFvN94rF3ZvFSD7Wp6CIhT6R5/6k6Zx8YQIrjWhgm6OVy1osUA8X7W79h2ISPqKqMNVJkjJ+N8S4xuQU0kfejnQ74Ie/uJiHCmbW5W2TjpL1aU3FQpPsGwR8h0rSeHhJAJzd8Ma+z8vvnnQHDyvetPBB0WgA/VMQCu8uEutyfYw2hDmB2+l2dDwkViaI7R95bReAGrpd5uNqklAXuR7yOeArz0ZZpHV0aZHGcNBxznMaZExSVZ5DVPW38UPn7Kgse8BnOWeLgnA1hJVp6CmBCtu+hKYt+atBPgRbM8IUINnKKZf/Sk6HeJIJZs662jD8/X93vFi0ZtyV2jEKJpouWw8j4vrGGsaDzTEUcyJgDqZj7tPJptM2L5B3BcFJmkGj2HO3N+LGDarJrVBBSiEjhTgx4NnLiKZnUbMx547mCRg2akk2w= secure: degV+qb2xHiea7E2dGk/WLvmYjq4ZsBn6ZPko+YhRcNm2GRXRaU3FqMBIecPtsEEFYaL5GwCQq/CgBf9aQxgDQ+t2CrmtGTtI9AGAbVBl//amNeJOoLe6QvrDpSQX5pUxwDLCng8cvoQK7ZxGlNCzDKiu4Ep4DUWgQVpauJkQ9nHjtSMZvUqCoI9h1lBy9Mxh7YFfHPW2PAXCqpV4VlNiIYF84UKdX3MXKLy9Yt0JBSNTWLZFp/fFw2qNwzFvN94rF3ZvFSD7Wp6CIhT6R5/6k6Zx8YQIrjWhgm6OVy1osUA8X7W79h2ISPqKqMNVJkjJ+N8S4xuQU0kfejnQ74Ie/uJiHCmbW5W2TjpL1aU3FQpPsGwR8h0rSeHhJAJzd8Ma+z8vvnnQHDyvetPBB0WgA/VMQCu8uEutyfYw2hDmB2+l2dDwkViaI7R95bReAGrpd5uNqklAXuR7yOeArz0ZZpHV0aZHGcNBxznMaZExSVZ5DVPW38UPn7Kgse8BnOWeLgnA1hJVp6CmBCtu+hKYt+atBPgRbM8IUINnKKZf/Sk6HeJIJZs662jD8/X93vFi0ZtyV2jEKJpouWw8j4vrGGsaDzTEUcyJgDqZj7tPJptM2L5B3BcFJmkGj2HO3N+LGDarJrVBBSiEjhTgx4NnLiKZnUbMx547mCRg2akk2w=
matrix: matrix:
- PGVERSION=9.5 - PGVERSION=9.5
- PGVERSION=9.4
before_install: before_install:
- git clone --depth 1 https://github.com/citusdata/tools.git - git clone --depth 1 https://github.com/citusdata/tools.git
- tools/travis/setup_apt.sh - tools/travis/setup_apt.sh

2
configure vendored
View File

@ -1915,7 +1915,7 @@ if test -z "$version_num"; then
as_fn_error $? "Could not detect PostgreSQL version from pg_config." "$LINENO" 5 as_fn_error $? "Could not detect PostgreSQL version from pg_config." "$LINENO" 5
fi fi
if test "$version_num" != '9.4' -a "$version_num" != '9.5'; then if test "$version_num" != '9.5'; then
as_fn_error $? "Citus is not compatible with the detected PostgreSQL version ${version_num}." "$LINENO" 5 as_fn_error $? "Citus is not compatible with the detected PostgreSQL version ${version_num}." "$LINENO" 5
else else
{ $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5

View File

@ -36,7 +36,7 @@ if test -z "$version_num"; then
AC_MSG_ERROR([Could not detect PostgreSQL version from pg_config.]) AC_MSG_ERROR([Could not detect PostgreSQL version from pg_config.])
fi fi
if test "$version_num" != '9.4' -a "$version_num" != '9.5'; then if test "$version_num" != '9.5'; then
AC_MSG_ERROR([Citus is not compatible with the detected PostgreSQL version ${version_num}.]) AC_MSG_ERROR([Citus is not compatible with the detected PostgreSQL version ${version_num}.])
else else
AC_MSG_NOTICE([building against PostgreSQL $version_num]) AC_MSG_NOTICE([building against PostgreSQL $version_num])

View File

@ -167,12 +167,6 @@ RouterExecutorStart(QueryDesc *queryDesc, int eflags, Task *task)
*/ */
queryDesc->planstate = (PlanState *) makeNode(MaterialState); queryDesc->planstate = (PlanState *) makeNode(MaterialState);
#if (PG_VERSION_NUM < 90500)
/* make sure that upsertQuery is false for versions that UPSERT is not available */
Assert(task->upsertQuery == false);
#endif
lockMode = CommutativityRuleToLockMode(commandType, task->upsertQuery); lockMode = CommutativityRuleToLockMode(commandType, task->upsertQuery);
if (lockMode != NoLock) if (lockMode != NoLock)
@ -322,14 +316,7 @@ CreateXactParticipantHash(void)
info.keysize = sizeof(NodeConnectionKey); info.keysize = sizeof(NodeConnectionKey);
info.entrysize = sizeof(NodeConnectionEntry); info.entrysize = sizeof(NodeConnectionEntry);
info.hcxt = TopTransactionContext; info.hcxt = TopTransactionContext;
hashFlags = (HASH_ELEM | HASH_CONTEXT); hashFlags = (HASH_ELEM | HASH_CONTEXT | HASH_BLOBS);
#if (PG_VERSION_NUM >= 90500)
hashFlags |= HASH_BLOBS;
#else
hashFlags |= HASH_FUNCTION;
info.hash = tag_hash;
#endif
xactParticipantHash = hash_create("citus xact participant hash", 32, &info, xactParticipantHash = hash_create("citus xact participant hash", 32, &info,
hashFlags); hashFlags);
@ -1190,17 +1177,13 @@ RouterTransactionCallback(XactEvent event, void *arg)
switch (event) switch (event)
{ {
#if (PG_VERSION_NUM >= 90500)
case XACT_EVENT_PARALLEL_COMMIT: case XACT_EVENT_PARALLEL_COMMIT:
#endif
case XACT_EVENT_COMMIT: case XACT_EVENT_COMMIT:
{ {
break; break;
} }
#if (PG_VERSION_NUM >= 90500)
case XACT_EVENT_PARALLEL_ABORT: case XACT_EVENT_PARALLEL_ABORT:
#endif
case XACT_EVENT_ABORT: case XACT_EVENT_ABORT:
{ {
bool commit = false; bool commit = false;
@ -1221,9 +1204,7 @@ RouterTransactionCallback(XactEvent event, void *arg)
break; break;
} }
#if (PG_VERSION_NUM >= 90500)
case XACT_EVENT_PARALLEL_PRE_COMMIT: case XACT_EVENT_PARALLEL_PRE_COMMIT:
#endif
case XACT_EVENT_PRE_COMMIT: case XACT_EVENT_PRE_COMMIT:
{ {
bool commit = true; bool commit = true;

View File

@ -1036,19 +1036,10 @@ IsAlterTableRenameStmt(RenameStmt *renameStmt)
{ {
isAlterTableRenameStmt = true; isAlterTableRenameStmt = true;
} }
#if (PG_VERSION_NUM >= 90500)
else if (renameStmt->renameType == OBJECT_TABCONSTRAINT) else if (renameStmt->renameType == OBJECT_TABCONSTRAINT)
{ {
isAlterTableRenameStmt = true; isAlterTableRenameStmt = true;
} }
#else
else if (renameStmt->renameType == OBJECT_CONSTRAINT &&
renameStmt->relationType == OBJECT_TABLE)
{
isAlterTableRenameStmt = true;
}
#endif
return isAlterTableRenameStmt; return isAlterTableRenameStmt;
} }
@ -1113,21 +1104,12 @@ SetLocalCommitProtocolTo2PC(void)
{ {
ereport(DEBUG2, (errmsg("switching to 2PC for the transaction"))); ereport(DEBUG2, (errmsg("switching to 2PC for the transaction")));
#if (PG_VERSION_NUM >= 90500)
set_config_option("citus.multi_shard_commit_protocol", set_config_option("citus.multi_shard_commit_protocol",
"2pc", "2pc",
PGC_USERSET, PGC_USERSET,
PGC_S_SESSION, PGC_S_SESSION,
GUC_ACTION_LOCAL, GUC_ACTION_LOCAL,
true, 0, false); true, 0, false);
#else
set_config_option("citus.multi_shard_commit_protocol",
"2pc",
PGC_USERSET,
PGC_S_SESSION,
GUC_ACTION_LOCAL,
true, 0);
#endif
} }
} }
@ -1429,11 +1411,7 @@ CheckCopyPermissions(CopyStmt *copyStatement)
if (is_from) if (is_from)
{ {
#if (PG_VERSION_NUM >= 90500)
rte->insertedCols = bms_add_member(rte->insertedCols, attno); rte->insertedCols = bms_add_member(rte->insertedCols, attno);
#else
rte->modifiedCols = bms_add_member(rte->modifiedCols, attno);
#endif
} }
else else
{ {
@ -1595,11 +1573,7 @@ ReplicateGrantStmt(Node *parsetree)
isFirst = true; isFirst = true;
foreach(granteeCell, grantStmt->grantees) foreach(granteeCell, grantStmt->grantees)
{ {
#if (PG_VERSION_NUM >= 90500)
RoleSpec *spec = lfirst(granteeCell); RoleSpec *spec = lfirst(granteeCell);
#else
PrivGrantee *spec = lfirst(granteeCell);
#endif
if (!isFirst) if (!isFirst)
{ {
@ -1607,7 +1581,6 @@ ReplicateGrantStmt(Node *parsetree)
} }
isFirst = false; isFirst = false;
#if (PG_VERSION_NUM >= 90500)
if (spec->roletype == ROLESPEC_CSTRING) if (spec->roletype == ROLESPEC_CSTRING)
{ {
appendStringInfoString(&granteesString, quote_identifier(spec->rolename)); appendStringInfoString(&granteesString, quote_identifier(spec->rolename));
@ -1624,16 +1597,6 @@ ReplicateGrantStmt(Node *parsetree)
{ {
appendStringInfoString(&granteesString, "PUBLIC"); appendStringInfoString(&granteesString, "PUBLIC");
} }
#else
if (spec->rolname)
{
appendStringInfoString(&granteesString, quote_identifier(spec->rolname));
}
else
{
appendStringInfoString(&granteesString, "PUBLIC");
}
#endif
} }
/* /*

View File

@ -675,11 +675,7 @@ TableOwner(Oid relationId)
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
#if (PG_VERSION_NUM < 90500)
return GetUserNameFromId(userId);
#else
return GetUserNameFromId(userId, false); return GetUserNameFromId(userId, false);
#endif
} }

View File

@ -40,9 +40,7 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#if (PG_VERSION_NUM >= 90500)
#include "utils/ruleutils.h" #include "utils/ruleutils.h"
#endif
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/tqual.h" #include "utils/tqual.h"
@ -646,11 +644,7 @@ GetTableDDLEvents(Oid relationId)
Oid constraintId = get_index_constraint(indexId); Oid constraintId = get_index_constraint(indexId);
Assert(constraintId != InvalidOid); Assert(constraintId != InvalidOid);
#if (PG_VERSION_NUM >= 90500)
statementDef = pg_get_constraintdef_command(constraintId); statementDef = pg_get_constraintdef_command(constraintId);
#else
statementDef = pg_get_constraintdef_string(constraintId);
#endif
} }
else else
{ {

View File

@ -43,12 +43,6 @@
#include "utils/snapmgr.h" #include "utils/snapmgr.h"
#if (PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90500)
/* Crude hack to avoid changing sizeof(ExplainState) in released branches (explain.c) */
#define grouping_stack extra->groupingstack
#endif
/* OR-able flags for ExplainXMLTag() (explain.c) */ /* OR-able flags for ExplainXMLTag() (explain.c) */
#define X_OPENING 0 #define X_OPENING 0
#define X_CLOSING 1 #define X_CLOSING 1

View File

@ -50,9 +50,7 @@ static MultiNode * MultiPlanTree(Query *queryTree);
static void ErrorIfQueryNotSupported(Query *queryTree); static void ErrorIfQueryNotSupported(Query *queryTree);
static bool HasUnsupportedJoinWalker(Node *node, void *context); static bool HasUnsupportedJoinWalker(Node *node, void *context);
static void ErrorIfSubqueryNotSupported(Query *subqueryTree); static void ErrorIfSubqueryNotSupported(Query *subqueryTree);
#if (PG_VERSION_NUM >= 90500)
static bool HasTablesample(Query *queryTree); static bool HasTablesample(Query *queryTree);
#endif
static bool HasOuterJoin(Query *queryTree); static bool HasOuterJoin(Query *queryTree);
static bool HasOuterJoinWalker(Node *node, void *maxJoinLevel); static bool HasOuterJoinWalker(Node *node, void *maxJoinLevel);
static bool HasComplexJoinOrder(Query *queryTree); static bool HasComplexJoinOrder(Query *queryTree);
@ -356,9 +354,7 @@ static void
ErrorIfQueryNotSupported(Query *queryTree) ErrorIfQueryNotSupported(Query *queryTree)
{ {
char *errorDetail = NULL; char *errorDetail = NULL;
#if (PG_VERSION_NUM >= 90500)
bool hasTablesample = false; bool hasTablesample = false;
#endif
bool hasUnsupportedJoin = false; bool hasUnsupportedJoin = false;
bool hasComplexJoinOrder = false; bool hasComplexJoinOrder = false;
bool hasComplexRangeTableType = false; bool hasComplexRangeTableType = false;
@ -412,7 +408,6 @@ ErrorIfQueryNotSupported(Query *queryTree)
errorDetail = "Distinct clause is currently unsupported"; errorDetail = "Distinct clause is currently unsupported";
} }
#if (PG_VERSION_NUM >= 90500)
if (queryTree->groupingSets) if (queryTree->groupingSets)
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
@ -425,7 +420,6 @@ ErrorIfQueryNotSupported(Query *queryTree)
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Tablesample is currently unsupported"; errorDetail = "Tablesample is currently unsupported";
} }
#endif
hasUnsupportedJoin = HasUnsupportedJoinWalker((Node *) queryTree->jointree, NULL); hasUnsupportedJoin = HasUnsupportedJoinWalker((Node *) queryTree->jointree, NULL);
if (hasUnsupportedJoin) if (hasUnsupportedJoin)
@ -458,8 +452,6 @@ ErrorIfQueryNotSupported(Query *queryTree)
} }
#if (PG_VERSION_NUM >= 90500)
/* HasTablesample returns tree if the query contains tablesample */ /* HasTablesample returns tree if the query contains tablesample */
static bool static bool
HasTablesample(Query *queryTree) HasTablesample(Query *queryTree)
@ -482,9 +474,6 @@ HasTablesample(Query *queryTree)
} }
#endif
/* /*
* HasUnsupportedJoinWalker returns tree if the query contains an unsupported * HasUnsupportedJoinWalker returns tree if the query contains an unsupported
* join type. We currently support inner, left, right, full and anti joins. * join type. We currently support inner, left, right, full and anti joins.

View File

@ -167,15 +167,9 @@ BuildAggregatePlan(Query *masterQuery, Plan *subPlan)
} }
/* finally create the plan */ /* finally create the plan */
#if (PG_VERSION_NUM >= 90500)
aggregatePlan = make_agg(NULL, aggregateTargetList, NIL, aggregateStrategy, aggregatePlan = make_agg(NULL, aggregateTargetList, NIL, aggregateStrategy,
&aggregateCosts, groupColumnCount, groupColumnIdArray, &aggregateCosts, groupColumnCount, groupColumnIdArray,
groupColumnOpArray, NIL, rowEstimate, subPlan); groupColumnOpArray, NIL, rowEstimate, subPlan);
#else
aggregatePlan = make_agg(NULL, aggregateTargetList, NIL, aggregateStrategy,
&aggregateCosts, groupColumnCount, groupColumnIdArray,
groupColumnOpArray, rowEstimate, subPlan);
#endif
return aggregatePlan; return aggregatePlan;
} }

View File

@ -15,11 +15,7 @@
#include <stddef.h> #include <stddef.h>
#if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90600)
#include "access/stratnum.h" #include "access/stratnum.h"
#else
#include "access/skey.h"
#endif
#include "access/xact.h" #include "access/xact.h"
#include "distributed/citus_clauses.h" #include "distributed/citus_clauses.h"
#include "distributed/citus_nodes.h" #include "distributed/citus_nodes.h"
@ -37,9 +33,7 @@
#include "distributed/shardinterval_utils.h" #include "distributed/shardinterval_utils.h"
#include "executor/execdesc.h" #include "executor/execdesc.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#if (PG_VERSION_NUM >= 90500)
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#endif
#include "nodes/nodeFuncs.h" #include "nodes/nodeFuncs.h"
#include "nodes/nodes.h" #include "nodes/nodes.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
@ -154,12 +148,10 @@ ErrorIfModifyQueryNotSupported(Query *queryTree)
bool hasValuesScan = false; bool hasValuesScan = false;
uint32 queryTableCount = 0; uint32 queryTableCount = 0;
bool specifiesPartitionValue = false; bool specifiesPartitionValue = false;
#if (PG_VERSION_NUM >= 90500)
ListCell *setTargetCell = NULL; ListCell *setTargetCell = NULL;
List *onConflictSet = NIL; List *onConflictSet = NIL;
Node *arbiterWhere = NULL; Node *arbiterWhere = NULL;
Node *onConflictWhere = NULL; Node *onConflictWhere = NULL;
#endif
CmdType commandType = queryTree->commandType; CmdType commandType = queryTree->commandType;
Assert(commandType == CMD_INSERT || commandType == CMD_UPDATE || Assert(commandType == CMD_INSERT || commandType == CMD_UPDATE ||
@ -357,7 +349,6 @@ ErrorIfModifyQueryNotSupported(Query *queryTree)
} }
} }
#if (PG_VERSION_NUM >= 90500)
if (commandType == CMD_INSERT && queryTree->onConflict != NULL) if (commandType == CMD_INSERT && queryTree->onConflict != NULL)
{ {
onConflictSet = queryTree->onConflict->onConflictSet; onConflictSet = queryTree->onConflict->onConflictSet;
@ -421,7 +412,6 @@ ErrorIfModifyQueryNotSupported(Query *queryTree)
"clause of INSERTs on distributed tables must be marked " "clause of INSERTs on distributed tables must be marked "
"IMMUTABLE"))); "IMMUTABLE")));
} }
#endif
if (specifiesPartitionValue) if (specifiesPartitionValue)
{ {
@ -689,7 +679,6 @@ RouterModifyTask(Query *originalQuery, Query *query)
/* grab shared metadata lock to stop concurrent placement additions */ /* grab shared metadata lock to stop concurrent placement additions */
LockShardDistributionMetadata(shardId, ShareLock); LockShardDistributionMetadata(shardId, ShareLock);
#if (PG_VERSION_NUM >= 90500)
if (originalQuery->onConflict != NULL) if (originalQuery->onConflict != NULL)
{ {
RangeTblEntry *rangeTableEntry = NULL; RangeTblEntry *rangeTableEntry = NULL;
@ -705,11 +694,6 @@ RouterModifyTask(Query *originalQuery, Query *query)
rangeTableEntry->alias = alias; rangeTableEntry->alias = alias;
} }
} }
#else
/* always set to false for PG_VERSION_NUM < 90500 */
upsertQuery = false;
#endif
deparse_shard_query(originalQuery, shardInterval->relationId, shardId, queryString); deparse_shard_query(originalQuery, shardInterval->relationId, shardId, queryString);
ereport(DEBUG4, (errmsg("distributed statement: %s", queryString->data))); ereport(DEBUG4, (errmsg("distributed statement: %s", queryString->data)));
@ -1095,12 +1079,10 @@ MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType)
return false; return false;
} }
#if (PG_VERSION_NUM >= 90500)
if (query->groupingSets) if (query->groupingSets)
{ {
return false; return false;
} }
#endif
/* only hash partitioned tables are supported */ /* only hash partitioned tables are supported */
distributedTableId = ExtractFirstDistributedTableId(query); distributedTableId = ExtractFirstDistributedTableId(query);
@ -1127,12 +1109,10 @@ MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType)
return false; return false;
} }
#if (PG_VERSION_NUM >= 90500)
if (rangeTableEntry->tablesample) if (rangeTableEntry->tablesample)
{ {
return false; return false;
} }
#endif
if (joinTree == NULL) if (joinTree == NULL)
{ {

View File

@ -341,7 +341,6 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
{ {
ReindexStmt *reindexStmt = (ReindexStmt *) parseTree; ReindexStmt *reindexStmt = (ReindexStmt *) parseTree;
#if (PG_VERSION_NUM >= 90500)
ReindexObjectType objectType = reindexStmt->kind; ReindexObjectType objectType = reindexStmt->kind;
if (objectType == REINDEX_OBJECT_TABLE || objectType == REINDEX_OBJECT_INDEX) if (objectType == REINDEX_OBJECT_TABLE || objectType == REINDEX_OBJECT_INDEX)
{ {
@ -357,23 +356,6 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
{ {
ereport(ERROR, (errmsg("cannot extend name for multi-relation reindex"))); ereport(ERROR, (errmsg("cannot extend name for multi-relation reindex")));
} }
#else
ObjectType objectType = reindexStmt->kind;
if (objectType == OBJECT_TABLE || objectType == OBJECT_INDEX)
{
char **objectName = &(reindexStmt->relation->relname);
char **objectSchemaName = &(reindexStmt->relation->schemaname);
/* prefix with schema name if it is not added already */
SetSchemaNameIfNotExist(objectSchemaName, schemaName);
AppendShardIdToName(objectName, shardId);
}
else if (objectType == OBJECT_DATABASE)
{
ereport(ERROR, (errmsg("cannot extend name for multi-relation reindex")));
}
#endif
else else
{ {
ereport(ERROR, (errmsg("invalid object type in reindex statement"), ereport(ERROR, (errmsg("invalid object type in reindex statement"),

View File

@ -34,16 +34,10 @@ static void FakeGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel,
Oid foreigntableid); Oid foreigntableid);
static void FakeGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, static void FakeGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel,
Oid foreigntableid); Oid foreigntableid);
#if (PG_VERSION_NUM >= 90300 && PG_VERSION_NUM < 90500)
static ForeignScan * FakeGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel,
Oid foreigntableid, ForeignPath *best_path,
List *tlist, List *scan_clauses);
#else
static ForeignScan * FakeGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, static ForeignScan * FakeGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel,
Oid foreigntableid, ForeignPath *best_path, Oid foreigntableid, ForeignPath *best_path,
List *tlist, List *scan_clauses, List *tlist, List *scan_clauses,
Plan *outer_plan); Plan *outer_plan);
#endif
static void FakeBeginForeignScan(ForeignScanState *node, int eflags); static void FakeBeginForeignScan(ForeignScanState *node, int eflags);
static TupleTableSlot * FakeIterateForeignScan(ForeignScanState *node); static TupleTableSlot * FakeIterateForeignScan(ForeignScanState *node);
static void FakeReScanForeignScan(ForeignScanState *node); static void FakeReScanForeignScan(ForeignScanState *node);
@ -95,42 +89,25 @@ FakeGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid)
Cost startup_cost = 0; Cost startup_cost = 0;
Cost total_cost = startup_cost + baserel->rows; Cost total_cost = startup_cost + baserel->rows;
#if (PG_VERSION_NUM >= 90300 && PG_VERSION_NUM < 90500)
add_path(baserel, (Path *) create_foreignscan_path(root, baserel, baserel->rows,
startup_cost, total_cost, NIL,
NULL, NIL));
#else
add_path(baserel, (Path *) create_foreignscan_path(root, baserel, baserel->rows, add_path(baserel, (Path *) create_foreignscan_path(root, baserel, baserel->rows,
startup_cost, total_cost, NIL, startup_cost, total_cost, NIL,
NULL, NULL, NIL)); NULL, NULL, NIL));
#endif
} }
/* /*
* FakeGetForeignPlan builds a fake foreign plan. * FakeGetForeignPlan builds a fake foreign plan.
*/ */
#if (PG_VERSION_NUM >= 90300 && PG_VERSION_NUM < 90500)
static ForeignScan * static ForeignScan *
FakeGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid, FakeGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid,
ForeignPath *best_path, List *tlist, List *scan_clauses) ForeignPath *best_path, List *tlist, List *scan_clauses,
#else Plan *outer_plan)
static ForeignScan *
FakeGetForeignPlan(PlannerInfo * root, RelOptInfo * baserel, Oid foreigntableid,
ForeignPath * best_path, List * tlist, List * scan_clauses,
Plan * outer_plan)
#endif
{ {
Index scan_relid = baserel->relid; Index scan_relid = baserel->relid;
scan_clauses = extract_actual_clauses(scan_clauses, false); scan_clauses = extract_actual_clauses(scan_clauses, false);
/* make_foreignscan has a different signature in 9.3 and 9.4 than in 9.5 */
#if (PG_VERSION_NUM >= 90300 && PG_VERSION_NUM < 90500)
return make_foreignscan(tlist, scan_clauses, scan_relid, NIL, NIL);
#else
return make_foreignscan(tlist, scan_clauses, scan_relid, NIL, NIL, NIL, NIL, return make_foreignscan(tlist, scan_clauses, scan_relid, NIL, NIL, NIL, NIL,
outer_plan); outer_plan);
#endif
} }

View File

@ -16,11 +16,7 @@
#include <string.h> #include <string.h>
#if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90600)
#include "access/stratnum.h" #include "access/stratnum.h"
#else
#include "access/skey.h"
#endif
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "distributed/metadata_cache.h" #include "distributed/metadata_cache.h"
#include "distributed/master_metadata_utility.h" #include "distributed/master_metadata_utility.h"

File diff suppressed because it is too large Load Diff

View File

@ -46,9 +46,7 @@
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/rel.h" #include "utils/rel.h"
#if (PG_VERSION_NUM >= 90500)
#include "utils/ruleutils.h" #include "utils/ruleutils.h"
#endif
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/typcache.h" #include "utils/typcache.h"
#include "utils/xml.h" #include "utils/xml.h"

View File

@ -725,11 +725,7 @@ CurrentUserName(void)
{ {
Oid userId = GetUserId(); Oid userId = GetUserId();
#if (PG_VERSION_NUM < 90500)
return GetUserNameFromId(userId);
#else
return GetUserNameFromId(userId, false); return GetUserNameFromId(userId, false);
#endif
} }

File diff suppressed because it is too large Load Diff

View File

@ -265,11 +265,7 @@ CreateJobSchema(StringInfo schemaName)
/* build a CREATE SCHEMA statement */ /* build a CREATE SCHEMA statement */
CreateSchemaStmt *createSchemaStmt = makeNode(CreateSchemaStmt); CreateSchemaStmt *createSchemaStmt = makeNode(CreateSchemaStmt);
createSchemaStmt->schemaname = schemaName->data; createSchemaStmt->schemaname = schemaName->data;
#if (PG_VERSION_NUM >= 90500)
createSchemaStmt->authrole = NULL; createSchemaStmt->authrole = NULL;
#else
createSchemaStmt->authid = NULL;
#endif
createSchemaStmt->schemaElts = NIL; createSchemaStmt->schemaElts = NIL;
/* allow schema names that start with pg_ */ /* allow schema names that start with pg_ */

View File

@ -369,9 +369,7 @@ CreateTaskTable(StringInfo schemaName, StringInfo relationName,
RangeVar *relation = NULL; RangeVar *relation = NULL;
List *columnDefinitionList = NIL; List *columnDefinitionList = NIL;
Oid relationId PG_USED_FOR_ASSERTS_ONLY = InvalidOid; Oid relationId PG_USED_FOR_ASSERTS_ONLY = InvalidOid;
#if (PG_VERSION_NUM >= 90500)
ObjectAddress relationObject; ObjectAddress relationObject;
#endif
Assert(schemaName != NULL); Assert(schemaName != NULL);
Assert(relationName != NULL); Assert(relationName != NULL);
@ -386,12 +384,8 @@ CreateTaskTable(StringInfo schemaName, StringInfo relationName,
createStatement = CreateStatement(relation, columnDefinitionList); createStatement = CreateStatement(relation, columnDefinitionList);
#if (PG_VERSION_NUM >= 90500)
relationObject = DefineRelation(createStatement, RELKIND_RELATION, InvalidOid, NULL); relationObject = DefineRelation(createStatement, RELKIND_RELATION, InvalidOid, NULL);
relationId = relationObject.objectId; relationId = relationObject.objectId;
#else
relationId = DefineRelation(createStatement, RELKIND_RELATION, InvalidOid);
#endif
Assert(relationId != InvalidOid); Assert(relationId != InvalidOid);
CommandCounterIncrement(); CommandCounterIncrement();

View File

@ -31,12 +31,6 @@
#include <sys/stat.h> /* for stat() */ #include <sys/stat.h> /* for stat() */
#endif #endif
#if (PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90500)
#ifdef USE_SSL
#include <openssl/ssl.h>
#endif /* USE_SSL */
#endif /* (PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90500) */
#include "portability/instr_time.h" #include "portability/instr_time.h"
#include "libpq-fe.h" #include "libpq-fe.h"
@ -1898,7 +1892,6 @@ connection_warnings(bool in_startup)
* *
* Prints information about the current SSL connection, if SSL is in use * Prints information about the current SSL connection, if SSL is in use
*/ */
#if (PG_VERSION_NUM >= 90500)
static void static void
printSSLInfo(void) printSSLInfo(void)
{ {
@ -1921,34 +1914,6 @@ printSSLInfo(void)
bits ? bits : _("unknown"), bits ? bits : _("unknown"),
(compression && strcmp(compression, "off") != 0) ? _("on") : _("off")); (compression && strcmp(compression, "off") != 0) ? _("on") : _("off"));
} }
#else
static void
printSSLInfo(void)
{
#ifdef USE_SSL
int sslbits = -1;
SSL *ssl;
ssl = PQgetssl(pset.db);
if (!ssl)
return; /* no SSL */
SSL_get_cipher_bits(ssl, &sslbits);
printf(_("SSL connection (protocol: %s, cipher: %s, bits: %d, compression: %s)\n"),
SSL_get_version(ssl), SSL_get_cipher(ssl), sslbits,
SSL_get_current_compression(ssl) ? _("on") : _("off"));
#else
/*
* If psql is compiled without SSL but is using a libpq with SSL, we
* cannot figure out the specifics about the connection. But we know it's
* SSL secured.
*/
if (PQgetssl(pset.db))
printf(_("SSL connection (unknown cipher)\n"));
#endif /* USE_SSL */
}
#endif
/* /*
* checkWin32Codepage * checkWin32Codepage

View File

@ -19,14 +19,7 @@
extern bool openQueryOutputFile(const char *fname, FILE **fout, bool *is_pipe); extern bool openQueryOutputFile(const char *fname, FILE **fout, bool *is_pipe);
extern bool setQFout(const char *fname); extern bool setQFout(const char *fname);
#if (PG_VERSION_NUM >= 90500)
extern void psql_error(const char *fmt,...) pg_attribute_printf(1, 2); extern void psql_error(const char *fmt,...) pg_attribute_printf(1, 2);
#else
extern void
psql_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
#endif
extern void NoticeProcessor(void *arg, const char *message); extern void NoticeProcessor(void *arg, const char *message);

View File

@ -12,13 +12,7 @@
#include "settings.h" #include "settings.h"
#include "common.h" #include "common.h"
#if (PG_VERSION_NUM >= 90500)
static void print_lo_result(const char *fmt,...) pg_attribute_printf(1, 2); static void print_lo_result(const char *fmt,...) pg_attribute_printf(1, 2);
#else
static void
print_lo_result(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
#endif
static void static void
print_lo_result(const char *fmt,...) print_lo_result(const char *fmt,...)

View File

@ -24,11 +24,9 @@
#define INVALID_JOB_ID 0 #define INVALID_JOB_ID 0
#define INVALID_TASK_ID 0 #define INVALID_TASK_ID 0
#if (PG_VERSION_NUM >= 90500)
/* reserved alias name for UPSERTs */ /* reserved alias name for UPSERTs */
#define UPSERT_ALIAS "citus_table_alias" #define UPSERT_ALIAS "citus_table_alias"
#endif
extern MultiPlan * MultiRouterPlanCreate(Query *originalQuery, Query *query, extern MultiPlan * MultiRouterPlanCreate(Query *originalQuery, Query *query,
MultiExecutorType taskExecutorType); MultiExecutorType taskExecutorType);

View File

@ -1,332 +0,0 @@
-- this test file aims to test UPSERT feature on Citus
-- note that output of this file for postgresql 9.4 will
-- be full syntax errors, which is expected.
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 980000;
ALTER SEQUENCE pg_catalog.pg_dist_jobid_seq RESTART 980000;
CREATE TABLE upsert_test
(
part_key int UNIQUE,
other_col int,
third_col int
);
-- distribute the table and create shards
SELECT master_create_distributed_table('upsert_test', 'part_key', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('upsert_test', '4', '2');
master_create_worker_shards
-----------------------------
(1 row)
-- do a regular insert
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1);
-- observe that there is a conflict and the following query does nothing
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT DO NOTHING;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- same as the above with different syntax
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO NOTHING;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
--again the same query with another syntax
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT ON CONSTRAINT upsert_test_part_key_key DO NOTHING;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- now, update the columns
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1)
ON CONFLICT (part_key) DO UPDATE SET other_col = 2, third_col = 4;
ERROR: syntax error at or near "ON"
LINE 2: ON CONFLICT (part_key) DO UPDATE SET other_col = 2, third_...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- use a WHERE clause, so that SET doesn't have an affect
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key)
DO UPDATE SET other_col = 30 WHERE upsert_test.other_col = 3;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- use a WHERE clause, that hits the row and updates it
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key)
DO UPDATE SET other_col = 30 WHERE upsert_test.other_col = 2;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- use two elements in the WHERE, that doesn't hit the row and updates it
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key)
DO UPDATE SET other_col = 30 WHERE upsert_test.other_col = 2 AND upsert_test.other_col = 3;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- use EXCLUDED keyword
INSERT INTO upsert_test (part_key, other_col, third_col) VALUES (1, 1, 100) ON CONFLICT (part_key)
DO UPDATE SET other_col = EXCLUDED.third_col;
ERROR: syntax error at or near "ON"
LINE 1: ...art_key, other_col, third_col) VALUES (1, 1, 100) ON CONFLIC...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- now update multiple columns with ALIAS table and reference to the row itself
INSERT INTO upsert_test as ups_test (part_key) VALUES (1)
ON CONFLICT (part_key) DO UPDATE SET other_col = ups_test.other_col + 50, third_col = 200;
ERROR: syntax error at or near "as"
LINE 1: INSERT INTO upsert_test as ups_test (part_key) VALUES (1)
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- now, do some more complex assignments
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key)
DO UPDATE SET other_col = upsert_test.other_col + 1,
third_col = upsert_test.third_col + (EXCLUDED.part_key + EXCLUDED.other_col) + 670;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- now, WHERE clause also has table reference
INSERT INTO upsert_test as ups_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key)
DO UPDATE SET other_col = (ups_test.other_col + ups_test.third_col + (EXCLUDED.part_key + EXCLUDED.other_col)) % 15
WHERE ups_test.third_col < 1000 + ups_test.other_col;
ERROR: syntax error at or near "as"
LINE 1: INSERT INTO upsert_test as ups_test (part_key, other_col) VA...
^
-- see the results
SELECT * FROM upsert_test;
part_key | other_col | third_col
----------+-----------+-----------
1 | 1 |
(1 row)
-- Test upsert, with returning:
INSERT INTO upsert_test (part_key, other_col) VALUES (2, 2)
ON CONFLICT (part_key) DO UPDATE SET other_col = 3
RETURNING *;
ERROR: syntax error at or near "ON"
LINE 2: ON CONFLICT (part_key) DO UPDATE SET other_col = 3
^
INSERT INTO upsert_test (part_key, other_col) VALUES (2, 2)
ON CONFLICT (part_key) DO UPDATE SET other_col = 3
RETURNING *;
ERROR: syntax error at or near "ON"
LINE 2: ON CONFLICT (part_key) DO UPDATE SET other_col = 3
^
-- create another table
CREATE TABLE upsert_test_2
(
part_key int,
other_col int,
third_col int,
PRIMARY KEY (part_key, other_col)
);
-- distribute the table and create shards
SELECT master_create_distributed_table('upsert_test_2', 'part_key', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('upsert_test_2', '4', '2');
master_create_worker_shards
-----------------------------
(1 row)
-- now show that Citus works with multiple columns as the PRIMARY KEY, including the partiton key
INSERT INTO upsert_test_2 (part_key, other_col) VALUES (1, 1);
INSERT INTO upsert_test_2 (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key, other_col) DO NOTHING;
ERROR: syntax error at or near "ON"
LINE 1: ...upsert_test_2 (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- this errors out since there is no unique constraint on partition key
INSERT INTO upsert_test_2 (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO NOTHING;
ERROR: syntax error at or near "ON"
LINE 1: ...upsert_test_2 (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- create another table
CREATE TABLE upsert_test_3
(
part_key int,
count int
);
-- note that this is not a unique index
CREATE INDEX idx_ups_test ON upsert_test_3(part_key);
-- distribute the table and create shards
SELECT master_create_distributed_table('upsert_test_3', 'part_key', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('upsert_test_3', '4', '2');
master_create_worker_shards
-----------------------------
(1 row)
-- since there are no unique indexes, error-out
INSERT INTO upsert_test_3 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_3.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_3 VALUES (1, 0) ON CONFLICT(part_key...
^
-- create another table
CREATE TABLE upsert_test_4
(
part_key int UNIQUE,
count int
);
-- distribute the table and create shards
SELECT master_create_distributed_table('upsert_test_4', 'part_key', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('upsert_test_4', '4', '2');
master_create_worker_shards
-----------------------------
(1 row)
-- a single row insert
INSERT INTO upsert_test_4 VALUES (1, 0);
-- show a simple count example use case
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key) DO UPDATE SET count = upsert_test_4.count + 1;
ERROR: syntax error at or near "ON"
LINE 1: INSERT INTO upsert_test_4 VALUES (1, 0) ON CONFLICT(part_key...
^
-- now see the results
SELECT * FROM upsert_test_4;
part_key | count
----------+-------
1 | 0
(1 row)
-- now test dropped columns
CREATE TABLE dropcol_distributed(key int primary key, drop1 int, keep1 text, drop2 numeric, keep2 float);
SELECT master_create_distributed_table('dropcol_distributed', 'key', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('dropcol_distributed', 4, 1);
master_create_worker_shards
-----------------------------
(1 row)
INSERT INTO dropcol_distributed AS dropcol (key, keep1, keep2) VALUES (1, '5', 5) ON CONFLICT(key)
DO UPDATE SET keep1 = dropcol.keep1;
ERROR: syntax error at or near "AS"
LINE 1: INSERT INTO dropcol_distributed AS dropcol (key, keep1, keep...
^
ALTER TABLE dropcol_distributed DROP COLUMN drop2;
INSERT INTO dropcol_distributed (key, keep1, keep2) VALUES (1, '5', 5) ON CONFLICT(key)
DO UPDATE SET keep1 = dropcol_distributed.keep1;
ERROR: syntax error at or near "ON"
LINE 1: ...istributed (key, keep1, keep2) VALUES (1, '5', 5) ON CONFLIC...
^
ALTER TABLE dropcol_distributed DROP COLUMN keep2;
INSERT INTO dropcol_distributed AS dropcol (key, keep1) VALUES (1, '5') ON CONFLICT(key)
DO UPDATE SET keep1 = dropcol.keep1;
ERROR: syntax error at or near "AS"
LINE 1: INSERT INTO dropcol_distributed AS dropcol (key, keep1) VALU...
^
ALTER TABLE dropcol_distributed DROP COLUMN drop1;
INSERT INTO dropcol_distributed AS dropcol (key, keep1) VALUES (1, '5') ON CONFLICT(key)
DO UPDATE SET keep1 = dropcol.keep1;
ERROR: syntax error at or near "AS"
LINE 1: INSERT INTO dropcol_distributed AS dropcol (key, keep1) VALU...
^
-- below we test the cases that Citus does not support
-- subquery in the SET clause
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO
UPDATE SET other_col = (SELECT count(*) from upsert_test);
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- non mutable function call in the SET
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO
UPDATE SET other_col = random()::int;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- non mutable function call in the WHERE
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO
UPDATE SET other_col = 5 WHERE upsert_test.other_col = random()::int;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- non mutable function call in the arbiter WHERE
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) WHERE part_key = random()::int
DO UPDATE SET other_col = 5;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^
-- error out on attempt to update the partition key
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT (part_key) DO
UPDATE SET part_key = 15;
ERROR: syntax error at or near "ON"
LINE 1: ...O upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLIC...
^