Re: Sloppiness around failure handling of parsePGArray in pg_dump

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Sloppiness around failure handling of parsePGArray in pg_dump
Date: 2020-11-18 09:19:40
Message-ID: A6F86482-D1B9-45B4-A774-862F2B9A8008@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 11 Nov 2020, at 07:13, Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> I would like to propose the attached to tighten the error handling in
> the area, generating a fatal error if an array cannot be parsed.

I agree that we should fix this even if it will have quite limited impact in
production settings. Patch LGTM, +1.

> I did not see the point of changing the assumptions we use for the parsing of
> function args or such when it comes to pre-8.4 dumps.

Another thing caught my eye here (while not the fault of this patch), we ensure
to clean up array leftover in case of parsePGArray failure, but we don't clean
up the potential allocations from the previous calls. Something like the below
seems more consistent.

@@ -12105,6 +12099,8 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
nitems != nallargs)
{
pg_log_warning("could not parse proargmodes array");
+ if (allargtypes)
+ free(allargtypes);
if (argmodes)
free(argmodes);
argmodes = NULL;
@@ -12119,6 +12115,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
nitems != nallargs)
{
pg_log_warning("could not parse proargnames array");
+ if (allargtypes)
+ free(allargtypes);
+ if (argmodes)
+ free(argmodes);
if (argnames)
free(argnames);
argnames = NULL;

> This issue is unlikely going to matter in practice, so I don't propose a
> backpatch.

Agreed, unless it's easier for dealing with backpatching other things, that
would be the only reason I reckon.

cheers ./daniel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2020-11-18 09:25:26 Re: Add LWLock blocker(s) information
Previous Message k.jamison@fujitsu.com 2020-11-18 09:04:49 RE: [Patch] Optimize dropping of relation buffers using dlist