Skip site navigation (1) Skip section navigation (2)

BUG #2123: join between stored procedures

From: "Konstantin S(dot) Zhinko [tIT]" <k(dot)zhinko(at)grape(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2123: join between stored procedures
Date: 2005-12-23 08:56:48
Message-ID: 20051223085648.CD7ACF0AC7@svr2.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2123
Logged by:          Konstantin S. Zhinko [tIT]
Email address:      k(dot)zhinko(at)grape(dot)ru
PostgreSQL version: 8.1.0
Operating system:   CentOS 3.5
Description:        join between stored procedures
Details: 

Hi all!

I have a very big problem...

Here the code:

/*SQL START*/

CREATE TABLE "public"."test_data" (
  "id" INTEGER NOT NULL, 
  "type" INTEGER NOT NULL, 
  "short_text" VARCHAR(255), 
  CONSTRAINT "test_data_pkey" PRIMARY KEY("id")
) WITH OIDS;

CREATE TYPE "public"."ret_id" AS (
  "id" INTEGER
);

CREATE TYPE "public"."test" AS (
  "id" INTEGER,
  "type" INTEGER,
  "info" VARCHAR(255)
);

CREATE OR REPLACE FUNCTION "public"."get_obj_list" () RETURNS SETOF
"public"."ret_id" AS
$body$
declare
       ret ret_id;
begin

     for ret in select test_data.id from test_data
     loop

     return next ret;
     
     end loop;

end;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

CREATE OR REPLACE FUNCTION "public"."get_obj" (id integer) RETURNS
"public"."test" AS
$body$
declare
       ret test;
       in_id alias for $1;
       
begin

     select * from test_data a into ret where a.id=in_id;
     return ret;

end;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

/*SQL END*/

It is ok, but when I try to join these procedures, server responses error

/*SQL START*/
SELECT b.*
FROM get_obj_list a
  LEFT JOIN get_obj(a.id) b ON 1=1
/*SQL END*/

Error: relation "a" does not exists.

Why it's so?

Responses

pgsql-bugs by date

Next:From: andrew_kazachkovDate: 2005-12-23 12:53:00
Subject: BUG #2124: Error "relation with OID ... does not exist" when using temporary table in function.
Previous:From: gotomoon gotomoonDate: 2005-12-23 07:45:41
Subject: Re: [BUGS] BUG #2118: could not connect to server [From zhuge xiao <zhuge@Rinaix.cn>]

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group