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

Re: patch fixing the old RETURN NEXT bug

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: patch fixing the old RETURN NEXT bug
Date: 2006-06-16 17:44:58
Message-ID: 200606161744.k5GHiwF09905@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Added to TODO:

       o Fix problems with RETURN NEXT on tables with
         dropped/added columns after function creation

          http://archives.postgresql.org/pgsql-patches/2006-02/msg00165$


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

Sergey E. Koposov wrote:
> Hello All,
> 
> I'm proposing the fix of this bug:
> http://archives.postgresql.org/pgsql-hackers/2005-02/msg00498.php
> 
> The exact SQL code exposing the error:
> 
> ----------
> 
> create table usno (ra real, dec real, bmag real, rmag real,ipix int8);
> CREATE OR REPLACE FUNCTION xxx(refcursor) RETURNS refcursor AS '
> DECLARE query varchar;
> BEGIN
> query = ''SELECT * FROM usno'';
> OPEN $1 FOR EXECUTE query;
> RETURN $1;
> END;
> ' LANGUAGE plpgsql;
> 
> CREATE OR REPLACE FUNCTION yyy() RETURNS SETOF usno AS '
> DECLARE rec record;
> DECLARE cur refcursor;
> BEGIN
> cur=xxx(''curs_name'');
> LOOP
>         FETCH cur into rec;
>         EXIT WHEN NOT FOUND;
>         RETURN NEXT rec;
> END LOOP;
> RETURN;
> END;
> ' LANGUAGE plpgsql;
> 
> insert into usno values(1,2,3,4);
> select * from yyy();
> alter table usno add column errbox box;
> select * from yyy();
> alter table usno drop column errbox;
> select * from yyy();
> 
> -------
> 
> The problem with that is in fact in pl_exec.c in function
> compatible_tupdesc(), which do not check for the deleted attributes.
> 
> The patch is attached.
> 
> Regards,
> 	Sergey
> 
> *****************************************************
> Sergey E. Koposov
> Max Planck Institute for Astronomy
> Web: http://lnfm1.sai.msu.ru/~math 
> E-mail: math(at)sai(dot)msu(dot)ru
> 

Content-Description: 

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

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

In response to

pgsql-hackers by date

Next:From: Stefan KaltenbrunnerDate: 2006-06-16 18:14:47
Subject: Re: Test request for Stats collector performance improvement
Previous:From: Josh BerkusDate: 2006-06-16 17:01:56
Subject: Re: Sun Donated a Sun Fire T2000 to the PostgreSQL community

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-06-16 18:08:25
Subject: Re: plpython tracebacks
Previous:From: Chander GanesanDate: 2006-06-16 16:46:37
Subject: Re: Omitting tablespace creation from pg_dumpall...

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