[GB.DB.MYSQL]

* NEW: If the connection host starts with a slash, then we supposed that we
  are connecting to localhost, and that the host is actually the path of
  the socket to use.


git-svn-id: svn://localhost/gambas/trunk@4130 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-09-16 13:15:12 +00:00
parent 61f9bb4db6
commit f315e8e717

View file

@ -597,6 +597,8 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
{
MYSQL *conn;
char *name;
char *host;
char *socket;
conn = mysql_init(NULL);
@ -611,9 +613,17 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
//fprintf(stderr, "mysql_real_connect: host = '%s'\n", desc->host);
if (!mysql_real_connect( conn, desc->host, desc->user, desc->password,
name, desc->port == NULL ? 0 : atoi(desc->port), NULL, /*unix_socket: if not null the
string specifies the socket or named pipe that should be used */
host = desc->host;
if (host && *host == '/')
{
socket = host;
host = NULL;
}
else
socket = NULL;
if (!mysql_real_connect( conn, host, desc->user, desc->password,
name, desc->port == NULL ? 0 : atoi(desc->port), socket,
CLIENT_MULTI_RESULTS /*client flag */)){
mysql_close(conn);
GB.Error("Cannot open database: &1", mysql_error(conn));