mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Invent start_proc parameters for PL/Tcl.
Define GUCs pltcl.start_proc and pltclu.start_proc. When set to a
nonempty value at the time a new Tcl interpreter is created, the
parameterless pltcl or pltclu function named by the GUC is called to
allow user-controlled initialization to occur within the interpreter.
This is modeled on plv8's start_proc parameter, and also has much in
common with plperl's on_init feature. It allows users to fully
replace the "modules" feature that was removed in commit 817f2a586
.
Since an initializer function could subvert later Tcl code in nearly
arbitrary ways, mark both GUCs as SUSET for now. It would be nice
to find a way to relax that someday; but the corresponding GUCs in
plperl are also SUSET, and there's not been much complaint.
Discussion: https://postgr.es/m/22067.1488046447@sss.pgh.pa.us
This commit is contained in:
21
src/pl/tcl/sql/pltcl_start_proc.sql
Normal file
21
src/pl/tcl/sql/pltcl_start_proc.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
--
|
||||
-- Test start_proc execution
|
||||
--
|
||||
|
||||
SET pltcl.start_proc = 'no_such_function';
|
||||
|
||||
select tcl_int4add(1, 2);
|
||||
select tcl_int4add(1, 2);
|
||||
|
||||
create function tcl_initialize() returns void as
|
||||
$$ elog NOTICE "in tcl_initialize" $$ language pltcl SECURITY DEFINER;
|
||||
|
||||
SET pltcl.start_proc = 'public.tcl_initialize';
|
||||
|
||||
select tcl_int4add(1, 2); -- fail
|
||||
|
||||
create or replace function tcl_initialize() returns void as
|
||||
$$ elog NOTICE "in tcl_initialize" $$ language pltcl;
|
||||
|
||||
select tcl_int4add(1, 2);
|
||||
select tcl_int4add(1, 2);
|
Reference in New Issue
Block a user