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

From: "Armando Taffarel Neto" <taffarel(at)solis(dot)coop(dot)br>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5030: Problem on "RETURN QUERY EXECUTE" when a column is dropped from a table
Date: 2009-09-02 17:25:44
Message-ID: 200909021725.n82HPiHu018379@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5030
Logged by: Armando Taffarel Neto
Email address: taffarel(at)solis(dot)coop(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2009-09-02 17:44:21 Re: BUG #5028: CASE returns ELSE value always when type is"char"
Previous Message Tom Lane 2009-09-02 17:19:07 Re: BUG #5028: CASE returns ELSE value always when type is"char"