OK, I have removed the -k unix socketpath option from the client side of
this patch, and modified libpq so if they specify a host with a leading
slash, it will be considered a unix socket path.  Attached is the
relevant patch to libpq.


> > Bruce Momjian writes:
> > 
> > > > Bruce Momjian writes:
> > > > 
> > > > > I am tempted to apply this.  This is the second person who asked for
> > > > > binding to a single port.  The patch looks quite complete, with doc
> > > > > changes.  It appears to be a thorough job.
> > > > 
> > > > Postmaster options are evil, please put something in backend/utils/guc.c.  
> > > > (This is not the fault of the patch submitter, since this interface is new
> > > > for 7.1, but that still doesn't mean we should subvert it.)
> > > 
> > > I have put code in guc.c to handle this, but there still are postmaster
> > > options for it too.


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [EMAIL PROTECTED]               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: fe-connect.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.145
diff -c -r1.145 fe-connect.c
*** fe-connect.c        2000/11/13 15:18:15     1.145
--- fe-connect.c        2000/11/13 23:36:38
***************
*** 332,337 ****
--- 332,356 ----
        PQconninfoFree(connOptions);
  
        /* ----------
+        * Allow unix socket specification in the host name
+        * ----------
+        */
+       if (conn->pghost && conn->pghost[0] == '/')
+       {
+               if (conn->pgunixsocket)
+                       free(conn->pgunixsocket);
+               conn->pgunixsocket = conn->pghost;
+               conn->pghost = NULL;
+       }
+       if (conn->pghostaddr && conn->pghostaddr[0] == '/')
+       {
+               if (conn->pgunixsocket)
+                       free(conn->pgunixsocket);
+               conn->pgunixsocket = conn->pghostaddr;
+               conn->pghostaddr = NULL;
+       }
+ 
+       /* ----------
         * Connect to the database
         * ----------
         */
***************
*** 443,455 ****
        else
                conn->pgport = strdup(pgport);
  
! #if FIX_ME
!       /* we need to modify the function to accept a unix socket path */
!       if (pgunixsocket)
!               conn->pgunixsocket = strdup(pgunixsocket);
!       else if ((tmp = getenv("PGUNIXSOCKET")) != NULL)
!               conn->pgunixsocket = strdup(tmp);
! #endif
  
        if (pgtty == NULL)
        {
--- 462,486 ----
        else
                conn->pgport = strdup(pgport);
  
!       /* ----------
!        * We don't allow unix socket path as a function parameter.
!        * This allows unix socket specification in the host name.
!        * ----------
!        */
!       if (conn->pghost && conn->pghost[0] == '/')
!       {
!               if (conn->pgunixsocket)
!                       free(conn->pgunixsocket);
!               conn->pgunixsocket = conn->pghost;
!               conn->pghost = NULL;
!       }
!       if (conn->pghostaddr && conn->pghostaddr[0] == '/')
!       {
!               if (conn->pgunixsocket)
!                       free(conn->pgunixsocket);
!               conn->pgunixsocket = conn->pghostaddr;
!               conn->pghostaddr = NULL;
!       }
  
        if (pgtty == NULL)
        {
***************
*** 778,784 ****
                {
                        printfPQExpBuffer(&conn->errorMessage,
                                                          "connectDBStart() -- "
!                                                "invalid host address: %s\n", 
conn->pghostaddr);
                        goto connect_errReturn;
                }
  
--- 809,815 ----
                {
                        printfPQExpBuffer(&conn->errorMessage,
                                                          "connectDBStart() -- "
!                                                         "invalid host address: 
%s\n", conn->pghostaddr);
                        goto connect_errReturn;
                }
  

Reply via email to