Re: Rules on a view overwrite default values. Any way to reinstate them?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bradley Kieser <brad(at)kieser(dot)net>
Cc: PgSQL ADMIN <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Rules on a view overwrite default values. Any way to reinstate them?
Date: 2005-01-03 17:32:18
Message-ID: 24511.1104773538@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Bradley Kieser <brad(at)kieser(dot)net> writes:
> The problem is that rules on a view mean that the default values for NOT
> NULL columns (used extensively) no longer trigger!

The way you're supposed to fix this is to attach default values to the
view itself.

ALTER TABLE myview ALTER COLUMN updated_time SET DEFAULT now();

Now an INSERT on myview will include the correct expression before view
expansion happens.

I'm not sure how long we've had this, but it's definitely in 7.4.

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Amauri Pimenta 2005-01-03 18:28:10 Problems with Postgresql 8.0.0
Previous Message Stephan Szabo 2005-01-03 17:30:59 Re: Rules on a view overwrite default values. Any way to