From 14fec1374fd571086414b701da368538a2c529d4 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Nov 2020 15:23:42 +0200 Subject: [PATCH 1/7] pg13 changes --- Makefile | 2 +- cstore_fdw.c | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 72daebc..4dcc316 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ ifndef MAJORVERSION MAJORVERSION := $(basename $(VERSION)) endif -ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10 11 12)) +ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10 11 12 13)) $(error PostgreSQL 9.3 to 12 is required to compile this extension) endif diff --git a/cstore_fdw.c b/cstore_fdw.c index b0a3277..2dfcd9d 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -24,7 +24,6 @@ #include "access/htup_details.h" #include "access/reloptions.h" #include "access/sysattr.h" -#include "access/tuptoaster.h" #include "catalog/namespace.h" #include "catalog/pg_foreign_table.h" #include "catalog/pg_namespace.h" @@ -68,6 +67,10 @@ #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) +#endif /* PG_VERSION_NUM */ /* local functions forward declarations */ #if PG_VERSION_NUM >= 100000 @@ -238,7 +241,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 +253,7 @@ cstore_ddl_event_end_trigger(PG_FUNCTION_ARGS) CreateCStoreDatabaseDirectory(MyDatabaseId); InitializeCStoreTableFile(relationId, relation); - heap_close(relation, AccessExclusiveLock); + table_close(relation, AccessExclusiveLock); } } @@ -377,7 +380,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 +540,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 +615,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 +826,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 +838,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 +1009,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 +1628,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 +1695,7 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId #endif add_path(baserel, foreignScanPath); - heap_close(relation, AccessShareLock); + table_close(relation, AccessShareLock); } @@ -1830,7 +1833,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 +1914,7 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId) } } - heap_close(relation, AccessShareLock); + table_close(relation, AccessShareLock); return columnList; } @@ -2317,7 +2320,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 +2392,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo) Relation relation = writeState->relation; CStoreEndWrite(writeState); - heap_close(relation, ShareUpdateExclusiveLock); + table_close(relation, ShareUpdateExclusiveLock); } } From 6205313f358f080de50b184a4e1530104c4d6ada Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Nov 2020 15:29:06 +0200 Subject: [PATCH 2/7] pg13 changes --- cstore_fdw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cstore_fdw.c b/cstore_fdw.c index 2dfcd9d..7d3fa7a 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -70,6 +70,8 @@ #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 */ From ccff9fede1e8a1a6c60f199e1d58faf2b34a1438 Mon Sep 17 00:00:00 2001 From: N/A <16502919+erma07@users.noreply.github.com> Date: Fri, 4 Dec 2020 16:49:30 +0200 Subject: [PATCH 3/7] Update cstore_fdw.c tuptoaster needed for PG_VERSION_NUM <= 120000 --- cstore_fdw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cstore_fdw.c b/cstore_fdw.c index 7d3fa7a..9357313 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -24,6 +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" From 593beddb26aae8beabdabcb1325e77d613fdda07 Mon Sep 17 00:00:00 2001 From: N/A <16502919+erma07@users.noreply.github.com> Date: Fri, 4 Dec 2020 17:41:19 +0200 Subject: [PATCH 4/7] Update .travis.yml add PGVERSION=13 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) 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 From fd28b0fa6b139d10d2a9a6c0bcb40153b6da236e Mon Sep 17 00:00:00 2001 From: N/A <16502919+erma07@users.noreply.github.com> Date: Fri, 4 Dec 2020 18:38:36 +0200 Subject: [PATCH 5/7] Update cstore_fdw.c --- cstore_fdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cstore_fdw.c b/cstore_fdw.c index 9357313..3efaadb 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -24,7 +24,7 @@ #include "access/htup_details.h" #include "access/reloptions.h" #include "access/sysattr.h" -#if PG_VERSION_NUM <= 120000 +#if PG_VERSION_NUM < 120000 #include "access/tuptoaster.h" #endif #include "catalog/namespace.h" From d0f3580225b56605e2265e383a76666f4ec42a0d Mon Sep 17 00:00:00 2001 From: N/A <16502919+erma07@users.noreply.github.com> Date: Sat, 5 Dec 2020 04:30:28 +0200 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 57de22ff3e446256f2e4d7fab2186f2c1ad54db7 Mon Sep 17 00:00:00 2001 From: N/A <16502919+erma07@users.noreply.github.com> Date: Fri, 11 Dec 2020 09:05:23 +0200 Subject: [PATCH 7/7] Update Makefile Co-authored-by: Ekin Dursun --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4dcc316..a329d79 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ ifndef MAJORVERSION endif ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10 11 12 13)) - $(error PostgreSQL 9.3 to 12 is required to compile this extension) + $(error PostgreSQL 9.3 to 13 is required to compile this extension) endif cstore.pb-c.c: cstore.proto