diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2024-04-23 15:27:40 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2024-04-23 15:32:06 -0400 |
commit | ba3e6e2bca97df14920375b0a1ebf4eab95b78b5 (patch) | |
tree | ee3e960a3d3ae2ff28dc719f5aa86aeea8b2173b /src/test/modules/test_json_parser/test_json_parser_perf.c | |
parent | b7d35d393edbe2d4333dde81496e8a362abc85bd (diff) | |
download | postgresql-ba3e6e2bca97df14920375b0a1ebf4eab95b78b5.tar.gz postgresql-ba3e6e2bca97df14920375b0a1ebf4eab95b78b5.zip |
Post review fixes for test_json_parser test module
. Add missing copytight notices
. improve code coverage
. put work files in a temp directory in the standard location
. improve error checking in C code
. indent perl files with perltidy
. add some comments
per comments from Michael Paquier
Discussion: https://postgr.es/m/ZiC3-cdFys4-6xSk@paquier.xyz
Diffstat (limited to 'src/test/modules/test_json_parser/test_json_parser_perf.c')
-rw-r--r-- | src/test/modules/test_json_parser/test_json_parser_perf.c | 13 |
1 files changed, 6 insertions, 7 deletions
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 c463046848c..f5c0e8dd9ae 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 @@ -23,6 +23,7 @@ #include "postgres_fe.h" #include "common/jsonapi.h" +#include "common/logging.h" #include "lib/stringinfo.h" #include "mb/pg_wchar.h" #include <stdio.h> @@ -52,7 +53,9 @@ main(int argc, char **argv) sscanf(argv[1], "%d", &iter); - json_file = fopen(argv[2], "r"); + if ((json_file = fopen(argv[2], "r")) == NULL) + pg_fatal("Could not open input file '%s': %m", argv[2]); + while ((n_read = fread(buff, 1, 6000, json_file)) > 0) { appendBinaryStringInfo(&json, buff, n_read); @@ -76,12 +79,8 @@ main(int argc, char **argv) freeJsonLexContext(lex); } if (result != JSON_SUCCESS) - { - fprintf(stderr, - "unexpected result %d (expecting %d) on parse\n", - result, JSON_SUCCESS); - exit(1); - } + pg_fatal("unexpected result %d (expecting %d) on parse", + result, JSON_SUCCESS); } exit(0); } |