mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Refactor sharedfileset.c to separate out fileset implementation.
Move fileset related implementation out of sharedfileset.c to allow its usage by backends that don't want to share filesets among different processes. After this split, fileset infrastructure is used by both sharedfileset.c and worker.c for the named temporary files that survive across transactions. Author: Dilip Kumar, based on suggestion by Andres Freund Reviewed-by: Hou Zhijie, Masahiko Sawada, Amit Kapila Discussion: https://postgr.es/m/E1mCC6U-0004Ik-Fs@gemulon.postgresql.org
This commit is contained in:
@@ -564,7 +564,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
|
||||
lt = <s->tapes[i];
|
||||
|
||||
pg_itoa(i, filename);
|
||||
file = BufFileOpenShared(fileset, filename, O_RDONLY);
|
||||
file = BufFileOpenFileSet(&fileset->fs, filename, O_RDONLY);
|
||||
filesize = BufFileSize(file);
|
||||
|
||||
/*
|
||||
@@ -610,7 +610,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
|
||||
* offset).
|
||||
*
|
||||
* The only thing that currently prevents writing to the leader tape from
|
||||
* working is the fact that BufFiles opened using BufFileOpenShared() are
|
||||
* working is the fact that BufFiles opened using BufFileOpenFileSet() are
|
||||
* read-only by definition, but that could be changed if it seemed
|
||||
* worthwhile. For now, writing to the leader tape will raise a "Bad file
|
||||
* descriptor" error, so tuplesort must avoid writing to the leader tape
|
||||
@@ -722,7 +722,7 @@ LogicalTapeSetCreate(int ntapes, bool preallocate, TapeShare *shared,
|
||||
char filename[MAXPGPATH];
|
||||
|
||||
pg_itoa(worker, filename);
|
||||
lts->pfile = BufFileCreateShared(fileset, filename);
|
||||
lts->pfile = BufFileCreateFileSet(&fileset->fs, filename);
|
||||
}
|
||||
else
|
||||
lts->pfile = BufFileCreateTemp(false);
|
||||
@@ -1096,7 +1096,7 @@ LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum, TapeShare *share)
|
||||
/* Handle extra steps when caller is to share its tapeset */
|
||||
if (share)
|
||||
{
|
||||
BufFileExportShared(lts->pfile);
|
||||
BufFileExportFileSet(lts->pfile);
|
||||
share->firstblocknumber = lt->firstBlockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,8 @@ sts_puttuple(SharedTuplestoreAccessor *accessor, void *meta_data,
|
||||
|
||||
/* Create one. Only this backend will write into it. */
|
||||
sts_filename(name, accessor, accessor->participant);
|
||||
accessor->write_file = BufFileCreateShared(accessor->fileset, name);
|
||||
accessor->write_file =
|
||||
BufFileCreateFileSet(&accessor->fileset->fs, name);
|
||||
|
||||
/* Set up the shared state for this backend's file. */
|
||||
participant = &accessor->sts->participants[accessor->participant];
|
||||
@@ -559,7 +560,7 @@ sts_parallel_scan_next(SharedTuplestoreAccessor *accessor, void *meta_data)
|
||||
|
||||
sts_filename(name, accessor, accessor->read_participant);
|
||||
accessor->read_file =
|
||||
BufFileOpenShared(accessor->fileset, name, O_RDONLY);
|
||||
BufFileOpenFileSet(&accessor->fileset->fs, name, O_RDONLY);
|
||||
}
|
||||
|
||||
/* Seek and load the chunk header. */
|
||||
|
||||
Reference in New Issue
Block a user