summaryrefslogtreecommitdiffstats
path: root/PgCommon.pm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:33:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:33:22 +0000
commit046e04938d6447035c279dbb7209ac6b412c5c5b (patch)
tree13949bbeb792dac80368f1285627679664d5fc12 /PgCommon.pm
parentReleasing progress-linux version 258-0.0~progress7.99u1. (diff)
downloadpostgresql-common-046e04938d6447035c279dbb7209ac6b412c5c5b.tar.xz
postgresql-common-046e04938d6447035c279dbb7209ac6b412c5c5b.zip
Merging upstream version 259.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'PgCommon.pm')
-rw-r--r--PgCommon.pm26
1 files changed, 9 insertions, 17 deletions
diff --git a/PgCommon.pm b/PgCommon.pm
index df4d060..918d228 100644
--- a/PgCommon.pm
+++ b/PgCommon.pm
@@ -5,7 +5,7 @@ PgCommon - Common functions for the postgresql-common framework
=head1 COPYRIGHT AND LICENSE
(C) 2008-2009 Martin Pitt <mpitt@debian.org>
- (C) 2012-2023 Christoph Berg <myon@debian.org>
+ (C) 2012-2024 Christoph Berg <myon@debian.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -1348,7 +1348,7 @@ sub get_db_encoding {
owner. (For versions >= 8.4; for older versions use get_cluster_locales()).
Arguments: <version> <cluster> <database>
- Returns: (LC_CTYPE, LC_COLLATE) or (undef,undef) if it cannot be determined.
+ Returns: (LC_CTYPE, LC_COLLATE, locprovider, iculocale, icurules) or undef if it cannot be determined.
PG15 adds locale provider and icu locale to the returned values
PG16 adds icu rules
@@ -1368,32 +1368,24 @@ sub get_db_locales {
my $orig_euid = $>;
$> = (stat (cluster_data_directory $version, $cluster))[4];
+ my $datlocprovider = $version >= 15 ? "CASE datlocprovider::text WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' WHEN 'b' THEN 'builtin' END" : "NULL";
+ my $daticulocale = ($version >= 15 and $version < 17) ? "daticulocale" : "NULL";
+ my $daticurules = $version >= 16 ? "daticurules" : "NULL";
+
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc',
- "SELECT datctype, datcollate FROM pg_database where datname = current_database()", $db or
+ "SELECT datctype, datcollate, $datlocprovider, $daticulocale, $daticurules FROM pg_database where datname = current_database()", $db or
die "Internal error: could not call $psql to determine datctype and datcollate: $!";
my $out = <PSQL> // error 'could not determine datctype and datcollate';
close PSQL;
($out) = $out =~ /^(.*)$/; # untaint
- ($ctype, $collate) = split /\|/, $out;
-
- if ($version >= 15) {
- open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc',
- "SELECT CASE datlocprovider::text WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END, daticulocale" .
- ($version >= 16 ? ", daticurules" : "") .
- " FROM pg_database where datname = current_database()", $db or
- die "Internal error: could not call $psql to determine datlocprovider: $!";
- $out = <PSQL> // error 'could not determine datlocprovider';
- close PSQL;
- ($out) = $out =~ /^(.*)$/; # untaint
- ($locale_provider, $icu_locale, $icu_rules) = split /\|/, $out;
- }
+ ($ctype, $collate, $locale_provider, $icu_locale, $icu_rules) = split /\|/, $out;
$> = $orig_euid;
restore_exec;
chomp $ctype;
chomp $collate;
return ($ctype, $collate, $locale_provider, $icu_locale, $icu_rules) unless $?;
- return (undef, undef);
+ return (undef, undef, undef, undef, undef);
}