Lists: | pgsql-hackers |
---|
From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Intended behaviour of SET search_path with SQL functions? |
Date: | 2008-03-06 17:17:28 |
Message-ID: | 47D02728.2060503@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
=> SHOW search_path;
search_path
-------------
beta
(1 row)
=> CREATE OR REPLACE FUNCTION func_b() RETURNS SETOF int AS $$
SELECT id FROM table_a;
$$ LANGUAGE sql SET search_path = alpha;
ERROR: relation "table_a" does not exist
CONTEXT: SQL function "func_b"
=> \d table_a
Did not find any relation named "table_a".
=> \d alpha.table_a
Table "alpha.table_a"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
If I temporarily create a beta.table_a then I get to create the function
and afterwards it does the right thing. It also works fine with a
pl/pgsql function - presumably it's all down to context on the initial
parse.
I can't think of a way to exploit this maliciously, or do anything other
than cause a little confusion, but I'm not sure it's intentional.
--
Richard Huxton
Archonet Ltd
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Intended behaviour of SET search_path with SQL functions? |
Date: | 2008-03-06 18:09:32 |
Message-ID: | 19078.1204826972@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Richard Huxton <dev(at)archonet(dot)com> writes:
> => CREATE OR REPLACE FUNCTION func_b() RETURNS SETOF int AS $$
> SELECT id FROM table_a;
> $$ LANGUAGE sql SET search_path = alpha;
> ERROR: relation "table_a" does not exist
Hmmm, I'll bet the validator forgets to apply the parameter modification.
In plpgsql we had to dumb down the validator to do only a bare
syntax check and not any semantic validation. Perhaps SQL function
validation should act the same? You can certainly think of plenty
of other reasons why a full semantics check might fail at function
definition time.
regards, tom lane