From f67444cfd85334d94fa9a878854871308fd6e2c2 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 17 Jul 2026 15:06:03 +0900 Subject: [PATCH v1] Rename getdatabaseencoding() to pg_database_encoding() and document it getdatabaseencoding() has been present but undocumented since PostgreSQL 6.5. Rename it to the more readable pg_database_encoding() (to match the existing pg_client_encoding() function) and add a documentation entry. Note that getdatabaseencoding() is used in psql for tab-completion of collations - for compatibility with older backends, change the function invocation to the equivalent current_setting('server_encoding'). --- contrib/citext/expected/citext_utf8.out | 2 +- contrib/citext/expected/citext_utf8_1.out | 2 +- contrib/citext/sql/citext_utf8.sql | 2 +- .../expected/fuzzystrmatch_utf8.out | 2 +- .../expected/fuzzystrmatch_utf8_1.out | 2 +- .../fuzzystrmatch/sql/fuzzystrmatch_utf8.sql | 2 +- contrib/hstore/expected/hstore_utf8.out | 2 +- contrib/hstore/expected/hstore_utf8_1.out | 2 +- contrib/hstore/sql/hstore_utf8.sql | 2 +- .../expected/pg_stash_advice_utf8.out | 2 +- .../expected/pg_stash_advice_utf8_1.out | 2 +- .../sql/pg_stash_advice_utf8.sql | 2 +- contrib/pg_trgm/expected/pg_utf8_trgm.out | 2 +- contrib/pg_trgm/expected/pg_utf8_trgm_1.out | 2 +- contrib/pg_trgm/sql/pg_utf8_trgm.sql | 2 +- contrib/unaccent/expected/unaccent.out | 2 +- contrib/unaccent/expected/unaccent_1.out | 2 +- contrib/unaccent/sql/unaccent.sql | 2 +- doc/src/sgml/func/func-string.sgml | 17 +++++++++++++++++ src/backend/catalog/information_schema.sql | 8 ++++---- src/backend/utils/mb/mbutils.c | 2 +- src/bin/psql/describe.c | 5 ++++- src/bin/psql/tab-complete.in.c | 2 +- src/include/catalog/pg_proc.dat | 4 ++-- src/pl/plperl/expected/plperl_unicode.out | 2 +- src/pl/plperl/expected/plperl_unicode_1.out | 2 +- src/pl/plperl/sql/plperl_unicode.sql | 2 +- src/pl/plpython/expected/plpython_unicode.out | 2 +- src/pl/plpython/expected/plpython_unicode_1.out | 2 +- src/pl/plpython/sql/plpython_unicode.sql | 2 +- src/pl/tcl/expected/pltcl_unicode.out | 2 +- src/pl/tcl/expected/pltcl_unicode_1.out | 2 +- src/pl/tcl/sql/pltcl_unicode.sql | 2 +- .../test_regex/expected/test_regex_utf8.out | 2 +- .../test_regex/expected/test_regex_utf8_1.out | 2 +- .../modules/test_regex/sql/test_regex_utf8.sql | 2 +- src/test/regress/expected/collate.icu.utf8.out | 2 +- .../regress/expected/collate.icu.utf8_1.out | 2 +- .../regress/expected/collate.linux.utf8.out | 2 +- .../regress/expected/collate.linux.utf8_1.out | 2 +- src/test/regress/expected/collate.utf8.out | 2 +- src/test/regress/expected/collate.utf8_1.out | 2 +- .../expected/collate.windows.win1252.out | 2 +- .../expected/collate.windows.win1252_1.out | 2 +- src/test/regress/expected/copyencoding.out | 2 +- src/test/regress/expected/copyencoding_1.out | 2 +- src/test/regress/expected/encoding.out | 2 +- src/test/regress/expected/encoding_1.out | 2 +- src/test/regress/expected/euc_kr.out | 2 +- src/test/regress/expected/euc_kr_1.out | 2 +- src/test/regress/expected/json_encoding.out | 8 ++++---- src/test/regress/expected/json_encoding_1.out | 8 ++++---- src/test/regress/expected/json_encoding_2.out | 2 +- src/test/regress/expected/jsonpath_encoding.out | 8 ++++---- .../regress/expected/jsonpath_encoding_1.out | 8 ++++---- .../regress/expected/jsonpath_encoding_2.out | 2 +- src/test/regress/expected/unicode.out | 2 +- src/test/regress/expected/unicode_1.out | 2 +- src/test/regress/sql/collate.icu.utf8.sql | 2 +- src/test/regress/sql/collate.linux.utf8.sql | 2 +- src/test/regress/sql/collate.utf8.sql | 2 +- .../regress/sql/collate.windows.win1252.sql | 2 +- src/test/regress/sql/copyencoding.sql | 2 +- src/test/regress/sql/encoding.sql | 2 +- src/test/regress/sql/euc_kr.sql | 2 +- src/test/regress/sql/json_encoding.sql | 4 ++-- src/test/regress/sql/jsonpath_encoding.sql | 4 ++-- src/test/regress/sql/unicode.sql | 2 +- 68 files changed, 105 insertions(+), 85 deletions(-) diff --git a/contrib/citext/expected/citext_utf8.out b/contrib/citext/expected/citext_utf8.out index 19538db674e..9680eea94f1 100644 --- a/contrib/citext/expected/citext_utf8.out +++ b/contrib/citext/expected/citext_utf8.out @@ -9,7 +9,7 @@ * * Also disable for Windows. It fails similarly, at least in some locales. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR version() ~ '(Visual C\+\+|mingw32|windows)' OR (SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i' FROM pg_database diff --git a/contrib/citext/expected/citext_utf8_1.out b/contrib/citext/expected/citext_utf8_1.out index 874ec8519e1..022fec10745 100644 --- a/contrib/citext/expected/citext_utf8_1.out +++ b/contrib/citext/expected/citext_utf8_1.out @@ -9,7 +9,7 @@ * * Also disable for Windows. It fails similarly, at least in some locales. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR version() ~ '(Visual C\+\+|mingw32|windows)' OR (SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i' FROM pg_database diff --git a/contrib/citext/sql/citext_utf8.sql b/contrib/citext/sql/citext_utf8.sql index ba283320797..4e186276fde 100644 --- a/contrib/citext/sql/citext_utf8.sql +++ b/contrib/citext/sql/citext_utf8.sql @@ -10,7 +10,7 @@ * Also disable for Windows. It fails similarly, at least in some locales. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR version() ~ '(Visual C\+\+|mingw32|windows)' OR (SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i' FROM pg_database diff --git a/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8.out b/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8.out index b0dd4880baf..d1cd4d94805 100644 --- a/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8.out +++ b/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8_1.out b/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8_1.out index 37aead89c0c..a7a61be5848 100644 --- a/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8_1.out +++ b/contrib/fuzzystrmatch/expected/fuzzystrmatch_utf8_1.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/fuzzystrmatch/sql/fuzzystrmatch_utf8.sql b/contrib/fuzzystrmatch/sql/fuzzystrmatch_utf8.sql index f42c01a1bba..c4d100ba005 100644 --- a/contrib/fuzzystrmatch/sql/fuzzystrmatch_utf8.sql +++ b/contrib/fuzzystrmatch/sql/fuzzystrmatch_utf8.sql @@ -3,7 +3,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/hstore/expected/hstore_utf8.out b/contrib/hstore/expected/hstore_utf8.out index bbc885a181a..150c97d84e3 100644 --- a/contrib/hstore/expected/hstore_utf8.out +++ b/contrib/hstore/expected/hstore_utf8.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/hstore/expected/hstore_utf8_1.out b/contrib/hstore/expected/hstore_utf8_1.out index 37aead89c0c..a7a61be5848 100644 --- a/contrib/hstore/expected/hstore_utf8_1.out +++ b/contrib/hstore/expected/hstore_utf8_1.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/hstore/sql/hstore_utf8.sql b/contrib/hstore/sql/hstore_utf8.sql index 38c9481ee64..a34f887172c 100644 --- a/contrib/hstore/sql/hstore_utf8.sql +++ b/contrib/hstore/sql/hstore_utf8.sql @@ -3,7 +3,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out b/contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out index 7c532571ed5..3073f8ec919 100644 --- a/contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out +++ b/contrib/pg_stash_advice/expected/pg_stash_advice_utf8.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/pg_stash_advice/expected/pg_stash_advice_utf8_1.out b/contrib/pg_stash_advice/expected/pg_stash_advice_utf8_1.out index 37aead89c0c..a7a61be5848 100644 --- a/contrib/pg_stash_advice/expected/pg_stash_advice_utf8_1.out +++ b/contrib/pg_stash_advice/expected/pg_stash_advice_utf8_1.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/pg_stash_advice/sql/pg_stash_advice_utf8.sql b/contrib/pg_stash_advice/sql/pg_stash_advice_utf8.sql index 13ba635267f..50dccd76b00 100644 --- a/contrib/pg_stash_advice/sql/pg_stash_advice_utf8.sql +++ b/contrib/pg_stash_advice/sql/pg_stash_advice_utf8.sql @@ -3,7 +3,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/pg_trgm/expected/pg_utf8_trgm.out b/contrib/pg_trgm/expected/pg_utf8_trgm.out index 0768e7d6a83..595a5d9714a 100644 --- a/contrib/pg_trgm/expected/pg_utf8_trgm.out +++ b/contrib/pg_trgm/expected/pg_utf8_trgm.out @@ -1,4 +1,4 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/contrib/pg_trgm/expected/pg_utf8_trgm_1.out b/contrib/pg_trgm/expected/pg_utf8_trgm_1.out index 8505c4fa552..51c048b0fc1 100644 --- a/contrib/pg_trgm/expected/pg_utf8_trgm_1.out +++ b/contrib/pg_trgm/expected/pg_utf8_trgm_1.out @@ -1,3 +1,3 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/pg_trgm/sql/pg_utf8_trgm.sql b/contrib/pg_trgm/sql/pg_utf8_trgm.sql index 0dd962ced83..7f2dd85dabd 100644 --- a/contrib/pg_trgm/sql/pg_utf8_trgm.sql +++ b/contrib/pg_trgm/sql/pg_utf8_trgm.sql @@ -1,4 +1,4 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/contrib/unaccent/expected/unaccent.out b/contrib/unaccent/expected/unaccent.out index 763f4ed9ffd..8cd4dff09f3 100644 --- a/contrib/unaccent/expected/unaccent.out +++ b/contrib/unaccent/expected/unaccent.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/unaccent/expected/unaccent_1.out b/contrib/unaccent/expected/unaccent_1.out index 37aead89c0c..a7a61be5848 100644 --- a/contrib/unaccent/expected/unaccent_1.out +++ b/contrib/unaccent/expected/unaccent_1.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/contrib/unaccent/sql/unaccent.sql b/contrib/unaccent/sql/unaccent.sql index 70c7f1c0a09..945928ae3c8 100644 --- a/contrib/unaccent/sql/unaccent.sql +++ b/contrib/unaccent/sql/unaccent.sql @@ -3,7 +3,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/doc/src/sgml/func/func-string.sgml b/doc/src/sgml/func/func-string.sgml index 0786573d7be..174c137375f 100644 --- a/doc/src/sgml/func/func-string.sgml +++ b/doc/src/sgml/func/func-string.sgml @@ -850,6 +850,23 @@ + + + + pg_database_encoding + + pg_database_encoding ( ) + name + + + Returns current database encoding name. + + + pg_database_encoding() + UTF8 + + + diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index 624d538a5c0..d4cd710a07b 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -381,9 +381,9 @@ GRANT SELECT ON attributes TO PUBLIC; CREATE VIEW character_sets AS SELECT CAST(null AS sql_identifier) AS character_set_catalog, CAST(null AS sql_identifier) AS character_set_schema, - CAST(getdatabaseencoding() AS sql_identifier) AS character_set_name, - CAST(CASE WHEN getdatabaseencoding() = 'UTF8' THEN 'UCS' ELSE getdatabaseencoding() END AS sql_identifier) AS character_repertoire, - CAST(getdatabaseencoding() AS sql_identifier) AS form_of_use, + CAST(pg_database_encoding() AS sql_identifier) AS character_set_name, + CAST(CASE WHEN pg_database_encoding() = 'UTF8' THEN 'UCS' ELSE pg_database_encoding() END AS sql_identifier) AS character_repertoire, + CAST(pg_database_encoding() AS sql_identifier) AS form_of_use, CAST(current_database() AS sql_identifier) AS default_collate_catalog, CAST(nc.nspname AS sql_identifier) AS default_collate_schema, CAST(c.collname AS sql_identifier) AS default_collate_name @@ -485,7 +485,7 @@ CREATE VIEW collation_character_set_applicability AS CAST(c.collname AS sql_identifier) AS collation_name, CAST(null AS sql_identifier) AS character_set_catalog, CAST(null AS sql_identifier) AS character_set_schema, - CAST(getdatabaseencoding() AS sql_identifier) AS character_set_name + CAST(pg_database_encoding() AS sql_identifier) AS character_set_name FROM pg_collation c, pg_namespace nc WHERE c.collnamespace = nc.oid AND collencoding IN (-1, (SELECT encoding FROM pg_database WHERE datname = current_database())); diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index e4f29c2b1c9..af0751ee596 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -1398,7 +1398,7 @@ GetDatabaseEncodingName(void) } Datum -getdatabaseencoding(PG_FUNCTION_ARGS) +pg_database_encoding(PG_FUNCTION_ARGS) { return DirectFunctionCall1(namein, CStringGetDatum(DatabaseEncoding->name)); } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index a2f09c26369..dd101d11a76 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -5231,7 +5231,10 @@ listCollations(const char *pattern, bool verbose, bool showSystem) * unusable collations, so you will need to hack name pattern processing * somehow to avoid inconsistent behavior. */ - appendPQExpBufferStr(&buf, " AND c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))\n"); + if (pset.sversion < 200000) + appendPQExpBufferStr(&buf, " AND c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))\n"); + else + appendPQExpBufferStr(&buf, " AND c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.pg_database_encoding()))\n"); if (!validateSQLNamePattern(&buf, pattern, true, false, "n.nspname", "c.collname", NULL, diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 1cacc8c3ea2..b0b2a0c887e 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -972,7 +972,7 @@ static const SchemaQuery Query_for_list_of_statistics = { static const SchemaQuery Query_for_list_of_collations = { .catname = "pg_catalog.pg_collation c", - .selcondition = "c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))", + .selcondition = "c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.current_setting('server_encoding')))", .viscondition = "pg_catalog.pg_collation_is_visible(c.oid)", .namespace = "c.collnamespace", .result = "c.collname", diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1c55a4dea34..71a9a8bd524 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3928,8 +3928,8 @@ # return database encoding name { oid => '1039', descr => 'encoding name of current database', - proname => 'getdatabaseencoding', provolatile => 's', prorettype => 'name', - proargtypes => '', prosrc => 'getdatabaseencoding' }, + proname => 'pg_database_encoding', provolatile => 's', prorettype => 'name', + proargtypes => '', prosrc => 'pg_database_encoding' }, # return client encoding name i.e. session encoding { oid => '810', descr => 'encoding name of current database', diff --git a/src/pl/plperl/expected/plperl_unicode.out b/src/pl/plperl/expected/plperl_unicode.out index 3c48f2e9611..702cb999d43 100644 --- a/src/pl/plperl/expected/plperl_unicode.out +++ b/src/pl/plperl/expected/plperl_unicode.out @@ -4,7 +4,7 @@ -- EUC_KR, or EUC_TW, for lack of any equivalent to U+00A0 (no-break space) in -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/plperl/expected/plperl_unicode_1.out b/src/pl/plperl/expected/plperl_unicode_1.out index 761de04b1ee..39522be7b8d 100644 --- a/src/pl/plperl/expected/plperl_unicode_1.out +++ b/src/pl/plperl/expected/plperl_unicode_1.out @@ -4,7 +4,7 @@ -- EUC_KR, or EUC_TW, for lack of any equivalent to U+00A0 (no-break space) in -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/plperl/sql/plperl_unicode.sql b/src/pl/plperl/sql/plperl_unicode.sql index 7e1ad745cdd..b1587592178 100644 --- a/src/pl/plperl/sql/plperl_unicode.sql +++ b/src/pl/plperl/sql/plperl_unicode.sql @@ -4,7 +4,7 @@ -- EUC_KR, or EUC_TW, for lack of any equivalent to U+00A0 (no-break space) in -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/plpython/expected/plpython_unicode.out b/src/pl/plpython/expected/plpython_unicode.out index bd8d9c561c9..861ce1c5274 100644 --- a/src/pl/plpython/expected/plpython_unicode.out +++ b/src/pl/plpython/expected/plpython_unicode.out @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/plpython/expected/plpython_unicode_1.out b/src/pl/plpython/expected/plpython_unicode_1.out index f8b21fd7eb7..6f0af8cd75e 100644 --- a/src/pl/plpython/expected/plpython_unicode_1.out +++ b/src/pl/plpython/expected/plpython_unicode_1.out @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/plpython/sql/plpython_unicode.sql b/src/pl/plpython/sql/plpython_unicode.sql index f45844b906e..9b3f26a440e 100644 --- a/src/pl/plpython/sql/plpython_unicode.sql +++ b/src/pl/plpython/sql/plpython_unicode.sql @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/tcl/expected/pltcl_unicode.out b/src/pl/tcl/expected/pltcl_unicode.out index d33afd7548f..8f0f3578f71 100644 --- a/src/pl/tcl/expected/pltcl_unicode.out +++ b/src/pl/tcl/expected/pltcl_unicode.out @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/tcl/expected/pltcl_unicode_1.out b/src/pl/tcl/expected/pltcl_unicode_1.out index f8b21fd7eb7..6f0af8cd75e 100644 --- a/src/pl/tcl/expected/pltcl_unicode_1.out +++ b/src/pl/tcl/expected/pltcl_unicode_1.out @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/pl/tcl/sql/pltcl_unicode.sql b/src/pl/tcl/sql/pltcl_unicode.sql index a09e4998b2b..5693f891cae 100644 --- a/src/pl/tcl/sql/pltcl_unicode.sql +++ b/src/pl/tcl/sql/pltcl_unicode.sql @@ -6,7 +6,7 @@ -- those encodings. However, testing with plain ASCII data would be rather -- useless, so we must live with that. -- -SELECT getdatabaseencoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') +SELECT pg_database_encoding() IN ('EUC_CN', 'EUC_JP', 'EUC_KR', 'EUC_TW') AS skip_test \gset \if :skip_test \quit diff --git a/src/test/modules/test_regex/expected/test_regex_utf8.out b/src/test/modules/test_regex/expected/test_regex_utf8.out index 329780ef400..458c6e222f3 100644 --- a/src/test/modules/test_regex/expected/test_regex_utf8.out +++ b/src/test/modules/test_regex/expected/test_regex_utf8.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/modules/test_regex/expected/test_regex_utf8_1.out b/src/test/modules/test_regex/expected/test_regex_utf8_1.out index 37aead89c0c..a7a61be5848 100644 --- a/src/test/modules/test_regex/expected/test_regex_utf8_1.out +++ b/src/test/modules/test_regex/expected/test_regex_utf8_1.out @@ -2,7 +2,7 @@ * This test must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/modules/test_regex/sql/test_regex_utf8.sql b/src/test/modules/test_regex/sql/test_regex_utf8.sql index 1f69f105fd7..80d4b3a54cd 100644 --- a/src/test/modules/test_regex/sql/test_regex_utf8.sql +++ b/src/test/modules/test_regex/sql/test_regex_utf8.sql @@ -3,7 +3,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out index fcfcc658bea..33a30bf6484 100644 --- a/src/test/regress/expected/collate.icu.utf8.out +++ b/src/test/regress/expected/collate.icu.utf8.out @@ -2,7 +2,7 @@ * This test is for ICU collations. */ /* skip test if not UTF8 server encoding or no ICU collations installed */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collprovider = 'i' AND collname <> 'unicode') = 0 AS skip_test \gset \if :skip_test diff --git a/src/test/regress/expected/collate.icu.utf8_1.out b/src/test/regress/expected/collate.icu.utf8_1.out index 25c99c4abf0..49bcdb164da 100644 --- a/src/test/regress/expected/collate.icu.utf8_1.out +++ b/src/test/regress/expected/collate.icu.utf8_1.out @@ -2,7 +2,7 @@ * This test is for ICU collations. */ /* skip test if not UTF8 server encoding or no ICU collations installed */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collprovider = 'i' AND collname <> 'unicode') = 0 AS skip_test \gset \if :skip_test diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out index c6e84c27b69..0ebe5691739 100644 --- a/src/test/regress/expected/collate.linux.utf8.out +++ b/src/test/regress/expected/collate.linux.utf8.out @@ -3,7 +3,7 @@ * locales is installed. It must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR version() !~ 'linux-gnu' AS skip_test \gset diff --git a/src/test/regress/expected/collate.linux.utf8_1.out b/src/test/regress/expected/collate.linux.utf8_1.out index ede5fdb5dcc..fe6dcad7881 100644 --- a/src/test/regress/expected/collate.linux.utf8_1.out +++ b/src/test/regress/expected/collate.linux.utf8_1.out @@ -3,7 +3,7 @@ * locales is installed. It must be run in a database with UTF-8 encoding, * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR version() !~ 'linux-gnu' AS skip_test \gset diff --git a/src/test/regress/expected/collate.utf8.out b/src/test/regress/expected/collate.utf8.out index cdd1a37ba18..7ba3b45228e 100644 --- a/src/test/regress/expected/collate.utf8.out +++ b/src/test/regress/expected/collate.utf8.out @@ -3,7 +3,7 @@ * builtin provider with the C.UTF-8 locale. */ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/expected/collate.utf8_1.out b/src/test/regress/expected/collate.utf8_1.out index e73fdf50c30..30a9126df54 100644 --- a/src/test/regress/expected/collate.utf8_1.out +++ b/src/test/regress/expected/collate.utf8_1.out @@ -3,6 +3,6 @@ * builtin provider with the C.UTF-8 locale. */ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/collate.windows.win1252.out b/src/test/regress/expected/collate.windows.win1252.out index 2a9e52a6b4a..6ba5e5e18f4 100644 --- a/src/test/regress/expected/collate.windows.win1252.out +++ b/src/test/regress/expected/collate.windows.win1252.out @@ -5,7 +5,7 @@ * of this, some test are lost from UTF-8 version, such as Turkish * dotted and undotted 'i'. */ -SELECT getdatabaseencoding() <> 'WIN1252' OR +SELECT pg_database_encoding() <> 'WIN1252' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE') AND collencoding = pg_char_to_encoding('WIN1252')) <> 3 OR (version() !~ 'Visual C\+\+' AND version() !~ 'mingw32' AND version() !~ 'windows') AS skip_test \gset diff --git a/src/test/regress/expected/collate.windows.win1252_1.out b/src/test/regress/expected/collate.windows.win1252_1.out index 879b12a4a0d..446f26436fb 100644 --- a/src/test/regress/expected/collate.windows.win1252_1.out +++ b/src/test/regress/expected/collate.windows.win1252_1.out @@ -5,7 +5,7 @@ * of this, some test are lost from UTF-8 version, such as Turkish * dotted and undotted 'i'. */ -SELECT getdatabaseencoding() <> 'WIN1252' OR +SELECT pg_database_encoding() <> 'WIN1252' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE') AND collencoding = pg_char_to_encoding('WIN1252')) <> 3 OR (version() !~ 'Visual C\+\+' AND version() !~ 'mingw32' AND version() !~ 'windows') AS skip_test \gset diff --git a/src/test/regress/expected/copyencoding.out b/src/test/regress/expected/copyencoding.out index 1e7ebc7d0e6..c8e8a4a76fe 100644 --- a/src/test/regress/expected/copyencoding.out +++ b/src/test/regress/expected/copyencoding.out @@ -2,7 +2,7 @@ -- Test cases for encoding with COPY commands -- -- skip test if not UTF8 server encoding -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/copyencoding_1.out b/src/test/regress/expected/copyencoding_1.out index a85ee2dbd18..f90eef534db 100644 --- a/src/test/regress/expected/copyencoding_1.out +++ b/src/test/regress/expected/copyencoding_1.out @@ -2,7 +2,7 @@ -- Test cases for encoding with COPY commands -- -- skip test if not UTF8 server encoding -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/encoding.out b/src/test/regress/expected/encoding.out index 2ecd255f182..9c30ff91251 100644 --- a/src/test/regress/expected/encoding.out +++ b/src/test/regress/expected/encoding.out @@ -1,5 +1,5 @@ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/expected/encoding_1.out b/src/test/regress/expected/encoding_1.out index a5b02090901..b0f2b668b44 100644 --- a/src/test/regress/expected/encoding_1.out +++ b/src/test/regress/expected/encoding_1.out @@ -1,4 +1,4 @@ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/euc_kr.out b/src/test/regress/expected/euc_kr.out index 7a61c89a43a..cc85c8472c9 100644 --- a/src/test/regress/expected/euc_kr.out +++ b/src/test/regress/expected/euc_kr.out @@ -1,7 +1,7 @@ -- This test is about EUC_KR encoding, chosen as perhaps the most prevalent -- non-UTF8, multibyte encoding as of 2026-01. Since UTF8 can represent all -- of EUC_KR, also run the test in UTF8. -SELECT getdatabaseencoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset +SELECT pg_database_encoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/expected/euc_kr_1.out b/src/test/regress/expected/euc_kr_1.out index faaac5d6355..08ae735cf98 100644 --- a/src/test/regress/expected/euc_kr_1.out +++ b/src/test/regress/expected/euc_kr_1.out @@ -1,6 +1,6 @@ -- This test is about EUC_KR encoding, chosen as perhaps the most prevalent -- non-UTF8, multibyte encoding as of 2026-01. Since UTF8 can represent all -- of EUC_KR, also run the test in UTF8. -SELECT getdatabaseencoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset +SELECT pg_database_encoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/json_encoding.out b/src/test/regress/expected/json_encoding.out index fe729db8c9d..b4f71e8c464 100644 --- a/src/test/regress/expected/json_encoding.out +++ b/src/test/regress/expected/json_encoding.out @@ -3,14 +3,14 @@ -- -- We provide expected-results files for UTF8 (json_encoding.out) -- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files - getdatabaseencoding ---------------------- +SELECT pg_database_encoding(); -- just to label the results files + pg_database_encoding +---------------------- UTF8 (1 row) diff --git a/src/test/regress/expected/json_encoding_1.out b/src/test/regress/expected/json_encoding_1.out index 5c8d91ad0b6..64ac47ff9d4 100644 --- a/src/test/regress/expected/json_encoding_1.out +++ b/src/test/regress/expected/json_encoding_1.out @@ -3,14 +3,14 @@ -- -- We provide expected-results files for UTF8 (json_encoding.out) -- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files - getdatabaseencoding ---------------------- +SELECT pg_database_encoding(); -- just to label the results files + pg_database_encoding +---------------------- SQL_ASCII (1 row) diff --git a/src/test/regress/expected/json_encoding_2.out b/src/test/regress/expected/json_encoding_2.out index 4fc8f0241ab..8e00603cdb4 100644 --- a/src/test/regress/expected/json_encoding_2.out +++ b/src/test/regress/expected/json_encoding_2.out @@ -3,7 +3,7 @@ -- -- We provide expected-results files for UTF8 (json_encoding.out) -- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/jsonpath_encoding.out b/src/test/regress/expected/jsonpath_encoding.out index d53affe364f..413d88c1a94 100644 --- a/src/test/regress/expected/jsonpath_encoding.out +++ b/src/test/regress/expected/jsonpath_encoding.out @@ -3,14 +3,14 @@ -- -- We provide expected-results files for UTF8 (jsonpath_encoding.out) -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files - getdatabaseencoding ---------------------- +SELECT pg_database_encoding(); -- just to label the results files + pg_database_encoding +---------------------- UTF8 (1 row) diff --git a/src/test/regress/expected/jsonpath_encoding_1.out b/src/test/regress/expected/jsonpath_encoding_1.out index 287324f0157..152101f1660 100644 --- a/src/test/regress/expected/jsonpath_encoding_1.out +++ b/src/test/regress/expected/jsonpath_encoding_1.out @@ -3,14 +3,14 @@ -- -- We provide expected-results files for UTF8 (jsonpath_encoding.out) -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files - getdatabaseencoding ---------------------- +SELECT pg_database_encoding(); -- just to label the results files + pg_database_encoding +---------------------- SQL_ASCII (1 row) diff --git a/src/test/regress/expected/jsonpath_encoding_2.out b/src/test/regress/expected/jsonpath_encoding_2.out index bb71bfe72c4..c0ecac9e578 100644 --- a/src/test/regress/expected/jsonpath_encoding_2.out +++ b/src/test/regress/expected/jsonpath_encoding_2.out @@ -3,7 +3,7 @@ -- -- We provide expected-results files for UTF8 (jsonpath_encoding.out) -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/expected/unicode.out b/src/test/regress/expected/unicode.out index 63e48d3a961..274178594f0 100644 --- a/src/test/regress/expected/unicode.out +++ b/src/test/regress/expected/unicode.out @@ -1,4 +1,4 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/expected/unicode_1.out b/src/test/regress/expected/unicode_1.out index 8505c4fa552..51c048b0fc1 100644 --- a/src/test/regress/expected/unicode_1.out +++ b/src/test/regress/expected/unicode_1.out @@ -1,3 +1,3 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql index ce4e2bb3ffd..4c8550b3eb8 100644 --- a/src/test/regress/sql/collate.icu.utf8.sql +++ b/src/test/regress/sql/collate.icu.utf8.sql @@ -3,7 +3,7 @@ */ /* skip test if not UTF8 server encoding or no ICU collations installed */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collprovider = 'i' AND collname <> 'unicode') = 0 AS skip_test \gset \if :skip_test diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql index 132d13af0a8..237f3d3d4d2 100644 --- a/src/test/regress/sql/collate.linux.utf8.sql +++ b/src/test/regress/sql/collate.linux.utf8.sql @@ -4,7 +4,7 @@ * because other encodings don't support all the characters used. */ -SELECT getdatabaseencoding() <> 'UTF8' OR +SELECT pg_database_encoding() <> 'UTF8' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR version() !~ 'linux-gnu' AS skip_test \gset diff --git a/src/test/regress/sql/collate.utf8.sql b/src/test/regress/sql/collate.utf8.sql index 52cf068dd0c..3f2f0d8117f 100644 --- a/src/test/regress/sql/collate.utf8.sql +++ b/src/test/regress/sql/collate.utf8.sql @@ -4,7 +4,7 @@ */ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/sql/collate.windows.win1252.sql b/src/test/regress/sql/collate.windows.win1252.sql index c7d6c97db16..1378d63f745 100644 --- a/src/test/regress/sql/collate.windows.win1252.sql +++ b/src/test/regress/sql/collate.windows.win1252.sql @@ -5,7 +5,7 @@ * of this, some test are lost from UTF-8 version, such as Turkish * dotted and undotted 'i'. */ -SELECT getdatabaseencoding() <> 'WIN1252' OR +SELECT pg_database_encoding() <> 'WIN1252' OR (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE') AND collencoding = pg_char_to_encoding('WIN1252')) <> 3 OR (version() !~ 'Visual C\+\+' AND version() !~ 'mingw32' AND version() !~ 'windows') AS skip_test \gset diff --git a/src/test/regress/sql/copyencoding.sql b/src/test/regress/sql/copyencoding.sql index c8905da5567..11880d186dd 100644 --- a/src/test/regress/sql/copyencoding.sql +++ b/src/test/regress/sql/copyencoding.sql @@ -3,7 +3,7 @@ -- -- skip test if not UTF8 server encoding -SELECT getdatabaseencoding() <> 'UTF8' +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit diff --git a/src/test/regress/sql/encoding.sql b/src/test/regress/sql/encoding.sql index 07d7dc8ff18..9d089162fa9 100644 --- a/src/test/regress/sql/encoding.sql +++ b/src/test/regress/sql/encoding.sql @@ -1,5 +1,5 @@ /* skip test if not UTF8 server encoding */ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/sql/euc_kr.sql b/src/test/regress/sql/euc_kr.sql index 1851b2a8c14..570fc845334 100644 --- a/src/test/regress/sql/euc_kr.sql +++ b/src/test/regress/sql/euc_kr.sql @@ -1,7 +1,7 @@ -- This test is about EUC_KR encoding, chosen as perhaps the most prevalent -- non-UTF8, multibyte encoding as of 2026-01. Since UTF8 can represent all -- of EUC_KR, also run the test in UTF8. -SELECT getdatabaseencoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset +SELECT pg_database_encoding() NOT IN ('EUC_KR', 'UTF8') AS skip_test \gset \if :skip_test \quit \endif diff --git a/src/test/regress/sql/json_encoding.sql b/src/test/regress/sql/json_encoding.sql index aceb8dbc3c6..70f07a9d664 100644 --- a/src/test/regress/sql/json_encoding.sql +++ b/src/test/regress/sql/json_encoding.sql @@ -4,13 +4,13 @@ -- We provide expected-results files for UTF8 (json_encoding.out) -- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files +SELECT pg_database_encoding(); -- just to label the results files -- first json diff --git a/src/test/regress/sql/jsonpath_encoding.sql b/src/test/regress/sql/jsonpath_encoding.sql index 55d9e30b95c..78fcfe79201 100644 --- a/src/test/regress/sql/jsonpath_encoding.sql +++ b/src/test/regress/sql/jsonpath_encoding.sql @@ -4,13 +4,13 @@ -- We provide expected-results files for UTF8 (jsonpath_encoding.out) -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. -SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') +SELECT pg_database_encoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test \gset \if :skip_test \quit \endif -SELECT getdatabaseencoding(); -- just to label the results files +SELECT pg_database_encoding(); -- just to label the results files -- checks for double-quoted values diff --git a/src/test/regress/sql/unicode.sql b/src/test/regress/sql/unicode.sql index 951f86a336e..1fa1a7edd78 100644 --- a/src/test/regress/sql/unicode.sql +++ b/src/test/regress/sql/unicode.sql @@ -1,4 +1,4 @@ -SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset +SELECT pg_database_encoding() <> 'UTF8' AS skip_test \gset \if :skip_test \quit \endif -- 2.50.1 (Apple Git-155)