[HACKERS] Should logtape.c blocks be of type long?

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема [HACKERS] Should logtape.c blocks be of type long?
Дата
Msg-id CAH2-WznCscXnWmnj=STC0aSa7QG+BRedDnZsP=Jo_R9GUZvUrg@mail.gmail.com
обсуждение исходный текст
Ответы Re: [HACKERS] Should logtape.c blocks be of type long?  (Robert Haas <robertmhaas@gmail.com>)
Re: [HACKERS] Should logtape.c blocks be of type long?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
logtape.c stores block numbers on disk. These block numbers are
represented in memory as being of type long. This is why BufFile
clients that use the block-based interface (currently limited to
logtape.c and gistbuildbuffers.c) must live with a specific
limitation, as noted within buffile.c:

/** BufFileSeekBlock --- block-oriented seek** Performs absolute seek to the start of the n'th BLCKSZ-sized block of*
thefile.  Note that users of this interface will fail if their files* exceed BLCKSZ * LONG_MAX bytes, but that is quite
alot; we don't work* with tables bigger than that, either...** Result is 0 if OK, EOF if not.  Logical position is not
movedif an* impossible seek is attempted.*/
 
int
BufFileSeekBlock(BufFile *file, long blknum)
{   ...
}

That restriction is fine on 64-bit Linux, where it is actually true
that "we don't work with tables that big either", but on Win64 long is
still only 4 bytes. 32-bit systems are similarly affected. Of course,
MaxBlockNumber is 0xFFFFFFFE, whereas LONG_MAX is only 0x7FFFFFFF on
affected systems.

Is it worth changing this interface to use int64, which is already
defined to be a "long int" on most real-world installations anyway?
Though it hardly matters, this would have some cost: logtape.c temp
files would have a higher storage footprint on win64 (i.e., the same
overhead as elsewhere).

I tend to be suspicious of use of the type "long" in general, because
in general one should assume that it is no wider than "int". This
calls into question why any code that uses "long" didn't just use
"int", at least in my mind.

-- 
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: [HACKERS] dropping partitioned tables without CASCADE
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Documentation improvements for partitioning