|
|
|
@ -1,4 +1,4 @@ |
|
|
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */ |
|
|
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.1 2005/11/30 12:50:37 meskes Exp $ */ |
|
|
|
|
|
|
|
|
|
|
|
#define POSTGRES_ECPG_INTERNAL |
|
|
|
#define POSTGRES_ECPG_INTERNAL |
|
|
|
#include "postgres_fe.h" |
|
|
|
#include "postgres_fe.h" |
|
|
|
@ -265,7 +265,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
struct sqlca_t *sqlca = ECPGget_sqlca(); |
|
|
|
struct sqlca_t *sqlca = ECPGget_sqlca(); |
|
|
|
enum COMPAT_MODE compat = c; |
|
|
|
enum COMPAT_MODE compat = c; |
|
|
|
struct connection *this; |
|
|
|
struct connection *this; |
|
|
|
char *dbname = name ? strdup(name) : NULL, |
|
|
|
char *dbname = name ? ECPGstrdup(name, lineno) : NULL, |
|
|
|
*host = NULL, |
|
|
|
*host = NULL, |
|
|
|
*tmp, |
|
|
|
*tmp, |
|
|
|
*port = NULL, |
|
|
|
*port = NULL, |
|
|
|
@ -287,7 +287,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
if (envname) |
|
|
|
if (envname) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ECPGfree(dbname); |
|
|
|
ECPGfree(dbname); |
|
|
|
dbname = strdup(envname); |
|
|
|
dbname = ECPGstrdup(envname, lineno); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
@ -307,17 +307,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
tmp = strrchr(dbname, ':'); |
|
|
|
tmp = strrchr(dbname, ':'); |
|
|
|
if (tmp != NULL) /* port number given */ |
|
|
|
if (tmp != NULL) /* port number given */ |
|
|
|
{ |
|
|
|
{ |
|
|
|
port = strdup(tmp + 1); |
|
|
|
port = ECPGstrdup(tmp + 1, lineno); |
|
|
|
*tmp = '\0'; |
|
|
|
*tmp = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tmp = strrchr(dbname, '@'); |
|
|
|
tmp = strrchr(dbname, '@'); |
|
|
|
if (tmp != NULL) /* host name given */ |
|
|
|
if (tmp != NULL) /* host name given */ |
|
|
|
{ |
|
|
|
{ |
|
|
|
host = strdup(tmp + 1); |
|
|
|
host = ECPGstrdup(tmp + 1, lineno); |
|
|
|
*tmp = '\0'; |
|
|
|
*tmp = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
realname = strdup(dbname); |
|
|
|
realname = ECPGstrdup(dbname, lineno); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0) |
|
|
|
else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -345,14 +345,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
tmp = strrchr(dbname + offset, '?'); |
|
|
|
tmp = strrchr(dbname + offset, '?'); |
|
|
|
if (tmp != NULL) /* options given */ |
|
|
|
if (tmp != NULL) /* options given */ |
|
|
|
{ |
|
|
|
{ |
|
|
|
options = strdup(tmp + 1); |
|
|
|
options = ECPGstrdup(tmp + 1, lineno); |
|
|
|
*tmp = '\0'; |
|
|
|
*tmp = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tmp = last_dir_separator(dbname + offset); |
|
|
|
tmp = last_dir_separator(dbname + offset); |
|
|
|
if (tmp != NULL) /* database name given */ |
|
|
|
if (tmp != NULL) /* database name given */ |
|
|
|
{ |
|
|
|
{ |
|
|
|
realname = strdup(tmp + 1); |
|
|
|
realname = ECPGstrdup(tmp + 1, lineno); |
|
|
|
*tmp = '\0'; |
|
|
|
*tmp = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -365,7 +365,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
if ((tmp2 = strchr(tmp + 1, ':')) != NULL) |
|
|
|
if ((tmp2 = strchr(tmp + 1, ':')) != NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
*tmp2 = '\0'; |
|
|
|
*tmp2 = '\0'; |
|
|
|
host = strdup(tmp + 1); |
|
|
|
host = ECPGstrdup(tmp + 1, lineno); |
|
|
|
if (strncmp(dbname, "unix:", 5) != 0) |
|
|
|
if (strncmp(dbname, "unix:", 5) != 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno); |
|
|
|
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno); |
|
|
|
@ -384,7 +384,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
port = strdup(tmp + 1); |
|
|
|
port = ECPGstrdup(tmp + 1, lineno); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strncmp(dbname, "unix:", 5) == 0) |
|
|
|
if (strncmp(dbname, "unix:", 5) == 0) |
|
|
|
@ -407,14 +407,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
host = strdup(dbname + offset); |
|
|
|
host = ECPGstrdup(dbname + offset, lineno); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
realname = strdup(dbname); |
|
|
|
realname = ECPGstrdup(dbname, lineno); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
realname = strdup(dbname); |
|
|
|
realname = ECPGstrdup(dbname, lineno); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
realname = NULL; |
|
|
|
realname = NULL; |
|
|
|
|