Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A937863252E for ; Thu, 8 Jan 2009 03:50:19 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 30590-04 for ; Thu, 8 Jan 2009 03:50:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.177]) by mail.postgresql.org (Postfix) with ESMTP id 26DD763251B for ; Thu, 8 Jan 2009 03:50:04 -0400 (AST) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis) id 0MKwtQ-1LKpeT3i2e-00056L; Thu, 08 Jan 2009 08:50:02 +0100 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1LKpeT-00061s-00 for pgsql-general@postgresql.org; Thu, 08 Jan 2009 08:50:01 +0100 Date: Thu, 8 Jan 2009 08:50:01 +0100 From: "A. Kretschmer" To: pgsql-general@postgresql.org Subject: Re: Fail of a return query from plpgsql function for a specific table Message-ID: <20090108075001.GB15370@a-kretschmer.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX19F+JFAVaY/6D64sonOumlN/P5nTUNtTHPM7GW mwdfAA6HNDtodijoQtkeF3NNy4DX94rH/MNfOT9+h1c4XkM6BR ujcrJ2/dhEESEm6oCbJGt9M3DkNqaqt X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200901/159 X-Sequence-Number: 142244 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