[PATCH] Clarify the comments about varlena header encoding

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема [PATCH] Clarify the comments about varlena header encoding
Дата
Msg-id CAJ7c6TOY_-mew61g4okz7H6+09JrwmTZEn3JnwVyeWhRXNzZGA@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] Clarify the comments about varlena header encoding
Список pgsql-hackers
Hi hackers,

I noticed that the comments regarding bit layouts for varlena headers
in postgres.h are somewhat misleading. For instance, when reading:

```
00xxxxxx 4-byte length word, aligned, uncompressed data (up to 1G)
```

... one can assume this is a 00xxxxxx byte followed by another 4 bytes
(which is wrong). Also one can read this as "aligned, uncompressed
data" (which again is wrong).

```
10000000 1-byte length word, unaligned, TOAST pointer
```

This is misleading too. The comments above this line say that `struct
varatt_external` is a TOAST pointer. sizeof(varatt_external) = 16,
plus 1 byte equals 17, right? However the documentation [1] claims the
result should be 18:

"""
Allowing for the varlena header bytes, the total size of an on-disk
TOAST pointer datum is therefore 18 bytes regardless of the actual
size of the represented value.
"""

I did my best to get rid of any ambiguity. The patch is attached.

[1]: https://www.postgresql.org/docs/current/storage-toast.html

-- 
Best regards,
Aleksander Alekseev

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: pg_walinspect: ReadNextXLogRecord's first_record argument
Следующее
От: Alvaro Herrera
Дата:
Сообщение: cataloguing NOT NULL constraints