mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Change logtape/tuplestore code to use int64 for block numbers
The code previously relied on "long" as type to track block numbers, which would be 4 bytes in all Windows builds or any 32-bit builds. This limited the code to be able to handle up to 16TB of data with the default block size of 8kB, like during a CLUSTER. This code now relies on a more portable int64, which should be more than enough for at least the next 20 years to come. This issue has been reported back in 2017, but nothing was done about it back then, so here we go now. Reported-by: Peter Geoghegan Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/CAH2-WznCscXnWmnj=STC0aSa7QG+BRedDnZsP=Jo_R9GUZvUrg@mail.gmail.com
This commit is contained in:
@@ -841,14 +841,14 @@ BufFileTell(BufFile *file, int *fileno, off_t *offset)
|
||||
*
|
||||
* Performs absolute seek to the start of the n'th BLCKSZ-sized block of
|
||||
* the file. Note that users of this interface will fail if their files
|
||||
* exceed BLCKSZ * LONG_MAX bytes, but that is quite a lot; we don't work
|
||||
* with tables bigger than that, either...
|
||||
* exceed BLCKSZ * PG_INT64_MAX bytes, but that is quite a lot; we don't
|
||||
* work with tables bigger than that, either...
|
||||
*
|
||||
* Result is 0 if OK, EOF if not. Logical position is not moved if an
|
||||
* impossible seek is attempted.
|
||||
*/
|
||||
int
|
||||
BufFileSeekBlock(BufFile *file, long blknum)
|
||||
BufFileSeekBlock(BufFile *file, int64 blknum)
|
||||
{
|
||||
return BufFileSeek(file,
|
||||
(int) (blknum / BUFFILE_SEG_SIZE),
|
||||
@@ -901,10 +901,10 @@ BufFileSize(BufFile *file)
|
||||
* begins. Caller should apply this as an offset when working off block
|
||||
* positions that are in terms of the original BufFile space.
|
||||
*/
|
||||
long
|
||||
int64
|
||||
BufFileAppend(BufFile *target, BufFile *source)
|
||||
{
|
||||
long startBlock = target->numFiles * BUFFILE_SEG_SIZE;
|
||||
int64 startBlock = target->numFiles * BUFFILE_SEG_SIZE;
|
||||
int newNumFiles = target->numFiles + source->numFiles;
|
||||
int i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user