Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+1-1
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

+1-1
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)