Docs for service file - Mailing list pgsql-patches
| From | Bruce Momjian |
|---|---|
| Subject | Docs for service file |
| Date | |
| Msg-id | 200301070425.h074PBK13334@candle.pha.pa.us Whole thread Raw |
| Responses |
Re: Docs for service file
|
| List | pgsql-patches |
Here is documentation and a sample file for the libpq service/PGSERVICE
capabilithy we added in 2000. Seems it was never documented. It allows
a central file, pg_service.conf to act as a central location for service
information.
You do connectdb("service=test") and a lookup is done to see the
connection parameters. The code assume pg_service exists in
install_dir/etc. Not sure if that is the right place, but it is a libpq
config file, so none of the other places seemed to make sense. Ideas?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v
retrieving revision 1.104
diff -c -c -r1.104 libpq.sgml
*** doc/src/sgml/libpq.sgml 6 Jan 2003 22:48:16 -0000 1.104
--- doc/src/sgml/libpq.sgml 7 Jan 2003 04:06:52 -0000
***************
*** 1,5 ****
<!--
! $Header: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v 1.104 2003/01/06 22:48:16 momjian Exp $
-->
<chapter id="libpq">
--- 1,5 ----
<!--
! $Header: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v 1.103 2002/12/13 05:49:10 momjian Exp $
-->
<chapter id="libpq">
***************
*** 206,211 ****
--- 206,224 ----
Set to 1 to require SSL connection to the backend. <application>Libpq</>
will then refuse to connect if the server does not support
SSL. Set to 0 (default) to negotiate with server.
+ </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>
Index: src/backend/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/Makefile,v
retrieving revision 1.90
diff -c -c -r1.90 Makefile
*** src/backend/Makefile 6 Jan 2003 03:18:26 -0000 1.90
--- src/backend/Makefile 7 Jan 2003 04:06:52 -0000
***************
*** 140,147 ****
> $(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_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.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)
--- 140,148 ----
> $(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-bin: postgres $(POSTGRES_IMP) installdirs
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
***************
*** 179,186 ****
endif
$(MAKE) -C catalog uninstall-data
rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
$(DESTDIR)$(datadir)/pg_ident.conf.sample \
! $(DESTDIR)$(datadir)/postgresql.conf.sample
##########################################################################
--- 180,188 ----
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
##########################################################################
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.218
diff -c -c -r1.218 fe-connect.c
*** src/interfaces/libpq/fe-connect.c 6 Jan 2003 22:48:16 -0000 1.218
--- src/interfaces/libpq/fe-connect.c 7 Jan 2003 04:07:00 -0000
***************
*** 2338,2351 ****
return 1;
}
! /* As default, 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);
! }
while ((line = fgets(buf, MAXBUFSIZE - 1, f)) != NULL)
{
--- 2338,2348 ----
return 1;
}
! /* 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)
! options[i].val = strdup(service);
while ((line = fgets(buf, MAXBUFSIZE - 1, f)) != NULL)
{
#
# Connection configuration file
#
# A service is a set of named connection parameters. You may specify
# multiple services in this file. Each starts with a service name in
# brackets. Subsequent lines have connection configuration parameters of
# the pattern "param=value". A sample configuration for template1 is
# included in this file. If no database name is specified, it is assumed
# to match the service name. Lines beginning with '#' are comments.
#
# Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
# rename it pg_service.conf.
#
#
#[template1]
#user=postgres
pgsql-patches by date: