Re: effective SELECT from child tables

From: Rod Taylor <pg(at)rbt(dot)ca>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>
Subject: Re: effective SELECT from child tables
Date: 2005-10-04 03:51:44
Message-ID: 1128397904.6543.151.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2005-10-03 at 23:24 -0400, Greg Stark wrote:
> Hannu Krosing <hannu(at)skype(dot)net> writes:
>
> > On P, 2005-10-02 at 23:00 -0400, Tom Lane wrote:
> > >
> > > Here's another interesting case to think about:
> > >
> > > ALTER TABLE ADD foo integer DEFAULT 1
> > > ...
> > > ALTER TABLE ALTER foo SET DEFAULT 2
> > >
> > > You'll have to pay the table-traversal cost on one step or the other.
> >
> > The second, ALTER ... SET DEFAULT, would only set default for newly
> > inserted columns, not the ones which are missing due to tuples being
> > created before the column existed.
>
> Hm. So you're saying there are only ever exactly two types of defaults. The
> "initial" default that applies to all tuples that were created before the
> column was added. And the "current" default that only ever applies to newly
> created tuples.
>
> That does seem to cleanly close this hole.

I don't think so.

ALTER TABLE tab ADD foo integer DEFAULT 1;
INSERT INTO tab DEFAULT VALUES;

ALTER TABLE tab ALTER foo SET DEFAULT 2
INSERT INTO tab DEFAULT VALUES;

ALTER TABLE tab ALTER foo SET DEFAULT 3
INSERT INTO tab DEFAULT VALUES;

SELECT foo FROM tab;
--

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2005-10-04 04:06:15 Re: effective SELECT from child tables
Previous Message Tom Lane 2005-10-04 03:51:18 Re: [HACKERS] External Sort timing debug statements