From f315e8e717a78970ac9bdf82ca93103ec72b15f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 16 Sep 2011 13:15:12 +0000 Subject: [PATCH] [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 --- gb.db.mysql/src/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gb.db.mysql/src/main.c b/gb.db.mysql/src/main.c index 4da1ceefb..d20d6c5b8 100644 --- a/gb.db.mysql/src/main.c +++ b/gb.db.mysql/src/main.c @@ -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));