]> 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:12:05 +0000 (16:12 +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/expected/encoding.out
src/test/regress/regress.c
src/test/regress/sql/encoding.sql

index cac1cb74782661c3dc14654aaf3d7a7d92119025..b3655527b0ab9d9c12f4ae68340c657d85187112 100644 (file)
@@ -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;
index 96cf30ac925a82327693cc1e958bc91601d87c45..a02f41c97279ebcc4cb44f49776276303cf25d9d 100644 (file)
@@ -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() */
index 782f90f0d629280d14fac4641a552c7324a8b1b3..d591818c3ebde88d7c47e944e7198b6104791c04 100644 (file)
@@ -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;