ECPG doesn't delete its output file in case of an error

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: ECPG doesn't delete its output file in case of an error
Date: 2010-04-03 16:22:39
Message-ID: 4BB76B4F.9050509@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I saw you changed my "warn about hidden vars" patch
to ET_ERROR instead of ET_FATAL. My thinking in using
ET_FATAL was that this is an error level that immedately
quits processing and deletes its output file. However,
you are right that we might want to report all such errors
in one run of ECPG.

But if ET_ERROR is used, the output file stays there as if
there was no error. Think about a project that uses Makefile
with say:
.PRECIOUS: %.c
to keep the generated C sources by ECPG. However, the implicit
thinking is that the files were correctly generated.

In such a case, GNU make won't delete the generated file,
and ECPG won't be called the next time "make" is run as
the *.c file already exists (make won't know that ECPG reported
an error code last time) and the C compiler will be called.
directly. GCC on the other hand, deletes its object file
in case of an error (it also reports as many errors as it can),
so running make next time won't attempt linking to a bad
object file.

Attached is the patch to delete the output file if an error
happened. Comments?

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachment Content-Type Size
pg90-delete-on-error.patch text/x-patch 638 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-04-03 19:02:58 Re: message clarifications
Previous Message Andrew Dunstan 2010-04-03 15:48:32 pgindent cleanup