Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1fe8d17

Browse files
author
Michael Meskes
committed
Check for non-existant connection in prepare statement handling.
Do not close files that weren't opened.
1 parent 000086b commit 1fe8d17

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,11 @@ Thu, 10 Apr 2008 12:42:25 +0200
23462346

23472347
- Fixed bug in PGTYPEStimestamp_sub that used pointers instead of the
23482348
values to substract.
2349+
2350+
Mon, 12 May 2008 18:19:08 +0200
2351+
2352+
- Check for non-existant connection in prepare statement handling.
2353+
- Do not close files that weren't opened.
23492354
- Set pgtypes library version to 3.1.
23502355
- Set compat library version to 3.1.
23512356
- Set ecpg library version to 6.2.

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.26 2008/02/07 11:09:13 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.27 2008/05/12 16:29:04 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -120,10 +120,11 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
120120
struct sqlca_t *sqlca = ECPGget_sqlca();
121121
PGresult *query;
122122

123-
ecpg_init_sqlca(sqlca);
124-
125123
con = ecpg_get_connection(connection_name);
126124

125+
if (!ecpg_init(con, connection_name, lineno))
126+
return false;
127+
127128
/* check if we already have prepared this statement */
128129
this = find_prepared_statement(name, con, &prev);
129130
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)
256257

257258
con = ecpg_get_connection(connection_name);
258259

260+
if (!ecpg_init(con, connection_name, lineno))
261+
return false;
262+
259263
this = find_prepared_statement(name, con, &prev);
260264
if (this)
261265
return deallocate_one(lineno, c, con, prev, this);

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.363 2008/03/27 07:56:00 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.364 2008/05/12 16:29:04 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -87,8 +87,10 @@ mmerror(int error_code, enum errortype type, char * error, ...)
8787
ret_value = error_code;
8888
break;
8989
case ET_FATAL:
90-
fclose(yyin);
91-
fclose(yyout);
90+
if (yyin)
91+
fclose(yyin);
92+
if (yyout)
93+
fclose(yyout);
9294
if (unlink(output_filename) != 0 && *output_filename != '-')
9395
fprintf(stderr, "Could not remove output file %s!\n", output_filename);
9496
exit(error_code);

0 commit comments

Comments
 (0)