postgresql - How to run the same function on different schemas -
i have multiple schemas / user same structure different data. there stored functions executed on these data, , far, stored in each schema. i'd store these functions in new schema, make easier, updating code, ... centralized.
i thought, search_path
defined "$user",public
reference user of current session / connection, hence queries different schemas have same search_path.
let's have table t1
users u1, u2, u3
, function uses table f1
.
originally, f1
in copied schemas u1, u2, u3
, running select * f1()
work each user. updating function become increasingly difficult number of users, want have new schema functions
1 f1
function inside.
now, running select * functions.f1()
returns error, t1
couldn't found. users search_path
s contain still same information. why search_path change based on function executing it, , how can prevent happening?
there mail on postgres mailing list: http://postgresql.nabble.com/function-doesn-t-see-change-in-search-path-td4971325.html , final workaround original situation. maybe change in meanwhile?
actually, thinking correct. when created new schema, exporting old function, pg_dump
added security definer
@ definition of each function.
changing security invoker
gives behavior expected (by me)
from documentation:
security invoker indicates function executed privileges of user calls it. default. security definer specifies function executed privileges of user created it.
Comments
Post a Comment