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
Expand all
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
Postgres documentation
-->
-->
...
@@ -26,7 +26,7 @@ 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> ]
...
@@ -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
...
...
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
Postgres documentation
-->
-->
...
@@ -15,17 +15,15 @@ Postgres documentation
...
@@ -15,17 +15,15 @@ Postgres documentation
<application>initlocation</application>
<application>initlocation</application>
</refname>
</refname>
<refpurpose>
<refpurpose>
Create a secondary <productname>Postgre
s
</productname> database storage area
Create a secondary <productname>Postgre
SQL
</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
...
@@ -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
...
@@ -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
...
@@ -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
</para>
a slash and is not valid as a path, it is assumed to be an environment variable,
<para>
which is referenced. See the examples at the end.
Creating a database storage area consists of creating the directories in which
database data might live.
</para>
</para>
<para>
<para>
There are two kinds of arguments for <application>initlocation</application>.
In order to use this command you must be logged in (using 'su', for example)
the database superuser.
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>
</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
...
@@ -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>
...
...
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
Postgres documentation
-->
-->
...
@@ -25,9 +25,9 @@ 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
...
@@ -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
...
@@ -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.
...
...
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
Postgres documentation
-->
-->
...
@@ -24,7 +24,7 @@ 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
...
@@ -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
...
@@ -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>
...
...
src/bin/initdb/initdb.sh
View file @
28125ed5
...
@@ -26,7 +26,7 @@
...
@@ -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
...
@@ -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
...
...
src/bin/initlocation/initlocation.sh
View file @
28125ed5
#!/bin/sh
#!/bin/sh
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
#
#
# init
area
.sh--
# init
location
.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
)
shift
;
PGALTDATA
=
"
$1
"
;
;;
;;
--username
)
shift
;
POSTGRES_SUPERUSERNAME
=
"
$1
"
;
;;
--location
)
--help
)
usage
=
1
;
;;
Location
=
"
$2
"
shift
;;
-u
)
shift
;
POSTGRES_SUPERUSERNAME
=
"
$1
"
;
;;
-D
)
-D
)
shift
;
PGALTDATA
=
"
$1
"
;
;;
Location
=
"
$2
"
-h
)
usage
=
t
;
;;
shift
;;
-
\?
)
usage
=
t
;
;;
-
*
)
badparm
=
$1
;
;;
--help
|
-
\?
)
*
)
PGALTDATA
=
"
$1
"
;
;;
usage
=
t
break
;;
-
*
)
echo
"
$CMDNAME
: unrecognized option
$badparm
"
echo
"Try -? for help."
exit
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
"
$CMDNAME
<location>"
echo
""
echo
""
echo
" -u SUPERUSER, --username=SUPERUSER "
echo
"Report bugs to <bugs@postgresql.org>."
echo
" -D DATADIR, --location=DATADIR "
exit
0
echo
" -?, --help "
echo
""
exit
1
fi
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
if
[
-z
"
$
Location
"
]
;
then
echo
"
$CMDNAME
:
You must identify the target area, where the new data
"
echo
"
$CMDNAME
:
missing required argument <location>
"
echo
"for this database system can reside. Do this with --location
"
echo
"Try -? for help.
"
exit
1
exit
1
fi
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"
# Here's what's going on:
echo
"environment variable set to your username and didn't specify the "
#
echo
"--username option"
# You can call initlocation ENVAR (no dollar sign), then ENVAR will
exit
1
# (a) be tested whether it is valid as a path, or
fi
# (b) be resolved as an environment variable.
# The latter has been the traditional behaviour.
POSTGRES_SUPERUID
=
`
pg_id
$POSTGRES_SUPERUSERNAME
`
#
# You can call initlocation $ENVAR, which will of course be resolved
if
[
$POSTGRES_SUPERUID
=
NOUSER
]
;
then
# by the shell, or initlocation some/path (containing at least one slash).
echo
"Valid username not given. You must specify the username for "
# Then you just take that path.
echo
"the Postgres superuser for the database system you are "
# This should apease users who are confused by the above behaviour.
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
if
!
echo
"
$Location
"
|
grep
-s
'/'
>
/dev/null 2>&1
&&
[
!
-d
"
$Location
"
]
;
then
echo
"Only the unix superuser may initialize a database with a different"
PGALTDATA
=
`
printenv
$Location
2> /dev/null
`
echo
"Postgres superuser. (You must be able to create files that belong"
if
[
-z
"
$PGALTDATA
"
]
;
then
echo
"to the specified unix user)."
echo
"
$CMDNAME
: environment variable
$PGALTDATA
not set"
exit
1
exit
1
fi
haveenv
=
t
else
PGALTDATA
=
"
$Location
"
haveenv
=
f
fi
fi
echo
"We are initializing the database area with username"
\
echo
"The location will be initialized with username
\"
$EffectiveUser
\"
."
"
$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
...
@@ -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."
exit_nicely
fi
else
echo
"Fixing permissions on pre-existing directory
$PGALTDATA
"
chmod
go-rwx
"
$PGALTDATA
"
||
exit_nicely
fi
fi
if
[
!
-d
$PGALTDATA
/base
]
;
then
if
[
!
-d
$PGALTDATA
/base
]
;
then
echo
"Creating Postgres database system directory
$PGALTDATA
/base"
echo
"Creating directory
$PGALTDATA
/base"
echo
mkdir
"
$PGALTDATA
/base"
mkdir
$PGALTDATA
/base
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
exit
1
;
fi
echo
"
$CMDNAME
: could not create
$PGALTDATA
/base"
chown
$POSTGRES_SUPERUSERNAME
$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
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
#!/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
src/bin/pg_dump/pg_dump.c
View file @
28125ed5
This diff is collapsed.
Click to expand it.
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