Re: thw rewriter and default values, again

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: thw rewriter and default values, again
Date: 2005-05-28 16:36:46
Message-ID: c2d9e70e05052809367c0c6b92@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/28/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Jaime Casanova <systemguards(at)gmail(dot)com> writes:
> > create rule ins_rule as on insert to v_foo do instead
> > insert into foo(col1, col2) values (new.col1, new.col2);
>
> > insert into v_foo(col2) values (1);
>
> > this give an error like:
> > psql:f:/views.sql:13: ERROR: null value in column "col1" violates
> > not-null constraint
>
> That's not a bug, and "fixing" it isn't acceptable.
>
> The correct solution to the problem you are looking at is
> to attach default expressions to the view itself. Adding
>
> alter table v_foo alter col1 set default nextval('public.foo_col1_seq');
>
> to your example makes it work as you wish.
>
I know you're right, but -when dealing with updateable views- doing
that implies to add a lot of time altering views when base table
change, and of course we maybe don't want all views get that values.

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Casanova 2005-05-28 16:38:43 Re: thw rewriter and default values, again
Previous Message Tom Lane 2005-05-28 15:23:30 Re: thw rewriter and default values, again