Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/backend/cdb/cdbappendonlystoragewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ AppendOnlyStorageWrite_TransactionCreateFile(AppendOnlyStorageWrite *storageWrit
// WALREP_FIXME: Pass isRedo == true, so that you don't get an error if it
// exists already. That's currently OK, but in the future, other things
// might depend on the isRedo flag, like whether to WAL-log the creation.
smgrcreate_ao(*relFileNode, segmentFileNum, true);
smgrcreate_ao(storageWrite->smgrAO, *relFileNode, segmentFileNum, true);

/*
* Create a WAL record, so that the segfile is also created after crash or
Expand Down
12 changes: 10 additions & 2 deletions src/backend/storage/smgr/smgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static File AORelOpenSegFileXlog(RelFileNode node, int32 segmentFileNum, int fil
static const f_smgr_ao smgrswao[] = {
/* regular file */
{
.smgr_create_ao = mdcreate_ao,
.smgr_FileClose = FileClose,
.smgr_FileDiskSize = FileDiskSize,
.smgr_FileTruncate = FileTruncate,
Expand Down Expand Up @@ -492,9 +493,16 @@ smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
* already because we are in a WAL replay sequence.
*/
void
smgrcreate_ao(RelFileNodeBackend rnode, int32 segmentFileNum, bool isRedo)
smgrcreate_ao(const struct f_smgr_ao *smgr,
RelFileNodeBackend rnode,
int32 segmentFileNum, bool isRedo)
{
mdcreate_ao(rnode, segmentFileNum, isRedo);
/* If we get there, check that provided smgr structure is sane.
* First off all, outer Appendonly IO utilities should
* pass valid smgr. Also, in-kernel smgr interface implementation
* smgr_create_ao as mdcreate_ao, and extension should define its own. */
Assert(smgr != NULL && smgr->smgr_create_ao != NULL);
smgr->smgr_create_ao(rnode, segmentFileNum, isRedo);
if (file_create_hook)
(*file_create_hook)(rnode);
}
Expand Down
5 changes: 4 additions & 1 deletion src/include/storage/smgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ typedef struct f_smgr
} f_smgr;

typedef struct f_smgr_ao {
void (*smgr_create_ao) (RelFileNodeBackend rnode, int32 segmentFileNum, bool isRedo);
off_t (*smgr_FileDiskSize) (File file);
void (*smgr_FileClose) (File file);
int (*smgr_FileTruncate) (File file, int64 offset, uint32 wait_event_info);
Expand Down Expand Up @@ -193,7 +194,9 @@ extern void smgrclose(SMgrRelation reln);
extern void smgrcloseall(void);
extern void smgrclosenode(RelFileNodeBackend rnode);
extern void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
extern void smgrcreate_ao(RelFileNodeBackend rnode, int32 segmentFileNum, bool isRedo);
extern void smgrcreate_ao(const struct f_smgr_ao *smgr,
RelFileNodeBackend rnode,
int32 segmentFileNum, bool isRedo);
extern void smgrdosyncall(SMgrRelation *rels, int nrels);
extern void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo);
extern void smgrextend(SMgrRelation reln, ForkNumber forknum,
Expand Down
Loading