Skip to content

Commit f32d967

Browse files
macdicehs-liuxh
authored andcommitted
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>
1 parent 12791a1 commit f32d967

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/test/regress/input/encoding.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8;
226226
DROP TABLE encoding_tests;
227227
DROP TABLE toast_4b_utf8;
228228
DROP FUNCTION test_encoding;
229+
DROP FUNCTION test_wchars_to_text;
229230
DROP FUNCTION test_text_to_wchars;
231+
DROP FUNCTION test_valid_server_encoding;
230232
DROP FUNCTION test_mblen_func;
231233
DROP FUNCTION test_bytea_to_text;
232234
DROP FUNCTION test_text_to_bytea;

src/test/regress/output/encoding.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8;
416416
DROP TABLE encoding_tests;
417417
DROP TABLE toast_4b_utf8;
418418
DROP FUNCTION test_encoding;
419+
DROP FUNCTION test_wchars_to_text;
419420
DROP FUNCTION test_text_to_wchars;
421+
DROP FUNCTION test_valid_server_encoding;
420422
DROP FUNCTION test_mblen_func;
421423
DROP FUNCTION test_bytea_to_text;
422424
DROP FUNCTION test_text_to_bytea;

src/test/regress/regress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ PG_FUNCTION_INFO_V1(test_valid_server_encoding);
14081408
Datum
14091409
test_valid_server_encoding(PG_FUNCTION_ARGS)
14101410
{
1411-
return pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0)));
1411+
PG_RETURN_BOOL(pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0))) >= 0);
14121412
}
14131413

14141414
/* Provide SQL access to IsBinaryCoercible() */

0 commit comments

Comments
 (0)