Updated user interfaces on initdb, initlocation, pg_dump, ipcclean to a GNU-compliant'ish state.
Made ipcclean work on Linux.
This commit is contained in:
parent
9e0b463473
commit
28125ed5e0
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.7 2000/01/15 18:30:27 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.8 2000/01/18 00:03:34 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ Postgres documentation
|
|||||||
initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
|
initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
|
||||||
[ --sysid|-i <replaceable class="parameter">sysid</replaceable> ]
|
[ --sysid|-i <replaceable class="parameter">sysid</replaceable> ]
|
||||||
[ --pwprompt|-W ]
|
[ --pwprompt|-W ]
|
||||||
[ --encoding|-e <replaceable class="parameter">encoding</replaceable> ]
|
[ --encoding|-E <replaceable class="parameter">encoding</replaceable> ]
|
||||||
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
|
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
|
||||||
[ --username|-u <replaceable class="parameter">name</replaceable> ]
|
[ --username|-u <replaceable class="parameter">name</replaceable> ]
|
||||||
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
|
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
|
||||||
@ -85,7 +85,7 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
|
|||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>--encoding=<replaceable class="parameter">encoding</replaceable></term>
|
<term>--encoding=<replaceable class="parameter">encoding</replaceable></term>
|
||||||
<term>-e <replaceable class="parameter">encoding</replaceable></term>
|
<term>-E <replaceable class="parameter">encoding</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Selects the multibyte encoding of the template database. This will also
|
Selects the multibyte encoding of the template database. This will also
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/initlocation.sgml,v 1.4 1999/07/22 15:09:12 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/initlocation.sgml,v 1.5 2000/01/18 00:03:34 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -15,17 +15,15 @@ Postgres documentation
|
|||||||
<application>initlocation</application>
|
<application>initlocation</application>
|
||||||
</refname>
|
</refname>
|
||||||
<refpurpose>
|
<refpurpose>
|
||||||
Create a secondary <productname>Postgres</productname> database storage area
|
Create a secondary <productname>PostgreSQL</productname> database storage area
|
||||||
</refpurpose>
|
</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<refsynopsisdivinfo>
|
<refsynopsisdivinfo>
|
||||||
<date>1999-07-20</date>
|
<date>2000-01-17</date>
|
||||||
</refsynopsisdivinfo>
|
</refsynopsisdivinfo>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble> | -D <replaceable class="parameter">altdir</replaceable> ]
|
initlocation <replaceable class="parameter">directory</replaceable>
|
||||||
[ --username=<replaceable class="parameter">name</replaceable> | -u <replaceable class="parameter">name</replaceable> ]
|
|
||||||
[ <replaceable class="parameter">altdir</replaceable> ]
|
|
||||||
</synopsis>
|
</synopsis>
|
||||||
|
|
||||||
<refsect2 id="R2-APP-INITLOCATION-1">
|
<refsect2 id="R2-APP-INITLOCATION-1">
|
||||||
@ -39,45 +37,14 @@ initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble
|
|||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>--location=<replaceable class="parameter">altdir</replaceable></term>
|
<term><replaceable class="parameter">directory</replaceable></term>
|
||||||
<term>-D <replaceable class="parameter">altdir</replaceable></term>
|
|
||||||
<term><replaceable class="parameter">altdir</replaceable></term>
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Where in your Unix filesystem do you want alternate databases to go?
|
Where in your Unix filesystem do you want alternate databases to go?
|
||||||
The top level directory is called the <envar>PGDATA</envar> directory, so you
|
|
||||||
might want to point your first alternate location at
|
|
||||||
<envar>PGDATA2</envar>.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>--username=<replaceable class="parameter">name</replaceable></term>
|
|
||||||
<term>-u <replaceable class="parameter">name</replaceable></term>
|
|
||||||
<term><envar>PGUSER</envar></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Who will be the Unix filesystem owner of this database storage area?
|
|
||||||
The
|
|
||||||
<productname>Postgres</productname> superuser is a Unix user
|
|
||||||
who owns all files that store the database
|
|
||||||
system and also owns the postmaster and backend processes that access them.
|
|
||||||
Usually, this is the user who should run <application>initlocation</application>
|
|
||||||
and who will thus have ownership of the directories and files.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Only the Unix superuser can create a database system with a
|
|
||||||
different user as the <productname>Postgres</productname> superuser.
|
|
||||||
Specifying a user other than the <productname>Postgres</productname> superuser
|
|
||||||
may lead to database security and data integrity problems. Refer to the
|
|
||||||
<citetitle><productname>PostgreSQL</productname> Administrator's Guide</citetitle>
|
|
||||||
for more information.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</para>
|
</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
@ -92,65 +59,6 @@ initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble
|
|||||||
<para>
|
<para>
|
||||||
<application>initlocation</application> will create directories in
|
<application>initlocation</application> will create directories in
|
||||||
the specified place.
|
the specified place.
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>
|
|
||||||
We are initializing the database area with username postgres (uid=500).
|
|
||||||
This user will own all the files and must also own the server process.
|
|
||||||
Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
|
|
||||||
Creating Postgres database system directory <replaceable class="parameter">altdir</replaceable>
|
|
||||||
</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Successful completion.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>
|
|
||||||
We are initializing the database area with username postgres (uid=500).
|
|
||||||
This user will own all the files and must also own the server process.
|
|
||||||
Creating Postgres database system directory /usr/local/src/testlocation
|
|
||||||
mkdir: cannot make directory `<replaceable class="parameter">altdir</replaceable>': Permission denied
|
|
||||||
</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
You do not have filesystem permission to write to the specified directory area.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>
|
|
||||||
Valid username not given. You must specify the username for
|
|
||||||
the Postgres superuser for the database system you are
|
|
||||||
initializing, either with the --username option or by default
|
|
||||||
to the USER environment variable.
|
|
||||||
</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The username which you have specified is not the
|
|
||||||
<productname>Postgres</productname> superuser.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>
|
|
||||||
Can't tell what username to use. You don't have the USER
|
|
||||||
environment variable set to your username and didn't specify the
|
|
||||||
--username option
|
|
||||||
</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Specify the <option>--username</option> command line option.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
</para>
|
</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
@ -164,41 +72,16 @@ environment variable set to your username and didn't specify the
|
|||||||
</title>
|
</title>
|
||||||
<para>
|
<para>
|
||||||
<application>initlocation</application>
|
<application>initlocation</application>
|
||||||
creates a new <productname>Postgres</productname> secondary database storage area.
|
creates a new <productname>PostgreSQL</productname> secondary database storage area.
|
||||||
A secondary storage area contains a required tree of directories with
|
See the discussion under <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title">
|
||||||
the correct file permissions on those directories.
|
about how to manage and use secondary storage areas. If the argument does not contain
|
||||||
|
a slash and is not valid as a path, it is assumed to be an environment variable,
|
||||||
|
which is referenced. See the examples at the end.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Creating a database storage area consists of creating the directories in which
|
In order to use this command you must be logged in (using 'su', for example)
|
||||||
database data might live.
|
the database superuser.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
There are two kinds of arguments for <application>initlocation</application>.
|
|
||||||
|
|
||||||
First, you can specify an environment variable (e.g. <envar>PGDATA2</envar>).
|
|
||||||
This environment variable should be known to the backend for later use in
|
|
||||||
<command>CREATE DATABASE/WITH LOCATION</command>
|
|
||||||
or
|
|
||||||
<command>createdb -D <replaceable class="parameter">altdir</replaceable></command>.
|
|
||||||
However, <emphasis>the backend daemon must have this variable in it's
|
|
||||||
environment</emphasis> for this to succeed.
|
|
||||||
|
|
||||||
Second, you may be able to specify an explicit
|
|
||||||
absolute path to the top directory of the storage area. However,this second
|
|
||||||
option is possible only if explicitly enabled during the
|
|
||||||
<productname>Postgres</productname> installation. It is usually disabled
|
|
||||||
to alleviate security and data integrity concerns.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
<productname>Postgres</productname> will add <filename>/base/</filename>
|
|
||||||
to the specified path to create the storage area.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
The backend requires that any argument to <option>WITH LOCATION</option> which is
|
|
||||||
in all uppercase and which has no path delimiters is an environment variable.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="R1-APP-INITLOCATION-2">
|
<refsect1 id="R1-APP-INITLOCATION-2">
|
||||||
@ -210,12 +93,19 @@ environment variable set to your username and didn't specify the
|
|||||||
</title>
|
</title>
|
||||||
<para>
|
<para>
|
||||||
To create a database in an alternate location, using an environment variable:
|
To create a database in an alternate location, using an environment variable:
|
||||||
|
<programlisting>
|
||||||
|
$ export PGDATA2=/opt/postgres/data
|
||||||
|
$ initlocation PGDATA2
|
||||||
|
$ createdb 'testdb' -D 'PGDATA2/testdb'
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
<programlisting>
|
<para>
|
||||||
% setenv PGDATA2 /opt/postgres/data
|
Alternatively, if you allow absolute paths you could write:
|
||||||
% initlocation PGDATA2
|
<programlisting>
|
||||||
% createdb -D PGDATA2
|
$ initlocation /opt/postgres/data
|
||||||
</programlisting>
|
$ createdb 'testdb' -D '/opt/postgres/data/testdb'
|
||||||
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.12 1999/07/22 15:09:13 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.13 2000/01/18 00:03:34 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ Postgres documentation
|
|||||||
<synopsis>
|
<synopsis>
|
||||||
pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
|
pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
|
||||||
pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||||
[ -t <replaceable class="parameter">table</replaceable> ] [ -f <replaceable class="parameter">outputfile</replaceable> ]
|
[ -t <replaceable class="parameter">table</replaceable> ]
|
||||||
[ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ]
|
[ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ]
|
||||||
[ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
|
[ -O ] [ -s ] [ -u ] [ -v ] [ -x ]
|
||||||
[ <replaceable class="parameter">dbname</replaceable> ]
|
[ <replaceable class="parameter">dbname</replaceable> ]
|
||||||
</synopsis>
|
</synopsis>
|
||||||
|
|
||||||
@ -92,15 +92,6 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceab
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>-f <replaceable class="parameter">filename</replaceable></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Specifies the output file. Defaults to <filename>stdout</filename>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>-n</term>
|
<term>-n</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -124,7 +115,7 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceab
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>-o</term>
|
<term>-O</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Dump object identifiers (<acronym>OID</acronym>s) for every table.
|
Dump object identifiers (<acronym>OID</acronym>s) for every table.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.5 1999/07/22 15:09:13 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.6 2000/01/18 00:03:34 petere Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ Postgres documentation
|
|||||||
</refsynopsisdivinfo>
|
</refsynopsisdivinfo>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
pg_dumpall
|
pg_dumpall
|
||||||
pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -a ] [ -d ] [ -D ] [ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
|
pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -a ] [ -d ] [ -D ] [ -O ] [ -s ] [ -u ] [ -v ] [ -x ]
|
||||||
</synopsis>
|
</synopsis>
|
||||||
|
|
||||||
<refsect2 id="R2-APP-PG-DUMPALL-1">
|
<refsect2 id="R2-APP-PG-DUMPALL-1">
|
||||||
@ -77,7 +77,7 @@ pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>-o</term>
|
<term>-O</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Dump object identifiers (<acronym>OID</acronym>s) for every table.
|
Dump object identifiers (<acronym>OID</acronym>s) for every table.
|
||||||
@ -277,7 +277,7 @@ dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
|
|||||||
To dump all databases:
|
To dump all databases:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
% pg_dumpall -o > db.out
|
% pg_dumpall > db.out
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<tip>
|
<tip>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.79 2000/01/15 18:30:31 petere Exp $
|
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.80 2000/01/18 00:03:35 petere Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -199,14 +199,14 @@ do
|
|||||||
;;
|
;;
|
||||||
# The encoding of the template1 database. Defaults to what you chose
|
# The encoding of the template1 database. Defaults to what you chose
|
||||||
# at configure time. (see above)
|
# at configure time. (see above)
|
||||||
--encoding|-e)
|
--encoding|-E)
|
||||||
MULTIBYTE="$2"
|
MULTIBYTE="$2"
|
||||||
shift;;
|
shift;;
|
||||||
--encoding=*)
|
--encoding=*)
|
||||||
MULTIBYTE=`echo $1 | sed 's/^--encoding=//'`
|
MULTIBYTE=`echo $1 | sed 's/^--encoding=//'`
|
||||||
;;
|
;;
|
||||||
-e*)
|
-E*)
|
||||||
MULTIBYTE=`echo $1 | sed 's/^-e//'`
|
MULTIBYTE=`echo $1 | sed 's/^-E//'`
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
PGDATA=$1
|
PGDATA=$1
|
||||||
|
@ -1,107 +1,112 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# initarea.sh--
|
# initlocation.sh--
|
||||||
# Create (initialize) a secondary Postgres database storage area.
|
# Create a secondary PostgreSQL database storage area.
|
||||||
#
|
|
||||||
# A database storage area contains individual Postgres databases.
|
|
||||||
#
|
|
||||||
# To create the database storage area, we create a root directory tree.
|
|
||||||
#
|
#
|
||||||
# Copyright (c) 1994, Regents of the University of California
|
# Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.3 1999/12/16 20:09:57 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.4 2000/01/18 00:03:36 petere Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
exit_nicely(){
|
||||||
|
echo "$CMDNAME failed."
|
||||||
|
rm -rf "$PGALTDATA"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CMDNAME=`basename $0`
|
CMDNAME=`basename $0`
|
||||||
POSTGRES_SUPERUSERNAME=$USER
|
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
|
||||||
|
|
||||||
|
if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ]
|
||||||
|
then
|
||||||
|
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
|
||||||
|
echo "as the (unprivileged) user that will own the server process."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
Location=
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--location=*) PGALTDATA="`echo $1 | sed 's/^--pgdata=//'`"; ;;
|
# These options are not really necessary, but what the heck.
|
||||||
--username=*) POSTGRES_SUPERUSERNAME="`echo $1 | sed 's/^--username=//'`" ;;
|
--location=*)
|
||||||
|
Location=`echo $1 | sed 's/^--pgdata=//'`
|
||||||
|
;;
|
||||||
|
--location)
|
||||||
|
Location="$2"
|
||||||
|
shift;;
|
||||||
|
-D)
|
||||||
|
Location="$2"
|
||||||
|
shift;;
|
||||||
|
|
||||||
--location) shift; PGALTDATA="$1"; ;;
|
--help|-\?)
|
||||||
--username) shift; POSTGRES_SUPERUSERNAME="$1"; ;;
|
usage=t
|
||||||
--help) usage=1; ;;
|
break;;
|
||||||
|
|
||||||
-u) shift; POSTGRES_SUPERUSERNAME="$1"; ;;
|
-*)
|
||||||
-D) shift; PGALTDATA="$1"; ;;
|
echo "$CMDNAME: unrecognized option $badparm"
|
||||||
-h) usage=t; ;;
|
echo "Try -? for help."
|
||||||
-\?) usage=t; ;;
|
exit 1
|
||||||
-*) badparm=$1; ;;
|
;;
|
||||||
*) PGALTDATA="$1"; ;;
|
*)
|
||||||
|
Location="$1"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$badparm" ]; then
|
|
||||||
echo "$CMDNAME: Unrecognized parameter '$badparm'. Try -? for help."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$usage" ]; then
|
if [ "$usage" ]; then
|
||||||
|
echo "$CMDNAME initializes an alternative filesystem location for database creation."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: $CMDNAME [options] datadir"
|
echo "Usage:"
|
||||||
echo ""
|
echo " $CMDNAME <location>"
|
||||||
echo " -u SUPERUSER, --username=SUPERUSER "
|
|
||||||
echo " -D DATADIR, --location=DATADIR "
|
|
||||||
echo " -?, --help "
|
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Report bugs to <bugs@postgresql.org>."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$Location" ]; then
|
||||||
|
echo "$CMDNAME: missing required argument <location>"
|
||||||
|
echo "Try -? for help."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
# Make sure he told us where to build the database area
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PGENVAR="$PGALTDATA"
|
#
|
||||||
PGENVAR=`printenv $PGENVAR`
|
# Here's what's going on:
|
||||||
if [ ! -z "$PGENVAR" ]; then
|
#
|
||||||
PGALTDATA=$PGENVAR
|
# You can call initlocation ENVAR (no dollar sign), then ENVAR will
|
||||||
echo "$CMDNAME: input argument points to $PGALTDATA"
|
# (a) be tested whether it is valid as a path, or
|
||||||
|
# (b) be resolved as an environment variable.
|
||||||
|
# The latter has been the traditional behaviour.
|
||||||
|
#
|
||||||
|
# You can call initlocation $ENVAR, which will of course be resolved
|
||||||
|
# by the shell, or initlocation some/path (containing at least one slash).
|
||||||
|
# Then you just take that path.
|
||||||
|
# This should apease users who are confused by the above behaviour.
|
||||||
|
#
|
||||||
|
|
||||||
|
if ! echo "$Location" | grep -s '/' >/dev/null 2>&1 && [ ! -d "$Location" ]; then
|
||||||
|
PGALTDATA=`printenv $Location 2> /dev/null`
|
||||||
|
if [ -z "$PGALTDATA" ]; then
|
||||||
|
echo "$CMDNAME: environment variable $PGALTDATA not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
haveenv=t
|
||||||
|
else
|
||||||
|
PGALTDATA="$Location"
|
||||||
|
haveenv=f
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$PGALTDATA" ]; then
|
echo "The location will be initialized with username \"$EffectiveUser\"."
|
||||||
echo "$CMDNAME: You must identify the target area, where the new data"
|
|
||||||
echo "for this database system can reside. Do this with --location"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
# Figure out who the Postgres superuser for the new database system will be.
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if [ -z "$POSTGRES_SUPERUSERNAME" ]; then
|
|
||||||
echo "Can't tell what username to use. You don't have the USER"
|
|
||||||
echo "environment variable set to your username and didn't specify the "
|
|
||||||
echo "--username option"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
POSTGRES_SUPERUID=`pg_id $POSTGRES_SUPERUSERNAME`
|
|
||||||
|
|
||||||
if [ $POSTGRES_SUPERUID = NOUSER ]; then
|
|
||||||
echo "Valid username not given. You must specify the username for "
|
|
||||||
echo "the Postgres superuser for the database system you are "
|
|
||||||
echo "initializing, either with the --username option or by default "
|
|
||||||
echo "to the USER environment variable."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $POSTGRES_SUPERUID -ne `pg_id` -a `pg_id` -ne 0 ]; then
|
|
||||||
echo "Only the unix superuser may initialize a database with a different"
|
|
||||||
echo "Postgres superuser. (You must be able to create files that belong"
|
|
||||||
echo "to the specified unix user)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "We are initializing the database area with username" \
|
|
||||||
"$POSTGRES_SUPERUSERNAME (uid=$POSTGRES_SUPERUID)."
|
|
||||||
echo "This user will own all the files and must also own the server process."
|
echo "This user will own all the files and must also own the server process."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -109,22 +114,51 @@ echo
|
|||||||
# Create the data directory if necessary
|
# Create the data directory if necessary
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
# don't want to leave anything lying around
|
||||||
|
trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15
|
||||||
|
|
||||||
# umask must disallow access to group, other for files and dirs
|
# umask must disallow access to group, other for files and dirs
|
||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
if [ ! -d $PGALTDATA ]; then
|
if [ ! -d $PGALTDATA ]; then
|
||||||
echo "Creating Postgres database system directory $PGALTDATA"
|
echo "Creating directory $PGALTDATA"
|
||||||
echo
|
mkdir "$PGALTDATA"
|
||||||
mkdir $PGALTDATA
|
if [ $? -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then exit 1; fi
|
echo "$CMDNAME: could not create $PGALTDATA"
|
||||||
chown $POSTGRES_SUPERUSERNAME $PGALTDATA
|
echo "Make sure $PGALTDATA is a valid path and that you have permission to access it."
|
||||||
fi
|
exit_nicely
|
||||||
if [ ! -d $PGALTDATA/base ]; then
|
fi
|
||||||
echo "Creating Postgres database system directory $PGALTDATA/base"
|
else
|
||||||
echo
|
echo "Fixing permissions on pre-existing directory $PGALTDATA"
|
||||||
mkdir $PGALTDATA/base
|
chmod go-rwx "$PGALTDATA" || exit_nicely
|
||||||
if [ $? -ne 0 ]; then exit 1; fi
|
|
||||||
chown $POSTGRES_SUPERUSERNAME $PGALTDATA/base
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit
|
|
||||||
|
if [ ! -d $PGALTDATA/base ]; then
|
||||||
|
echo "Creating directory $PGALTDATA/base"
|
||||||
|
mkdir "$PGALTDATA/base"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "$CMDNAME: could not create $PGALTDATA/base"
|
||||||
|
echo "Make sure $PGALTDATA/base is a valid path and that you have permission to access it."
|
||||||
|
exit_nicely
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Fixing permissions on pre-existing directory $PGALTDATA/base"
|
||||||
|
chmod go-rwx "$PGALTDATA/base" || exit_nicely
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "$CMDNAME is complete."
|
||||||
|
# We can only suggest them these commands if they used the environment
|
||||||
|
# variable notation. Otherwise they would be induced to use an absolute
|
||||||
|
# path, which the backend won't allow by default.
|
||||||
|
if [ "$haveenv" = "t" ]; then
|
||||||
|
echo "You can now create a database using"
|
||||||
|
echo " CREATE DATABASE <name> WITH LOCATION = '$Location/<name>'"
|
||||||
|
echo "in SQL, or"
|
||||||
|
echo " createdb <name> -D '$Location/<name>'"
|
||||||
|
echo "from the shell."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
@ -1,8 +1,102 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.2 1998/08/22 05:19:31 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.3 2000/01/18 00:03:36 petere Exp $
|
||||||
#
|
#
|
||||||
PATH=PG_OPT_IPCCLEANPATH_PARAM:$PATH
|
|
||||||
export PATH
|
CMDNAME=`basename $0`
|
||||||
ipcs | egrep '^m .*|^s .*' | egrep "`whoami`|postgres" | \
|
|
||||||
|
if [ "$1" = '-?' -o "$1" = "--help" ]; then
|
||||||
|
echo "$CMDNAME cleans up shared memory and semaphores from aborted PostgreSQL backends."
|
||||||
|
echo
|
||||||
|
echo "Usage:"
|
||||||
|
echo " $CMDNAME"
|
||||||
|
echo
|
||||||
|
echo "Note: Since the utilities underlying this script are very different"
|
||||||
|
echo "from platform to platform, chances are that it might not work on"
|
||||||
|
echo "yours. If that is the case, please write to <bugs@postgresql.org>"
|
||||||
|
echo "so that your platform can be supported in the future."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ]
|
||||||
|
then
|
||||||
|
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
|
||||||
|
echo "as the (unprivileged) user that owned the server process."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
|
||||||
|
|
||||||
|
#-----------------------------------
|
||||||
|
# List of platform-specific hacks
|
||||||
|
# Feel free to add yours here.
|
||||||
|
#-----------------------------------
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is based on RedHat 5.2.
|
||||||
|
#
|
||||||
|
if [ `uname` = 'Linux' ]; then
|
||||||
|
ipcs_id=
|
||||||
|
ipcs_cpid=
|
||||||
|
ipcs_lpid=
|
||||||
|
did_anything=
|
||||||
|
|
||||||
|
if ps x | grep -s 'postmaster' >& /dev/null ; then
|
||||||
|
echo "$CMDNAME: You still have a postmaster running."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shared memory
|
||||||
|
for val in `ipcs -m -p | grep '^[0-9]' | awk '{printf "%s %s\n", $1, $3, $4}'`; do
|
||||||
|
if [ -z "$ipcs_id" ]; then
|
||||||
|
ipcs_id=$val
|
||||||
|
# Note: We can do -n here, because we know the platform.
|
||||||
|
echo -n "Shared memory $ipcs_id ... "
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipcs_lpid=$val
|
||||||
|
|
||||||
|
# Don't do anything if process still running.
|
||||||
|
# (This check is conceptually phony, but it's
|
||||||
|
# useful anyway in practice.)
|
||||||
|
ps hj$ipcs_pid >& /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "skipped. Process still exists (pid $ipcs_pid)."
|
||||||
|
else
|
||||||
|
# try remove
|
||||||
|
ipcrm shm $ipcs_id
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
did_anything=t
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
ipcs_id=
|
||||||
|
ipcs_cpid=
|
||||||
|
ipcs_lpid=
|
||||||
|
done
|
||||||
|
|
||||||
|
# semaphores
|
||||||
|
for val in `ipcs -s -c | grep '^[0-9]' | awk '{printf "%s\n", $1}'`; do
|
||||||
|
echo -n "Semaphore $val ... "
|
||||||
|
# try remove
|
||||||
|
ipcrm sem $val
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
did_anything=t
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -z "$did_anything" ] && echo "$CMDNAME: nothing removed" && exit 1
|
||||||
|
exit 0
|
||||||
|
fi # end Linux
|
||||||
|
|
||||||
|
|
||||||
|
# This is the original implementation. It seems to work
|
||||||
|
# on FreeBSD, SunOS/Solaris, HP-UX, IRIX, and probably
|
||||||
|
# some others.
|
||||||
|
|
||||||
|
ipcs | egrep '^m .*|^s .*' | egrep "$EffectiveUser" | \
|
||||||
awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh
|
awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.132 2000/01/16 03:54:58 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.133 2000/01/18 00:03:37 petere Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -69,6 +69,7 @@
|
|||||||
#include "catalog/pg_language.h"
|
#include "catalog/pg_language.h"
|
||||||
#include "catalog/pg_trigger.h"
|
#include "catalog/pg_trigger.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include "libpq-fe.h"
|
#include "libpq-fe.h"
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
@ -122,61 +123,63 @@ char g_comment_end[10];
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(const char *progname)
|
help(const char *progname)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
printf("%s dumps a database to a text file.\n\n", progname);
|
||||||
"\nUsage: %s [options] dbname\n\n", progname);
|
puts( "Usage:");
|
||||||
|
printf(" %s [options] dbname\n\n", progname);
|
||||||
|
puts( "Options:");
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
fprintf(stderr,
|
puts(
|
||||||
|
" -a, --data-only dump out only the data, not the schema\n"
|
||||||
" -a, --data-only dump out only the data, no schema\n"
|
" -c, --clean clean (drop) schema prior to create\n"
|
||||||
" -c, --clean clean(drop) schema prior to create\n"
|
" -d, --inserts dump data as INSERT, rather than COPY, commands\n"
|
||||||
" -d, --insert-proper dump data as proper insert strings\n"
|
" -D, --attribute-inserts dump data as INSERT commands with attribute names\n"
|
||||||
" -D, --insert-attr dump data as inserts with attribute names\n"
|
" -h, --host <hostname> server host name\n"
|
||||||
" -f, --out file script output filename\n"
|
" -n, --no-quotes suppress most quotes around identifiers\n"
|
||||||
" -h, --host hostname server host name\n"
|
" -N, --quotes enable most quotes around identifiers\n"
|
||||||
" -n, --no-quotes suppress most quotes around identifiers\n"
|
" -O, --oids dump object ids (oids)\n"
|
||||||
" -N, --quotes enable most quotes around identifiers\n"
|
" -p, --port <port> server port number\n"
|
||||||
" -o, --oids dump object id's (oids)\n"
|
" -s, --schema-only dump out only the schema, no data\n"
|
||||||
" -p, --port port server port number\n"
|
" -t, --table <table> dump for this table only\n"
|
||||||
" -s, --schema-only dump out only the schema, no data\n"
|
" -u, --password use password authentication\n"
|
||||||
" -t, --table table dump for this table only\n"
|
" -v, --verbose verbose\n"
|
||||||
" -u, --password use password authentication\n"
|
" -x, --no-acl do not dump ACL's (grant/revoke)\n"
|
||||||
" -v, --verbose verbose\n"
|
);
|
||||||
" -x, --no-acl do not dump ACL's (grant/revoke)\n"
|
|
||||||
" -?, --help show this help message\n"
|
|
||||||
|
|
||||||
); /* fprintf */
|
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,
|
puts(
|
||||||
|
" -a dump out only the data, no schema\n"
|
||||||
" -a dump out only the data, no schema\n"
|
" -c clean (drop) schema prior to create\n"
|
||||||
" -c clean(drop) schema prior to create\n"
|
" -d dump data as INSERT, rather than COPY, commands\n"
|
||||||
" -d dump data as proper insert strings\n"
|
" -D dump data as INSERT commands with attribute names\n"
|
||||||
" -D dump data as inserts with attribute names\n"
|
" -h <hostname> server host name\n"
|
||||||
" -f filename script output filename\n"
|
" -n suppress most quotes around identifiers\n"
|
||||||
" -h hostname server host name\n"
|
" -N enable most quotes around identifiers\n"
|
||||||
" -n suppress most quotes around identifiers\n"
|
" -O dump object ids (oids)\n"
|
||||||
" -N enable most quotes around identifiers\n"
|
" -p <port> server port number\n"
|
||||||
" -o dump object id's (oids)\n"
|
" -s dump out only the schema, no data\n"
|
||||||
" -p port server port number\n"
|
" -t <table> dump for this table only\n"
|
||||||
" -s dump out only the schema, no data\n"
|
" -u use password authentication\n"
|
||||||
" -t table dump for this table only\n"
|
" -v verbose\n"
|
||||||
" -u use password authentication\n"
|
" -x do not dump ACL's (grant/revoke)\n"
|
||||||
" -v verbose\n"
|
);
|
||||||
" -x do not dump ACL's (grant/revoke)\n"
|
|
||||||
" -? show this help message\n"
|
|
||||||
|
|
||||||
); /* fprintf */
|
|
||||||
#endif
|
#endif
|
||||||
|
puts("If no database name is not supplied, then the PGDATABASE environment\nvariable value is used.\n");
|
||||||
fprintf(stderr,
|
puts("Report bugs to <bugs@postgresql.org>.");
|
||||||
"\nIf dbname is not supplied, then the DATABASE environment variable value is used.\n\n");
|
|
||||||
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
version(void)
|
||||||
|
{
|
||||||
|
puts("pg_dump (PostgreSQL) " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION);
|
||||||
|
puts("Copyright (C) 2000 PostgreSQL Global Development Team");
|
||||||
|
puts("Copyright (C) 1996 Regents of the University of California");
|
||||||
|
puts("Read the file COPYING to see the usage and distribution terms.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exit_nicely(PGconn *conn)
|
exit_nicely(PGconn *conn)
|
||||||
{
|
{
|
||||||
@ -551,14 +554,13 @@ main(int argc, char **argv)
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"data-only", no_argument, NULL, 'a'},
|
{"data-only", no_argument, NULL, 'a'},
|
||||||
{"clean", no_argument, NULL, 'c'},
|
{"clean", no_argument, NULL, 'c'},
|
||||||
{"insert-proper",no_argument, NULL, 'd'},
|
{"inserts",no_argument, NULL, 'd'},
|
||||||
{"insert-attr", no_argument, NULL, 'D'},
|
{"attribute-inserts", no_argument, NULL, 'D'},
|
||||||
{"out", required_argument, NULL, 'f'},
|
{"output", required_argument, NULL, '\037'}, /* see note below */
|
||||||
{"to-file", required_argument, NULL, 'f'},
|
|
||||||
{"host", required_argument, NULL, 'h'},
|
{"host", required_argument, NULL, 'h'},
|
||||||
{"no-quotes", no_argument, NULL, 'n'},
|
{"no-quotes", no_argument, NULL, 'n'},
|
||||||
{"quotes", no_argument, NULL, 'N'},
|
{"quotes", no_argument, NULL, 'N'},
|
||||||
{"oids", no_argument, NULL, 'o'},
|
{"oids", no_argument, NULL, 'O'},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
{"schema-only", no_argument, NULL, 's'},
|
{"schema-only", no_argument, NULL, 's'},
|
||||||
{"table", required_argument, NULL, 't'},
|
{"table", required_argument, NULL, 't'},
|
||||||
@ -566,6 +568,7 @@ main(int argc, char **argv)
|
|||||||
{"verbose", no_argument, NULL, 'v'},
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
{"no-acl", no_argument, NULL, 'x'},
|
{"no-acl", no_argument, NULL, 'x'},
|
||||||
{"help", no_argument, NULL, '?'},
|
{"help", no_argument, NULL, '?'},
|
||||||
|
{"version", no_argument, NULL, 'V'}
|
||||||
};
|
};
|
||||||
int optindex;
|
int optindex;
|
||||||
#endif
|
#endif
|
||||||
@ -580,12 +583,33 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
dataOnly = schemaOnly = dumpData = attrNames = false;
|
dataOnly = schemaOnly = dumpData = attrNames = false;
|
||||||
|
|
||||||
progname = *argv;
|
if (!strrchr(argv[0], SEP_CHAR))
|
||||||
|
progname = argv[0];
|
||||||
|
else
|
||||||
|
progname = strrchr(argv[0], SEP_CHAR) + 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A note on options:
|
||||||
|
*
|
||||||
|
* The standard option for specifying an output file is -o/--output.
|
||||||
|
* The standard option for specifying an input file is -f/--file.
|
||||||
|
* pg_dump used to use -f for specifying an output file.
|
||||||
|
* Unfortunately, -o is already in use for oids.
|
||||||
|
*
|
||||||
|
* Therefore I instituted the following:
|
||||||
|
* + The -f option is gone. Most people use > for output redirection anyway
|
||||||
|
* so there is really not a big point in supporting output files.
|
||||||
|
* + If you like, and can, you can use --output, but it's not documented.
|
||||||
|
* + The preferred option for oids is now -O. -o generates a warning.
|
||||||
|
* + In the (very far) future the -o option could be used to used for
|
||||||
|
* specifying an output file.
|
||||||
|
* -- petere 2000-01-17
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
while ((c = getopt_long(argc, argv, "acdDf:h:nNop:st:uvxz?", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "acdDh:nNoOp:st:uvxzV?\037", long_options, &optindex)) != -1)
|
||||||
#else
|
#else
|
||||||
while ((c = getopt(argc, argv, "acdDf:h:nNop:st:uvxz?")) != -1)
|
while ((c = getopt(argc, argv, "acdDh:nNoOp:st:uvxzV?")) != -1)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -605,7 +629,7 @@ main(int argc, char **argv)
|
|||||||
dumpData = true;
|
dumpData = true;
|
||||||
attrNames = true;
|
attrNames = true;
|
||||||
break;
|
break;
|
||||||
case 'f': /* output file name */
|
case '\037': /* output file name, see note above */
|
||||||
filename = optarg;
|
filename = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h': /* server host */
|
case 'h': /* server host */
|
||||||
@ -618,7 +642,9 @@ main(int argc, char **argv)
|
|||||||
case 'N': /* Force double-quotes on identifiers */
|
case 'N': /* Force double-quotes on identifiers */
|
||||||
force_quotes = true;
|
force_quotes = true;
|
||||||
break;
|
break;
|
||||||
case 'o': /* Dump oids */
|
case 'o':
|
||||||
|
fprintf(stderr, "%s: The -o option for dumping oids is deprecated. Please use -O.");
|
||||||
|
case 'O': /* Dump oids */
|
||||||
oids = true;
|
oids = true;
|
||||||
break;
|
break;
|
||||||
case 'p': /* server port */
|
case 'p': /* server port */
|
||||||
@ -662,15 +688,17 @@ main(int argc, char **argv)
|
|||||||
case 'x': /* skip ACL dump */
|
case 'x': /* skip ACL dump */
|
||||||
aclsSkip = true;
|
aclsSkip = true;
|
||||||
break;
|
break;
|
||||||
case 'z': /* Old ACL option bjm 1999/05/27 */
|
case 'V':
|
||||||
fprintf(stderr,
|
version();
|
||||||
"%s: The -z option(dump ACLs) is now the default, continuing.\n",
|
exit(0);
|
||||||
progname);
|
break;
|
||||||
break;
|
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
help(progname);
|
||||||
usage(progname);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: unknown option -%c\nTry -? for help.\n", progname, c);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,7 +707,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n",
|
"%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n",
|
||||||
progname);
|
progname);
|
||||||
exit(2);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open the output file */
|
/* open the output file */
|
||||||
@ -697,16 +725,16 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: could not open output file named %s for writing\n",
|
"%s: could not open output file named %s for writing\n",
|
||||||
progname, filename);
|
progname, filename);
|
||||||
exit(2);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find database */
|
/* find database */
|
||||||
if (!(dbname = argv[optind]) &&
|
if (!(dbname = argv[optind]) &&
|
||||||
!(dbname = getenv("DATABASE")))
|
!(dbname = getenv("PGDATABASE")))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: no database name specified\n", progname);
|
fprintf(stderr, "%s: no database name specified\n", progname);
|
||||||
exit(2);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* g_conn = PQsetdb(pghost, pgport, NULL, NULL, dbname); */
|
/* g_conn = PQsetdb(pghost, pgport, NULL, NULL, dbname); */
|
||||||
@ -1417,7 +1445,7 @@ getFuncs(int *numFuncs)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "failed sanity check: %s has %d args\n",
|
fprintf(stderr, "failed sanity check: %s has %d args\n",
|
||||||
finfo[i].proname, finfo[i].nargs);
|
finfo[i].proname, finfo[i].nargs);
|
||||||
exit(2);
|
exit(1);
|
||||||
}
|
}
|
||||||
parseNumericArray(PQgetvalue(res, i, i_proargtypes),
|
parseNumericArray(PQgetvalue(res, i, i_proargtypes),
|
||||||
finfo[i].argtypes,
|
finfo[i].argtypes,
|
||||||
@ -2922,7 +2950,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "failed sanity check, table %s was not found\n",
|
fprintf(stderr, "failed sanity check, table %s was not found\n",
|
||||||
indinfo[i].indrelname);
|
indinfo[i].indrelname);
|
||||||
exit(2);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(indinfo[i].indproc, "0") == 0)
|
if (strcmp(indinfo[i].indproc, "0") == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user