diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
commit | 9a374b77fb53e4cfbca121e4fa278a7d71bde7c4 (patch) | |
tree | 6591af757bd9df12549279b4b87f01e0ce98bd79 /src/bin/pg_basebackup/bbstreamer_zstd.c | |
parent | 5c431c7fb327e1abc70b7a197650f8d45fd5bede (diff) | |
download | postgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.tar.gz postgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.zip |
Improve frontend error logging style.
Get rid of the separate "FATAL" log level, as it was applied
so inconsistently as to be meaningless. This mostly involves
s/pg_log_fatal/pg_log_error/g.
Create a macro pg_fatal() to handle the common use-case of
pg_log_error() immediately followed by exit(1). Various
modules had already invented either this or equivalent macros;
standardize on pg_fatal() and apply it where possible.
Invent the ability to add "detail" and "hint" messages to a
frontend message, much as we have long had in the backend.
Except where rewording was needed to convert existing coding
to detail/hint style, I have (mostly) resisted the temptation
to change existing message wording.
Patch by me. Design and patch reviewed at various stages by
Robert Haas, Kyotaro Horiguchi, Peter Eisentraut and
Daniel Gustafsson.
Discussion: https://postgr.es/m/1363732.1636496441@sss.pgh.pa.us
Diffstat (limited to 'src/bin/pg_basebackup/bbstreamer_zstd.c')
-rw-r--r-- | src/bin/pg_basebackup/bbstreamer_zstd.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/bin/pg_basebackup/bbstreamer_zstd.c b/src/bin/pg_basebackup/bbstreamer_zstd.c index f94c5c041d3..e2c76503cc7 100644 --- a/src/bin/pg_basebackup/bbstreamer_zstd.c +++ b/src/bin/pg_basebackup/bbstreamer_zstd.c @@ -82,10 +82,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) streamer->cctx = ZSTD_createCCtx(); if (!streamer->cctx) - { - pg_log_error("could not create zstd compression context"); - exit(1); - } + pg_fatal("could not create zstd compression context"); /* Set compression level, if specified */ if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0) @@ -93,11 +90,8 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) ret = ZSTD_CCtx_setParameter(streamer->cctx, ZSTD_c_compressionLevel, compress->level); if (ZSTD_isError(ret)) - { - pg_log_error("could not set zstd compression level to %d: %s", - compress->level, ZSTD_getErrorName(ret)); - exit(1); - } + pg_fatal("could not set zstd compression level to %d: %s", + compress->level, ZSTD_getErrorName(ret)); } /* Set # of workers, if specified */ @@ -111,11 +105,8 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) ret = ZSTD_CCtx_setParameter(streamer->cctx, ZSTD_c_nbWorkers, compress->workers); if (ZSTD_isError(ret)) - { - pg_log_error("could not set compression worker count to %d: %s", - compress->workers, ZSTD_getErrorName(ret)); - exit(1); - } + pg_fatal("could not set compression worker count to %d: %s", + compress->workers, ZSTD_getErrorName(ret)); } /* Initialize the ZSTD output buffer. */ @@ -125,8 +116,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) return &streamer->base; #else - pg_log_error("this build does not support zstd compression"); - exit(1); + pg_fatal("this build does not support zstd compression"); #endif } @@ -271,10 +261,7 @@ bbstreamer_zstd_decompressor_new(bbstreamer *next) streamer->dctx = ZSTD_createDCtx(); if (!streamer->dctx) - { - pg_log_error("could not create zstd decompression context"); - exit(1); - } + pg_fatal("could not create zstd decompression context"); /* Initialize the ZSTD output buffer. */ streamer->zstd_outBuf.dst = streamer->base.bbs_buffer.data; @@ -283,8 +270,7 @@ bbstreamer_zstd_decompressor_new(bbstreamer *next) return &streamer->base; #else - pg_log_error("this build does not support compression"); - exit(1); + pg_fatal("this build does not support zstd compression"); #endif } @@ -328,7 +314,8 @@ bbstreamer_zstd_decompressor_content(bbstreamer *streamer, &mystreamer->zstd_outBuf, &inBuf); if (ZSTD_isError(ret)) - pg_log_error("could not decompress data: %s", ZSTD_getErrorName(ret)); + pg_log_error("could not decompress data: %s", + ZSTD_getErrorName(ret)); } } |