Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Date: 2013-12-02 20:15:11
Message-ID: CAEZATCUDDXc9eAAjXO0Kd6o_y1B9JxEZqtzy6USgTKMWeSqh6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2 December 2013 19:37, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> Dean Rasheed escribió:
>
>> +/*
>> + * If a schema was explicitly specified, test if it exists. If it does not,
>> + * report the schema as missing rather than the child object.
>> + */
>> +static bool
>> +schema_does_not_exist_skipping(List *objname,
>> + const char **msg,
>> + char **name)
>> +{
>> + RangeVar *rel;
>> +
>> + rel = makeRangeVarFromNameList(objname);
>> +
>> + if (rel->schemaname != NULL &&
>> + !OidIsValid(LookupNamespaceNoError(rel->schemaname)))
>> + {
>> + *msg = gettext_noop("schema \"%s\" does not exist, skipping");
>> + *name = rel->schemaname;
>> +
>> + return true;
>> + }
>> +
>> + return false;
>> +}
>
> In success cases, are we leaking a lot of memory? In the error case I
> guess it doesn't matter that the RangeVar is getting leaked (we're
> aborting anyway), but if we're called and everything turns out to work,
> are things cleaned up timely?
>

I think that memory gets freed at the end of the DROP command, so I
don't think this is a concern. In any case, that RangeVar is only of
order 50 bytes. If we were concerned about memory leakage here, a
bigger concern would be the calling code in does_not_exist_skipping(),
which is using NameListToString() which allocates at least 1024 bytes
for the name of the non-existent object without freeing it.

Regards,
Dean

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2013-12-02 20:28:01 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Previous Message Alvaro Herrera 2013-12-02 19:37:18 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2013-12-02 20:15:59 Re: Extension Templates S03E11
Previous Message Stephen Frost 2013-12-02 20:15:01 Re: Extension Templates S03E11