diff options
author | Michael Meskes <meskes@postgresql.org> | 2010-04-03 19:30:49 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2010-04-03 19:30:49 +0000 |
commit | 5f5ba923346daf841b9ab8cd7ffc208bafbee6c2 (patch) | |
tree | 0d72c0602d6bc176842087d90209a99e7c69b8a0 | |
parent | a404a12fb48a7623fb806e98f1f9b12b4443aeb1 (diff) | |
download | postgresql-5f5ba923346daf841b9ab8cd7ffc208bafbee6c2.tar.gz postgresql-5f5ba923346daf841b9ab8cd7ffc208bafbee6c2.zip |
Make ecpg in line with other compilers in that it deletes its output if there was an error processing the input file.
Work done by Zoltan.
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 1c90202b57c..3247e959829 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.114 2010/02/26 02:01:31 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.115 2010/04/03 19:30:49 meskes Exp $ */ /* Main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* Copyright (c) 1996-2010, PostgreSQL Global Development Group */ @@ -469,6 +469,14 @@ main(int argc, char *const argv[]) fclose(yyin); if (out_option == 0 && yyout != stdout) fclose(yyout); + /* + * If there was an error, delete the output file. + */ + if (ret_value != 0) + { + if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0) + fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename); + } } if (output_filename && out_option == 0) |