Skip to content

Commit f7bd0a3

Browse files
committed
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
1 parent 896cd26 commit f7bd0a3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/test/modules/test_json_parser/test_json_parser_incremental.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ main(int argc, char **argv)
124124
makeJsonLexContextIncremental(&lex, PG_UTF8, need_strings);
125125
initStringInfo(&json);
126126

127-
if ((json_file = fopen(testfile, "r")) == NULL)
127+
if ((json_file = fopen(testfile, PG_BINARY_R)) == NULL)
128128
pg_fatal("error opening input: %m");
129129

130130
if (fstat(fileno(json_file), &statbuf) != 0)

src/test/modules/test_json_parser/test_json_parser_perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ main(int argc, char **argv)
5555

5656
sscanf(argv[1], "%d", &iter);
5757

58-
if ((json_file = fopen(argv[2], "r")) == NULL)
58+
if ((json_file = fopen(argv[2], PG_BINARY_R)) == NULL)
5959
pg_fatal("Could not open input file '%s': %m", argv[2]);
6060

6161
while ((n_read = fread(buff, 1, 6000, json_file)) > 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy