dbTalk Databases Forums  

[BUGS] INSTEAD rule bug?

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] INSTEAD rule bug? in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dmitry Tkach
 
Posts: n/a

Default [BUGS] INSTEAD rule bug? - 07-15-2003 , 11:16 AM






Here is a problem a ran into:

testdb=# create table test (x int);
CREATE TABLE
testdb=# create table test_view as select * from test;
SELECT
testdb=# create rule insert_test as on insert to test_view do instead
insert into test values (new.*);
CREATE RULE
testdb=# create rule skip_test as on insert to test_view where x is null
do instead nothing;
CREATE RULE
testdb=# insert into test_view values (null);
INSERT 17259 1
testdb=# select * from test;
x
---

(1 row)

According to the last rule the insert should not have happened, right?
How come it got ignored?

Thanks!

Dima



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] INSTEAD rule bug? - 07-15-2003 , 11:41 AM






Dmitry Tkach <dmitry (AT) openratings (DOT) com> writes:
Quote:
testdb=# create table test_view as select * from test;
SELECT
That is not a view, it's only a static copy of the original table.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #3  
Old   
Dmitry Tkach
 
Posts: n/a

Default Re: [BUGS] INSTEAD rule bug? - 07-15-2003 , 11:48 AM



Tom Lane wrote:

Quote:
Dmitry Tkach <dmitry (AT) openratings (DOT) com> writes:


testdb=# create table test_view as select * from test;
SELECT



That is not a view, it's only a static copy of the original table.

regards, tom lane


I know... That was a typo in my sql :-)
But for this example it doesn't matter - that view/table is only needed
to illustrate the rules behaviour on insert.
You can just replace 'table' with 'view' in that statement - the
behaviour of the insert is exactly the same anyway.

Dima


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.