Re: Fail of a return query from plpgsql function for a specific table - Mailing list pgsql-general

From A. Kretschmer
Subject Re: Fail of a return query from plpgsql function for a specific table
Date
Msg-id 20090108075001.GB15370@a-kretschmer.de
Whole thread Raw
In response to Fail of a return query from plpgsql function for a specific table  ("c k" <shreeseva.learning@gmail.com>)
List pgsql-general
In response to c k :
> Hi all,
> I have a table accgroups and many others. I have written a test function as
> follows.
> CREATE OR REPLACE FUNCTION uf_testfunction()
>   RETURNS SETOF associates AS
> $BODY$
> begin
> return query select * from associates;
> return;
> end;
> $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;
> This works fine for above table but not works at all for accgroups table. As I
> searched for this over web, it is identified as a bug for tables whose columns
> are changed(deleted and added). Is it true?
> How to solve this issue?
> Thanks
> CPK

I can't reproduce your problem:

test=# create table foo (a int, b int);
CREATE TABLE
test=# create or replace function get_foo() returns setof foo as $$begin return query select * from foo; return; end;
$$LANGUAGE 'plpgsql' VOLATILE; 
CREATE FUNCTION
test=# select * from get_foo();
 a | b
---+---
(0 rows)

test=# alter table foo add column c int;
ALTER TABLE
test=# select * from get_foo();
 a | b | c
---+---+---
(0 rows)


(only if i drop a column):
test=# alter table foo drop column c;
ALTER TABLE
test=# select * from get_foo();
ERROR:  structure of query does not match function result type
CONTEXT:  PL/pgSQL function "get_foo" line 1 at RETURN QUERY



Please, provide us an example including the error you got.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

pgsql-general by date:

Previous
From: Mayuresh Nirhali
Date:
Subject: Error: column "host" does not exist
Next
From: Reg Me Please
Date:
Subject: Re: Error: column "host" does not exist