Re: effective SELECT from child tables

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: effective SELECT from child tables
Дата
Msg-id 877jct9azb.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: effective SELECT from child tables  (Rod Taylor <pg@rbt.ca>)
Список pgsql-hackers
Rod Taylor <pg@rbt.ca> writes:

> > 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;

This inserts a physical "1" in the record (the "current" default").

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

This inserts a physical "2" in the record.

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

This inserts a physical "3" in the record.

> SELECT foo FROM tab;

This checks for any old records that predate the column and use the "initial"
default of 1 for those records. The three records above all postdate the
column addition so they have values present, namely 1, 2, and 3.

-- 
greg



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: effective SELECT from child tables
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Tuning current tuplesort external sort code for 8.2