aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/ecpglib/connect.c
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2006-07-28 10:10:42 +0000
committerMichael Meskes <meskes@postgresql.org>2006-07-28 10:10:42 +0000
commit9e76b4c7c5969b44ac5fb034db8bb12481492e8f (patch)
treed9b0364d1f3d2d379949a2d87737ffba6c6e6276 /src/interfaces/ecpg/ecpglib/connect.c
parent72ba3cb50f60151a0c6816a2cb3990de237442d4 (diff)
downloadpostgresql-9e76b4c7c5969b44ac5fb034db8bb12481492e8f.tar.gz
postgresql-9e76b4c7c5969b44ac5fb034db8bb12481492e8f.zip
And one more:
Connection identifier has to be unique
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/connect.c')
-rw-r--r--src/interfaces/ecpg/ecpglib/connect.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 3cba42d25ff..dcc70a57544 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.30 2006/06/21 11:38:07 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.31 2006/07/28 10:10:42 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -295,12 +295,21 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
- if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
- return false;
-
if (dbname == NULL && connection_name == NULL)
connection_name = "DEFAULT";
+ /* check if the identifier is unique */
+ if (ECPGget_connection(connection_name))
+ {
+ ECPGfree(dbname);
+ ECPGlog("connect: connection identifier %s is already in use\n",
+ connection_name);
+ return false;
+ }
+
+ if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
+ return false;
+
if (dbname != NULL)
{
/* get the detail information out of dbname */