Re: updatable views and default values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jaime Casanova" <systemguards(at)gmail(dot)com>
Cc: "Pgsql Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: updatable views and default values
Date: 2006-08-31 22:29:50
Message-ID: 24863.1157063390@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Jaime Casanova" <systemguards(at)gmail(dot)com> writes:
> now that you're reviewing the updatable view patch, i think we must
> decide what you're position will be about if the updatable view should
> inherit the base table default values... or if we want to create
> default values for every view if we want they match with the base
> table ones... (fwiw, informix does the former)

I'm inclined to agree that if we create an automatic INSERT rule for a
view, we ought to automatically copy the base table's defaults up to the
view as well. Otherwise the user will certainly want to do that by
hand, and the whole point of this feature is to eliminate the need to do
obvious things by hand.

I think that this would require adding a flag to pg_attrdef entries to
show whether they were created implicitly or not, so that pg_dump would
know not to dump them.

But wait, what if the user does ALTER SET DEFAULT on the base table ---
shouldn't that then propagate to the view? Perhaps it would be better
if the implementation didn't explicitly store a default expression
attached to the view, but were willing to "drill down" to the base table
and grab its default. You could still override that by explicitly
attaching a different default to the view, but 90% of the time this
would be the right thing.

For backwards compatibility we should probably say that this automatic
lifting of base-table defaults happens only if the INSERT rule is
implicitly generated ... if you write a manual INSERT rule you need
manual defaults too. Or should "propagate default values" become an
explicit attribute of ON INSERT rules?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2006-08-31 22:29:52 Re: Win32 hard crash problem
Previous Message Alvaro Herrera 2006-08-31 22:28:54 Re: Win32 hard crash problem