Re: In RULEs, INSERT does not use DEFAULTs

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: In RULEs, INSERT does not use DEFAULTs
Date: 2005-06-13 05:13:02
Message-ID: 20050613051302.GE18728@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jun 12, 2005 at 11:48:29PM -0400, Tom Lane wrote:
> David Fetter <david(at)fetter(dot)org> writes:
> > I believe this isn't just my problem. Without access to a the
> > underlying column's DEFAULT, how can people implement the automated
> > WRITEable VIEWs?
>
> That's a reasonable question, but translating "insert null" to "insert
> the default" is not a reasonable answer.

Right. My mistake.

> There was some speculation just a couple days ago about inventing a
> function that would compute the default associated with some other
> table's column, but it's not clear how to make that work (in
> particular, how to declare the result type of such a function).

I was looking into polymorphic functions for this. At least in
PL/PgSQL (which isn't a general solution, but I was looking for my own
solution) there is a way to get the return type based on the input
types.

> Another possibility is a command along the lines of
> ALTER view ALTER col LINK DEFAULT TO othertable.col;

I still think that something like this (i.e. the VIEWs column has the
same default as its underlying base TABLE or VIEW, where there is one)
should be the default behavior. Principle of Least Astonishiment.

> (syntax open to argument of course) which accomplishes the
> same thing without having to figure a way to avoid the constraints
> of a specific function result type.

It'd be nice to have one of these :)

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2005-06-13 05:56:12 Re: The Contrib Roundup (long)
Previous Message Rod Taylor 2005-06-13 04:03:21 Re: In RULEs, INSERT does not use DEFAULTs