mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
TestUpgradeXversion knows how to make the main regression database's
references to pg_regress.so be version-independent. But it doesn't
do that for plperl's database, so that the C function added by
commit b7e3a52a8
is causing cross-version upgrade test failures.
Path of least resistance is to just drop the function at the end
of the new test.
In <= v14, also take the opportunity to clean up the generated
test files.
Security: CVE-2024-10979
62 lines
1.3 KiB
PL/PgSQL
62 lines
1.3 KiB
PL/PgSQL
--
|
|
-- Test the environment setting
|
|
--
|
|
|
|
-- directory path and dlsuffix are passed to us in environment variables
|
|
\getenv libdir PG_LIBDIR
|
|
\getenv dlsuffix PG_DLSUFFIX
|
|
|
|
\set regresslib :libdir '/regress' :dlsuffix
|
|
|
|
CREATE FUNCTION get_environ()
|
|
RETURNS text[]
|
|
AS :'regresslib', 'get_environ'
|
|
LANGUAGE C STRICT;
|
|
|
|
-- fetch the process environment
|
|
|
|
CREATE FUNCTION process_env () RETURNS text[]
|
|
LANGUAGE plpgsql AS
|
|
$$
|
|
|
|
declare
|
|
res text[];
|
|
tmp text[];
|
|
f record;
|
|
begin
|
|
for f in select unnest(get_environ()) as t loop
|
|
tmp := regexp_split_to_array(f.t, '=');
|
|
if array_length(tmp, 1) = 2 then
|
|
res := res || tmp;
|
|
end if;
|
|
end loop;
|
|
return res;
|
|
end
|
|
|
|
$$;
|
|
|
|
-- plperl should not be able to affect the process environment
|
|
|
|
DO
|
|
$$
|
|
$ENV{TEST_PLPERL_ENV_FOO} = "shouldfail";
|
|
untie %ENV;
|
|
$ENV{TEST_PLPERL_ENV_FOO} = "testval";
|
|
my $penv = spi_exec_query("select unnest(process_env()) as pe");
|
|
my %received;
|
|
for (my $f = 0; $f < $penv->{processed}; $f += 2)
|
|
{
|
|
my $k = $penv->{rows}[$f]->{pe};
|
|
my $v = $penv->{rows}[$f+1]->{pe};
|
|
$received{$k} = $v;
|
|
}
|
|
unless (exists $received{TEST_PLPERL_ENV_FOO})
|
|
{
|
|
elog(NOTICE, "environ unaffected")
|
|
}
|
|
|
|
$$ LANGUAGE plperl;
|
|
|
|
-- clean up to simplify cross-version upgrade testing
|
|
DROP FUNCTION get_environ();
|