pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-general@postgresql.org
Subject: Re: Fail of a return query from plpgsql function for a specific table
Date: Thu, 8 Jan 2009 08:50:01 +0100
Message-ID: <20090108075001.GB15370@a-kretschmer.de> (raw)
In-Reply-To: <d8e7a1e30901071317x1eb1c731se957c95695512152@mail.gmail.com>
References: <d8e7a1e30901071317x1eb1c731se957c95695512152@mail.gmail.com>

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



view thread (2+ messages)

Message-ID: <20090108075001.GB15370@a-kretschmer.de>
Permalink:  ../20090108075001.GB15370@a-kretschmer.de/
Also on:    postgresql.org/message-id/20090108075001.GB15370@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: andreas.kretschmer@schollglas.com, pgsql-general@postgresql.org
  Subject: Re: Fail of a return query from plpgsql function for a specific table
  In-Reply-To: <20090108075001.GB15370@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox