Re: Strange problem with create table as select * from table;

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: depesz(at)depesz(dot)com, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange problem with create table as select * from table;
Date: 2011-11-05 18:20:23
Message-ID: 20111105182023.GA17051@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cstdenis 2011-11-05 18:39:40 Distinct on a non-sort column
Previous Message Andrus 2011-11-05 15:36:47 How to find owning schema in function

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2011-11-05 18:46:58 Re: Include commit identifier in version() function
Previous Message Josh Kupershmidt 2011-11-05 17:32:37 proposal: psql concise mode