Re: Strange problem with create table as select * from table; - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Strange problem with create table as select * from table;
Date
Msg-id 20111105182023.GA17051@svana.org
Whole thread Raw
In response to Re: Strange problem with create table as select * from table;  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Fri, Nov 04, 2011 at 09:04:02PM -0400, Tom Lane wrote:
> Hah ... I have a theory.
>
> I will bet that you recently added some column(s) to the source table
> using ALTER TABLE ADD COLUMN and no default value, so that the added
> columns were nulls and no table rewrite happened.  And that these
> troublesome rows predate that addition, but contained no nulls before
> that.  And that they are the only rows that, in addition to the above
> conditions, contain data fields wide enough to require out-of-line
> toasting.
>
> These conditions together are enough to break the assumption in
> toast_insert_or_update that the old and new tuples must have the same
> value of t_hoff.

Wow! Good catch.

> This is trivial to fix, now that we know there's a problem --- the
> function is only using that assumption to save itself a couple lines
> of code.  Penny wise, pound foolish :-(

No doubt the assumption was true when the code was written, but still.

Hve a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
   -- Arthur Schopenhauer

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Strange problem with create table as select * from table;
Next
From: Steve Murphy
Date:
Subject: What is *wrong* with this query???