Set up startup procedure in config
plv8.start_proc = 'plv8_startup'
Created function:
CREATE OR REPLACE FUNCTION plv8_startup ()
RETURNS void AS
$body$
this.hello = function(name){
return name + ', hello!';
};
$body$
LANGUAGE 'plv8'
VOLATILE
CALLED ON NULL INPUT
SECURITY DEFINER
COST 100;
Under postgres user everything works well:
DO $$
plv8.elog(NOTICE, hello('John'));
$$ LANGUAGE plv8;
the result - John, hello! Then created user test and tryed to run the function:
ERROR: ReferenceError: hello is not defined
SQL-state: XX000
tryied to grant user test on execute plv8_startup - the result is the same. What is wrong?