postgres.git / summary / log / commit / refs

commit    bd626ef093b2e5f279285a344c8ac53d67cdfd76
Author:   Thomas Munro <tmunro@postgresql.org>
Date:     Tue Feb 17 00:53:32 2026 +0000

    Fix test_valid_server_encoding helper function.
    
    Commit c67bef3f325 introduced this test helper function for use by
    src/test/regress/sql/encoding.sql, but its logic was incorrect.  It
    confused an encoding ID for a boolean so it gave the wrong results for
    some inputs, and also forgot the usual return macro.  The mistake didn't
    affect values actually used in the test, so there is no change in
    behavior.
    
    Also drop it and another missed function at the end of the test, for
    consistency.
    
    Backpatch-through: 14
    Author: Zsolt Parragi <zsolt.parragi@percona.com>


src/test/regress/expected/encoding.out | 2 ++ src/test/regress/regress.c | 2 +- src/test/regress/sql/encoding.sql | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/regress/expected/encoding.out b/src/test/regress/expected/encoding.out index cac1cb74782..b3655527b0a 100644 --- a/src/test/regress/expected/encoding.out +++ b/src/test/regress/expected/encoding.out @@ -419,7 +419,9 @@ SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8; DROP TABLE encoding_tests; DROP TABLE toast_4b_utf8; DROP FUNCTION test_encoding; +DROP FUNCTION test_wchars_to_text; DROP FUNCTION test_text_to_wchars; +DROP FUNCTION test_valid_server_encoding; DROP FUNCTION test_mblen_func; DROP FUNCTION test_bytea_to_text; DROP FUNCTION test_text_to_bytea; diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 96cf30ac925..a02f41c9727 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1251,7 +1251,7 @@ PG_FUNCTION_INFO_V1(test_valid_server_encoding); Datum test_valid_server_encoding(PG_FUNCTION_ARGS) { - return pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0))); + PG_RETURN_BOOL(pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0))) >= 0); } /* Provide SQL access to IsBinaryCoercible() */ diff --git a/src/test/regress/sql/encoding.sql b/src/test/regress/sql/encoding.sql index 782f90f0d62..d591818c3eb 100644 --- a/src/test/regress/sql/encoding.sql +++ b/src/test/regress/sql/encoding.sql @@ -231,7 +231,9 @@ SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8; DROP TABLE encoding_tests; DROP TABLE toast_4b_utf8; DROP FUNCTION test_encoding; +DROP FUNCTION test_wchars_to_text; DROP FUNCTION test_text_to_wchars; +DROP FUNCTION test_valid_server_encoding; DROP FUNCTION test_mblen_func; DROP FUNCTION test_bytea_to_text; DROP FUNCTION test_text_to_bytea; [parent: 8cef93d8a588]