Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2150c2e

Browse files
committed
UUNET is looking into offering PostgreSQL as a part of a managed web
hosting product, on both shared and dedicated machines. We currently offer Oracle and MySQL, and it would be a nice middle-ground. However, as shipped, PostgreSQL lacks the following features we need that MySQL has: 1. The ability to listen only on a particular IP address. Each hosting customer has their own IP address, on which all of their servers (http, ftp, real media, etc.) run. 2. The ability to place the Unix-domain socket in a mode 700 directory. This allows us to automatically create an empty database, with an empty DBA password, for new or upgrading customers without having to interactively set a DBA password and communicate it to (or from) the customer. This in turn cuts down our install and upgrade times. 3. The ability to connect to the Unix-domain socket from within a change-rooted environment. We run CGI programs chrooted to the user's home directory, which is another reason why we need to be able to specify where the Unix-domain socket is, instead of /tmp. 4. The ability to, if run as root, open a pid file in /var/run as root, and then setuid to the desired user. (mysqld -u can almost do this; I had to patch it, too). The patch below fixes problem 1-3. I plan to address #4, also, but haven't done so yet. These diffs are big enough that they should give the PG development team something to think about in the meantime :-) Also, I'm about to leave for 2 weeks' vacation, so I thought I'd get out what I have, which works (for the problems it tackles), now. With these changes, we can set up and run PostgreSQL with scripts the same way we can with apache or proftpd or mysql. In summary, this patch makes the following enhancements: 1. Adds an environment variable PGUNIXSOCKET, analogous to MYSQL_UNIX_PORT, and command line options -k --unix-socket to the relevant programs. 2. Adds a -h option to postmaster to set the hostname or IP address to listen on instead of the default INADDR_ANY. 3. Extends some library interfaces to support the above. 4. Fixes a few memory leaks in PQconnectdb(). The default behavior is unchanged from stock 7.0.2; if you don't use any of these new features, they don't change the operation. David J. MacKenzie
1 parent 7633cad commit 2150c2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+627
-87
lines changed

doc/src/sgml/environ.sgml

+12-11
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ $ export PATH
4747
</Para>
4848

4949
<Para>
50-
If your site administrator has not set things up in the
51-
default way, you may have some more work to do. For example, if the database
52-
server machine is a remote machine, you
53-
will need to set the <Acronym>PGHOST</Acronym> environment variable to the name
54-
of the database server machine. The environment variable
55-
<Acronym>PGPORT</Acronym> may also have to be set. The bottom line is this: if
56-
you try to start an application program and it complains
57-
that it cannot connect to the <Application>postmaster</Application>,
58-
you should immediately consult your site administrator to make sure that your
59-
environment is properly set up.
60-
</Para>
50+
51+
If your site administrator has not set things up in the default way,
52+
you may have some more work to do. For example, if the database server
53+
machine is a remote machine, you will need to set the
54+
<Acronym>PGHOST</Acronym> environment variable to the name of the
55+
database server machine. The environment variable
56+
<Acronym>PGPORT</Acronym> or <envar>PGUNIXSOCKET</envar> may also have
57+
to be set. The bottom line is this: if you try to start an application
58+
program and it complains that it cannot connect to the
59+
<Application>postmaster</Application>, you should immediately consult
60+
your site administrator to make sure that your environment is properly
61+
set up. </Para>
6162

6263
</Chapter>

doc/src/sgml/libpq++.sgml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.17 2000/09/29 20:21:34 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.18 2000/11/13 15:18:07 momjian Exp $
33
-->
44

55
<chapter id="libpqplusplus">
@@ -91,6 +91,13 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.17 2000/09/29 20:21:
9191
backend.
9292
</para>
9393
</listitem>
94+
<listitem>
95+
<para>
96+
<envar>PGUNIXSOCKET</envar> sets the full Unix domain socket
97+
file name for communicating with the <productname>Postgres</productname>
98+
backend.
99+
</para>
100+
</listitem>
94101
<listitem>
95102
<para>
96103
<envar>PGDATABASE</envar> sets the default

doc/src/sgml/libpq.sgml

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.44 2000/10/17 14:27:50 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.45 2000/11/13 15:18:07 momjian Exp $
33
-->
44

55
<chapter id="libpq-chapter">
@@ -133,6 +133,15 @@ PGconn *PQconnectdb(const char *conninfo)
133133
</listitem>
134134
</varlistentry>
135135

136+
<varlistentry>
137+
<term><literal>unixsocket</literal></term>
138+
<listitem>
139+
<para>
140+
Full path to Unix-domain socket file to connect to at the server host.
141+
</para>
142+
</listitem>
143+
</varlistentry>
144+
136145
<varlistentry>
137146
<term><literal>dbname</literal></term>
138147
<listitem>
@@ -554,6 +563,16 @@ char *PQport(const PGconn *conn)
554563
</para>
555564
</listitem>
556565

566+
<listitem>
567+
<para>
568+
<function>PQunixsocket</function>
569+
Returns the name of the Unix-domain socket of the connection.
570+
<synopsis>
571+
char *PQunixsocket(const PGconn *conn)
572+
</synopsis>
573+
</para>
574+
</listitem>
575+
557576
<listitem>
558577
<para>
559578
<function>PQtty</function>
@@ -1832,6 +1851,13 @@ backend.
18321851
</listitem>
18331852
<listitem>
18341853
<para>
1854+
<envar>PGPORT</envar> sets the default port or local Unix domain socket
1855+
file extension for communicating with the <productname>Postgres</productname>
1856+
backend.
1857+
</para>
1858+
</listitem>
1859+
<listitem>
1860+
<para>
18351861
<envar>PGDATABASE</envar> sets the default
18361862
<productname>Postgres</productname> database name.
18371863
</para>

doc/src/sgml/ref/createdb.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.11 2000/11/11 23:01:38 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.12 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -56,6 +56,18 @@ Postgres documentation
5656
</listitem>
5757
</varlistentry>
5858

59+
<varlistentry>
60+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
61+
<listitem>
62+
<para>
63+
Specifies the Unix-domain socket on which the
64+
<application>postmaster</application> is running.
65+
Without this option, the socket is created in <filename>/tmp</filename>
66+
based on the port number.
67+
</para>
68+
</listitem>
69+
</varlistentry>
70+
5971
<varlistentry>
6072
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
6173
<listitem>

doc/src/sgml/ref/createlang.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.10 2000/11/11 23:01:38 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.11 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -101,6 +101,18 @@ Postgres documentation
101101
</listitem>
102102
</varlistentry>
103103

104+
<varlistentry>
105+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
106+
<listitem>
107+
<para>
108+
Specifies the Unix-domain socket on which the
109+
<application>postmaster</application> is running.
110+
Without this option, the socket is created in <filename>/tmp</filename>
111+
based on the port number.
112+
</para>
113+
</listitem>
114+
</varlistentry>
115+
104116
<varlistentry>
105117
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
106118
<listitem>

doc/src/sgml/ref/createuser.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.10 2000/11/11 23:01:40 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.11 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -55,6 +55,18 @@ Postgres documentation
5555
</listitem>
5656
</varlistentry>
5757

58+
<varlistentry>
59+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
60+
<listitem>
61+
<para>
62+
Specifies the Unix-domain socket on which the
63+
<application>postmaster</application> is running.
64+
Without this option, the socket is created in <filename>/tmp</filename>
65+
based on the port number.
66+
</para>
67+
</listitem>
68+
</varlistentry>
69+
5870
<varlistentry>
5971
<term>-e, --echo</term>
6072
<listitem>

doc/src/sgml/ref/dropdb.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.4 2000/11/11 23:01:45 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.5 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -55,6 +55,18 @@ Postgres documentation
5555
</listitem>
5656
</varlistentry>
5757

58+
<varlistentry>
59+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
60+
<listitem>
61+
<para>
62+
Specifies the Unix-domain socket on which the
63+
<application>postmaster</application> is running.
64+
Without this option, the socket is created in <filename>/tmp</filename>
65+
based on the port number.
66+
</para>
67+
</listitem>
68+
</varlistentry>
69+
5870
<varlistentry>
5971
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
6072
<listitem>

doc/src/sgml/ref/droplang.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.4 2000/11/11 23:01:45 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.5 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -101,6 +101,18 @@ Postgres documentation
101101
</listitem>
102102
</varlistentry>
103103

104+
<varlistentry>
105+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
106+
<listitem>
107+
<para>
108+
Specifies the Unix-domain socket on which the
109+
<application>postmaster</application> is running.
110+
Without this option, the socket is created in <filename>/tmp</filename>
111+
based on the port number.
112+
</para>
113+
</listitem>
114+
</varlistentry>
115+
104116
<varlistentry>
105117
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
106118
<listitem>

doc/src/sgml/ref/dropuser.sgml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.5 2000/11/11 23:01:45 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.6 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -55,6 +55,18 @@ Postgres documentation
5555
</listitem>
5656
</varlistentry>
5757

58+
<varlistentry>
59+
<term>-k, --unixsocket <replaceable class="parameter">path</replaceable></term>
60+
<listitem>
61+
<para>
62+
Specifies the Unix-domain socket on which the
63+
<application>postmaster</application> is running.
64+
Without this option, the socket is created in <filename>/tmp</filename>
65+
based on the port number.
66+
</para>
67+
</listitem>
68+
</varlistentry>
69+
5870
<varlistentry>
5971
<term>-e, --echo</term>
6072
<listitem>

doc/src/sgml/ref/pg_dump.sgml

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.20 2000/10/05 19:48:18 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.21 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -24,7 +24,9 @@ Postgres documentation
2424
</refsynopsisdivinfo>
2525
<synopsis>
2626
pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
27-
pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
27+
pg_dump [ -h <replaceable class="parameter">host</replaceable> ]
28+
[ -k <replaceable class="parameter">path</replaceable> ]
29+
[ -p <replaceable class="parameter">port</replaceable> ]
2830
[ -t <replaceable class="parameter">table</replaceable> ]
2931
[ -a ] [ -c ] [ -d ] [ -D ] [ -i ] [ -n ] [ -N ]
3032
[ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
@@ -204,6 +206,21 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceab
204206
</listitem>
205207
</varlistentry>
206208

209+
<varlistentry>
210+
<term>-k <replaceable class="parameter">path</replaceable></term>
211+
<listitem>
212+
<para>
213+
Specifies the local Unix domain socket file path
214+
on which the <application>postmaster</application>
215+
is listening for connections.
216+
Without this option, the socket path name defaults to
217+
the value of the <envar>PGUNIXSOCKET</envar> environment
218+
variable (if set), otherwise it is constructed
219+
from the port number.
220+
</para>
221+
</listitem>
222+
</varlistentry>
223+
207224
<varlistentry>
208225
<term>-p <replaceable class="parameter">port</replaceable></term>
209226
<listitem>

doc/src/sgml/ref/pg_dumpall.sgml

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.11 2000/11/02 21:13:31 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.12 2000/11/13 15:18:08 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -23,7 +23,7 @@ Postgres documentation
2323
<date>1999-07-20</date>
2424
</refsynopsisdivinfo>
2525
<synopsis>
26-
pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -a ] [ -d ] [ -D ] [ -O ] [ -s ] [ -u ] [ -v ] [ -x ] [ --accounts-only ]
26+
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 ]
2727
</synopsis>
2828

2929
<refsect2 id="R2-APP-PG-DUMPALL-1">
@@ -149,6 +149,21 @@ pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
149149
</listitem>
150150
</varlistentry>
151151

152+
<varlistentry>
153+
<term>-k <replaceable class="parameter">path</replaceable></term>
154+
<listitem>
155+
<para>
156+
Specifies the local Unix domain socket file path
157+
on which the <application>postmaster</application>
158+
is listening for connections.
159+
Without this option, the socket path name defaults to
160+
the value of the <envar>PGUNIXSOCKET</envar> environment
161+
variable (if set), otherwise it is constructed
162+
from the port number.
163+
</para>
164+
</listitem>
165+
</varlistentry>
166+
152167
<varlistentry>
153168
<term>-p <replaceable class="parameter">port</replaceable></term>
154169
<listitem>

0 commit comments

Comments
 (0)