pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Andres Freund <andres@anarazel.de>
Cc: suchithjn22@gmail.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: The documentation for storage type 'plain' actually allows single byte header
Date: Sun, 15 Jan 2023 16:40:27 -0500
Message-ID: <1698750.1673818827@sss.pgh.pa.us> (raw)
In-Reply-To: <d99b3e0beebdde0741d28035aaea7f4af56fa050.camel@cybertec.at>
References: <167336599095.2667301.15497893107226841625@wrigleys.postgresql.org>
	<d99b3e0beebdde0741d28035aaea7f4af56fa050.camel@cybertec.at>

Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Tue, 2023-01-10 at 15:53 +0000, PG Doc comments form wrote:
>>> PLAIN prevents either compression or out-of-line storage; furthermore it
>>> disables use of single-byte headers for varlena types. This is the only
>>> possible strategy for columns of non-TOAST-able data types.

>> However, it does allow "single byte" headers. How to verify this?
>> CREATE EXTENSION pageinspect;
>> CREATE TABLE test(a VARCHAR(10000) STORAGE PLAIN);
>> INSERT INTO test VALUES (repeat('A',10));
>> 
>> Now peek into the page with pageinspect functions
>> 
>> SELECT left(encode(t_data, 'hex'), 40) FROM
>> heap_page_items(get_raw_page('test', 0));
>> 
>> This returned value of "1741414141414141414141".

> I think that the documentation is wrong.  The attached patch removes the
> offending half-sentence.

The documentation is correct, what is broken is the code.  I'm not
sure when we broke it, but what I see in tracing through the INSERT
is that we are forming the tuple using a tupdesc with the wrong
value of attstorage.  It looks like the tupdesc belongs to the
virtual slot representing the output of the INSERT statement,
which is not identical to the target relation's tupdesc.

(The virtual slot's tupdesc is probably reverse-engineered from
just the data types of the columns, so it'll have whatever is the
default attstorage for the data type.  It's blind luck that this
attstorage value isn't used for anything more consequential,
like TOAST decisions.)

			regards, tom lane





view thread (19+ messages)  latest in thread

Message-ID: <1698750.1673818827@sss.pgh.pa.us>
Permalink:  ../1698750.1673818827@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1698750.1673818827@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, andres@anarazel.de, suchithjn22@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: The documentation for storage type 'plain' actually allows single byte header
  In-Reply-To: <1698750.1673818827@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox