Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 204771927162 for ; Tue, 26 Jun 2012 21:03:09 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sjfiu-0004Dq-9u for pgsql-bugs@postgresql.org; Wed, 27 Jun 2012 00:03:08 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sjfif-0008UJ-Mi for pgsql-bugs@postgresql.org; Wed, 27 Jun 2012 00:02:56 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1Sjfif-0008SV-9N for pgsql-bugs@postgresql.org; Wed, 27 Jun 2012 00:02:53 +0000 Date: Wed, 27 Jun 2012 00:02:53 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6708: pgsql_fdw's foreign table cann't used in plpgsql function To: pgsql-bugs@postgresql.org From: digoal@126.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/220 X-Sequence-Number: 33447 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=3D1 make USE_PGXS=3D1 make install 2.TEST digoal=3D# 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=3D# \set VERBOSITY verbose digoal=3D# 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;