diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:46:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:46:48 +0000 |
commit | 311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch) | |
tree | 0ec307299b1dada3701e42f4ca6eda57d708261e /src/pl/plperl/sql/plperl_shared.sql | |
parent | Initial commit. (diff) | |
download | postgresql-15-upstream.tar.xz postgresql-15-upstream.zip |
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pl/plperl/sql/plperl_shared.sql')
-rw-r--r-- | src/pl/plperl/sql/plperl_shared.sql | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/pl/plperl/sql/plperl_shared.sql b/src/pl/plperl/sql/plperl_shared.sql new file mode 100644 index 0000000..b60e114 --- /dev/null +++ b/src/pl/plperl/sql/plperl_shared.sql @@ -0,0 +1,41 @@ +-- test plperl.on_plperl_init via the shared hash +-- (must be done before plperl is first used) + +-- This test tests setting on_plperl_init before loading plperl + +-- testing on_plperl_init gets run, and that it can alter %_SHARED +SET plperl.on_plperl_init = '$_SHARED{on_init} = 42'; + +-- test the shared hash + +create function setme(key text, val text) returns void language plperl as $$ + + my $key = shift; + my $val = shift; + $_SHARED{$key}= $val; + +$$; + +create function getme(key text) returns text language plperl as $$ + + my $key = shift; + return $_SHARED{$key}; + +$$; + +select setme('ourkey','ourval'); + +select getme('ourkey'); + +select getme('on_init'); + +-- verify that we can use $_SHARED in strict mode +create or replace function perl_shared() returns int as $$ +use strict; +my $val = $_SHARED{'stuff'}; +$_SHARED{'stuff'} = '1'; +return $val; +$$ language plperl; + +select perl_shared(); +select perl_shared(); |