Re: In RULEs, INSERT does not use DEFAULTs

Поиск
Список
Период
Сортировка
От Rod Taylor
Тема Re: In RULEs, INSERT does not use DEFAULTs
Дата
Msg-id 1118635401.723.33.camel@home
обсуждение исходный текст
Ответ на Re: In RULEs, INSERT does not use DEFAULTs  (David Fetter <david@fetter.org>)
Список pgsql-hackers
On Sun, 2005-06-12 at 20:33 -0700, David Fetter wrote:
> On Sun, Jun 12, 2005 at 10:56:22PM -0400, Tom Lane wrote:
> > David Fetter <david@fetter.org> writes:
> > > At one time, INSERTing a NULL into a column with a DEFAULT used to
> > > INSERT the DEFAULT.  Is there some way to get this behavior back?
> > 
> > PG has *never* done that in any version that I can recall, and it
> > isn't likely that we would install such an obvious violation of the
> > SQL spec.
> 
> > The correct way to get the behavior you are after is to attach a
> > default to the view's column (ALTER view ALTER col SET DEFAULT ...)
> 
> With all due respect, that's a giant foot gun in terms of maintenance,
> i.e. making a single behavior depend on two things that can easily
> get out of sync.  With hand-altered DEFAULTs, there's no way to alter
> the DEFAULTs on the the base TABLE and have those changes propagate,
> as people would usually want it to.

Change the table and view to use a domain.
       CREATE DOMAIN tabviewtype_x AS integer DEFAULT 12;

Altering the default of the domain will bump both the table and view
defaults, or anywhere else that type happens to be used.

-- 
Rod Taylor <pg@rbt.ca>



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: In RULEs, INSERT does not use DEFAULTs
Следующее
От: David Fetter
Дата:
Сообщение: Re: In RULEs, INSERT does not use DEFAULTs