Bug with views and defaults - Mailing list pgsql-hackers

From Mark Hollomon
Subject Bug with views and defaults
Date
Msg-id 3948E296.6CA16A0A@americasm01.nt.com
Whole thread Raw
Responses Re: Bug with views and defaults  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
CREATE TABLE foo (name TEXT,type CHAR(1),when_added TIMESTAMP DEFAULT 'now'
);

CREATE VIEW mytype AS SELECT name, when_added FROM foo WHERE type = 'M';

CREATE RULE mytype_insert ASON INSERT TO mytype DO INSTEADINSERT INTO foo (name, type) VALUES (NEW.name, 'M');

db=# insert into foo (name, type) VALUES ('n1', 'M');
INSERT 414488 1
db=# insert into mytype (name) VALUES ('n2');
INSERT 414489 1
db=# select * from foo;name | type |       when_added
------+------+------------------------n1   | M    | 2000-06-15 09:53:44-04n2   | M    | 2000-06-15 09:52:27-04
(2 rows)

Inserting directly into foo sets when_added to the current time.
Inserting through the view sets it to what looks like the time of
view creation.

-- 

Mark Hollomon
mhh@nortelnetworks.com
ESN 451-9008 (302)454-9008


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Big 7.1 open items
Next
From: Thomas Lockhart
Date:
Subject: Re: Re: Big 7.1 open items