rules and default values

From: nconway(at)klamath(dot)dyndns(dot)org (Neil Conway)
To: pgsql-hackers(at)postgresql(dot)org
Cc: mojo(at)thewickedtribe(dot)net
Subject: rules and default values
Date: 2002-03-30 23:53:46
Message-ID: 20020330235346.GD27863@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

In IRC, "StuckMojo" commented that the following behavior doesn't seem
to be ideal:

nconway=> create table my_table (col1 int default 5, col2 int default
10);
CREATE
nconway=> create view my_view (col1, col2) as select * from my_table;
CREATE
nconway=> create rule insert_rule as on insert to my_view do instead
insert into my_table values (new.*);
CREATE
nconway=> insert into my_table default values;
INSERT 112714 1
nconway=> insert into my_view default values;
INSERT 0 0
nconway=> select * from my_table;
col1 | col2
------+------
5 | 10
|
(2 rows)

In other words, when the insert statement on the view is transformed by
the rule, the "default value" columns are replaced by explicit NULL
values (which is the default value for the columns of the pseudo-table
created by CREATE VIEW). Is this the correct behavior?

Cheers,

Neil

--
Neil Conway <neilconway(at)rogers(dot)com>
PGP Key ID: DB3C29FC

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-03-31 00:26:01 Re: rules and default values
Previous Message Peter Eisentraut 2002-03-30 22:50:21 Re: How to give permission to others on data directory