libpq: Remove deprecated connection parameters authtype and tty
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 9 Mar 2021 14:01:22 +0000 (15:01 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 9 Mar 2021 14:01:22 +0000 (15:01 +0100)
The authtype parameter was deprecated and made inactive in commit
d5bbe2aca55bc8, but the environment variable was left defined and thus
tested with a getenv call even though the value is of no use.  Also,
if it would exist it would be copied but never freed as the cleanup
code had been removed.

tty was deprecated in commit cb7fb3ca958ec8bd5a14e7 but most of the
infrastructure around it remained in place.

Author: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/DDDF36F3-582A-4C02-8598-9B464CC42B34@yesql.se

doc/src/sgml/libpq.sgml
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-int.h
src/test/examples/testlibpq4.c

index 6d2e86a1f5933b7581e853005d40f9a8e1b512ac..2e0c06102ee7386a7d187ab1305275c5566d2a74 100644 (file)
@@ -232,6 +232,11 @@ PGconn *PQsetdbLogin(const char *pghost,
         if it had been passed to <xref linkend="libpq-PQconnectdb"/>, and the remaining
         parameters are then applied as specified for <xref linkend="libpq-PQconnectdbParams"/>.
       </para>
+
+      <para>
+        <literal>pgtty</literal> is no longer used and any value passed will
+        be ignored.
+      </para>
      </listitem>
     </varlistentry>
 
@@ -2119,10 +2124,10 @@ char *PQport(const PGconn *conn);
 
      <listitem>
       <para>
-       Returns the debug <acronym>TTY</acronym> of the connection.
-       (This is obsolete, since the server no longer pays attention
-       to the <acronym>TTY</acronym> setting, but the function remains
-       for backward compatibility.)
+       This function no longer does anything, but it remains for backwards
+       compatibility.  The function always return an empty string, or
+       <symbol>NULL</symbol> if the <parameter>conn</parameter> argument is
+       <symbol>NULL</symbol>.
 
 <synopsis>
 char *PQtty(const PGconn *conn);
index a294d293ebee3accbc2b17fe3969dad8cb68c3fc..aeb64c5bca335d2bea78085810f69157f8672e86 100644 (file)
@@ -120,9 +120,7 @@ static int  ldapServiceLookup(const char *purl, PQconninfoOption *options,
  * by environment variables
  */
 #define DefaultHost        "localhost"
-#define DefaultTty     ""
 #define DefaultOption  ""
-#define DefaultAuthtype          ""
 #ifdef USE_SSL
 #define DefaultChannelBinding  "prefer"
 #else
@@ -192,14 +190,6 @@ typedef struct _internalPQconninfoOption
 } internalPQconninfoOption;
 
 static const internalPQconninfoOption PQconninfoOptions[] = {
-   /*
-    * "authtype" is no longer used, so mark it "don't show".  We keep it in
-    * the array so as not to reject conninfo strings from old apps that might
-    * still try to set it.
-    */
-   {"authtype", "PGAUTHTYPE", DefaultAuthtype, NULL,
-   "Database-Authtype", "D", 20, -1},
-
    {"service", "PGSERVICE", NULL, NULL,
    "Database-Service", "", 20, -1},
 
@@ -243,14 +233,6 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
        "Client-Encoding", "", 10,
    offsetof(struct pg_conn, client_encoding_initial)},
 
-   /*
-    * "tty" is no longer used either, but keep it present for backwards
-    * compatibility.
-    */
-   {"tty", "PGTTY", DefaultTty, NULL,
-       "Backend-Debug-TTY", "D", 40,
-   offsetof(struct pg_conn, pgtty)},
-
    {"options", "PGOPTIONS", DefaultOption, NULL,
        "Backend-Options", "", 40,
    offsetof(struct pg_conn, pgoptions)},
@@ -1581,15 +1563,6 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
            goto oom_error;
    }
 
-   if (pgtty && pgtty[0] != '\0')
-   {
-       if (conn->pgtty)
-           free(conn->pgtty);
-       conn->pgtty = strdup(pgtty);
-       if (!conn->pgtty)
-           goto oom_error;
-   }
-
    if (login && login[0] != '\0')
    {
        if (conn->pguser)
@@ -4031,8 +4004,6 @@ freePGconn(PGconn *conn)
        free(conn->pghostaddr);
    if (conn->pgport)
        free(conn->pgport);
-   if (conn->pgtty)
-       free(conn->pgtty);
    if (conn->connect_timeout)
        free(conn->connect_timeout);
    if (conn->pgtcp_user_timeout)
@@ -6633,12 +6604,16 @@ PQport(const PGconn *conn)
    return "";
 }
 
+/*
+ * No longer does anything, but the function remains for API backwards
+ * compatibility.
+ */
 char *
 PQtty(const PGconn *conn)
 {
    if (!conn)
        return NULL;
-   return conn->pgtty;
+   return "";
 }
 
 char *
index cca98c14bf88a4c165dc31d3c222413e1a19373c..0965c5ac511be17c6b8d1bcbeec5b3d2bea61766 100644 (file)
@@ -338,8 +338,6 @@ struct pg_conn
                                 * precedence over pghost. */
    char       *pgport;         /* the server's communication port number, or
                                 * a comma-separated list of ports */
-   char       *pgtty;          /* tty on which the backend messages is
-                                * displayed (OBSOLETE, NOT USED) */
    char       *connect_timeout;    /* connection timeout (numeric string) */
    char       *pgtcp_user_timeout; /* tcp user timeout (numeric string) */
    char       *client_encoding_initial;    /* encoding to use */
index dd11bbc46dc3d895da5f604f1781705302c2feb5..da4443072da32f3b68921fa01b054189ce3bef5d 100644 (file)
@@ -50,8 +50,7 @@ main(int argc, char **argv)
 {
    char       *pghost,
               *pgport,
-              *pgoptions,
-              *pgtty;
+              *pgoptions;
    char       *dbName1,
               *dbName2;
    char       *tblName;
@@ -88,13 +87,12 @@ main(int argc, char **argv)
    pgport = NULL;              /* port of the backend */
    pgoptions = NULL;           /* special options to start up the backend
                                 * server */
-   pgtty = NULL;               /* debugging tty for the backend */
 
    /* make a connection to the database */
-   conn1 = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName1);
+   conn1 = PQsetdb(pghost, pgport, pgoptions, NULL, dbName1);
    check_prepare_conn(conn1, dbName1);
 
-   conn2 = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName2);
+   conn2 = PQsetdb(pghost, pgport, pgoptions, NULL, dbName2);
    check_prepare_conn(conn2, dbName2);
 
    /* start a transaction block */