INSERT into VIEW

Started by Oleg Broytmannover 26 years ago2 messages
#1Oleg Broytmann
phd@sun.med.ru

Hello!

PostgreSQL 6.4.2.

ran=> create table t (some_number int4, some_string text);
CREATE
ran=> insert into t values(-1,'a');
INSERT 20362 1
ran=> insert into t values(1,'d');
INSERT 20363 1
ran=> create view v as select * from t where some_number>=0;
CREATE
ran=> insert into v values (17,'q');
INSERT 20375 1
ran=> select * from t;
some_number|some_string
-----------+-----------
-1|a
1|d
(2 rows)

What is 20375? Is it real OID of dummy row?

Oleg.
----
Oleg Broytmann http://members.xoom.com/phd2/ phd2@earthling.net
Programmers don't die, they just GOSUB without RETURN.

#2Noname
wieck@debis.com
In reply to: Oleg Broytmann (#1)
Re: [HACKERS] INSERT into VIEW

Hello!

PostgreSQL 6.4.2.

ran=> create table t (some_number int4, some_string text);
CREATE
ran=> insert into t values(-1,'a');
INSERT 20362 1
ran=> insert into t values(1,'d');
INSERT 20363 1
ran=> create view v as select * from t where some_number>=0;
CREATE
ran=> insert into v values (17,'q');
INSERT 20375 1
ran=> select * from t;
some_number|some_string
-----------+-----------
-1|a
1|d
(2 rows)

What is 20375? Is it real OID of dummy row?

It's the OID of the real row that got stored into relation v.

Do a

DROP RULE "_RETv";
SELECT * FROM v;

and you'll get back your (17,'q') row.

Maybe you should read now some chapters in the programmers
manual about the implementation of views, the rule system
etc.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck@debis.com (Jan Wieck) #