Re: pageinspect: add tuple_data_record() - Mailing list pgsql-hackers

From Andres Freund
Subject Re: pageinspect: add tuple_data_record()
Date
Msg-id 20181017172051.pz5cmyozq6jva346@alap3.anarazel.de
Whole thread Raw
In response to Re: pageinspect: add tuple_data_record()  (James Coleman <jtc331@gmail.com>)
Responses Re: pageinspect: add tuple_data_record()  (James Coleman <jtc331@gmail.com>)
List pgsql-hackers
Hi,

On 2018-10-17 13:14:17 -0400, James Coleman wrote:
> > It's far from only toast that could be problematic here.
> >
> 
> Do you have an example in mind? Wouldn’t the tuples have to be corrupted in
> some way to have problems with being interpreted as a datum? Or are you
> thinking very old tuples with a radically different structure to be causing
> the problem?

There's plenty ways it can go horribly wrong. Let's start with something
simple:

BEGIN;
ALTER TABLE ... ADD COLUMN blarg INT;
INSERT ... (blag) VALUES (132467890);
ROLLBACK;

ALTER TABLE ... ADD COLUMN blarg TEXT;

If you now read the table with your function you'll see a dead row that
will re-interpret a int datum as a text datum. Which in all likelyhood
will crash the server.

And yes, it's more likely to break with your patch, but I think the
current *split* function is dangerous too, and shouldn't have been added
without *A LOT* more attention to issues like this.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: James Coleman
Date:
Subject: Re: pageinspect: add tuple_data_record()
Next
From: Larry Rosenman
Date:
Subject: Peripatus/failures