mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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
22 lines
506 B
PL/PgSQL
22 lines
506 B
PL/PgSQL
--
|
|
-- 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);
|