Skip to content

Commit

Permalink
Fix CStoreDefaultFilePath to use current database id and relationid
Browse files Browse the repository at this point in the history
PG12 does not maintain relfilenode for foreign tables. It broke
cstore's default file name creation logic. New code is simpler.
  • Loading branch information
mtuncer committed Nov 3, 2019
1 parent db6cc99 commit 4497b13
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cstore_fdw.c
Expand Up @@ -1553,22 +1553,15 @@ ValidateForeignTableOptions(char *filename, char *compressionTypeString,

/*
* CStoreDefaultFilePath constructs the default file path to use for a cstore_fdw
* table. The path is of the form $PGDATA/cstore_fdw/{databaseOid}/{relfilenode}.
* table. The path is of the form $PGDATA/cstore_fdw/{databaseOid}/{foreignTableId}.
*/
static char *
CStoreDefaultFilePath(Oid foreignTableId)
{
Relation relation = relation_open(foreignTableId, AccessShareLock);
RelFileNode relationFileNode = relation->rd_node;

Oid databaseOid = relationFileNode.dbNode;
Oid relationFileOid = relationFileNode.relNode;

Oid databaseOid = MyDatabaseId;
StringInfo cstoreFilePath = makeStringInfo();
appendStringInfo(cstoreFilePath, "%s/%s/%u/%u", DataDir, CSTORE_FDW_NAME,
databaseOid, relationFileOid);

relation_close(relation, AccessShareLock);
databaseOid, foreignTableId);

return cstoreFilePath->data;
}
Expand Down

0 comments on commit 4497b13

Please sign in to comment.