Remove -k unix socketpath option from client side, allow hostname with
authorBruce Momjian <bruce@momjian.us>
Mon, 13 Nov 2000 23:37:54 +0000 (23:37 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 13 Nov 2000 23:37:54 +0000 (23:37 +0000)
leading slash to behave as a unix socket path.

32 files changed:
doc/src/sgml/libpq.sgml
doc/src/sgml/ref/createdb.sgml
doc/src/sgml/ref/createlang.sgml
doc/src/sgml/ref/createuser.sgml
doc/src/sgml/ref/dropdb.sgml
doc/src/sgml/ref/droplang.sgml
doc/src/sgml/ref/dropuser.sgml
doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_dumpall.sgml
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/vacuumdb.sgml
src/backend/postmaster/postmaster.c
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_restore.c
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/help.c
src/bin/psql/prompt.c
src/bin/psql/startup.c
src/bin/scripts/createdb
src/bin/scripts/createlang.sh
src/bin/scripts/createuser
src/bin/scripts/dropdb
src/bin/scripts/droplang
src/bin/scripts/dropuser
src/bin/scripts/vacuumdb
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-int.h

index 28f772afc74e7e16b7247309d53ccd6e31b1b6b2..aec57bc47ff8aeb7ba4c893f11d62d146b37d7a2 100644 (file)
@@ -1844,9 +1844,9 @@ Without a host name, libpq will connect using a local Unix domain socket.
 </listitem>
 <listitem>
 <para>
-<envar>PGPORT</envar>  sets the default port or local Unix domain socket
-file extension for communicating with the <productname>Postgres</productname>
-backend.
+<envar>PGPORT</envar> and <envar>PGUNIXSOCKET</envar> set the default
+port or local Unix domain socket file extension for communicating with
+the <productname>Postgres</productname> backend.
 </para>
 </listitem>
 <listitem>
index 11ee9daa3d3d020a7f17486d0319f3107de514d0..dc0544bc859ae2b796b868e64c50488ff1bdd72b 100644 (file)
@@ -56,18 +56,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-U, --username <replaceable class="parameter">username</replaceable></term>
       <listitem>
index 77781d0c34e2bd135c11989019833ddd71d691b9..42cdfad5de342f4e9435bd3ceb54e07bc6176c09 100644 (file)
@@ -101,18 +101,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-U, --username <replaceable class="parameter">username</replaceable></term>
       <listitem>
index 24ce46a96bde0a91f6b72af32aba882fdcef8b26..0dd0e466fd40f81f867535fdea63ce761a9ee1d8 100644 (file)
@@ -55,18 +55,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-e, --echo</term>
       <listitem>
index c090908d83ee464810bca8ee3a48f10aa30e71e5..792410406137ee3f039b29256076264e33d8830d 100644 (file)
@@ -55,18 +55,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-U, --username <replaceable class="parameter">username</replaceable></term>
       <listitem>
index 84551fa108d8a69cedfa2733358f5508e91b3c9b..406d0b08a582eef886a0589e71aedcecddba76db 100644 (file)
@@ -101,18 +101,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-U, --username <replaceable class="parameter">username</replaceable></term>
       <listitem>
index b39ad281f3cafe4b89c0335d2df6013652b8d249..de8a78e3e9a64e4b3200e722976d48179a47945c 100644 (file)
@@ -55,18 +55,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-e, --echo</term>
       <listitem>
index 29d48f1545b0d4485476b4cad03cf9c87a3aaab7..1a50c8338086dfa33f9921ce39ac040246708afa 100644 (file)
@@ -25,7 +25,6 @@ Postgres documentation
   <synopsis>
 pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
 pg_dump [ -h <replaceable class="parameter">host</replaceable> ]
-    [ -k <replaceable class="parameter">path</replaceable> ]
     [ -p <replaceable class="parameter">port</replaceable> ]
     [ -t <replaceable class="parameter">table</replaceable> ]
     [ -a ] [ -c ] [ -d ] [ -D ] [ -i ] [ -n ] [ -N ]
@@ -206,21 +205,6 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ]
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term>-k <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-       <para>
-       Specifies the local Unix domain socket file path
-       on which the <application>postmaster</application>
-       is listening for connections.
-        Without this option, the socket path name defaults to
-        the value of the <envar>PGUNIXSOCKET</envar> environment
-       variable (if set), otherwise it is constructed
-        from the port number.
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry>
       <term>-p <replaceable class="parameter">port</replaceable></term>
       <listitem>
index e8b7c32294f0138207c6d82f6cb5bf11053e8681..b2905e7387bac6c1b8b9abfa60e07e790c328fde 100644 (file)
@@ -23,7 +23,7 @@ Postgres documentation
    <date>1999-07-20</date>
   </refsynopsisdivinfo>
   <synopsis>
-pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -k <replaceable class="parameter">path</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -a ] [ -d ] [ -D ] [ -O ] [ -s ] [ -u ] [ -v ] [ -x ] [ --accounts-only ]
+pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -a ] [ -d ] [ -D ] [ -O ] [ -s ] [ -u ] [ -v ] [ -x ] [ --accounts-only ]
   </synopsis>
 
   <refsect2 id="R2-APP-PG-DUMPALL-1">
@@ -149,21 +149,6 @@ pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -k <replac
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term>-k <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-       <para>
-       Specifies the local Unix domain socket file path
-       on which the <application>postmaster</application>
-       is listening for connections.
-        Without this option, the socket path name defaults to
-        the value of the <envar>PGUNIXSOCKET</envar> environment
-       variable (if set), otherwise it is constructed
-        from the port number.
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry>
       <term>-p <replaceable class="parameter">port</replaceable></term>
       <listitem>
index 08348451310f2d5f7523d55b142fbf378385d301..6563854785e4eeab8f50ddc900780c2e17d1817a 100644 (file)
@@ -1329,19 +1329,6 @@ Access permissions for database "test"
     </varlistentry>
 
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
-
     <varlistentry>
       <term>-H, --html</term>
       <listitem>
index 8d6961c6cc5e6ffff4f969d93292cc26fa83b9a9..368a82f23306e7ffec0d6a434674a7331252ce47 100644 (file)
@@ -136,18 +136,6 @@ Postgres documentation
       </listitem>
      </varlistentry>
 
-    <varlistentry>
-      <term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
-      <listitem>
-      <para>
-      Specifies the Unix-domain socket on which the
-      <application>postmaster</application> is running.
-      Without this option, the socket is created in <filename>/tmp</filename>
-      based on the port number.
-      </para>
-      </listitem>
-    </varlistentry>
-
      <varlistentry>
       <term>-U <replaceable class="parameter">username</replaceable></term>
       <term>--username <replaceable class="parameter">username</replaceable></term>
index a6c3219474bcf679af343554713c51998c3214b7..6079d92bdf1fbf78ae99d4c93fb6fa44f05c8277 100644 (file)
@@ -1334,8 +1334,8 @@ get_host_port(void)
                {
                        char msg[1024];
                        snprintf(msg, sizeof(msg),
-                                "FATAL: get_host_port: gethostbyname(%s) failed: %s\n",
-                                HostName, hstrerror(h_errno));
+                                "FATAL: get_host_port: gethostbyname(%s) failed\n",
+                                HostName);
                        fputs(msg, stderr);
                        pqdebug("%s", msg);
                        exit(1);
index ffe071a6655f7147ee2f059521b8abbb906e3b7b..8fceb26c8e24645bd2c010947e508f1d19b86157 100644 (file)
@@ -99,9 +99,8 @@ typedef struct _restoreOptions {
 
        int                     useDB;
        char            *dbname;
-       char            *pghost;
        char            *pgport;
-       char            *pgunixsocket;
+       char            *pghost;
        int                     ignoreVersion;
        int                     requirePassword;
 
@@ -123,7 +122,6 @@ PGconn* ConnectDatabase(Archive *AH,
                const char*     dbname,
                const char*     pghost,
                const char*     pgport,
-               const char*     pgunixsocket,
                const int       reqPwd,
                const int       ignoreVersion);
 
index 085a2eb3297189f6596757cff9f9beb1f4d6d1e8..d8a969b41e0279623081d0869737c869be389845 100644 (file)
@@ -131,9 +131,8 @@ void RestoreArchive(Archive* AHX, RestoreOptions *ropt)
                if (AH->version < K_VERS_1_3)
                        die_horribly(AH, "Direct database connections are not supported in pre-1.3 archives");
 
-               ConnectDatabase(AHX, ropt->dbname, ropt->pghost, ropt->pgport,
-                                                       ropt->pgunixsocket, ropt->requirePassword,
-                                                       ropt->ignoreVersion);
+               ConnectDatabase(AHX, ropt->dbname, ropt->pghost, ropt->pgport, 
+                                                       ropt->requirePassword, ropt->ignoreVersion);
 
                /*
                 * If no superuser was specified then see if the current user will do...
index a938f5e3395bb15b6ef1c6a467904477fe21a743..2c7291e6c6917f678c6711c2ecac34c532546412 100644 (file)
@@ -187,7 +187,6 @@ typedef struct _archiveHandle {
        char                            *archdbname;            /* DB name *read* from archive */
        char                            *pghost;
        char                            *pgport;
-       char                            *pgunixsocket;
        PGconn                          *connection;
        PGconn                          *blobConnection;        /* Connection for BLOB xref */
        int                                     txActive;                       /* Flag set if TX active on connection */
index 082edd582417ccf190223934becede5cc8f0df87..72189eb29fbe7433b338cf0a37b465bdc3721f0f 100644 (file)
@@ -273,7 +273,6 @@ PGconn* ConnectDatabase(Archive *AHX,
                const char*     dbname,
                const char*     pghost,
                const char*     pgport,
-               const char*     pgunixsocket,
                const int               reqPwd,
                const int               ignoreVersion)
 {
@@ -308,15 +307,6 @@ PGconn* ConnectDatabase(Archive *AHX,
        else
            AH->pgport = NULL;
 
-       if (pgunixsocket != NULL)
-       {
-               AH->pgport = strdup(pgunixsocket);
-               sprintf(tmp_string, "unixsocket=%s ", AH->pgunixsocket);
-               strcat(connect_string, tmp_string);
-       }
-       else
-           AH->pgunixsocket = NULL;
-
        sprintf(tmp_string, "dbname=%s ", AH->dbname);
        strcat(connect_string, tmp_string);
 
index c052acbfa5f7a446706bfbbfe54b088e1b6e9dd8..e107086b21322cda4e28801b4a7748da66af4a40 100644 (file)
@@ -200,7 +200,6 @@ help(const char *progname)
                "  -F, --format {c|f|p}     output file format (custom, files, plain text)\n"
                "  -h, --host <hostname>    server host name\n"
                "  -i, --ignore-version     proceed when database version != pg_dump version\n"
-               "  -k, --unixsocket <path>  server Unix-domain socket name\n"
                "  -n, --no-quotes          suppress most quotes around identifiers\n"
                "  -N, --quotes             enable most quotes around identifiers\n"
                "  -o, --oids               dump object ids (oids)\n"
@@ -227,7 +226,6 @@ help(const char *progname)
                "  -F {c|f|p}               output file format (custom, files, plain text)\n"
                "  -h <hostname>            server host name\n"
                "  -i                       proceed when database version != pg_dump version\n"
-               "  -k <path>                server Unix-domain socket name\n"
                "  -n                       suppress most quotes around identifiers\n"
                "  -N                       enable most quotes around identifiers\n"
                "  -o                       dump object ids (oids)\n"
@@ -631,7 +629,6 @@ main(int argc, char **argv)
        const char *dbname = NULL;
        const char *pghost = NULL;
        const char *pgport = NULL;
-       const char *pgunixsocket = NULL;
        char       *tablename = NULL;
        bool            oids = false;
        TableInfo  *tblinfo;
@@ -661,7 +658,6 @@ main(int argc, char **argv)
                {"attribute-inserts", no_argument, NULL, 'D'},
                {"host", required_argument, NULL, 'h'},
                {"ignore-version", no_argument, NULL, 'i'},
-               {"unixsocket", required_argument, NULL, 'k'},
                {"no-reconnect", no_argument, NULL, 'R'},
                {"no-quotes", no_argument, NULL, 'n'},
                {"quotes", no_argument, NULL, 'N'},
@@ -756,10 +752,6 @@ main(int argc, char **argv)
                                ignore_version = true;
                                break;
 
-                       case 'k':                       /* server Unix-domain socket */
-                               pgunixsocket = optarg;
-                               break;
-
                        case 'n':                       /* Do not force double-quotes on
                                                                 * identifiers */
                                force_quotes = false;
@@ -956,8 +948,7 @@ main(int argc, char **argv)
        dbname = argv[optind];
 
        /* Open the database using the Archiver, so it knows about it. Errors mean death */
-       g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, pgunixsocket,
-                                                        use_password, ignore_version);
+       g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, use_password, ignore_version);
 
        /*
         * Start serializable transaction to dump consistent data
index cafb7e9df602a5e8b1d6c86a15942c1f57a538ca..458482ed5112d2ed093c7a6a44b1cb4afda685e2 100644 (file)
@@ -101,7 +101,6 @@ struct option cmdopts[] = {
                                { "ignore-version", 0, NULL, 'i'},
                                { "index", 2, NULL, 'I'},
                                { "list", 0, NULL, 'l'},
-                               { "unixsocket", 1, NULL, 'k' },
                                { "no-acl", 0, NULL, 'x' },
                                { "no-owner", 0, NULL, 'O'},
                                { "no-reconnect", 0, NULL, 'R' },
@@ -133,9 +132,9 @@ int main(int argc, char **argv)
        progname = *argv;
 
 #ifdef HAVE_GETOPT_LONG
-       while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:k:lNoOp:P:rRsS:t:T:uU:vx", cmdopts, NULL)) != EOF)
+       while ((c = getopt_long(argc, argv, "acCd:f:F:h:i:lNoOp:P:rRsS:t:T:uU:vx", cmdopts, NULL)) != EOF)
 #else
-       while ((c = getopt(argc, argv, "acCd:f:F:h:i:k:lNoOp:P:rRsS:t:T:uU:vx")) != -1)
+       while ((c = getopt(argc, argv, "acCd:f:F:h:i:lNoOp:P:rRsS:t:T:uU:vx")) != -1)
 #endif
        {
                switch (c)
@@ -171,10 +170,6 @@ int main(int argc, char **argv)
                        case 'i':
                                opts->ignoreVersion = 1;
                                break;
-                       case 'k':
-                               if (strlen(optarg) != 0)
-                                       opts->pgunixsocket = strdup(optarg);
-                               break;
                        case 'N':
                                opts->origOrder = 1;
                                break;
index 38303b379a5db3906e2e649d12cbd1bba96a7dc2..868159768f5cda54514b96c0499de509fd6ce582 100644 (file)
@@ -1202,7 +1202,6 @@ do_connect(const char *new_dbname, const char *new_user)
        SetVariable(pset.vars, "USER", NULL);
        SetVariable(pset.vars, "HOST", NULL);
        SetVariable(pset.vars, "PORT", NULL);
-       SetVariable(pset.vars, "UNIXSOCKET", NULL);
        SetVariable(pset.vars, "ENCODING", NULL);
 
        /* If dbname is "" then use old name, else new one (even if NULL) */
@@ -1232,7 +1231,6 @@ do_connect(const char *new_dbname, const char *new_user)
        do
        {
                need_pass = false;
-               /* FIXME use PQconnectdb to support passing the Unix socket */
                pset.db = PQsetdbLogin(PQhost(oldconn), PQport(oldconn),
                                                           NULL, NULL, dbparam, userparam, pwparam);
 
@@ -1309,7 +1307,6 @@ do_connect(const char *new_dbname, const char *new_user)
        SetVariable(pset.vars, "USER", PQuser(pset.db));
        SetVariable(pset.vars, "HOST", PQhost(pset.db));
        SetVariable(pset.vars, "PORT", PQport(pset.db));
-       SetVariable(pset.vars, "UNIXSOCKET", PQunixsocket(pset.db));
        SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
 
        pset.issuper = test_superuser(PQuser(pset.db));
index 78201c1313adb351974d2006b37c2665b7cc582e..ed37cb35c8d41760665cfd00995a8bc68e9f157f 100644 (file)
@@ -329,7 +329,6 @@ PSQLexec(const char *query)
                        SetVariable(pset.vars, "DBNAME", NULL);
                        SetVariable(pset.vars, "HOST", NULL);
                        SetVariable(pset.vars, "PORT", NULL);
-                       SetVariable(pset.vars, "UNIXSOCKET", NULL);
                        SetVariable(pset.vars, "USER", NULL);
                        SetVariable(pset.vars, "ENCODING", NULL);
                        return NULL;
@@ -509,7 +508,6 @@ SendQuery(const char *query)
                                SetVariable(pset.vars, "DBNAME", NULL);
                                SetVariable(pset.vars, "HOST", NULL);
                                SetVariable(pset.vars, "PORT", NULL);
-                               SetVariable(pset.vars, "UNIXSOCKET", NULL);
                                SetVariable(pset.vars, "USER", NULL);
                                SetVariable(pset.vars, "ENCODING", NULL);
                                return false;
index 5c4ff62a7934b6f3e4f2c1a20e652185cf8bc24c..8c601ab5771fcf0c0a19968cc4f4a556c18ae7cd 100644 (file)
@@ -103,16 +103,6 @@ usage(void)
        puts(")");
 
        puts("  -H              HTML table output mode (-P format=html)");
-
-       /* Display default Unix-domain socket */
-       env = getenv("PGUNIXSOCKET");
-       printf("  -k <path>       Specify Unix domain socket name (default: ");
-       if (env)
-               fputs(env, stdout);
-       else
-               fputs("computed from the port", stdout);
-       puts(")");
-
        puts("  -l              List available databases, then exit");
        puts("  -n              Disable readline");
        puts("  -o <filename>   Send query output to filename (or |pipe)");
index 6b06e4d184a5cd031d66012e9601b01f151ce38e..304922d65ef5ca8065551332e296e33298e9365d 100644 (file)
@@ -190,11 +190,6 @@ get_prompt(promptStatus_t status)
                                        if (pset.db && PQport(pset.db))
                                                strncpy(buf, PQport(pset.db), MAX_PROMPT_SIZE);
                                        break;
-                                       /* DB server Unix-domain socket */
-                               case '<':
-                                       if (pset.db && PQunixsocket(pset.db))
-                                               strncpy(buf, PQunixsocket(pset.db), MAX_PROMPT_SIZE);
-                                       break;
                                        /* DB server user name */
                                case 'n':
                                        if (pset.db)
index e7b6ab6e86d69de58883ad72fbfd7c5227e1cf9a..8cd8168cd12abd4981119d04f80383ed3c19d1c7 100644 (file)
@@ -65,7 +65,6 @@ struct adhoc_opts
        char       *dbname;
        char       *host;
        char       *port;
-       char       *unixsocket;
        char       *username;
        enum _actions action;
        char       *action_string;
@@ -162,7 +161,6 @@ main(int argc, char *argv[])
        do
        {
                need_pass = false;
-               /* FIXME use PQconnectdb to allow setting the unix socket */
                pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
                        options.action == ACT_LIST_DB ? "template1" : options.dbname,
                                                           username, password);
@@ -208,7 +206,6 @@ main(int argc, char *argv[])
        SetVariable(pset.vars, "USER", PQuser(pset.db));
        SetVariable(pset.vars, "HOST", PQhost(pset.db));
        SetVariable(pset.vars, "PORT", PQport(pset.db));
-       SetVariable(pset.vars, "UNIXSOCKET", PQunixsocket(pset.db));
        SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
 
 #ifndef WIN32
@@ -323,7 +320,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
                {"field-separator", required_argument, NULL, 'F'},
                {"host", required_argument, NULL, 'h'},
                {"html", no_argument, NULL, 'H'},
-               {"unixsocket", required_argument, NULL, 'k'},
                {"list", no_argument, NULL, 'l'},
                {"no-readline", no_argument, NULL, 'n'},
                {"output", required_argument, NULL, 'o'},
@@ -357,14 +353,14 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
        memset(options, 0, sizeof *options);
 
 #ifdef HAVE_GETOPT_LONG
-       while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:lh:Hk:no:p:P:qRsStT:uU:v:VWxX?", long_options, &optindex)) != -1)
+       while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?", long_options, &optindex)) != -1)
 #else                                                  /* not HAVE_GETOPT_LONG */
 
        /*
         * Be sure to leave the '-' in here, so we can catch accidental long
         * options.
         */
-       while ((c = getopt(argc, argv, "aAc:d:eEf:F:lh:Hk:no:p:P:qRsStT:uU:v:VWxX?-")) != -1)
+       while ((c = getopt(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?-")) != -1)
 #endif  /* not HAVE_GETOPT_LONG */
        {
                switch (c)
@@ -410,9 +406,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
                        case 'l':
                                options->action = ACT_LIST_DB;
                                break;
-                       case 'k':
-                               options->unixsocket = optarg;
-                               break;
                        case 'n':
                                options->no_readline = true;
                                break;
index 35eeb463e3b4498d9f6040489bdb60cd7916a6e6..07e0f015289eb1c79b0e7b545b0d2ba07ef900df 100644 (file)
@@ -50,15 +50,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
        --username|-U)
                PSQLOPT="$PSQLOPT -U $2"
                shift;;
@@ -123,7 +114,6 @@ if [ "$usage" ]; then
        echo "  -E, --encoding=ENCODING         Multibyte encoding for the database"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -e, --echo                      Show the query being sent to the backend"
index 3da2cad59f3d715611fb5dc8ab930a241bef776e..e17174889639836a643a8952b2a1bc19a06a572f 100644 (file)
@@ -65,15 +65,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
        --username|-U)
                PSQLOPT="$PSQLOPT -U $2"
                shift;;
@@ -135,7 +126,6 @@ if [ "$usage" ]; then
        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -d, --dbname=DBNAME             Database to install language in"
index 69ea4bc61b18b0cc4c446173c4e10830d4b423d6..9d46d88a58863ef240724886cf5248f6f3ab0319 100644 (file)
@@ -63,15 +63,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
 # Note: These two specify the user to connect as (like in psql),
 #       not the user you're creating.
        --username|-U)
@@ -144,7 +135,6 @@ if [ "$usage" ]; then
        echo "  -P, --pwprompt                  Assign a password to new user"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as (not the one to create)"
        echo "  -W, --password                  Prompt for password to connect"
        echo "  -e, --echo                      Show the query being sent to the backend"
index 75b8a6221fdf082af512a81ac69bd0d229288734..fccfecf6e00b9f31f23072c226184658cef17c0f 100644 (file)
@@ -59,15 +59,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
        --username|-U)
                PSQLOPT="$PSQLOPT -U $2"
                shift;;
@@ -112,7 +103,6 @@ if [ "$usage" ]; then
        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -i, --interactive               Prompt before deleting anything"
index 778f77c7d1f30c71591fa19aebcbf01da62bdafc..6ba26c7642ade449b469ae53d731c0989f6df7f6 100644 (file)
@@ -65,15 +65,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
        --username|-U)
                PSQLOPT="$PSQLOPT -U $2"
                shift;;
@@ -122,7 +113,6 @@ if [ "$usage" ]; then
        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -d, --dbname=DBNAME             Database to remove language from"
index 458aa84fe6bbf6e4e7d71c14afc57fc0fb14da2c..3282a3d61e0f4d92da734787346fd710526bd05e 100644 (file)
@@ -59,15 +59,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
 # Note: These two specify the user to connect as (like in psql),
 #       not the user you're dropping.
        --username|-U)
@@ -114,7 +105,6 @@ if [ "$usage" ]; then
        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as (not the one to drop)"
        echo "  -W, --password                  Prompt for password to connect"
        echo "  -i, --interactive               Prompt before deleting anything"
index 930b6b38104998cfa830e6e0635f3d050a6c49bf..de46af0371b4659e5a0c02091ba3b6a45d958ed0 100644 (file)
@@ -52,15 +52,6 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --unixsocket|-k)
-               PSQLOPT="$PSQLOPT -k $2"
-               shift;;
-        -k*)
-                PSQLOPT="$PSQLOPT $1"
-                ;;
-        --unixsocket=*)
-                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
-                ;;
        --username|-U)
                PSQLOPT="$PSQLOPT -U $2"
                shift;;
@@ -130,7 +121,6 @@ if [ "$usage" ]; then
         echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
-       echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -d, --dbname=DBNAME             Database to vacuum"
index 39e32770d58499694e9312f1e3c62295fd63c1b3..24d122e030a6b101fb023ad1c14c37456ae61d4a 100644 (file)
@@ -331,6 +331,25 @@ PQconnectStart(const char *conninfo)
         */
        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,13 +462,25 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
        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
+       /* ----------
+        * 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,7 +809,7 @@ connectDBStart(PGconn *conn)
                {
                        printfPQExpBuffer(&conn->errorMessage,
                                                          "connectDBStart() -- "
-                                                "invalid host address: %s\n", conn->pghostaddr);
+                                                         "invalid host address: %s\n", conn->pghostaddr);
                        goto connect_errReturn;
                }
 
index 6786ccb6a1ac3a3d19328f5762a93bc72e06904d..4945f63b9806ce5fedf06e2c62ea00ddaabe6b73 100644 (file)
@@ -203,8 +203,8 @@ struct pg_conn
                                                                 * numbers-and-dots notation. Takes
                                                                 * precedence over above. */
        char       *pgport;                     /* the server's communication port */
-       char       *pgunixsocket;               /* the Unix-domain socket that the server is listening on;
-                                                * if NULL, uses a default constructed from pgport */
+       char       *pgunixsocket;       /* the Unix-domain socket that the server is listening on;
+                                                                * if NULL, uses a default constructed from pgport */
        char       *pgtty;                      /* tty on which the backend messages is
                                                                 * displayed (NOT ACTUALLY USED???) */
        char       *pgoptions;          /* options to start the backend with */