Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D3247633969 for ; Tue, 8 Jun 2010 11:33:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 45271-05 for ; Tue, 8 Jun 2010 14:33:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay.ptn-ipout02.plus.net (relay.ptn-ipout02.plus.net [212.159.7.36]) by mail.postgresql.org (Postfix) with ESMTP id 0DC406335E0 for ; Tue, 8 Jun 2010 11:33:35 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsGAD/xDUzUOFPl/2dsb2JhbACSMYwTcb4jhRYE Received: from plesk-mail01.plus.net ([212.56.83.229]) by relay.ptn-ipout02.plus.net with ESMTP; 08 Jun 2010 15:33:32 +0100 Received: (qmail 17270 invoked from network); 8 Jun 2010 14:33:30 +0000 Received: from host81-147-64-21.range81-147.btcentralplus.com (HELO osiris.mauzo.dyndns.org) (81.147.64.21) by plesk-mail01.plus.net with SMTP; 8 Jun 2010 14:33:28 +0000 Received: (qmail 67905 invoked by uid 1001); 8 Jun 2010 14:33:27 -0000 Date: Tue, 8 Jun 2010 15:33:27 +0100 From: Ben Morrow To: pgsql-sql@postgresql.org Subject: Casts in foreign schemas Message-ID: <20100608143327.GA67823@osiris.mauzo.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201006/30 X-Sequence-Number: 34221 Is this behaviour expected? (This is with 8.4.3 on FreeBSD.) create schema one; set search_path to one; create type foo as (x integer); create function foo (integer) returns foo language plpgsql as $$ declare y foo; begin y.x = $1; return y; end $$; create cast (integer as foo) with function foo (integer); grant usage on schema one to public; grant execute on function foo (integer) to public; create schema two; -- reconnect as a different user set search_path to two; select 3::one.foo; ERROR: type "foo" does not exist CONTEXT: compilation of PL/pgSQL function "foo" near line 2 set search_path to two, one; select 3::foo; foo ----- (3) (1 row) My understanding of things was that PL/pgSQL functions were compiled at CREATE FUNCTION time, using the SEARCH_PATH currently in effect. Is that wrong? Is there some GRANT I'm missing that will make this work? Ben