Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
28125ed5
Commit
28125ed5
authored
Jan 18, 2000
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated user interfaces on initdb, initlocation, pg_dump, ipcclean to a GNU-compliant'ish state.
Made ipcclean work on Linux.
parent
9e0b4634
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
351 additions
and
314 deletions
+351
-314
doc/src/sgml/ref/initdb.sgml
doc/src/sgml/ref/initdb.sgml
+3
-3
doc/src/sgml/ref/initlocation.sgml
doc/src/sgml/ref/initlocation.sgml
+24
-134
doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_dump.sgml
+4
-13
doc/src/sgml/ref/pg_dumpall.sgml
doc/src/sgml/ref/pg_dumpall.sgml
+4
-4
src/bin/initdb/initdb.sh
src/bin/initdb/initdb.sh
+4
-4
src/bin/initlocation/initlocation.sh
src/bin/initlocation/initlocation.sh
+116
-82
src/bin/ipcclean/ipcclean.sh
src/bin/ipcclean/ipcclean.sh
+98
-4
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+98
-70
No files found.
doc/src/sgml/ref/initdb.sgml
View file @
28125ed5
<!--
$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
-->
...
...
@@ -26,7 +26,7 @@ Postgres documentation
initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
[ --sysid|-i <replaceable class="parameter">sysid</replaceable> ]
[ --pwprompt|-W ]
[ --encoding|-
e
<replaceable class="parameter">encoding</replaceable> ]
[ --encoding|-
E
<replaceable class="parameter">encoding</replaceable> ]
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
[ --username|-u <replaceable class="parameter">name</replaceable> ]
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
...
...
@@ -85,7 +85,7 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
<varlistentry>
<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>
<para>
Selects the multibyte encoding of the template database. This will also
...
...
doc/src/sgml/ref/initlocation.sgml
View file @
28125ed5
<!--
$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
-->
...
...
@@ -15,17 +15,15 @@ Postgres documentation
<application>initlocation</application>
</refname>
<refpurpose>
Create a secondary <productname>Postgre
s
</productname> database storage area
Create a secondary <productname>Postgre
SQL
</productname> database storage area
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>
1999-07-20
</date>
<date>
2000-01-17
</date>
</refsynopsisdivinfo>
<synopsis>
initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble> | -D <replaceable class="parameter">altdir</replaceable> ]
[ --username=<replaceable class="parameter">name</replaceable> | -u <replaceable class="parameter">name</replaceable> ]
[ <replaceable class="parameter">altdir</replaceable> ]
initlocation <replaceable class="parameter">directory</replaceable>
</synopsis>
<refsect2 id="R2-APP-INITLOCATION-1">
...
...
@@ -39,45 +37,14 @@ initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble
<variablelist>
<varlistentry>
<term>--location=<replaceable class="parameter">altdir</replaceable></term>
<term>-D <replaceable class="parameter">altdir</replaceable></term>
<term><replaceable class="parameter">altdir</replaceable></term>
<term><replaceable class="parameter">directory</replaceable></term>
<listitem>
<para>
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>
</listitem>
</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>
</para>
</refsect2>
...
...
@@ -92,65 +59,6 @@ initlocation [ --location=<replaceable class="parameter">er">al</replaceable>ble
<para>
<application>initlocation</application> will create directories in
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>
</refsect2>
</refsynopsisdiv>
...
...
@@ -164,41 +72,16 @@ environment variable set to your username and didn't specify the
</title>
<para>
<application>initlocation</application>
creates a new <productname>Postgres</productname> secondary database storage area.
A secondary storage area contains a required tree of directories with
the correct file permissions on those directories.
</para>
<para>
Creating a database storage area consists of creating the directories in which
database data might live.
creates a new <productname>PostgreSQL</productname> secondary database storage area.
See the discussion under <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title">
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>
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.
In order to use this command you must be logged in (using 'su', for example)
the database superuser.
</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 id="R1-APP-INITLOCATION-2">
...
...
@@ -210,12 +93,19 @@ environment variable set to your username and didn't specify the
</title>
<para>
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>
% setenv PGDATA2 /opt/postgres/data
% initlocation PGDATA2
% createdb -D PGDATA2
</programlisting>
<para>
Alternatively, if you allow absolute paths you could write:
<programlisting>
$ initlocation /opt/postgres/data
$ createdb 'testdb' -D '/opt/postgres/data/testdb'
</programlisting>
</para>
</refsect1>
</refentry>
...
...
doc/src/sgml/ref/pg_dump.sgml
View file @
28125ed5
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.1
2 1999/07/22 15:09:13 thomas
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.1
3 2000/01/18 00:03:34 petere
Exp $
Postgres documentation
-->
...
...
@@ -25,9 +25,9 @@ Postgres documentation
<synopsis>
pg_dump [ <replaceable class="parameter">dbname</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 ]
[ -
o
] [ -s ] [ -u ] [ -v ] [ -x ]
[ -
O
] [ -s ] [ -u ] [ -v ] [ -x ]
[ <replaceable class="parameter">dbname</replaceable> ]
</synopsis>
...
...
@@ -92,15 +92,6 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceab
</listitem>
</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>
<term>-n</term>
<listitem>
...
...
@@ -124,7 +115,7 @@ pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceab
</varlistentry>
<varlistentry>
<term>-
o
</term>
<term>-
O
</term>
<listitem>
<para>
Dump object identifiers (<acronym>OID</acronym>s) for every table.
...
...
doc/src/sgml/ref/pg_dumpall.sgml
View file @
28125ed5
<!--
$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
-->
...
...
@@ -24,7 +24,7 @@ Postgres documentation
</refsynopsisdivinfo>
<synopsis>
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>
<refsect2 id="R2-APP-PG-DUMPALL-1">
...
...
@@ -77,7 +77,7 @@ pg_dumpall [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
</varlistentry>
<varlistentry>
<term>-
o
</term>
<term>-
O
</term>
<listitem>
<para>
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:
<programlisting>
% pg_dumpall
-o
> db.out
% pg_dumpall > db.out
</programlisting>
<tip>
...
...
src/bin/initdb/initdb.sh
View file @
28125ed5
...
...
@@ -26,7 +26,7 @@
#
#
# 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
# at configure time. (see above)
--encoding
|
-
e
)
--encoding
|
-
E
)
MULTIBYTE
=
"
$2
"
shift
;;
--encoding
=
*
)
MULTIBYTE
=
`
echo
$1
|
sed
's/^--encoding=//'
`
;;
-
e
*
)
MULTIBYTE
=
`
echo
$1
|
sed
's/^-
e
//'
`
-
E
*
)
MULTIBYTE
=
`
echo
$1
|
sed
's/^-
E
//'
`
;;
*
)
PGDATA
=
$1
...
...
src/bin/initlocation/initlocation.sh
View file @
28125ed5
#!/bin/sh
#-------------------------------------------------------------------------
#
# init
area
.sh--
# Create
(initialize) a secondary Postgres
database storage area.
# init
location
.sh--
# 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
#
#
# 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
`
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
]
do
case
"
$1
"
in
--location
=
*
)
PGALTDATA
=
"
`
echo
$1
|
sed
's/^--pgdata=//'
`
"
;
;;
--username
=
*
)
POSTGRES_SUPERUSERNAME
=
"
`
echo
$1
|
sed
's/^--username=//'
`
"
;;
--location
)
shift
;
PGALTDATA
=
"
$1
"
;
;;
--username
)
shift
;
POSTGRES_SUPERUSERNAME
=
"
$1
"
;
;;
--help
)
usage
=
1
;
;;
-u
)
shift
;
POSTGRES_SUPERUSERNAME
=
"
$1
"
;
;;
-D
)
shift
;
PGALTDATA
=
"
$1
"
;
;;
-h
)
usage
=
t
;
;;
-
\?
)
usage
=
t
;
;;
-
*
)
badparm
=
$1
;
;;
*
)
PGALTDATA
=
"
$1
"
;
;;
case
"
$1
"
in
# These options are not really necessary, but what the heck.
--location
=
*
)
Location
=
`
echo
$1
|
sed
's/^--pgdata=//'
`
;;
--location
)
Location
=
"
$2
"
shift
;;
-D
)
Location
=
"
$2
"
shift
;;
--help
|
-
\?
)
usage
=
t
break
;;
-
*
)
echo
"
$CMDNAME
: unrecognized option
$badparm
"
echo
"Try -? for help."
exit
1
;;
*
)
Location
=
"
$1
"
;;
esac
shift
done
if
[
-n
"
$badparm
"
]
;
then
echo
"
$CMDNAME
: Unrecognized parameter '
$badparm
'. Try -? for help."
exit
1
fi
if
[
"
$usage
"
]
;
then
echo
"
$CMDNAME
initializes an alternative filesystem location for database creation."
echo
""
echo
"Usage:
$CMDNAME
[options] datadir"
echo
"Usage:"
echo
"
$CMDNAME
<location>"
echo
""
echo
" -u SUPERUSER, --username=SUPERUSER "
echo
" -D DATADIR, --location=DATADIR "
echo
" -?, --help "
echo
""
exit
1
echo
"Report bugs to <bugs@postgresql.org>."
exit
0
fi
#-------------------------------------------------------------------------
# Make sure he told us where to build the database area
#-------------------------------------------------------------------------
PGENVAR
=
"
$PGALTDATA
"
PGENVAR
=
`
printenv
$PGENVAR
`
if
[
!
-z
"
$PGENVAR
"
]
;
then
PGALTDATA
=
$PGENVAR
echo
"
$CMDNAME
: input argument points to
$PGALTDATA
"
fi
if
[
-z
"
$
PGALTDATA
"
]
;
then
echo
"
$CMDNAME
:
You must identify the target area, where the new data
"
echo
"for this database system can reside. Do this with --location
"
if
[
-z
"
$
Location
"
]
;
then
echo
"
$CMDNAME
:
missing required argument <location>
"
echo
"Try -? for help.
"
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
#
# Here's what's going on:
#
# You can call initlocation ENVAR (no dollar sign), then ENVAR will
# (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
[
$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
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
echo
"We are initializing the database area with username"
\
"
$POSTGRES_SUPERUSERNAME
(uid=
$POSTGRES_SUPERUID
)."
echo
"The location will be initialized with username
\"
$EffectiveUser
\"
."
echo
"This user will own all the files and must also own the server process."
echo
...
...
@@ -109,22 +114,51 @@ echo
# 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
077
if
[
!
-d
$PGALTDATA
]
;
then
echo
"Creating Postgres database system directory
$PGALTDATA
"
echo
mkdir
$PGALTDATA
if
[
$?
-ne
0
]
;
then
exit
1
;
fi
chown
$POSTGRES_SUPERUSERNAME
$PGALTDATA
echo
"Creating directory
$PGALTDATA
"
mkdir
"
$PGALTDATA
"
if
[
$?
-ne
0
]
;
then
echo
"
$CMDNAME
: could not create
$PGALTDATA
"
echo
"Make sure
$PGALTDATA
is a valid path and that you have permission to access it."
exit_nicely
fi
else
echo
"Fixing permissions on pre-existing directory
$PGALTDATA
"
chmod
go-rwx
"
$PGALTDATA
"
||
exit_nicely
fi
if
[
!
-d
$PGALTDATA
/base
]
;
then
echo
"Creating Postgres database system directory
$PGALTDATA
/base"
echo
mkdir
$PGALTDATA
/base
if
[
$?
-ne
0
]
;
then
exit
1
;
fi
chown
$POSTGRES_SUPERUSERNAME
$PGALTDATA
/base
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
exit
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
src/bin/ipcclean/ipcclean.sh
View file @
28125ed5
#!/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
ipcs | egrep
'^m .*|^s .*'
| egrep
"
`
whoami
`
|postgres"
|
\
CMDNAME
=
`
basename
$0
`
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
src/bin/pg_dump/pg_dump.c
View file @
28125ed5
...
...
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.13
2 2000/01/16 03:54:58 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.13
3 2000/01/18 00:03:37 petere
Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -69,6 +69,7 @@
#include "catalog/pg_language.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "version.h"
#include "libpq-fe.h"
#ifndef HAVE_STRDUP
...
...
@@ -122,61 +123,63 @@ char g_comment_end[10];
static
void
usage
(
const
char
*
progname
)
help
(
const
char
*
progname
)
{
fprintf
(
stderr
,
"
\n
Usage: %s [options] dbname
\n\n
"
,
progname
);
printf
(
"%s dumps a database to a text file.
\n\n
"
,
progname
);
puts
(
"Usage:"
);
printf
(
" %s [options] dbname
\n\n
"
,
progname
);
puts
(
"Options:"
);
#ifdef HAVE_GETOPT_LONG
fprintf
(
stderr
,
" -a, --data-only dump out only the data, no schema
\n
"
" -c, --clean clean(drop) schema prior to create
\n
"
" -d, --insert-proper dump data as proper insert strings
\n
"
" -D, --insert-attr dump data as inserts with attribute names
\n
"
" -f, --out file script output filename
\n
"
" -h, --host hostname server host name
\n
"
" -n, --no-quotes suppress most quotes around identifiers
\n
"
" -N, --quotes enable most quotes around identifiers
\n
"
" -o, --oids dump object id's (oids)
\n
"
" -p, --port port server port number
\n
"
" -s, --schema-only dump out only the schema, no data
\n
"
" -t, --table table dump for this table only
\n
"
" -u, --password use password authentication
\n
"
" -v, --verbose verbose
\n
"
" -x, --no-acl do not dump ACL's (grant/revoke)
\n
"
" -?, --help show this help message
\n
"
);
/* fprintf */
puts
(
" -a, --data-only dump out only the data, not the schema
\n
"
" -c, --clean clean (drop) schema prior to create
\n
"
" -d, --inserts dump data as INSERT, rather than COPY, commands
\n
"
" -D, --attribute-inserts dump data as INSERT commands with attribute names
\n
"
" -h, --host <hostname> server host name
\n
"
" -n, --no-quotes suppress most quotes around identifiers
\n
"
" -N, --quotes enable most quotes around identifiers
\n
"
" -O, --oids dump object ids (oids)
\n
"
" -p, --port <port> server port number
\n
"
" -s, --schema-only dump out only the schema, no data
\n
"
" -t, --table <table> dump for this table only
\n
"
" -u, --password use password authentication
\n
"
" -v, --verbose verbose
\n
"
" -x, --no-acl do not dump ACL's (grant/revoke)
\n
"
);
#else
fprintf
(
stderr
,
" -a dump out only the data, no schema
\n
"
" -c clean(drop) schema prior to create
\n
"
" -d dump data as proper insert strings
\n
"
" -D dump data as inserts with attribute names
\n
"
" -f filename script output filename
\n
"
" -h hostname server host name
\n
"
" -n suppress most quotes around identifiers
\n
"
" -N enable most quotes around identifiers
\n
"
" -o dump object id's (oids)
\n
"
" -p port server port number
\n
"
" -s dump out only the schema, no data
\n
"
" -t table dump for this table only
\n
"
" -u use password authentication
\n
"
" -v verbose
\n
"
" -x do not dump ACL's (grant/revoke)
\n
"
" -? show this help message
\n
"
);
/* fprintf */
puts
(
" -a dump out only the data, no schema
\n
"
" -c clean (drop) schema prior to create
\n
"
" -d dump data as INSERT, rather than COPY, commands
\n
"
" -D dump data as INSERT commands with attribute names
\n
"
" -h <hostname> server host name
\n
"
" -n suppress most quotes around identifiers
\n
"
" -N enable most quotes around identifiers
\n
"
" -O dump object ids (oids)
\n
"
" -p <port> server port number
\n
"
" -s dump out only the schema, no data
\n
"
" -t <table> dump for this table only
\n
"
" -u use password authentication
\n
"
" -v verbose
\n
"
" -x do not dump ACL's (grant/revoke)
\n
"
);
#endif
puts
(
"If no database name is not supplied, then the PGDATABASE environment
\n
variable value is used.
\n
"
);
puts
(
"Report bugs to <bugs@postgresql.org>."
);
}
fprintf
(
stderr
,
"
\n
If 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
exit_nicely
(
PGconn
*
conn
)
{
...
...
@@ -551,14 +554,13 @@ main(int argc, char **argv)
static
struct
option
long_options
[]
=
{
{
"data-only"
,
no_argument
,
NULL
,
'a'
},
{
"clean"
,
no_argument
,
NULL
,
'c'
},
{
"insert-proper"
,
no_argument
,
NULL
,
'd'
},
{
"insert-attr"
,
no_argument
,
NULL
,
'D'
},
{
"out"
,
required_argument
,
NULL
,
'f'
},
{
"to-file"
,
required_argument
,
NULL
,
'f'
},
{
"inserts"
,
no_argument
,
NULL
,
'd'
},
{
"attribute-inserts"
,
no_argument
,
NULL
,
'D'
},
{
"output"
,
required_argument
,
NULL
,
'\037'
},
/* see note below */
{
"host"
,
required_argument
,
NULL
,
'h'
},
{
"no-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'
},
{
"schema-only"
,
no_argument
,
NULL
,
's'
},
{
"table"
,
required_argument
,
NULL
,
't'
},
...
...
@@ -566,6 +568,7 @@ main(int argc, char **argv)
{
"verbose"
,
no_argument
,
NULL
,
'v'
},
{
"no-acl"
,
no_argument
,
NULL
,
'x'
},
{
"help"
,
no_argument
,
NULL
,
'?'
},
{
"version"
,
no_argument
,
NULL
,
'V'
}
};
int
optindex
;
#endif
...
...
@@ -580,12 +583,33 @@ main(int argc, char **argv)
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
while
((
c
=
getopt_long
(
argc
,
argv
,
"acdD
f:h:nNop:st:uvxz?
"
,
long_options
,
&
optindex
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
argv
,
"acdD
h:nNoOp:st:uvxzV?
\037
"
,
long_options
,
&
optindex
))
!=
-
1
)
#else
while
((
c
=
getopt
(
argc
,
argv
,
"acdDf:h:nNop:st:uvxz
?"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"acdDh:nNoOp:st:uvxzV
?"
))
!=
-
1
)
#endif
{
switch
(
c
)
...
...
@@ -605,7 +629,7 @@ main(int argc, char **argv)
dumpData
=
true
;
attrNames
=
true
;
break
;
case
'
f'
:
/* output file nam
e */
case
'
\037'
:
/* output file name, see note abov
e */
filename
=
optarg
;
break
;
case
'h'
:
/* server host */
...
...
@@ -618,7 +642,9 @@ main(int argc, char **argv)
case
'N'
:
/* Force double-quotes on identifiers */
force_quotes
=
true
;
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
;
break
;
case
'p'
:
/* server port */
...
...
@@ -662,15 +688,17 @@ main(int argc, char **argv)
case
'x'
:
/* skip ACL dump */
aclsSkip
=
true
;
break
;
case
'z'
:
/* Old ACL option bjm 1999/05/27 */
fprintf
(
stderr
,
"%s: The -z option(dump ACLs) is now the default, continuing.
\n
"
,
progname
);
break
;
case
'V'
:
version
();
exit
(
0
);
break
;
case
'?'
:
default:
usage
(
progname
);
help
(
progname
);
exit
(
0
);
break
;
default:
fprintf
(
stderr
,
"%s: unknown option -%c
\n
Try -? for help.
\n
"
,
progname
,
c
);
exit
(
1
);
}
}
...
...
@@ -679,7 +707,7 @@ main(int argc, char **argv)
fprintf
(
stderr
,
"%s: INSERT's can not set oids, so INSERT and OID options can not be used together.
\n
"
,
progname
);
exit
(
2
);
exit
(
1
);
}
/* open the output file */
...
...
@@ -697,16 +725,16 @@ main(int argc, char **argv)
fprintf
(
stderr
,
"%s: could not open output file named %s for writing
\n
"
,
progname
,
filename
);
exit
(
2
);
exit
(
1
);
}
}
/* find database */
if
(
!
(
dbname
=
argv
[
optind
])
&&
!
(
dbname
=
getenv
(
"DATABASE"
)))
!
(
dbname
=
getenv
(
"
PG
DATABASE"
)))
{
fprintf
(
stderr
,
"%s: no database name specified
\n
"
,
progname
);
exit
(
2
);
exit
(
1
);
}
/* 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
"
,
finfo
[
i
].
proname
,
finfo
[
i
].
nargs
);
exit
(
2
);
exit
(
1
);
}
parseNumericArray
(
PQgetvalue
(
res
,
i
,
i_proargtypes
),
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
"
,
indinfo
[
i
].
indrelname
);
exit
(
2
);
exit
(
1
);
}
if
(
strcmp
(
indinfo
[
i
].
indproc
,
"0"
)
==
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment