rules and default values - Mailing list pgsql-hackers

From nconway@klamath.dyndns.org (Neil Conway)
Subject rules and default values
Date
Msg-id 20020330235346.GD27863@klamath.dyndns.org
Whole thread Raw
Responses Re: rules and default values  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@rogers.com>
PGP Key ID: DB3C29FC


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: How to give permission to others on data directory
Next
From: Tom Lane
Date:
Subject: Re: rules and default values