pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function
2+ messages / 2 participants
[nested] [flat]

* BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function
@ 2012-06-27 00:02 digoal@126.com
  2012-07-04 03:07 ` Re: BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function Shigeru HANADA <shigeru.hanada@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: digoal@126.com @ 2012-06-27 00:02 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6708
Logged by:          digoal.zhou
Email address:      digoal@126.com
PostgreSQL version: 9.1.3
Operating system:   CentOS 5.x bit64
Description:        

pgsql_fdw's foreign table "cache lookup failed for type 0" bug when used in
function
1.INSTALL
https://github.com/dvarrazzo/interdbconnect/downloads
mv pgsql_fdw $PG_SRC/contrib/
cd $PG_SRC/contrib/pgsql_fdw
. /home/postgres/.bash_profile
USE_PGXS=1 make
USE_PGXS=1 make install
2.TEST
digoal=# create extension pgsql_fdw;
CREATE EXTENSION

CREATE SERVER srv_digoal FOREIGN DATA WRAPPER pgsql_fdw
OPTIONS (host '172.16.3.33', port '5432', dbname 'digoal');

CREATE USER MAPPING FOR digoal SERVER srv_digoal
OPTIONS (user 'rmt_digoal', password 'DIGOAL123');

grant usage on foreign server srv_digoal to digoal;

\c digoal digoal
CREATE FOREIGN TABLE test
(
id int
) server srv_digoal options (nspname 'digoal', relname 'table_digoal');

select * from test;
It can do success, and return currect rows;

but , if test table in plpgsql function , then error occur:
create or replace function f_test () returns int as $$
declare
begin
perform 1 from test limit 1;
return 0;
end;
$$ language plpgsql;


digoal=# \set VERBOSITY verbose
digoal=# select * from f_test();
ERROR:  XX000: cache lookup failed for type 0
CONTEXT:  SQL statement "SELECT 1 from test limit 1"
PL/pgSQL function "f_test" line 3 at PERFORM
LOCATION:  getTypeOutputInfo, lsyscache.c:2440

3. DETAIL information please visit my blog : 
http://blog.163.com/digoal@126/blog/static/16387704020125218171919/

thanks very much;






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function
  2012-06-27 00:02 BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function digoal@126.com
@ 2012-07-04 03:07 ` Shigeru HANADA <shigeru.hanada@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Shigeru HANADA @ 2012-07-04 03:07 UTC (permalink / raw)
  To: digoal@126.com; +Cc: pgsql-bugs

(2012/06/27 9:02), digoal@126.com wrote:
> pgsql_fdw's foreign table "cache lookup failed for type 0" bug when used in
> function

Thanks for the report!

I could reproduce the problem.  The cause of error was wrong handling of
parameters given by PL/pgSQL for PL/pgSQL variables and parameters.

They need instantiation with callback routine, and might have InvalidOid
(0) for type oid.  I fixed pgsql_fdw for two points:

1) instantiate parameters given by PL/pgSQL with callback function
2) use TEXTOID for type-unknown parameters which are not used in remote
query

Please try HEAD of git.
    https://sourceforge.net/projects/interdbconnect/develop

Regards,
-- 
Shigeru HANADA





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-07-04 03:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 00:02 BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function digoal@126.com
2012-07-04 03:07 ` Shigeru HANADA <shigeru.hanada@gmail.com>

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