postgresql - calling functions in pg_temp schema without prefix -
in postgres pg_temp
schema default on search path. explained tom lane here functions in pg_temp
schema not callable default without prefix security reasons.
however states in order call functions in pg_temp
schema without prefix have explicitly add temp schema search path. unfortunately of postgresql 9.4 doesn't seem work anymore.
set search_path pg_temp,public; -- create function in temp schema create function test_fun() returns int $$ select 1; $$ language sql; -- results in "function test_fun() not exist" select test_fun(); -- works select pg_temp.test_fun();
is there way call functions in pg_temp schema without prefixing them?
this highly convenient developing new functions.
looks tome lane not 100% precise on 1 – checked 9.2 9.5, , in each of these need qualify function pg_temp
. setting search_path
not enough.
see postgresql commit aa27977fe21a7dfa4da4376ad66ae37cb8f0d0b5:
support explicit placement of temporary-table schema within search_path. needed allow security-definer function set secure value of search_path. without it, malicious user can use temporary objects execute code privileges of security-definer function. pushing temp schema of search path not quite enough, because function or operator @ of path might still capture control 1 nearer front due having more exact datatype match. hence, disable searching temp schema altogether functions , operators.
security: cve-2007-2138
see in particular changes in funcnamegetcandidates
:
@@ -549,12 +586,16 @@ funcnamegetcandidates(list *names, int nargs) } else { - /* consider procs in search path */ + /* + * consider procs in search path , not + * in temp namespace. + */ listcell *nsp; foreach(nsp, activesearchpath) { - if (procform->pronamespace == lfirst_oid(nsp)) + if (procform->pronamespace == lfirst_oid(nsp) && + procform->pronamespace != mytempnamespace) break; pathpos++; }
Comments
Post a Comment