OSDN Git Service

Document libpq service capability, and add sample file.
authorBruce Momjian <bruce@momjian.us>
Tue, 7 Jan 2003 04:25:29 +0000 (04:25 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 7 Jan 2003 04:25:29 +0000 (04:25 +0000)
doc/src/sgml/libpq.sgml
src/backend/Makefile
src/interfaces/libpq/fe-connect.c

index 4b6caf4..6dbc13e 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.104 2003/01/06 22:48:16 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.105 2003/01/07 04:25:29 momjian Exp $
 -->
 
  <chapter id="libpq">
@@ -209,6 +209,19 @@ PGconn *PQconnectdb(const char *conninfo)
      </para>
      </listitem>
     </varlistentry>
+
+    <varlistentry>
+     <term><literal>service</literal></term>
+     <listitem>
+     <para>
+      Service name to use for additional parameters.  It specifies a service
+      name in pg_service.conf that holds additional connection parameters.
+      This allows applications to specify only a service name so connection parameters 
+      can be centrally maintained.  See <literal>pg_service.conf.sample</> for
+      information on how to set up the file.
+     </para>
+     </listitem>
+    </varlistentry>
    </variablelist>
 
    If  any  parameter is unspecified, then the corresponding
index 9df4b92..d538880 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.90 2003/01/06 03:18:26 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.91 2003/01/07 04:25:29 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -140,8 +140,9 @@ else
                > $(srcdir)/libpq/pg_hba.conf.sample.no_ipv6
        $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample.no_ipv6 $(DESTDIR)$(datadir)/pg_hba.conf.sample
 endif
+       $(INSTALL_DATA) $(srcdir)/libpq/pg_service.conf.sample $(DESTDIR)$(datadir)/pg_service.conf.sample
        $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample
-       $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
+        $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
 
 install-bin: postgres $(POSTGRES_IMP) installdirs
        $(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
@@ -179,8 +180,9 @@ endif
 endif
        $(MAKE) -C catalog uninstall-data
        rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
+             $(DESTDIR)$(datadir)/pg_service.conf.sample \
              $(DESTDIR)$(datadir)/pg_ident.conf.sample \
-             $(DESTDIR)$(datadir)/postgresql.conf.sample
+              $(DESTDIR)$(datadir)/postgresql.conf.sample
 
 
 ##########################################################################
index 7ff4de0..0e015f1 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.218 2003/01/06 22:48:16 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.219 2003/01/07 04:25:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2338,14 +2338,11 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
                        return 1;
                }
 
-               /* As default, set the database name to the name of the service */
+               /* If not already set, set the database name to the name of the service */
                for (i = 0; options[i].keyword; i++)
                        if (strcmp(options[i].keyword, "dbname") == 0)
-                       {
-                               if (options[i].val != NULL)
-                                       free(options[i].val);
-                               options[i].val = strdup(service);
-                       }
+                               if (options[i].val == NULL)
+                                       options[i].val = strdup(service);
 
                while ((line = fgets(buf, MAXBUFSIZE - 1, f)) != NULL)
                {