diff options
author | Michael Meskes <meskes@postgresql.org> | 2008-05-12 16:30:17 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2008-05-12 16:30:17 +0000 |
commit | f496eb31b27856570eb62c16c00b0717fb0b63e7 (patch) | |
tree | 7c1ff3f8fdde8ddc5ea9fbb0badf55a999ea73e9 | |
parent | cc22720644176e7caaa9d6534c00885ef51a80dd (diff) | |
download | postgresql-f496eb31b27856570eb62c16c00b0717fb0b63e7.tar.gz postgresql-f496eb31b27856570eb62c16c00b0717fb0b63e7.zip |
Check for non-existant connection in prepare statement handling.
Do not close files that weren't opened.
-rw-r--r-- | src/interfaces/ecpg/ecpglib/prepare.c | 10 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/preproc.y | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index 6c0268bdb1d..d5e25a77299 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.26 2008/02/07 11:09:13 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.26.2.1 2008/05/12 16:30:17 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -120,10 +120,11 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co struct sqlca_t *sqlca = ECPGget_sqlca(); PGresult *query; - ecpg_init_sqlca(sqlca); - con = ecpg_get_connection(connection_name); + if (!ecpg_init(con, connection_name, lineno)) + return false; + /* check if we already have prepared this statement */ this = find_prepared_statement(name, con, &prev); if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this)) @@ -256,6 +257,9 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name) con = ecpg_get_connection(connection_name); + if (!ecpg_init(con, connection_name, lineno)) + return false; + this = find_prepared_statement(name, con, &prev); if (this) return deallocate_one(lineno, c, con, prev, this); diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index 8f660694a18..5f576276b50 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359.2.2 2008/03/01 03:26:44 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.359.2.3 2008/05/12 16:30:17 meskes Exp $ */ /* Copyright comment */ %{ @@ -87,8 +87,10 @@ mmerror(int error_code, enum errortype type, char * error, ...) ret_value = error_code; break; case ET_FATAL: - fclose(yyin); - fclose(yyout); + if (yyin) + fclose(yyin); + if (yyout) + fclose(yyout); if (unlink(output_filename) != 0 && *output_filename != '-') fprintf(stderr, "Could not remove output file %s!\n", output_filename); exit(error_code); |