summaryrefslogtreecommitdiffstats
path: root/src/pl/plperl/expected/plperl_shared.out
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
commit293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch)
treefc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /src/pl/plperl/expected/plperl_shared.out
parentInitial commit. (diff)
downloadpostgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz
postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pl/plperl/expected/plperl_shared.out')
-rw-r--r--src/pl/plperl/expected/plperl_shared.out56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/pl/plperl/expected/plperl_shared.out b/src/pl/plperl/expected/plperl_shared.out
new file mode 100644
index 0000000..464e220
--- /dev/null
+++ b/src/pl/plperl/expected/plperl_shared.out
@@ -0,0 +1,56 @@
+-- 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');
+ setme
+-------
+
+(1 row)
+
+select getme('ourkey');
+ getme
+--------
+ ourval
+(1 row)
+
+select getme('on_init');
+ getme
+-------
+ 42
+(1 row)
+
+-- 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();
+ perl_shared
+-------------
+
+(1 row)
+
+select perl_shared();
+ perl_shared
+-------------
+ 1
+(1 row)
+