Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group