Skip to content

Commit

Permalink
Remove Postgres 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Oct 11, 2019
1 parent 9563341 commit 74cb168
Show file tree
Hide file tree
Showing 103 changed files with 671 additions and 24,171 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ if test -z "$version_num"; then
as_fn_error $? "Could not detect PostgreSQL version from pg_config." "$LINENO" 5
fi
if test "$version_num" != '10' -a "$version_num" != '11' -a "$version_num" != '12'; then
if test "$version_num" != '11' -a "$version_num" != '12'; then
as_fn_error $? "Citus is not compatible with the detected PostgreSQL version ${version_num}." "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if test -z "$version_num"; then
AC_MSG_ERROR([Could not detect PostgreSQL version from pg_config.])
fi

if test "$version_num" != '10' -a "$version_num" != '11' -a "$version_num" != '12'; then
if test "$version_num" != '11' -a "$version_num" != '12'; then
AC_MSG_ERROR([Citus is not compatible with the detected PostgreSQL version ${version_num}.])
else
AC_MSG_NOTICE([building against PostgreSQL $version_num])
Expand Down
5 changes: 0 additions & 5 deletions src/backend/distributed/commands/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include "postgres.h"

#if PG_VERSION_NUM >= 110000

#include "catalog/pg_proc.h"
#include "commands/defrem.h"
#include "distributed/citus_ruleutils.h"
Expand Down Expand Up @@ -207,6 +205,3 @@ CallFuncExprRemotely(CallStmt *callStmt, DistObjectCacheEntry *procedure,

return true;
}


#endif /* PG_VERSION_NUM >= 110000 */
9 changes: 3 additions & 6 deletions src/backend/distributed/commands/create_distributed_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include "catalog/index.h"
#include "catalog/pg_am.h"
#include "catalog/pg_attribute.h"
#if (PG_VERSION_NUM < 110000)
#include "catalog/pg_constraint_fn.h"
#endif
#include "catalog/pg_enum.h"
#include "catalog/pg_extension.h"
#include "catalog/pg_opclass.h"
Expand Down Expand Up @@ -1166,9 +1163,9 @@ CreateTruncateTrigger(Oid relationId)
trigger->whenClause = NULL;
trigger->isconstraint = false;

CreateTriggerInternal(trigger, NULL, relationId, InvalidOid, InvalidOid, InvalidOid,
InvalidOid, InvalidOid, NULL,
internal, false);
CreateTrigger(trigger, NULL, relationId, InvalidOid, InvalidOid, InvalidOid,
InvalidOid, InvalidOid, NULL,
internal, false);
}


Expand Down
18 changes: 7 additions & 11 deletions src/backend/distributed/commands/foreign_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#if (PG_VERSION_NUM >= 120000)
#include "access/genam.h"
#endif
#if (PG_VERSION_NUM < 110000)
#include "catalog/pg_constraint_fn.h"
#endif
#include "catalog/pg_type.h"
#include "distributed/colocation_utils.h"
#include "distributed/commands.h"
Expand Down Expand Up @@ -151,7 +148,8 @@ ErrorIfUnsupportedForeignConstraintExists(Relation relation, char referencingDis
pgConstraint = heap_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ,
relation->rd_id);
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidIndexId, true, NULL,
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidTypidNameIndexId,
true, NULL,
scanKeyCount, scanKey);

heapTuple = systable_getnext(scanDescriptor);
Expand Down Expand Up @@ -515,19 +513,16 @@ GetTableForeignConstraintCommands(Oid relationId)
pgConstraint = heap_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ,
relationId);
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidIndexId, true, NULL,
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidTypidNameIndexId,
true, NULL,
scanKeyCount, scanKey);

heapTuple = systable_getnext(scanDescriptor);
while (HeapTupleIsValid(heapTuple))
{
Form_pg_constraint constraintForm = (Form_pg_constraint) GETSTRUCT(heapTuple);

#if (PG_VERSION_NUM >= 110000)
bool inheritedConstraint = OidIsValid(constraintForm->conparentid);
#else
bool inheritedConstraint = false;
#endif

if (!inheritedConstraint && constraintForm->contype == CONSTRAINT_FOREIGN)
{
Expand Down Expand Up @@ -571,7 +566,8 @@ HasForeignKeyToReferenceTable(Oid relationId)
pgConstraint = heap_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ,
relationId);
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidIndexId, true, NULL,
scanDescriptor = systable_beginscan(pgConstraint, ConstraintRelidTypidNameIndexId,
true, NULL,
scanKeyCount, scanKey);

heapTuple = systable_getnext(scanDescriptor);
Expand Down Expand Up @@ -679,7 +675,7 @@ HeapTupleOfForeignConstraintIncludesColumn(HeapTuple heapTuple, Oid relationId,
{
AttrNumber attrNo = DatumGetInt16(columnArray[attrIdx]);

char *colName = get_attname_internal(relationId, attrNo, false);
char *colName = get_attname(relationId, attrNo, false);
if (strncmp(colName, columnName, NAMEDATALEN) == 0)
{
return true;
Expand Down
30 changes: 6 additions & 24 deletions src/backend/distributed/commands/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ static void ErrorIfFunctionDependsOnExtension(const ObjectAddress *functionAddre

PG_FUNCTION_INFO_V1(create_distributed_function);

#if PG_VERSION_NUM >= 110000
#define AssertIsFunctionOrProcedure(objtype) \
Assert((objtype) == OBJECT_FUNCTION || (objtype) == OBJECT_PROCEDURE)
#else
#define AssertIsFunctionOrProcedure(objtype) \
Assert(objtype == OBJECT_FUNCTION)
#endif


/*
Expand Down Expand Up @@ -597,9 +592,7 @@ GetFunctionAlterOwnerCommand(const RegProcedure funcOid)

procOwner = procform->proowner;

#if (PG_VERSION_NUM >= 110000)
isProcedure = procform->prokind == PROKIND_PROCEDURE;
#endif

ReleaseSysCache(proctup);
}
Expand Down Expand Up @@ -878,12 +871,10 @@ CreateFunctionStmtObjectAddress(CreateFunctionStmt *stmt, bool missing_ok)
ObjectWithArgs *objectWithArgs = NULL;
ListCell *parameterCell = NULL;

#if PG_VERSION_NUM >= 110000
if (stmt->is_procedure)
{
objectType = OBJECT_PROCEDURE;
}
#endif

objectWithArgs = makeNode(ObjectWithArgs);
objectWithArgs->objname = stmt->funcname;
Expand All @@ -910,10 +901,7 @@ PlanAlterFunctionStmt(AlterFunctionStmt *stmt, const char *queryString)
const ObjectAddress *address = NULL;
List *commands = NIL;

/* AlterFunctionStmt->objtype has only been added since pg11 */
#if PG_VERSION_NUM >= 110000
AssertIsFunctionOrProcedure(stmt->objtype);
#endif

address = GetObjectAddressFromParseTree((Node *) stmt, false);
if (!ShouldPropagateAlterFunction(address))
Expand Down Expand Up @@ -1249,13 +1237,7 @@ ProcessAlterFunctionSchemaStmt(AlterObjectSchemaStmt *stmt, const char *queryStr
const ObjectAddress *
AlterFunctionStmtObjectAddress(AlterFunctionStmt *stmt, bool missing_ok)
{
ObjectType objectType = OBJECT_FUNCTION;

#if PG_VERSION_NUM >= 110000
objectType = stmt->objtype;
#endif

return FunctionToObjectAddress(objectType, stmt->func, missing_ok);
return FunctionToObjectAddress(stmt->objtype, stmt->func, missing_ok);
}


Expand Down Expand Up @@ -1303,7 +1285,7 @@ AlterFunctionSchemaStmtObjectAddress(AlterObjectSchemaStmt *stmt, bool missing_o
AssertIsFunctionOrProcedure(stmt->objectType);

objectWithArgs = castNode(ObjectWithArgs, stmt->object);
funcOid = LookupFuncWithArgsCompat(stmt->objectType, objectWithArgs, true);
funcOid = LookupFuncWithArgs(stmt->objectType, objectWithArgs, true);
names = objectWithArgs->objname;

if (funcOid == InvalidOid)
Expand All @@ -1322,7 +1304,7 @@ AlterFunctionSchemaStmtObjectAddress(AlterObjectSchemaStmt *stmt, bool missing_o
* error if the type didn't exist in the first place.
*/
objectWithArgs->objname = newNames;
funcOid = LookupFuncWithArgsCompat(stmt->objectType, objectWithArgs, true);
funcOid = LookupFuncWithArgs(stmt->objectType, objectWithArgs, true);
objectWithArgs->objname = names; /* restore the original names */

/*
Expand All @@ -1336,8 +1318,8 @@ AlterFunctionSchemaStmtObjectAddress(AlterObjectSchemaStmt *stmt, bool missing_o
* has just been created (if possible at all). For safety we assign the
* funcOid.
*/
funcOid = LookupFuncWithArgsCompat(stmt->objectType, objectWithArgs,
missing_ok);
funcOid = LookupFuncWithArgs(stmt->objectType, objectWithArgs,
missing_ok);
}
}

Expand All @@ -1363,7 +1345,7 @@ FunctionToObjectAddress(ObjectType objectType, ObjectWithArgs *objectWithArgs,

AssertIsFunctionOrProcedure(objectType);

funcOid = LookupFuncWithArgsCompat(objectType, objectWithArgs, missing_ok);
funcOid = LookupFuncWithArgs(objectType, objectWithArgs, missing_ok);
address = palloc0(sizeof(ObjectAddress));
ObjectAddressSet(*address, ProcedureRelationId, funcOid);

Expand Down
16 changes: 5 additions & 11 deletions src/backend/distributed/commands/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ PlanReindexStmt(ReindexStmt *reindexStatement, const char *reindexCommand)
#endif
state.locked_table_oid = InvalidOid;

indOid = RangeVarGetRelidInternal(reindexStatement->relation,
indOid = RangeVarGetRelidExtended(reindexStatement->relation,
lockmode, 0,
RangeVarCallbackForReindexIndex,
&state);
Expand All @@ -243,7 +243,7 @@ PlanReindexStmt(ReindexStmt *reindexStatement, const char *reindexCommand)
}
else
{
RangeVarGetRelidInternal(reindexStatement->relation, lockmode, 0,
RangeVarGetRelidExtended(reindexStatement->relation, lockmode, 0,
RangeVarCallbackOwnsTable, NULL);

relation = heap_openrv(reindexStatement->relation, NoLock);
Expand Down Expand Up @@ -349,7 +349,7 @@ PlanDropIndexStmt(DropStmt *dropIndexStatement, const char *dropIndexCommand)
state.heapOid = InvalidOid;
state.concurrent = dropIndexStatement->concurrent;

indexId = RangeVarGetRelidInternal(rangeVar, lockmode, rvrFlags,
indexId = RangeVarGetRelidExtended(rangeVar, lockmode, rvrFlags,
RangeVarCallbackForDropIndex,
(void *) &state);

Expand Down Expand Up @@ -654,10 +654,8 @@ RangeVarCallbackForDropIndex(const RangeVar *rel, Oid relOid, Oid oldRelOid, voi
*/
expected_relkind = classform->relkind;

#if PG_VERSION_NUM >= 110000
if (expected_relkind == RELKIND_PARTITIONED_INDEX)
expected_relkind = RELKIND_INDEX;
#endif

if (expected_relkind != relkind)
ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
Expand All @@ -667,7 +665,7 @@ RangeVarCallbackForDropIndex(const RangeVar *rel, Oid relOid, Oid oldRelOid, voi
if (!pg_class_ownercheck(relOid, GetUserId()) &&
!pg_namespace_ownercheck(classform->relnamespace, GetUserId()))
{
aclcheck_error(ACLCHECK_NOT_OWNER, ACLCHECK_OBJECT_INDEX, rel->relname);
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX, rel->relname);
}

if (!allowSystemTableMods && IsSystemClass(relOid, classform))
Expand Down Expand Up @@ -747,11 +745,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, Oid relId, Oid oldRelI
relkind = get_rel_relkind(relId);
if (!relkind)
return;
if (relkind != RELKIND_INDEX
#if PG_VERSION_NUM >= 110000
&& relkind != RELKIND_PARTITIONED_INDEX
#endif
)
if (relkind != RELKIND_INDEX && relkind != RELKIND_PARTITIONED_INDEX)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index", relation->relname)));
Expand Down
4 changes: 0 additions & 4 deletions src/backend/distributed/commands/schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ PlanAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, const char *queryString)
return PlanAlterTypeSchemaStmt(stmt, queryString);
}

#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
return PlanAlterFunctionSchemaStmt(stmt, queryString);
Expand Down Expand Up @@ -198,9 +196,7 @@ ProcessAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, const char *queryStrin
return;
}

#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
ProcessAlterFunctionSchemaStmt(stmt, queryString);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/commands/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ ErrorIfUnsupportedConstraint(Relation relation, char distributionMethod,
}

attributeCount = indexInfo->ii_NumIndexAttrs;
attributeNumberArray = IndexInfoAttributeNumberArray(indexInfo);
attributeNumberArray = indexInfo->ii_IndexAttrNumbers;

for (attributeIndex = 0; attributeIndex < attributeCount; attributeIndex++)
{
Expand Down
11 changes: 1 addition & 10 deletions src/backend/distributed/commands/utility_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,

parsetree = ProcessCreateSubscriptionStmt(createSubStmt);
}
#if (PG_VERSION_NUM >= 110000)

if (IsA(parsetree, CallStmt))
{
CallStmt *callStmt = (CallStmt *) parsetree;
Expand Down Expand Up @@ -253,7 +253,6 @@ multi_ProcessUtility(PlannedStmt *pstmt,

return;
}
#endif

if (IsA(parsetree, DoStmt))
{
Expand Down Expand Up @@ -426,9 +425,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
break;
}

#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
ddlJobs = PlanDropFunctionStmt(dropStatement, queryString);
Expand Down Expand Up @@ -484,9 +481,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
break;
}

#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
ddlJobs = PlanRenameFunctionStmt(renameStmt, queryString);
Expand Down Expand Up @@ -843,9 +838,7 @@ PlanAlterOwnerStmt(AlterOwnerStmt *stmt, const char *queryString)
return PlanAlterTypeOwnerStmt(stmt, queryString);
}

#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
return PlanAlterFunctionOwnerStmt(stmt, queryString);
Expand All @@ -871,9 +864,7 @@ PlanAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, const char *queryString
{
switch (stmt->objectType)
{
#if PG_VERSION_NUM >= 110000
case OBJECT_PROCEDURE:
#endif
case OBJECT_FUNCTION:
{
return PlanAlterFunctionDependsStmt(stmt, queryString);
Expand Down
Loading

0 comments on commit 74cb168

Please sign in to comment.