diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2024-07-09 17:29:48 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2024-07-09 17:34:47 -0400 |
commit | e72f787ea6b287ed624c1f5be71eb13e405b1577 (patch) | |
tree | 774ccab7ef38f068e43a9057232064b641641bb1 /src | |
parent | d3e076549b99d1130053223adb9c1fa909d75dc0 (diff) | |
download | postgresql-e72f787ea6b287ed624c1f5be71eb13e405b1577.tar.gz postgresql-e72f787ea6b287ed624c1f5be71eb13e405b1577.zip |
Prevent CRLF conversion of inputs in json_parser test module
Do this by opening the file in PG_BINARY_R mode. This prevents us from
getting wrong byte count from stat().
Per complaint from Andres Freund
Discussion: https://postgr.es/m/20240707052030.r77hbdkid3mwksop@awork3.anarazel.de
Backpatch to rlease 17 where this code was introduced
Diffstat (limited to 'src')
-rw-r--r-- | src/test/modules/test_json_parser/test_json_parser_incremental.c | 2 | ||||
-rw-r--r-- | src/test/modules/test_json_parser/test_json_parser_perf.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/test/modules/test_json_parser/test_json_parser_incremental.c b/src/test/modules/test_json_parser/test_json_parser_incremental.c index 7cd3dcf276b..175e1302844 100644 --- a/src/test/modules/test_json_parser/test_json_parser_incremental.c +++ b/src/test/modules/test_json_parser/test_json_parser_incremental.c @@ -124,7 +124,7 @@ main(int argc, char **argv) makeJsonLexContextIncremental(&lex, PG_UTF8, need_strings); initStringInfo(&json); - if ((json_file = fopen(testfile, "r")) == NULL) + if ((json_file = fopen(testfile, PG_BINARY_R)) == NULL) pg_fatal("error opening input: %m"); if (fstat(fileno(json_file), &statbuf) != 0) diff --git a/src/test/modules/test_json_parser/test_json_parser_perf.c b/src/test/modules/test_json_parser/test_json_parser_perf.c index ea85626cbd8..74cc5f3f548 100644 --- a/src/test/modules/test_json_parser/test_json_parser_perf.c +++ b/src/test/modules/test_json_parser/test_json_parser_perf.c @@ -55,7 +55,7 @@ main(int argc, char **argv) sscanf(argv[1], "%d", &iter); - if ((json_file = fopen(argv[2], "r")) == NULL) + if ((json_file = fopen(argv[2], PG_BINARY_R)) == NULL) pg_fatal("Could not open input file '%s': %m", argv[2]); while ((n_read = fread(buff, 1, 6000, json_file)) > 0) |