2 -- Test the environment setting
4 -- directory path and dlsuffix are passed to us in environment variables
5 \getenv libdir PG_LIBDIR
6 \getenv dlsuffix PG_DLSUFFIX
7 \set regresslib :libdir '/regress' :dlsuffix
8 CREATE FUNCTION get_environ()
10 AS :'regresslib', 'get_environ'
12 -- fetch the process environment
13 CREATE FUNCTION process_env () RETURNS text[]
22 for f in select unnest(get_environ()) as t loop
23 tmp := regexp_split_to_array(f.t, '=');
24 if array_length(tmp, 1) = 2 then
32 -- plperl should not be able to affect the process environment
35 $ENV{TEST_PLPERL_ENV_FOO} = "shouldfail";
37 $ENV{TEST_PLPERL_ENV_FOO} = "testval";
38 my $penv = spi_exec_query("select unnest(process_env()) as pe");
40 for (my $f = 0; $f < $penv->{processed}; $f += 2)
42 my $k = $penv->{rows}[$f]->{pe};
43 my $v = $penv->{rows}[$f+1]->{pe};
46 unless (exists $received{TEST_PLPERL_ENV_FOO})
48 elog(NOTICE, "environ unaffected")
52 WARNING: attempted alteration of $ENV{TEST_PLPERL_ENV_FOO} at line 12.
53 NOTICE: environ unaffected
54 -- clean up to simplify cross-version upgrade testing
55 DROP FUNCTION get_environ();