X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B41B3564C6 for ; Tue, 1 Mar 2005 09:01:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72761-04 for ; Tue, 1 Mar 2005 09:01:02 +0000 (GMT) Received: from post.tau.ac.il (post.tau.ac.il [132.66.16.11]) by svr1.postgresql.org (Postfix) with ESMTP id BC87E531C8 for ; Tue, 1 Mar 2005 09:01:01 +0000 (GMT) Received: from vams.tau.ac.il (localhost.localdomain [127.0.0.1]) by VAMS.dummy (Postfix) with SMTP id 9DB7133A738; Tue, 1 Mar 2005 11:01:00 +0200 (IST) Received: from localhost (manray.tau.ac.il [132.66.17.10]) by post.tau.ac.il (Postfix) with ESMTP id 8A62633A738; Tue, 1 Mar 2005 11:01:00 +0200 (IST) Received: from we1.il.sphera.com (we1.il.sphera.com [212.29.248.194]) by webmail2.tau.ac.il (IMP) with HTTP for ; Tue, 1 Mar 2005 11:00:59 +0200 Message-ID: <1109667659.42242f4bb5c42@webmail2.tau.ac.il> Date: Tue, 1 Mar 2005 11:00:59 +0200 From: Ramon Danieli To: pgsql-odbc@postgresql.org Cc: Dave Page , Peter Eisentraut Subject: Re: Unix domain socket References: <200502242116.34158.peter_e@gmx.net> In-Reply-To: <200502242116.34158.peter_e@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 User-Agent: Internet Messaging Program (IMP) 3.2.2 X-Originating-IP: 212.29.248.194 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/1 X-Sequence-Number: 5019 Quoting Peter Eisentraut : > Dave Page wrote: > > Hmm, did even realise it had crept in there. Well to enable it you > > will need to define the HAVE_UNIX_SOCKETS macro when you compile. > > Does it then work? As for why it's done the way it is, I have no idea > > - it was committed by Hiroshi Inoue, so he'd need to answer that - > > unfortunately though, he no longer works on psqlODBC. >=20 > HAVE_UNIX_SOCKETS is defined in the server source tree, so I guess this= =20 > could be a leftover from those days. Turn on the macro and see if you=20 > get it working. >=20 > --=20 The macro is turned on automatically (RHL 4.0AS, gcc version 3.4.2 200410= 17 (Red Hat 3.4.2-6.fc3)) and it works. The following patch allow users to configure the Unix domain socket path, using the "Uds" property. I took some code from the unixODBC PG driver and performed the necessary adjustments. Please note that unlike unixODBC, I have followed the current convention,= which means that: 1) "Uds" is considered only if "Servername" is empty. 2) Default path is "/tmp". 3) The provided path should point the folder that comtains the UDS node. Please let me know if you find anything wrong in this patch and whether i= t will be included sometimes in the near future. Thanks, Ramon diff -Naur psqlodbc-08.00.0004/connection.c psqlodbc-08.00.0004.patch/connection.c --- psqlodbc-08.00.0004/connection.c 2005-01-28 23:36:14.000000000 +0200 +++ psqlodbc-08.00.0004.patch/connection.c 2005-02-27 14:40:34.430232000 = +0200 @@ -725,7 +725,16 @@ return 0; } =20 - mylog("CC_connect(): DSN =3D '%s', server =3D '%s', port =3D '%s', dat= abase =3D '%s', username =3D '%s', password=3D'%s'\n", ci->dsn, ci->server, ci->port, ci-= >database, ci->username, ci->password ? "xxxxx" : ""); + mylog("CC_connect(): DSN =3D '%s', server =3D '%s', port =3D '%s'," +#ifdef HAVE_UNIX_SOCKETS + " uds =3D '%s'," +#endif + " database =3D '%s', username =3D '%s'," + " password=3D'%s'\n", ci->dsn, ci->server, ci->port, +#ifdef HAVE_UNIX_SOCKETS + ci->uds, +#endif + ci->database, ci->username, ci->password ? "xxxxx" : ""); =20 another_version_retry: =20 @@ -747,7 +756,11 @@ =20 mylog("connecting to the server socket...\n"); =20 - SOCK_connect_to(sock, (short) atoi(ci->port), ci->server); + SOCK_connect_to(sock, (short) atoi(ci->port), ci->server +#ifdef HAVE_UNIX_SOCKETS + , ci->uds +#endif + ); if (SOCK_get_errcode(sock) !=3D 0) { mylog("connection to the server socket failed.\n"); diff -Naur psqlodbc-08.00.0004/connection.h psqlodbc-08.00.0004.patch/connection.h --- psqlodbc-08.00.0004/connection.h 2005-01-28 23:36:14.000000000 +0200 +++ psqlodbc-08.00.0004.patch/connection.h 2005-02-27 16:04:37.469858000 = +0200 @@ -19,6 +19,10 @@ #include #endif =20 +#if !defined WIN32 && defined HAVE_SYS_UN_H && !defined HAVE_UNIX_SOCKET= S +#define HAVE_UNIX_SOCKETS +#endif + typedef enum { CONN_NOT_CONNECTED, /* Connection has not been established */ @@ -239,6 +243,9 @@ char conn_settings[LARGE_REGISTRY_LEN]; char protocol[SMALL_REGISTRY_LEN]; char port[SMALL_REGISTRY_LEN]; +#ifdef HAVE_UNIX_SOCKETS + char uds[LARGE_REGISTRY_LEN]; +#endif char onlyread[SMALL_REGISTRY_LEN]; char fake_oid_index[SMALL_REGISTRY_LEN]; char show_oid_column[SMALL_REGISTRY_LEN]; diff -Naur psqlodbc-08.00.0004/dlg_specific.c psqlodbc-08.00.0004.patch/dlg_specific.c --- psqlodbc-08.00.0004/dlg_specific.c 2005-01-28 23:36:15.000000000 +020= 0 +++ psqlodbc-08.00.0004.patch/dlg_specific.c 2005-02-27 16:03:10.55949500= 0 +0200 @@ -286,6 +286,11 @@ else if (stricmp(attribute, INI_PORT) =3D=3D 0) strcpy(ci->port, value); =20 +#ifdef HAVE_UNIX_SOCKETS + else if (stricmp(attribute, INI_UDS) =3D=3D 0) + strcpy(ci->uds, value); +#endif + else if (stricmp(attribute, INI_READONLY) =3D=3D 0 || stricmp(attribute= , "A0") =3D=3D 0) strcpy(ci->onlyread, value); =20 @@ -492,6 +497,11 @@ if (ci->port[0] =3D=3D '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->por= t), ODBC_INI); =20 +#ifdef HAVE_UNIX_SOCKETS + if (ci->uds[0] =3D=3D '\0' || overwrite) + SQLGetPrivateProfileString(DSN, INI_UDS, "", ci->uds, sizeof(ci->uds), ODBC_INI); +#endif + if (ci->onlyread[0] =3D=3D '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI); =20 @@ -725,6 +735,13 @@ ci->port, ODBC_INI); =20 +#ifdef HAVE_UNIX_SOCKETS + SQLWritePrivateProfileString(DSN, + INI_UDS, + ci->uds, + ODBC_INI); +#endif + SQLWritePrivateProfileString(DSN, INI_USER, ci->username, diff -Naur psqlodbc-08.00.0004/dlg_specific.h psqlodbc-08.00.0004.patch/dlg_specific.h --- psqlodbc-08.00.0004/dlg_specific.h 2005-01-28 23:36:15.000000000 +020= 0 +++ psqlodbc-08.00.0004.patch/dlg_specific.h 2005-02-27 14:10:03.39319000= 0 +0200 @@ -38,6 +38,14 @@ #define INI_KDESC "Description" /* Data source description */ #define INI_SERVER "Servername" /* Name of Server running PostgreSQL *= / #define INI_PORT "Port" /* Port on which the Postmaster is listening = */ + +#if !defined WIN32 && defined HAVE_SYS_UN_H +#ifndef HAVE_UNIX_SOCKETS +#define HAVE_UNIX_SOCKETS +#endif +#define INI_UDS "Uds" /* Unix domain socket path*/ +#endif + #define INI_DATABASE "Database" /* Database Name */ #define INI_USER "Username" /* Default User Name */ #define INI_PASSWORD "Password" /* Default Password */ diff -Naur psqlodbc-08.00.0004/socket.c psqlodbc-08.00.0004.patch/socket.= c --- psqlodbc-08.00.0004/socket.c 2005-01-28 23:36:20.000000000 +0200 +++ psqlodbc-08.00.0004.patch/socket.c 2005-02-27 16:20:34.993553000 +020= 0 @@ -109,7 +109,11 @@ =20 =20 char -SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname) +SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname +#ifdef HAVE_UNIX_SOCKETS + , char *uds /* unix domain socket path */ +#endif + ) { #if defined (POSIX_MULTITHREAD_SUPPORT) const int bufsz =3D 8192;=20 @@ -140,7 +144,7 @@ =20 =20 /* - * If it is a valid IP address, use it. Otherwise use hostname lookup. + * If it is a valid IP address, use it. Otherwise use AF_UNIX socket. */ if (hostname && hostname[0]) { @@ -196,7 +200,7 @@ } un->sun_family =3D family =3D AF_UNIX; /* passing NULL means that this only suports the pg default "/tmp" */ - UNIXSOCK_PATH(un, port, ((char *) NULL)); + UNIXSOCK_PATH(un, port, uds); sLen =3D UNIXSOCK_LEN(un); self->sadr =3D (struct sockaddr *) un; } diff -Naur psqlodbc-08.00.0004/socket.h psqlodbc-08.00.0004.patch/socket.= h --- psqlodbc-08.00.0004/socket.h 2005-01-28 23:36:20.000000000 +0200 +++ psqlodbc-08.00.0004.patch/socket.h 2005-02-27 16:18:22.733047000 +020= 0 @@ -34,7 +34,7 @@ =20 #define SOCK_ERRNO errno #define SOCK_ERRNO_SET(e) (errno =3D e) -#ifdef HAVE_SYS_UN_H +#if defined HAVE_SYS_UN_H && !defined HAVE_UNIX_SOCKETS #define HAVE_UNIX_SOCKETS #endif /* HAVE_SYS_UN_H */ #else @@ -121,7 +121,12 @@ /* Socket prototypes */ SocketClass *SOCK_Constructor(const ConnectionClass *conn); void SOCK_Destructor(SocketClass *self); -char SOCK_connect_to(SocketClass *self, unsigned short port, char *host= name); +char SOCK_connect_to(SocketClass *self, unsigned short port, + char *hostname +#ifdef HAVE_UNIX_SOCKETS + , char *uds +#endif + ); void SOCK_get_n_char(SocketClass *self, char *buffer, int len); void SOCK_put_n_char(SocketClass *self, char *buffer, int len); BOOL SOCK_get_string(SocketClass *self, char *buffer, int bufsize); ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.