Re: pg_dump, gzwrite, and errno

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Kunshchikov Vladimir <Vladimir(dot)Kunshchikov(at)infotecs(dot)ru>
Subject: Re: pg_dump, gzwrite, and errno
Date: 2020-06-18 21:20:27
Message-ID: 20200618212027.GA17103@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Jun-11, Justin Pryzby wrote:

> --- a/src/bin/pg_dump/pg_backup_directory.c
> +++ b/src/bin/pg_dump/pg_backup_directory.c
> @@ -347,8 +347,12 @@ _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
> lclContext *ctx = (lclContext *) AH->formatData;
>
> if (dLen > 0 && cfwrite(data, dLen, ctx->dataFH) != dLen)
> + {
> + if (errno == 0)
> + errno = ENOSPC;
> fatal("could not write to output file: %s",
> get_cfp_error(ctx->dataFH));
> + }
> }

This seems correct to me. (I spent a long time looking at zlib sources
to convince myself that it does work with compressed files too). There
are more calls to cfwrite in pg_backup_directory.c though -- we should
patch them all.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2020-06-18 21:26:50 Re: Add support for INDEX_CLEANUP and TRUNCATE to vacuumdb
Previous Message Andrew Dunstan 2020-06-18 20:53:15 Re: jsonpath versus NaN