diff --git a/.travis.yml b/.travis.yml index f83f720..734a9b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ env: - PGVERSION=10 - PGVERSION=11 - PGVERSION=12 + - PGVERSION=13 before_install: - git clone -b v0.7.13 --depth 1 https://github.com/citusdata/tools.git diff --git a/Makefile b/Makefile index 72daebc..a329d79 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,8 @@ ifndef MAJORVERSION MAJORVERSION := $(basename $(VERSION)) endif -ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10 11 12)) - $(error PostgreSQL 9.3 to 12 is required to compile this extension) +ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10 11 12 13)) + $(error PostgreSQL 9.3 to 13 is required to compile this extension) endif cstore.pb-c.c: cstore.proto diff --git a/README.md b/README.md index 1a20f3a..901f0dd 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ installation's bin/ directory path. For example: PATH=/usr/local/pgsql/bin/:$PATH make sudo PATH=/usr/local/pgsql/bin/:$PATH make install -**Note.** cstore_fdw requires PostgreSQL version from 9.3 to 12. It doesn't +**Note.** cstore_fdw requires PostgreSQL version from 9.3 to 13. It doesn't support earlier versions of PostgreSQL. diff --git a/cstore_fdw.c b/cstore_fdw.c index b0a3277..3efaadb 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -24,7 +24,9 @@ #include "access/htup_details.h" #include "access/reloptions.h" #include "access/sysattr.h" +#if PG_VERSION_NUM < 120000 #include "access/tuptoaster.h" +#endif #include "catalog/namespace.h" #include "catalog/pg_foreign_table.h" #include "catalog/pg_namespace.h" @@ -68,6 +70,12 @@ #include "utils/tqual.h" #endif +#if PG_VERSION_NUM < 120000 +#define table_open(x, y) heap_open(x, y) +#define table_close(x, y) heap_close(x, y) +#define table_openrv(x, y) heap_openrv(x, y) +#define table_closerv(x, y) heap_closerv(x, y) +#endif /* PG_VERSION_NUM */ /* local functions forward declarations */ #if PG_VERSION_NUM >= 100000 @@ -238,7 +246,7 @@ cstore_ddl_event_end_trigger(PG_FUNCTION_ARGS) { Oid relationId = RangeVarGetRelid(createStatement->base.relation, AccessShareLock, false); - Relation relation = heap_open(relationId, AccessExclusiveLock); + Relation relation = table_open(relationId, AccessExclusiveLock); /* * Make sure database directory exists before creating a table. @@ -250,7 +258,7 @@ cstore_ddl_event_end_trigger(PG_FUNCTION_ARGS) CreateCStoreDatabaseDirectory(MyDatabaseId); InitializeCStoreTableFile(relationId, relation); - heap_close(relation, AccessExclusiveLock); + table_close(relation, AccessExclusiveLock); } } @@ -377,7 +385,7 @@ CStoreProcessUtility(Node * parseTree, const char *queryString, foreach(cstoreRelationCell, cstoreRelationList) { Relation relation = (Relation) lfirst(cstoreRelationCell); - heap_close(relation, AccessExclusiveLock); + table_close(relation, AccessExclusiveLock); } } else if (nodeTag(parseTree) == T_AlterTableStmt) @@ -537,7 +545,7 @@ CopyIntoCStoreTable(const CopyStmt *copyStatement, const char *queryString) * Open and lock the relation. We acquire ShareUpdateExclusiveLock to allow * concurrent reads, but block concurrent writes. */ - relation = heap_openrv(copyStatement->relation, ShareUpdateExclusiveLock); + relation = table_openrv(copyStatement->relation, ShareUpdateExclusiveLock); relationId = RelationGetRelid(relation); /* allocate column values and nulls arrays */ @@ -612,7 +620,7 @@ CopyIntoCStoreTable(const CopyStmt *copyStatement, const char *queryString) /* end read/write sessions and close the relation */ EndCopyFrom(copyState); CStoreEndWrite(writeState); - heap_close(relation, ShareUpdateExclusiveLock); + table_close(relation, ShareUpdateExclusiveLock); return processedRowCount; } @@ -823,7 +831,7 @@ OpenRelationsForTruncate(List *cstoreTableList) foreach(relationCell, cstoreTableList) { RangeVar *rangeVar = (RangeVar *) lfirst(relationCell); - Relation relation = heap_openrv(rangeVar, AccessExclusiveLock); + Relation relation = table_openrv(rangeVar, AccessExclusiveLock); Oid relationId = relation->rd_id; AclResult aclresult = pg_class_aclcheck(relationId, GetUserId(), ACL_TRUNCATE); @@ -835,7 +843,7 @@ OpenRelationsForTruncate(List *cstoreTableList) /* check if this relation is repeated */ if (list_member_oid(relationIdList, relationId)) { - heap_close(relation, AccessExclusiveLock); + table_close(relation, AccessExclusiveLock); } else { @@ -1006,7 +1014,7 @@ DistributedTable(Oid relationId) return false; } - heapRelation = heap_open(partitionOid, AccessShareLock); + heapRelation = table_open(partitionOid, AccessShareLock); ScanKeyInit(&scanKey[0], ATTR_NUM_PARTITION_RELATION_ID, InvalidStrategy, F_OIDEQ, ObjectIdGetDatum(relationId)); @@ -1625,7 +1633,7 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId { Path *foreignScanPath = NULL; CStoreFdwOptions *cstoreFdwOptions = CStoreGetOptions(foreignTableId); - Relation relation = heap_open(foreignTableId, AccessShareLock); + Relation relation = table_open(foreignTableId, AccessShareLock); /* * We skip reading columns that are not in query. Here we assume that all @@ -1692,7 +1700,7 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId #endif add_path(baserel, foreignScanPath); - heap_close(relation, AccessShareLock); + table_close(relation, AccessShareLock); } @@ -1830,7 +1838,7 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId) List *restrictInfoList = baserel->baserestrictinfo; ListCell *restrictInfoCell = NULL; const AttrNumber wholeRow = 0; - Relation relation = heap_open(foreignTableId, AccessShareLock); + Relation relation = table_open(foreignTableId, AccessShareLock); TupleDesc tupleDescriptor = RelationGetDescr(relation); /* first add the columns used in joins and projections */ @@ -1911,7 +1919,7 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId) } } - heap_close(relation, AccessShareLock); + table_close(relation, AccessShareLock); return columnList; } @@ -2317,7 +2325,7 @@ CStoreBeginForeignInsert(ModifyTableState *modifyTableState, ResultRelInfo *rela Relation relation = NULL; foreignTableOid = RelationGetRelid(relationInfo->ri_RelationDesc); - relation = heap_open(foreignTableOid, ShareUpdateExclusiveLock); + relation = table_open(foreignTableOid, ShareUpdateExclusiveLock); cstoreFdwOptions = CStoreGetOptions(foreignTableOid); tupleDescriptor = RelationGetDescr(relationInfo->ri_RelationDesc); @@ -2389,7 +2397,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo) Relation relation = writeState->relation; CStoreEndWrite(writeState); - heap_close(relation, ShareUpdateExclusiveLock); + table_close(relation, ShareUpdateExclusiveLock); } }