Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Bugs > Re: BUG #4271: ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 3883 of 4193
Post > Topic >>

Re: BUG #4271: dropped columns conflict with returning

by bruce@[EMAIL PROTECTED] (Bruce Momjian) Aug 20, 2008 at 05:27 PM

Added to TODO:

	Enable creation of RETURNING rules on inherited tables that have dropped
	columns
	
	    http://archives.postgresql.org/pgsql-bugs/2008-06/msg00183.php

---------------------------------------------------------------------------

Tom Lane wrote:
> "Alexey Bashtanov" <bashtanov@[EMAIL PROTECTED]
> writes:
> > I have created a partitioned table cache with partitions
cache_id_g_4184088
> > and cache_id_le_4184088 those inherit cache.
> > I provided insert by the following rule:
> > CREATE RULE cache_partic AS ON INSERT TO cache DO INSTEAD INSERT INTO
> > cache_id_g_4184088 VALUES (new.*) RETURNING cache_id_g_4184088.*;
> 
> > after I ran 
> > ALTER TABLE cache add column foo
> > ALTER TABLE cache add column bar
> > ALTER TABLE cache drop column bar
> > ALTER TABLE cache add column quackquack
> 
> > this rule started to work incorrectly: it did not store foo and
quackquack
> > values but used nulls instead.
> 
> This is expected behavior because the * expressions are expanded when
> the rule is defined:
> 
> regression=# create table foo(f1 int, f2 int, f3 int);
> CREATE TABLE
> regression=# create table foo1() inherits (foo);
> CREATE TABLE
> regression=# create rule redirect as on insert to foo do instead
> insert into foo1 values(new.*) returning foo1.*;
> CREATE RULE
> regression=# \d foo
>       Table "public.foo"
>  Column |  Type   | Modifiers 
> --------+---------+-----------
>  f1     | integer | 
>  f2     | integer | 
>  f3     | integer | 
> Rules:
>     redirect AS
>     ON INSERT TO foo DO INSTEAD  INSERT INTO foo1 (f1, f2, f3) 
>   VALUES (new.f1, new.f2, new.f3)
>   RETURNING foo1.f1, foo1.f2, foo1.f3
> 
> regression=# alter table foo add column f4 int;
> ALTER TABLE
> regression=# \d foo
>       Table "public.foo"
>  Column |  Type   | Modifiers 
> --------+---------+-----------
>  f1     | integer | 
>  f2     | integer | 
>  f3     | integer | 
>  f4     | integer | 
> Rules:
>     redirect AS
>     ON INSERT TO foo DO INSTEAD  INSERT INTO foo1 (f1, f2, f3) 
>   VALUES (new.f1, new.f2, new.f3)
>   RETURNING foo1.f1, foo1.f2, foo1.f3
> 
> Of course you can redefine the rule after adding a column:
> 
> regression=# create or replace rule redirect as on insert to foo do
instead
> insert into foo1 values(new.*) returning foo1.*;
> CREATE RULE
> regression=# \d foo
>       Table "public.foo"
>  Column |  Type   | Modifiers 
> --------+---------+-----------
>  f1     | integer | 
>  f2     | integer | 
>  f3     | integer | 
>  f4     | integer | 
> Rules:
>     redirect AS
>     ON INSERT TO foo DO INSTEAD  INSERT INTO foo1 (f1, f2, f3, f4) 
>   VALUES (new.f1, new.f2, new.f3, new.f4)
>   RETURNING foo1.f1, foo1.f2, foo1.f3, foo1.f4
> 
> 
> > When I tried to ReCREATE this rule, POSTGRESQL said 'ERROR:  cannot
convert
> > relation containing dropped columns to view'
> 
> What did you do *exactly*?  I tried
> 
> regression=# alter table foo add column f5 int;
> ALTER TABLE
> regression=# alter table foo drop column f5;
> ALTER TABLE
> regression=# create or replace rule redirect as on insert to foo do
instead
> insert into foo1 values(new.*) returning foo1.*;
> ERROR:  RETURNING list has too few entries
> 
> which does seem like a bug but it's not what you are describing.
> 
> 			regards, tom lane
> 
> -- 
> Sent via pgsql-bugs mailing list (pgsql-bugs@[EMAIL PROTECTED]
)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs

-- 
  Bruce Momjian  <bruce@[EMAIL PROTECTED]
>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
 




 5 Posts in Topic:
BUG #4271: dropped columns conflict with returning rules
bashtanov@[EMAIL PROTECTE  2008-06-29 02:07:50 
Re: BUG #4271: dropped columns conflict with returning rules
tgl@[EMAIL PROTECTED] (T  2008-06-29 11:49:58 
Re: BUG #4271: dropped columns conflict with returning rules
tgl@[EMAIL PROTECTED] (T  2008-06-29 12:38:33 
Re: BUG #4271: dropped columns conflict with returning
bruce@[EMAIL PROTECTED]   2008-08-20 17:27:05 
Re: BUG #4271: dropped columns conflict with returning rules
bashtanov@[EMAIL PROTECTE  2008-06-29 20:25:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 11:10:58 CST 2008.