Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
Дата
Msg-id CAPpHfdu3YRGVvfFTLWoiVXGD5ZXSBY-MXqwmP1UErz9-Yf1CDQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)  (Aleksander Alekseev <aleksander@timescale.com>)
Список pgsql-hackers
On Mon, Nov 6, 2023 at 4:38 PM Aleksander Alekseev <aleksander@timescale.com> wrote:
> > > PFE the corrected patchset v58.
> >
> > I'd like to revive this thread.
>
> Many thanks for your comments and suggestions.
>
> > I think it worth adding asserts here to verify there is no overflow making us mapping different segments into the same files.
>
> Sorry, I didn't understand this one. Maybe you could provide the exact code?

I actually meant this.

static int  inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
    if (ctl->long_segment_names)
    {
        /*
         * We could use 16 characters here but the disadvantage would be that
         * the SLRU segments will be hard to distinguish from WAL segments.
         *
         * For this reason we use 15 characters. It is enough but also means
         * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
         */
        Assert(segno >= 0 && segno <= 0x1000000000000000);
        return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
                        (long long) segno);
    }
    else
    {
        Assert(segno >= 0 && segno <= 0x10000);
        return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
                        (unsigned int) segno);
    }
}

As I now get, snprintf() wouldn't just truncate the high signs, instead it will use more characters.  But I think assertions are useful anyway.

------
Regards,
Alexander Korotkov

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Fix search_path for all maintenance commands
Следующее
От: Matthias van de Meent
Дата:
Сообщение: Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan