]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix test_valid_server_encoding helper function.
authorThomas Munro <tmunro@postgresql.org>
Tue, 17 Feb 2026 00:53:32 +0000 (13:53 +1300)
committerThomas Munro <tmunro@postgresql.org>
Tue, 17 Feb 2026 03:22:36 +0000 (16:22 +1300)
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/input/encoding.source
src/test/regress/output/encoding.source
src/test/regress/regress.c

index efdfecd3c05417053cf9d68d88ff82f1615f6a85..d080bef2f80f7c9739d0530d42c338f6f60581d4 100644 (file)
@@ -226,7 +226,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;
index 3405b7541d0c6a77c2211b387dede97f601a0486..6e730e8737e8554b9b4984c19a0fd741b60cd485 100644 (file)
@@ -416,7 +416,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;
index b527fe144bba20fdebc370ebbfd9e55fcbd8af67..436af638a0dac9618f7015e3b835bfc99c66ee14 100644 (file)
@@ -1408,7 +1408,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() */