Обсуждение: BUG #5030: Problem on "RETURN QUERY EXECUTE" when a column is dropped from a table

Поиск
Список
Период
Сортировка

BUG #5030: Problem on "RETURN QUERY EXECUTE" when a column is dropped from a table

От
"Armando Taffarel Neto"
Дата:
The following bug has been logged online:

Bug reference:      5030
Logged by:          Armando Taffarel Neto
Email address:      taffarel@solis.coop.br
PostgreSQL version: 8.4.0
Operating system:   Linux Ubuntu 9.04
Description:        Problem on "RETURN QUERY EXECUTE" when a column is
dropped from a table
Details:

CREATE TABLE foo (f1 int, f2 int);

CREATE OR REPLACE FUNCTION test_foo() RETURNS SETOF foo AS $$
DECLARE
    query varchar;
BEGIN
    query := 'SELECT * FROM foo';
    RETURN QUERY EXECUTE query;
END;
$$ LANGUAGE plpgsql;

SELECT * FROM test_foo(); --OK

ALTER TABLE foo DROP COLUMN f2;

CREATE OR REPLACE FUNCTION test_foo() RETURNS SETOF foo AS $$
DECLARE
    query varchar;
BEGIN
    query := 'SELECT * FROM foo';
    RETURN QUERY EXECUTE query;
END;
$$ LANGUAGE plpgsql;

SELECT * FROM test_foo();
ERROR:  structure of query does not match function result type
DETAIL:  Number of returned columns (1) does not match expected column count
(2).
CONTEXT:  PL/pgSQL function "test_foo" line 5 at RETURN QUERY

Re: BUG #5030: Problem on "RETURN QUERY EXECUTE" when a column is dropped from a table

От
Jaime Casanova
Дата:
On Wed, Sep 2, 2009 at 12:25 PM, Armando Taffarel
Neto<taffarel@solis.coop.br> wrote:
>
> SELECT * FROM test_foo();
> ERROR: =C2=A0structure of query does not match function result type
> DETAIL: =C2=A0Number of returned columns (1) does not match expected colu=
mn count
> (2).
> CONTEXT: =C2=A0PL/pgSQL function "test_foo" line 5 at RETURN QUERY
>

yeah! that bug was fixed here
http://archives.postgresql.org/pgsql-committers/2009-08/msg00068.php
but only in the currently in develop 8.5

are we going to backpatch this? while i think we should i know nothing
about how feasible that is

--=20
Atentamente,
Jaime Casanova
Soporte y capacitaci=C3=B3n de PostgreSQL
Asesor=C3=ADa y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157