diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-02-14 10:00:24 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-02-14 10:00:24 +0000 |
commit | dcda71fbaac3620758797565a3345ff28e48cfb9 (patch) | |
tree | 0a2b6619f4c31398bd5ce67af1d92c5d3d76fd1f /src/mysql.c | |
parent | 4c6de4be1b8652212d06188a4dd511243babd0be (diff) | |
download | gamma-dcda71fbaac3620758797565a3345ff28e48cfb9.tar.gz gamma-dcda71fbaac3620758797565a3345ff28e48cfb9.tar.bz2 |
(s_mysql_connect): If hostname starts with a slash, treat it as a path to UNIX socket.
Diffstat (limited to 'src/mysql.c')
-rw-r--r-- | src/mysql.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mysql.c b/src/mysql.c index fdaaeee..ea74d5b 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -1,5 +1,5 @@ /* This file is part of guile-sql. - Copyright (C) 2002 Sergey Poznyakoff + Copyright (C) 2002,2004 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,13 +46,18 @@ s_mysql_connect (char *hostname, int port, MYSQL *mysql; SCM smob; struct sql_connect *conn; - + char *socket_path = NULL; + mysql = mysql_init(NULL); if (!mysql) return SCM_BOOL_F; + if (hostname[0] == '/') { + socket_path = hostname; + hostname = "localhost"; + } if (!mysql_real_connect(mysql, hostname, user, pass, dbname, - port, NULL, 0)) { + port, socket_path, 0)) { mysql_close(mysql); return SCM_BOOL_F; } |