Skip to content

Commit

Permalink
Merge 57de22f into 60e3b3f
Browse files Browse the repository at this point in the history
  • Loading branch information
erma07 committed Dec 11, 2020
2 parents 60e3b3f + 57de22f commit 78cc104
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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.


Expand Down
36 changes: 22 additions & 14 deletions cstore_fdw.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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
{
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1692,7 +1700,7 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId
#endif

add_path(baserel, foreignScanPath);
heap_close(relation, AccessShareLock);
table_close(relation, AccessShareLock);
}


Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -1911,7 +1919,7 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId)
}
}

heap_close(relation, AccessShareLock);
table_close(relation, AccessShareLock);

return columnList;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -2389,7 +2397,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
Relation relation = writeState->relation;

CStoreEndWrite(writeState);
heap_close(relation, ShareUpdateExclusiveLock);
table_close(relation, ShareUpdateExclusiveLock);
}
}

Expand Down

0 comments on commit 78cc104

Please sign in to comment.