diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-08-27 16:15:42 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-08-27 16:15:42 +0000 |
commit | 99a5619e7b39938eb72bb57576495a27e27f5ee6 (patch) | |
tree | 60bc9098a7ac19e74bee1911ddfe1a7faa323c0b /src/interfaces/ecpg/ecpglib/connect.c | |
parent | 162e8f1fd53eb485e0b7c22331444f245420d3ba (diff) | |
download | postgresql-99a5619e7b39938eb72bb57576495a27e27f5ee6.tar.gz postgresql-99a5619e7b39938eb72bb57576495a27e27f5ee6.zip |
- Enabled single-quoted connection targets.
- Fixed a memory leak/segfault in unsuccessful connection.
- Some changes to test files.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/connect.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index dd855025f43..4ce68c23e16 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.33 2006/08/13 10:18:29 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.34 2006/08/27 16:15:41 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -316,25 +316,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p if (dbname != NULL) { /* get the detail information out of dbname */ - if (strchr(dbname, '@') != NULL) - { - /* old style: dbname[@server][:port] */ - tmp = strrchr(dbname, ':'); - if (tmp != NULL) /* port number given */ - { - port = ECPGstrdup(tmp + 1, lineno); - *tmp = '\0'; - } - - tmp = strrchr(dbname, '@'); - if (tmp != NULL) /* host name given */ - { - host = ECPGstrdup(tmp + 1, lineno); - *tmp = '\0'; - } - realname = ECPGstrdup(dbname, lineno); - } - else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0) + if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0) { int offset = 0; @@ -396,6 +378,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ECPGfree(realname); if (dbname) ECPGfree(dbname); + free(this); return false; } } @@ -419,7 +402,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ECPGfree(realname); if (dbname) ECPGfree(dbname); - ecpg_finish(this); + free(this); return false; } } @@ -427,11 +410,25 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p host = ECPGstrdup(dbname + offset, lineno); } - else - realname = ECPGstrdup(dbname, lineno); } else + { + /* old style: dbname[@server][:port] */ + tmp = strrchr(dbname, ':'); + if (tmp != NULL) /* port number given */ + { + port = ECPGstrdup(tmp + 1, lineno); + *tmp = '\0'; + } + + tmp = strrchr(dbname, '@'); + if (tmp != NULL) /* host name given */ + { + host = ECPGstrdup(tmp + 1, lineno); + *tmp = '\0'; + } realname = ECPGstrdup(dbname, lineno); + } } else realname = NULL; |