Re: [PATCHES] COPY when 'filename' is a directory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Brent Verner <brent(at)rcfile(dot)org>, Douglas Trainor <trainor(at)uic(dot)edu>, pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] COPY when 'filename' is a directory
Date: 2002-02-24 02:41:28
Message-ID: 28203.1014518488@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> Actually, my recommendation is to remove it altogether. The mechanisms
>> are in place to close allocated files after elog(), so why waste thought
>> and code space to release them manually?

> Fix applied. There is a FileFree() just below this in the code:
> if (!pipe)
> FreeFile(fp);
> We don't need the if (!pipe) because this code is in an else of
> if(pipe). For clarity, it seems the FreeFile call makes sense.

Huh? That FreeFile is *necessary* because it is not in an elog(ERROR)
path; and by my reading the "if (!pipe)" is needed too.

We do have a fair amount of other code that releases resources just
before doing elog(ERROR); so Brent was just emulating code he saw
elsewhere... but it's a coding habit I think we should move away from.
If the resource in question would be released anyway during error
recovery, then I don't see the value of doing it "by hand"; it just
bloats the backend (and adds potential for error, as in this case).
The only exception I'd make is for the case of releasing a spinlock or
LWLock; it's better to release the lock ASAP so as not to block other
backends longer than necessary.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2002-02-24 02:47:44 Re: [PATCHES] COPY when 'filename' is a directory
Previous Message Bruce Momjian 2002-02-24 02:31:35 Re: [PATCHES] COPY when 'filename' is a directory

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2002-02-24 02:47:44 Re: [PATCHES] COPY when 'filename' is a directory
Previous Message Bruce Momjian 2002-02-24 02:31:35 Re: [PATCHES] COPY when 'filename' is a directory