New scripts for create/drop user/db from Peter Eisentraut
This commit is contained in:
parent
21b69148dc
commit
240e4c98f5
@ -8,7 +8,7 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/doc/src/sgml/Makefile,v 1.10 1999/08/08 04:18:29 thomas Exp $
|
||||
# $Header: /cvsroot/pgsql/doc/src/sgml/Makefile,v 1.11 1999/12/04 04:53:14 momjian Exp $
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@ -67,10 +67,11 @@ vpath %.sgml ./ref
|
||||
|
||||
MANSOURCES= $(wildcard ref/*.sgml)
|
||||
|
||||
APPLICATIONS= createdb.sgml createuser.sgml \
|
||||
createlang.sgml \
|
||||
destroydb.sgml destroyuser.sgml \
|
||||
destroylang.sgml \
|
||||
APPLICATIONS= \
|
||||
createdb.sgml
|
||||
createuser.sgml \
|
||||
dropdb.sgml
|
||||
dropuser.sgml \
|
||||
initdb.sgml initlocation.sgml \
|
||||
ipcclean.sgml \
|
||||
pg_dump.sgml \
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.22 1999/10/09 02:29:15 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.23 1999/12/04 04:53:14 momjian Exp $
|
||||
Documentation Guide
|
||||
Thomas Lockhart
|
||||
|
||||
@ -503,8 +503,8 @@ Status
|
||||
<row><entry> ./doc/src/sgml/ref/createuser.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/declare.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/delete.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/destroydb.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/destroyuser.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/dropdb.sgml </entry><entry> Renamed for v7.0 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/dropuser.sgml </entry><entry> Renamed for v7.0 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/drop_aggregate.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/drop_database.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
<row><entry> ./doc/src/sgml/ref/drop_function.sgml </entry><entry> New for v6.4 </entry></row>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.12 1999/10/01 15:24:09 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.13 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
Complete list of usable sgml source files in this directory.
|
||||
-->
|
||||
@ -100,11 +100,9 @@ Complete list of usable sgml source files in this directory.
|
||||
|
||||
<!-- these are in the "utilities" reference chapter -->
|
||||
<!entity createdb system "createdb.sgml">
|
||||
<!entity createlang system "createlang.sgml">
|
||||
<!entity createuser system "createuser.sgml">
|
||||
<!entity destroydb system "destroydb.sgml">
|
||||
<!entity destroylang system "destroylang.sgml">
|
||||
<!entity destroyuser system "destroyuser.sgml">
|
||||
<!entity dropdb system "dropdb.sgml">
|
||||
<!entity dropuser system "dropuser.sgml">
|
||||
<!entity ecpgRef system "ecpg-ref.sgml">
|
||||
<!entity initdb system "initdb.sgml">
|
||||
<!entity initlocation system "initlocation.sgml">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/commands.sgml,v 1.19 1999/10/01 15:24:09 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/commands.sgml,v 1.20 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -107,11 +107,9 @@ functions supported by <productname>Postgres</productname>.
|
||||
</abstract>
|
||||
|
||||
&createdb;
|
||||
&createlang;
|
||||
&createuser;
|
||||
&destroydb;
|
||||
&destroylang;
|
||||
&destroyuser;
|
||||
&dropdb;
|
||||
&dropuser;
|
||||
&ecpgRef;
|
||||
&pgAccess;
|
||||
&pgAdmin;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.9 1999/07/22 15:09:07 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.10 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -68,7 +68,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATIO
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
CREATEDB
|
||||
CREATE DATABASE
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -184,16 +184,15 @@ comment from Olly; response from Thomas...
|
||||
<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
|
||||
|
||||
<prompt>$</prompt> <userinput>psql olly</userinput>
|
||||
<computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
|
||||
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
|
||||
|
||||
type \? for help on slash commands
|
||||
type \q to quit
|
||||
type \g or terminate with semicolon to execute query
|
||||
You are currently connected to the database: template1
|
||||
|
||||
<computeroutput>Welcome to psql, the PostgreSQL interactive terminal.
|
||||
(Please type \copyright to see the distribution terms of PostgreSQL.)
|
||||
|
||||
Type \h for help with SQL commands,
|
||||
\? for help on internal slash commands,
|
||||
\q to quit,
|
||||
\g or terminate with semicolon to execute query.
|
||||
<prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
|
||||
<computeroutput>CREATEDB</computeroutput>
|
||||
<computeroutput>CREATE DATABASE</computeroutput>
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.10 1999/11/30 03:57:23 momjian Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_user.sgml,v 1.11 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="SQL-CREATEUSER">
|
||||
<refmeta>
|
||||
<refentrytitle>
|
||||
<refentrytitle id="sql-createuser-title">
|
||||
CREATE USER
|
||||
</refentrytitle>
|
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.6 1999/08/06 13:50:30 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.7 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -15,22 +15,20 @@ Postgres documentation
|
||||
<application>createdb</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Create a new <productname>Postgres</productname> database
|
||||
Create a new <productname>PostgreSQL</productname> database
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-07-20</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
createdb [ <replaceable class="parameter">dbname</replaceable> ]
|
||||
createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ -D <replaceable class="parameter">datadir</replaceable> ] [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
|
||||
createdb [ <replaceable class="parameter">options</replaceable> ] <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">description</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-CREATEDB-1">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
@ -39,43 +37,66 @@ createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replacea
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<term>-h, --host <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
is running.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<term>-p, --port <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
is listening for connections.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-u</term>
|
||||
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use password authentication.
|
||||
Prompts for
|
||||
<replaceable class="parameter">username</replaceable>
|
||||
and <replaceable class="parameter">password</replaceable>.
|
||||
Username to connect as.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-D <replaceable class="parameter">datadir</replaceable></term>
|
||||
<term>-W, --password</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Force password prompt.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-e, --echo</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Echo the queries that <application>createdb</application> generates
|
||||
and sends to the backend.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-q, --quiet</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not display a response.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-D, --dbpath <replaceable class="parameter">datadir</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the alternate database location for this database installation.
|
||||
@ -85,177 +106,141 @@ createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replacea
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-E, --encoding <replaceable class="parameter">encoding</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the character encoding scheme to be used with this database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">dbname</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the database to be created. The name must be
|
||||
unique among all <productname>Postgres</productname> databases in this installation.
|
||||
<replaceable class="parameter">dbname</replaceable>
|
||||
defaults to the value of the
|
||||
<envar>USER</envar>
|
||||
environment variable.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">description</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
This optionally specifies a comment to be associated with the newly created
|
||||
database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
|
||||
<literal>-W</literal>, and <literal>-e</literal> are passed on literally to
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-CREATEDB-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>createdb</application> will create files in the
|
||||
<filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
|
||||
data area for the new database.
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
|
||||
createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<term><computeroutput>CREATE DATABASE</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>createdb</application> could not attach to the
|
||||
<application>postmaster</application>
|
||||
process on the specified host and port. If you see this message,
|
||||
ensure that the <application>postmaster</application>
|
||||
is running on the proper host and that you have specified the proper
|
||||
port. If your site uses an authentication system, ensure that you
|
||||
have obtained the required authentication credentials.
|
||||
</para>
|
||||
<para>The database was successfully created.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
|
||||
createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<term><computeroutput>createdb: Database creation failed.</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have a valid entry in the relation <literal>pg_shadow</literal>
|
||||
and and will not be allowed to access <productname>Postgres</productname>.
|
||||
Contact your <productname>Postgres</productname> administrator.
|
||||
</para>
|
||||
<para>(Says it all.)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
|
||||
createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<term><computeroutput>createdb: Comment creation failed.</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have permission to create new databases.
|
||||
Contact your <productname>Postgres</productname> site administrator.
|
||||
The comment/description for the database could not be created.
|
||||
the database itself will have been created already. You can use the
|
||||
<acronym>SQL</acronym> command <command>COMMENT ON DATABASE</command> to
|
||||
create the comment later on.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
|
||||
createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The database already exists.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server. Ensure that your site administrator has
|
||||
properly installed <productname>Postgres</productname>and initialized the site with
|
||||
<application>initdb</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
If there is an error condition, the backend error message will be displayed.
|
||||
See <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title">
|
||||
and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<application>createdb</application> internally runs
|
||||
<command>CREATE DATABASE</command> from <application>psql</application>
|
||||
while connected to the <literal>template1</literal> database.
|
||||
</para>
|
||||
</note>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-CREATEDB-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>createdb</application> creates a new
|
||||
<productname>Postgres</productname> database.
|
||||
The person who executes this command becomes
|
||||
the database administrator, or <acronym>DBA</acronym>,
|
||||
for this database and is the only
|
||||
person, other than the <productname>Postgres</productname> super-user,
|
||||
who can destroy it.
|
||||
<application>createdb</application> creates a new <productname>PostgreSQL</productname>
|
||||
database. The user who executes this command becomes the database owner.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>createdb</application> is a shell script that invokes
|
||||
<application>psql</application>.
|
||||
Hence, a <application>postmaster</application>
|
||||
process must be running on the database server host before
|
||||
<application>createdb</application>
|
||||
is executed. The
|
||||
<envar>PGOPTION</envar>
|
||||
and
|
||||
<envar>PGREALM</envar>
|
||||
environment variables will be passed on to
|
||||
<application>psql</application>
|
||||
and processed as described in
|
||||
<xref linkend="app-psql-title" endterm="app-psql-title">.
|
||||
<application>createdb</application> is a shell script wrapper around the
|
||||
<acronym>SQL</acronym> command
|
||||
<xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title"> via
|
||||
the <productname>PostgreSQL</productname> interactive terminal
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
|
||||
special about creating databases via this or other methods. This means
|
||||
that the <application>psql</application> must be found by the script and that
|
||||
a database server is running at the targeted host. Also, any default
|
||||
settings and environment variables available to <application>psql</application>
|
||||
and the <application>libpq</application> front-end library do apply.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-CREATEDB-2">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To create the database <literal>demo</literal>
|
||||
using the postmaster on the local host, port 5432:
|
||||
using the default database server:
|
||||
|
||||
<programlisting>
|
||||
$ createdb demo
|
||||
$ <userinput>createdb demo</userinput>
|
||||
CREATE DATABASE
|
||||
</programlisting>
|
||||
|
||||
The response is the same as you would have gotten from running the
|
||||
<command>CREATE DATABASE</command> <acronym>SQL</acronym> command.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To create the database <literal>demo</literal>
|
||||
using the postmaster on host eden, port 5000:
|
||||
using the postmaster on host eden, port 5000, using the <literal>LATIN1</literal>
|
||||
encoding scheme and look at the underlying query:
|
||||
|
||||
<programlisting>
|
||||
$ createdb -p 5000 -h eden demo
|
||||
$ <userinput>createdb -p 5000 -h eden -E LATIN1 -e demo</userinput>
|
||||
QUERY: CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'
|
||||
CREATE DATABASE
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -1,172 +0,0 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.1 1999/08/06 13:50:30 thomas Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-CREATELANG">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-CREATELANG-TITLE">
|
||||
<application>createlang</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname id="createlang">
|
||||
<application>createlang</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Add a new programming language to a <productname>Postgres</productname> database
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-08-05</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
createlang [ <replaceable class="parameter">langname</replaceable> ]
|
||||
createlang [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ <replaceable class="parameter">langname</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-CREATELANG-1">
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
<application>createlang</application> accepts the following command line arguments:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">langname</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the backend programming language to be defined.
|
||||
<application>createlang</application> will prompt for
|
||||
<replaceable class="parameter">langname</replaceable>
|
||||
if it is not specified on the command line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>createlang</application> also accepts
|
||||
the following command line arguments for connection parameters:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<!--
|
||||
<varlistentry>
|
||||
<term>-u</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use password authentication.
|
||||
Prompts for
|
||||
<replaceable class="parameter">username</replaceable>
|
||||
and <replaceable class="parameter">password</replaceable>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
-->
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-CREATELANG-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-04</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>createlang</application> installs a new programming
|
||||
language into a <productname>Postgres</productname> server,
|
||||
so has not explicit external output.
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-CREATELANG-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-04</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
|
||||
<para>
|
||||
<application>createlang</application> is a utility for adding a new
|
||||
programming language to a
|
||||
<productname>Postgres</productname> database.
|
||||
<application>createlang</application> currently accepts two
|
||||
languages, <literal>plsql</literal> and <literal>pltcl</literal>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-CREATELANG-2">
|
||||
<title>
|
||||
Notes
|
||||
</title>
|
||||
|
||||
<para>
|
||||
See
|
||||
<xref linkend="sql-createlanguage" endterm="sql-createlanguage-title">
|
||||
for more details.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-CREATELANG-3">
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To install <literal>pltcl</literal>:
|
||||
|
||||
<programlisting>
|
||||
% createlang pltcl
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.5 1999/07/22 15:09:09 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.6 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -15,23 +15,21 @@ Postgres documentation
|
||||
<application>createuser</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Create a new <productname>Postgres</productname> user
|
||||
Create a new <productname>PostgreSQL</productname> user
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-07-20</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsynopsisdivinfo>
|
||||
|
||||
<synopsis>
|
||||
createuser [ <replaceable class="parameter">username</replaceable> ]
|
||||
createuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ -i <replaceable class="parameter">userid</replaceable> ] [ -d | -D ] [ -u | -U ]
|
||||
[ <replaceable class="parameter">username</replaceable> ]
|
||||
createuser [ <replaceable class="parameter">options</replaceable> ] [ <replaceable class="parameter">username</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-CREATEUSER-1">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
@ -40,76 +38,89 @@ createuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<term>-h, --host <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
is running.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<term>-p, --port <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
is listening for connections.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-d</term>
|
||||
<term>-e, --echo</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Allows the user to create databases.
|
||||
Echo the queries that <application>createdb</application> generates
|
||||
and sends to the backend.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-D</term>
|
||||
<term>-q, --quiet</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Forbids the user to create databases.
|
||||
Do not display a response.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-i <replaceable class="parameter">userid</replaceable></term>
|
||||
<term>-d, --createdb</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the numeric identifier to be associated with this user.
|
||||
This identifier must be unique among all
|
||||
<productname>Postgres</productname> users, and is not required
|
||||
to match the operating system UID.
|
||||
You will be prompted for an identifier if none is specified on the command line,
|
||||
and it will suggest an identifier matching the UID.
|
||||
Allows the new user to create databases.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-u</term>
|
||||
<term>-D, --no-createdb</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Allows the user to create other users.
|
||||
Forbids the new user to create databases.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-U</term>
|
||||
<term>-a, --adduser</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Forbids the user to create other users.
|
||||
Allows the new user to create other users.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-A, --no-adduser</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Forbids the new user to create other users.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-P, --pwprompt</term>
|
||||
<listitem>
|
||||
<para>
|
||||
If given, <application>createuser</application> will issue a prompt for
|
||||
the password of the new user. This is not necessary if you do not plan
|
||||
on using password authentication.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@ -118,166 +129,126 @@ createuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replac
|
||||
<term><replaceable class="parameter">username</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the <productname>Postgres</productname> user to be created.
|
||||
This name must be unique among all <productname>Postgres</productname> users.
|
||||
You will be prompted for a name if none is specified on the command line.
|
||||
Specifies the name of the <productname>PostgreSQL</productname> user to be created.
|
||||
This name must be unique among all <productname>PostgreSQL</productname> users.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
You will be prompted for a name and other missing information if it is not
|
||||
specified on the command line.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The options <literal>-h</literal>, <literal>-p</literal>, and <literal>-e</literal>,
|
||||
are passed on literally to <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. If you
|
||||
need the <application>psql</application> options <literal>-U</literal> and
|
||||
<literal>-W</literal> as well, you can uncomment the
|
||||
respective lines in the source. They are disabled by default because of the potential
|
||||
conceptual confusion between existing and new users.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-CREATEUSER-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>createuser</application> will add an entry in the
|
||||
<literal>pg_user</literal> or <literal>pg_shadow</literal> system table.
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
|
||||
createuser: database access failed.
|
||||
</computeroutput></term>
|
||||
<term><computeroutput>CREATE USER</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>createuser</application> could not attach to the
|
||||
<application>postmaster</application>
|
||||
process on the specified host and port. If you see this message,
|
||||
ensure that the <application>postmaster</application>
|
||||
is running on the proper host and that you have specified the proper
|
||||
port. If your site uses an authentication system, ensure that you
|
||||
have obtained the required authentication credentials.
|
||||
All is well.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
|
||||
createuser: database access failed.
|
||||
</computeroutput></term>
|
||||
<term><computeroutput>createuser: Creation of user "<replaceable class="parameter">username</replaceable>" failed.</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have a valid entry in the relation <literal>pg_shadow</literal>
|
||||
and and will not be allowed to access <productname>Postgres</productname>. Contact your
|
||||
<productname>Postgres</productname> administrator.
|
||||
Something went wrong. The user was not created.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
createuser: <replaceable class="parameter">username</replaceable> cannot create users.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have permission to create new users; contact your
|
||||
<productname>Postgres</productname> site administrator.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
createuser: user "<replaceable class="parameter">username</replaceable>" already exists
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The user to be added already has an entry in the
|
||||
<literal>pg_shadow</literal> class.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
database access failed
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server. Ensure that your site administrator has
|
||||
properly installed <productname>Postgres</productname>and initialized the site with
|
||||
<application>initdb</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
<application>createuser</application> internally runs
|
||||
<command>CREATE USER</command> from <application>psql</application>
|
||||
while connected to the <literal>template1</literal> database.
|
||||
</para>
|
||||
</note>
|
||||
If there is an error condition, the backend error message will be displayed.
|
||||
See <xref linkend="SQL-CREATEUSER" endterm="SQL-CREATEUSER-title">
|
||||
and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-CREATEUSER-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
<date>1998-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>createuser</application> creates a
|
||||
new <productname>Postgres</productname> user.
|
||||
new <productname>PostgreSQL</productname> user.
|
||||
Only users with <literal>usesuper</literal> set in
|
||||
the <literal>pg_shadow</literal> class can create
|
||||
new <productname>Postgres</productname> users. As shipped,
|
||||
the user <literal>postgres</literal> can create users.
|
||||
</para>
|
||||
<para>
|
||||
<application>createuser</application> is a shell script that invokes
|
||||
<application>psql</application>.
|
||||
Hence, a <application>postmaster</application>
|
||||
process must be running on the database server host before
|
||||
<application>createuser</application> is executed.
|
||||
The
|
||||
<envar>PGOPTION</envar>
|
||||
and
|
||||
<envar>PGREALM</envar>
|
||||
environment variables will be passed on to
|
||||
<application>psql</application>
|
||||
and processed as described in
|
||||
<xref endterm="app-psql-title" linkend="app-psql-title">.
|
||||
new <productname>Postgres</productname> users.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Once invoked, <application>createuser</application>
|
||||
will ask a series of questions to obtain parameters not specified on
|
||||
the command line. The new user's database login name and a numeric
|
||||
user identifier must be specified.
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The <productname>Postgres</productname> user identifier
|
||||
does not need to be the same as the user's Unix UID. However, typically
|
||||
they are assigned to be the same.
|
||||
</para>
|
||||
</note>
|
||||
<application>createuser</application> is a shell script wrapper around the
|
||||
<acronym>SQL</acronym> command
|
||||
<xref linkend="SQL-CREATEUSER" endterm="SQL-CREATEUSER-title"> via
|
||||
the <productname>PostgreSQL</productname> interactive terminal
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
|
||||
special about creating users via this or other methods. This means
|
||||
that the <application>psql</application> must be found by the script and that
|
||||
a database server is running at the targeted host. Also, any default
|
||||
settings and environment variables available to <application>psql</application>
|
||||
and the <application>libpq</application> front-end library do apply.
|
||||
</para>
|
||||
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
<refsect1 id="R1-APP-CREATEUSER-2">
|
||||
<refsect1info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
You must also describe the privileges of the new user for security purposes.
|
||||
Specifically, you will be asked whether the new user should be able to
|
||||
act as <productname>Postgres</productname> super-user,
|
||||
whether the new user may create new databases and whether the new user
|
||||
is allowed to create other new users.
|
||||
To create a user <literal>joe</literal>
|
||||
on the default database server:
|
||||
|
||||
<programlisting>
|
||||
$ <userinput>createuser joe</userinput>
|
||||
Is the new user allowed to create databases? (y/n) <userinput>n</userinput>
|
||||
Shall the new user be allowed to create more new users? (y/n) <userinput>n</userinput>
|
||||
CREATE USER
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To create the same user <literal>joe</literal>
|
||||
using the postmaster on host eden, port 5000, avoiding
|
||||
the prompts and taking a look at the underlying query:
|
||||
|
||||
<programlisting>
|
||||
$ <userinput>createuser -p 5000 -h eden -D -A -e joe</userinput>
|
||||
QUERY: CREATE USER "joe" NOCREATEDB NOCREATEUSER
|
||||
CREATE USER
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@ -1,281 +0,0 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/destroydb.sgml,v 1.5 1999/07/22 15:09:10 thomas Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-DESTROYDB">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-DESTROYDB-TITLE">
|
||||
<application>destroydb</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>
|
||||
<application>destroydb</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Remove an existing <productname>Postgres</productname> database
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-07-20</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
destroydb [ <replaceable class="parameter">dbname</replaceable> ]
|
||||
destroydb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ -i ] [ <replaceable class="parameter">dbname</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYDB-1">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-i</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Run in interactive mode.
|
||||
Prompts for confirmation before destroying a database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">dbname</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the database to be destroyed. The database
|
||||
must be one of the existing <productname>Postgres</productname> databases
|
||||
in this installation.
|
||||
<replaceable class="parameter">dbname</replaceable>
|
||||
defaults to the value of the
|
||||
<envar>USER</envar>
|
||||
environment variable.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYDB-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>destroydb</application> will remove files from the
|
||||
<filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
|
||||
data area for the existing database.
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
connectDB() failed: Is the postmaster running and accepting connections
|
||||
at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>destroydb</application> could not attach to the
|
||||
<application>postmaster</application>
|
||||
process on the specified host and port. If you see this message,
|
||||
ensure that the <application>postmaster</application>
|
||||
is running on the proper host and that you have specified the proper
|
||||
port. If your site uses an authentication system, ensure that you
|
||||
have obtained the required authentication credentials.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have a valid entry in the relation <literal>pg_shadow</literal>
|
||||
and and will not be allowed to access <productname>Postgres</productname>.
|
||||
Contact your <productname>Postgres</productname> administrator.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have permission to destroy (or create) databases.
|
||||
Contact your <productname>Postgres</productname> site administrator.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' does not exist.
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The database to be removed does not have an entry in the
|
||||
<literal>pg_database</literal> class.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
ERROR: destroydb: database '<replaceable class="parameter">dbname</replaceable>' is not owned by you.
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You are not the Database Administrator (DBA) for the specified database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
destroydb: database destroy failed on <replaceable class="parameter">dbname</replaceable>.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server. Ensure that your site administrator has
|
||||
properly installed <productname>Postgres</productname>and initialized the site with
|
||||
<application>initdb</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<application>destroydb</application> internally runs
|
||||
<command>DESTROY DATABASE</command> from <application>psql</application>
|
||||
while connected to the <literal>template1</literal> database.
|
||||
</para>
|
||||
</note>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYDB-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>destroydb</application> destroys an existing
|
||||
<productname>Postgres</productname> database.
|
||||
The person who executes this command must be
|
||||
the database administrator, or <acronym>DBA</acronym>,
|
||||
or must be the <productname>Postgres</productname> super-user.
|
||||
The program runs silently; no confirmation message will be displayed.
|
||||
After the database is destroyed, a Unix shell prompt will reappear.
|
||||
</para>
|
||||
<para>
|
||||
All references to
|
||||
the database are removed, including the directory containing this
|
||||
database and its associated files.
|
||||
</para>
|
||||
<para>
|
||||
<application>destroydb</application> is a shell script that invokes
|
||||
<application>psql</application>.
|
||||
Hence, a <application>postmaster</application>
|
||||
process must be running on the database server host before
|
||||
<application>destroydb</application>
|
||||
is executed. The
|
||||
<envar>PGOPTION</envar>
|
||||
and
|
||||
<envar>PGREALM</envar>
|
||||
environment variables will be passed on to
|
||||
<application>psql</application>
|
||||
and processed as described in <xref endterm="app-psql-title" linkend="app-psql-title">.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYDB-2">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To destroy the database <literal>demo</literal>
|
||||
using the postmaster on the local host, port 5432:
|
||||
<programlisting>
|
||||
destroydb demo
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
To destroy the database <literal>demo</literal>
|
||||
using the postmaster on host eden, port 5000:
|
||||
<programlisting>
|
||||
destroydb -p 5000 -h eden demo
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
@ -1,172 +0,0 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/destroylang.sgml,v 1.1 1999/08/06 13:50:30 thomas Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-DESTROYLANG">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-DESTROYLANG-TITLE">
|
||||
<application>destroylang</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname id="destroylang">
|
||||
<application>destroylang</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Add a programming language to a <productname>Postgres</productname> database
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-08-05</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
destroylang [ <replaceable class="parameter">langname</replaceable> ]
|
||||
destroylang [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ <replaceable class="parameter">langname</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYLANG-1">
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
<application>destroylang</application> accepts the following command line arguments:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">langname</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the backend programming language to be destroyed.
|
||||
<application>destroylang</application> will prompt for
|
||||
<replaceable class="parameter">langname</replaceable>
|
||||
if it is not specified on the command line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>destroylang</application> also accepts
|
||||
the following command line arguments for connection parameters:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<!--
|
||||
<varlistentry>
|
||||
<term>-u</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use password authentication.
|
||||
Prompts for
|
||||
<replaceable class="parameter">username</replaceable>
|
||||
and <replaceable class="parameter">password</replaceable>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
-->
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYLANG-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-04</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>destroylang</application> removes an existing programming
|
||||
language from a <productname>Postgres</productname> server,
|
||||
so has not explicit external output.
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYLANG-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-04</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
|
||||
<para>
|
||||
<application>destroylang</application> is a utility for removing an
|
||||
existing programming language from a
|
||||
<productname>Postgres</productname> database.
|
||||
<application>destroylang</application> currently accepts two
|
||||
languages, <literal>plsql</literal> and <literal>pltcl</literal>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYLANG-2">
|
||||
<title>
|
||||
Notes
|
||||
</title>
|
||||
|
||||
<para>
|
||||
See
|
||||
<xref linkend="sql-droplanguage" endterm="sql-droplanguage-title">
|
||||
for more details.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYLANG-3">
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To remove <literal>pltcl</literal>:
|
||||
|
||||
<programlisting>
|
||||
% destroylang pltcl
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
@ -1,259 +0,0 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/destroyuser.sgml,v 1.5 1999/07/22 15:09:10 thomas Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-DESTROYUSER">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-DESTROYUSER-TITLE">
|
||||
<application>destroyuser</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>
|
||||
<application>destroyuser</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Destroy a <productname>Postgres</productname> user and associated databases
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-07-20</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
destroyuser [ <replaceable class="parameter">username</replaceable> ]
|
||||
destroyuser [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
|
||||
[ <replaceable class="parameter">username</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYUSER-1">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running. Defaults to using a local Unix domain socket
|
||||
rather than an IP connection.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections. The port number defaults to 5432,
|
||||
or the value of the <envar>PGPORT</envar>
|
||||
environment variable (if set).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">username</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the <productname>Postgres</productname> user to be removed.
|
||||
This name must exist in the <productname>Postgres</productname> installation.
|
||||
You will be prompted for a name if none is specified on the command line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-DESTROYUSER-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
<application>destroyuser</application> will remove an entry in the
|
||||
<literal>pg_user</literal> or <literal>pg_shadow</literal> system table,
|
||||
and will remove all databases for which that user is the administrator
|
||||
(<acronym>DBA</acronym>).
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
connectDB() failed: Is the postmaster running and accepting connections
|
||||
at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
|
||||
destroyuser: database access failed.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<application>destroyuser</application> could not attach to the
|
||||
<application>postmaster</application>
|
||||
process on the specified host and port. If you see this message,
|
||||
ensure that the <application>postmaster</application>
|
||||
is running on the proper host and that you have specified the proper
|
||||
port. If your site uses an authentication system, ensure that you
|
||||
have obtained the required authentication credentials.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
Connection to database 'template1' failed.
|
||||
FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
|
||||
destroyuser: database access failed.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have a valid entry in the relation <literal>pg_shadow</literal>
|
||||
and and will not be allowed to access <productname>Postgres</productname>. Contact your
|
||||
<productname>Postgres</productname> administrator.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
destroyuser: <replaceable class="parameter">username</replaceable> cannot delete users.
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You do not have permission to delete users; contact your
|
||||
<productname>Postgres</productname> site administrator.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
destroyuser: user "<replaceable class="parameter">username</replaceable>" already exists
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The user to be added already has an entry in the
|
||||
<literal>pg_shadow</literal> class.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
database access failed
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server. Ensure that your site administrator has
|
||||
properly installed <productname>Postgres</productname>and initialized the site with
|
||||
<application>initdb</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
destroydb on <replaceable class="parameter">dbname</replaceable> failed - exiting
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server. There was possibly a Unix permissions problem with the
|
||||
specified database.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
delete of user <replaceable class="parameter">username</replaceable> was UNSUCCESSFUL
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An internal error occurred in <application>psql</application>
|
||||
or in the backend server.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
<application>destroyuser</application> internally runs
|
||||
<command>DROP USER</command> from <application>psql</application>
|
||||
while connected to the <literal>template1</literal> database.
|
||||
</para>
|
||||
</note>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-DESTROYUSER-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>destroyuser</application> removes an existing
|
||||
<productname>Postgres</productname> user
|
||||
and the databases for which that user
|
||||
is database administrator.
|
||||
Only users with <literal>usesuper</literal> set in
|
||||
the <literal>pg_shadow</literal> class can destroy
|
||||
<productname>Postgres</productname> users. As shipped,
|
||||
the user <literal>postgres</literal> can remove users.
|
||||
</para>
|
||||
<para>
|
||||
<application>destroyuser</application> is a shell script that invokes
|
||||
<application>psql</application>.
|
||||
Hence, a <application>postmaster</application>
|
||||
process must be running on the database server host before
|
||||
<application>destroyuser</application> is executed.
|
||||
The
|
||||
<envar>PGOPTION</envar>
|
||||
and
|
||||
<envar>PGREALM</envar>
|
||||
environment variables will be passed on to
|
||||
<application>psql</application>
|
||||
and processed as described in <xref endterm="app-psql-title" linkend="app-psql-title">.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Once invoked, <application>destroyuser</application>
|
||||
will warn you about the databases that will be destroyed in the
|
||||
process and permit you to abort the removal of the user if desired.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_database.sgml,v 1.7 1999/08/06 13:50:30 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_database.sgml,v 1.8 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -59,7 +59,7 @@ DROP DATABASE <replaceable class="PARAMETER">name</replaceable>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>
|
||||
DESTROYDB
|
||||
DROP DATABASE
|
||||
</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
@ -116,14 +116,13 @@ WARN: destroydb: database "<replaceable class="parameter">name</replaceable>" do
|
||||
|
||||
<para>
|
||||
This query cannot be executed while connected to the target
|
||||
database. It is usually preferable to use
|
||||
<xref linkend="app-destroydb" endterm="app-destroydb-title">
|
||||
instead.
|
||||
database. Thus, it might be more convenient to use
|
||||
<xref linkend="app-dropdb" endterm="app-dropdb-title">
|
||||
from the shell instead.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Refer to
|
||||
<xref linkend="app-createdb" endterm="app-createdb-title"> and
|
||||
<xref linkend="sql-createdatabase" endterm="sql-createdatabase-title">
|
||||
for information on how to create a database.
|
||||
</para>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_user.sgml,v 1.7 1999/07/22 15:09:11 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_user.sgml,v 1.8 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
@ -95,7 +95,7 @@ ERROR: removeUser: user "<replaceable class="parameter">name</replaceable>" does
|
||||
along with any databases owned by the user. It
|
||||
does not remove tables, views, or triggers owned by the
|
||||
named user in databases not owned by the user. This statement
|
||||
can be used in place of the <application>destroyuser</application>
|
||||
can be used in place of the <application>dropuser</application>
|
||||
script, regardless of how the user was created.
|
||||
</para>
|
||||
|
||||
|
232
doc/src/sgml/ref/dropdb.sgml
Normal file
232
doc/src/sgml/ref/dropdb.sgml
Normal file
@ -0,0 +1,232 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.1 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-DROPDB">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-DROPDB-TITLE">
|
||||
<application>dropdb</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>
|
||||
<application>dropdb</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Remove an existing <productname>PostgreSQL</productname> database
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-11-07</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
dropdb [ <replaceable class="parameter">options</replaceable> ] <replaceable class="parameter">dbname</replaceable>
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-DROPDB-1">
|
||||
<refsect2info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h, --host <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p, --port <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Username to connect as.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-W, --password</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Force password prompt.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-e, --echo</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Echo the queries that <application>dropdb</application> generates
|
||||
and sends to the backend.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-q, --quiet</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not display a response.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-i, --interactive</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Issues a verification prompt before doing anything destructive.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">dbname</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the database to be removed. The database
|
||||
must be one of the existing <productname>PostgreSQL</productname> databases
|
||||
in this installation.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
|
||||
<literal>-W</literal>, and <literal>-e</literal> are passed on literally to
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
|
||||
<refsect2 id="R2-APP-DROPDB-2">
|
||||
<refsect2info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>DROP DATABASE</computeroutput></term>
|
||||
<listitem>
|
||||
<para>The database was successfully removed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>dropdb: Database removal failed.</computeroutput></term>
|
||||
<listitem>
|
||||
<para>Something didn't work out.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
If there is an error condition, the backend error message will be displayed.
|
||||
See <xref linkend="SQL-DROPDATABASE" endterm="SQL-DROPDATABASE-title">
|
||||
and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
|
||||
<refsect1 id="R1-APP-DROPDB-1">
|
||||
<refsect1info>
|
||||
<date>1998-10-02</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>dropdb</application> destroys an existing
|
||||
<productname>PostgreSQL</productname> database.
|
||||
The user who executes this command must be a database
|
||||
superuser or the owner of the database.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>dropdb</application> is a shell script wrapper around the
|
||||
<acronym>SQL</acronym> command
|
||||
<xref linkend="SQL-DROPDATABASE" endterm="SQL-DROPDATABASE-title"> via
|
||||
the <productname>PostgreSQL</productname> interactive terminal
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
|
||||
special about dropping databases via this or other methods. This means
|
||||
that the <application>psql</application> must be found by the script and that
|
||||
a database server is running at the targeted host. Also, any default
|
||||
settings and environment variables available to <application>psql</application>
|
||||
and the <application>libpq</application> front-end library do apply.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-DROPDB-2">
|
||||
<refsect1info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To destroy the database <literal>demo</literal>
|
||||
on the default database server:
|
||||
<programlisting>
|
||||
$ <userinput>dropdb demo</userinput>
|
||||
DROP DATABASE
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
To destroy the database <literal>demo</literal>
|
||||
using the postmaster on host eden, port 5000, with verification
|
||||
and a peek at the underlying query:
|
||||
<programlisting>
|
||||
$ <userinput>dropdb -p 5000 -h eden -i -e demo</userinput>
|
||||
Database "demo" will be permanently deleted.
|
||||
Are you sure? (y/n) <userinput>y</userinput>
|
||||
QUERY: DROP DATABASE "demo"
|
||||
DROP DATABASE
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
227
doc/src/sgml/ref/dropuser.sgml
Normal file
227
doc/src/sgml/ref/dropuser.sgml
Normal file
@ -0,0 +1,227 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.1 1999/12/04 04:53:15 momjian Exp $
|
||||
Postgres documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-DROPUSER">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-DROPUSER-TITLE">
|
||||
<application>dropuser</application>
|
||||
</refentrytitle>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>
|
||||
<application>dropuser</application>
|
||||
</refname>
|
||||
<refpurpose>
|
||||
Drops (removes) a <productname>Postgres</productname> user
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<refsynopsisdivinfo>
|
||||
<date>1999-11-07</date>
|
||||
</refsynopsisdivinfo>
|
||||
<synopsis>
|
||||
dropuser [ <replaceable class="parameter">options</replaceable> ] [ <replaceable class="parameter">username</replaceable> ]
|
||||
</synopsis>
|
||||
|
||||
<refsect2 id="R2-APP-DROPUSER-1">
|
||||
<refsect2info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Inputs
|
||||
</title>
|
||||
<para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>-h, --host <replaceable class="parameter">host</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the hostname of the machine on which the
|
||||
<application>postmaster</application>
|
||||
is running.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-p, --port <replaceable class="parameter">port</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the Internet TCP/IP port or local Unix domain socket file
|
||||
extension on which the <application>postmaster</application>
|
||||
is listening for connections.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-e, --echo</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Echo the queries that <application>createdb</application> generates
|
||||
and sends to the backend.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-q, --quiet</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not display a response.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-i, --interactive</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prompt for confirmation before actually removing the user.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">username</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the name of the <productname>PostgreSQL</productname> user to be removed.
|
||||
This name must exist in the <productname>Postgres</productname> installation.
|
||||
You will be prompted for a name if none is specified on the command line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The options <literal>-h</literal>, <literal>-p</literal>, and <literal>-e</literal>,
|
||||
are passed on literally to <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. If you
|
||||
need the <application>psql</application> options <literal>-U</literal> and
|
||||
<literal>-W</literal> as well, you can uncomment the
|
||||
respective lines in the source. They are disabled by default because of the potential
|
||||
conceptual confusion between existing and new users.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2 id="R2-APP-DROPUSER-2">
|
||||
<refsect2info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect2info>
|
||||
<title>
|
||||
Outputs
|
||||
</title>
|
||||
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><computeroutput>DROP USER</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
All is well.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><computeroutput>dropuser: Deletion of user "<replaceable class="parameter">username</replaceable>" failed.</computeroutput></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Something went wrong. The user was not removed.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
If there is an error condition, the backend error message will be displayed.
|
||||
See <xref linkend="SQL-DROPUSER" endterm="SQL-DROPUSER-title">
|
||||
and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-DROPUSER-1">
|
||||
<refsect1info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Description
|
||||
</title>
|
||||
<para>
|
||||
<application>dropuser</application> removes an existing
|
||||
<productname>PostgreSQL</productname> user
|
||||
<emphasis>and</emphasis> the databases which that user owned.
|
||||
Only users with <literal>usesuper</literal> set in
|
||||
the <literal>pg_shadow</literal> class can destroy
|
||||
<productname>PostgreSQL</productname> users.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<application>dropuser</application> is a shell script wrapper around the
|
||||
<acronym>SQL</acronym> command
|
||||
<xref linkend="SQL-DROPUSER" endterm="SQL-DROPUSER-title"> via
|
||||
the <productname>PostgreSQL</productname> interactive terminal
|
||||
<xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
|
||||
special about removing users via this or other methods. This means
|
||||
that the <application>psql</application> must be found by the script and that
|
||||
a database server is running at the targeted host. Also, any default
|
||||
settings and environment variables available to <application>psql</application>
|
||||
and the <application>libpq</application> front-end library do apply.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="R1-APP-DROPUSER-2">
|
||||
<refsect1info>
|
||||
<date>1999-11-07</date>
|
||||
</refsect1info>
|
||||
<title>
|
||||
Usage
|
||||
</title>
|
||||
<para>
|
||||
To remove user <literal>joe</literal>
|
||||
from the default database server:
|
||||
<programlisting>
|
||||
$ <userinput>dropuser joe</userinput>
|
||||
DROP USER
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To remove user <literal>joe</literal>
|
||||
using the postmaster on host eden, port 5000, with verification
|
||||
and a peek at the underlying query:
|
||||
<programlisting>
|
||||
$ <userinput>dropuser -p 5000 -h eden -i -e joe</userinput>
|
||||
User "joe" and any owned databases will be permanently deleted.
|
||||
Are you sure? (y/n) <userinput>y</userinput>
|
||||
QUERY: DROP USER "joe"
|
||||
DROP USER
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
@ -7,16 +7,15 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.18 1999/05/20 16:49:59 wieck Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.19 1999/12/04 04:53:16 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ..
|
||||
include ../Makefile.global
|
||||
|
||||
DIRS = pg_id pg_version psql pg_dump pg_passwd cleardbdir createdb \
|
||||
createlang createuser destroydb destroylang destroyuser initdb \
|
||||
vacuumdb initlocation ipcclean
|
||||
DIRS = pg_id pg_version psql pg_dump pg_passwd cleardbdir \
|
||||
createlang destroylang initdb initlocation ipcclean
|
||||
|
||||
ifdef MULTIBYTE
|
||||
DIRS += pg_encoding
|
||||
|
@ -1,28 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for bin/createdb
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/createdb/Attic/Makefile,v 1.10 1998/07/26 04:31:12 scrappy Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global
|
||||
|
||||
all: createdb
|
||||
|
||||
createdb: createdb.sh
|
||||
sed 's/__MULTIBYTE__/$(MULTIBYTE)/' createdb.sh > createdb
|
||||
|
||||
install: createdb
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
|
||||
|
||||
clean:
|
||||
rm -f createdb
|
||||
|
||||
dep depend:
|
@ -1,121 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# createdb.sh--
|
||||
# create a postgres database
|
||||
#
|
||||
# this program runs the monitor with the "-c" option to create
|
||||
# the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.12 1999/11/18 21:47:37 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
MBENABLED=__MULTIBYTE__
|
||||
MB=
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
if [ -z "$LOGNAME" ]; then
|
||||
if [ -z "`whoami`" ]; then
|
||||
echo "$CMDNAME: cannot determine user name"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
USER=$LOGNAME
|
||||
export USER
|
||||
fi
|
||||
fi
|
||||
|
||||
dbname=$USER
|
||||
|
||||
PASSWDOPT="";
|
||||
|
||||
while test -n "$1"
|
||||
do
|
||||
case $1 in
|
||||
--help) usage=1;;
|
||||
|
||||
-a) AUTHSYS=$2; shift;;
|
||||
-h) PGHOST=$2; shift;;
|
||||
-p) PGPORT=$2; shift;;
|
||||
-u) PASSWDOPT=$1;;
|
||||
-D) dbpath=$2; shift;;
|
||||
-E)
|
||||
if [ -z "$MBENABLED" ];then
|
||||
echo "$CMDNAME: you need to turn on MB compile time option"
|
||||
exit 1
|
||||
fi
|
||||
MB=$2
|
||||
MBID=`pg_encoding $MB`
|
||||
if [ -z "$MBID" ];then
|
||||
echo "$CMDNAME: $MB is not a valid encoding name"
|
||||
exit 1
|
||||
fi
|
||||
shift;;
|
||||
-*) echo "$CMDNAME: unrecognized parameter $1"; usage=1;;
|
||||
*) dbname=$1;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if [ "$usage" ]; then
|
||||
if [ -z "$MBENABLED" ];then
|
||||
echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> [dbname]"
|
||||
exit 1
|
||||
else
|
||||
echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> -E <encoding> [dbname]"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$AUTHSYS" ]; then
|
||||
AUTHOPT=""
|
||||
else
|
||||
AUTHOPT="-a $AUTHSYS"
|
||||
fi
|
||||
|
||||
if [ -z "$PGHOST" ]; then
|
||||
PGHOSTOPT=""
|
||||
else
|
||||
PGHOSTOPT="-h $PGHOST"
|
||||
fi
|
||||
|
||||
if [ -z "$PGPORT" ]; then
|
||||
PGPORTOPT=""
|
||||
else
|
||||
PGPORTOPT="-p $PGPORT"
|
||||
fi
|
||||
|
||||
if [ -z "$dbpath" ]; then
|
||||
location=""
|
||||
else
|
||||
# if [ ! -d "$dbpath"/base ]; then
|
||||
# echo "$CMDNAME: database creation failed on $dbname."
|
||||
# echo "directory $dbpath/base not found."
|
||||
# exit 1
|
||||
# fi
|
||||
location="with location = '$dbpath'"
|
||||
fi
|
||||
if [ -z "$MBENABLED" -o -z "$MB" ]; then
|
||||
encoding=""
|
||||
else
|
||||
encoding="encoding = '$MB'"
|
||||
if [ -z "$location" ];then
|
||||
encoding="with $encoding"
|
||||
fi
|
||||
fi
|
||||
|
||||
psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create database \"$dbname\" $location $encoding" template1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: database creation failed on $dbname."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,32 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for bin/createuser
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/createuser/Attic/Makefile,v 1.9 1998/08/22 05:19:16 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global
|
||||
|
||||
SEDSCRIPT= \
|
||||
-e "s^PG_OPT_DASH_N_PARAM^$(DASH_N)^g" \
|
||||
-e "s^PG_OPT_BACKSLASH_C_PARAM^$(BACKSLASH_C)^g"
|
||||
|
||||
all: createuser
|
||||
|
||||
createuser: createuser.sh
|
||||
sed $(SEDSCRIPT) <createuser.sh >createuser
|
||||
|
||||
install: createuser
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
|
||||
|
||||
clean:
|
||||
rm -f createuser
|
||||
|
||||
dep depend:
|
@ -1,252 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# createuser.sh--
|
||||
# utility for creating a user in the POSTGRES database
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/createuser/Attic/createuser.sh,v 1.13 1999/09/27 16:44:56 momjian Exp $
|
||||
#
|
||||
# Note - this should NOT be setuid.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
SYSID=
|
||||
CANADDUSER=
|
||||
CANCREATE=
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
if [ -z "$LOGNAME" ]; then
|
||||
if [ -z "`whoami`" ]; then
|
||||
echo "$CMDNAME: cannot determine user name"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
USER=$LOGNAME
|
||||
export USER
|
||||
fi
|
||||
fi
|
||||
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
-a) AUTHSYS=$2; shift;;
|
||||
-h) PGHOST=$2; shift;;
|
||||
-p) PGPORT=$2; shift;;
|
||||
-d) CANCREATE=t;;
|
||||
-D) CANCREATE=f;;
|
||||
-u) CANADDUSER=t;;
|
||||
-U) CANADDUSER=f;;
|
||||
-i) SYSID=$2; shift;;
|
||||
*) NEWUSER=$1;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if [ -z "$AUTHSYS" ]; then
|
||||
AUTHOPT=""
|
||||
else
|
||||
AUTHOPT="-a $AUTHSYS"
|
||||
fi
|
||||
|
||||
if [ -z "$PGHOST" ]; then
|
||||
PGHOSTOPT=""
|
||||
else
|
||||
PGHOSTOPT="-h $PGHOST"
|
||||
fi
|
||||
|
||||
if [ -z "$PGPORT" ]; then
|
||||
PGPORTOPT=""
|
||||
else
|
||||
PGPORTOPT="-p $PGPORT"
|
||||
fi
|
||||
|
||||
PARGS="-tq $AUTHOPT $PGHOSTOPT $PGPORTOPT"
|
||||
|
||||
#
|
||||
# generate the first part of the actual monitor command
|
||||
#
|
||||
|
||||
PSQL="psql $PARGS"
|
||||
|
||||
#
|
||||
# see if user $USER is a superuser
|
||||
#
|
||||
|
||||
QUERY="select usesuper from pg_user where usename = '$USER' "
|
||||
#echo $QUERY
|
||||
|
||||
ADDUSER=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$ADDUSER" ]
|
||||
then
|
||||
|
||||
if [ $ADDUSER != "t" ]
|
||||
then
|
||||
echo "$CMDNAME: $USER cannot create users." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# get the user name of the new user. Make sure it doesn't already exist.
|
||||
#
|
||||
|
||||
if [ -z "$NEWUSER" ]
|
||||
then
|
||||
echo PG_OPT_DASH_N_PARAM "Enter name of user to add ---> PG_OPT_BACKSLASH_C_PARAM"
|
||||
read NEWUSER
|
||||
fi
|
||||
|
||||
QUERY="select usesysid from pg_user where usename = '$NEWUSER' "
|
||||
|
||||
RES=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$RES" ]
|
||||
then
|
||||
echo "$CMDNAME: user "\"$NEWUSER\"" already exists" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done=0
|
||||
|
||||
#
|
||||
# get the system id of the new user. Make sure it is unique.
|
||||
#
|
||||
|
||||
while [ $done -ne 1 ]
|
||||
do
|
||||
DEFSYSID=`pg_id $NEWUSER 2>/dev/null`
|
||||
if [ $? -eq 0 ]; then
|
||||
DEFMSG=" or RETURN to use unix user ID: $DEFSYSID"
|
||||
else
|
||||
DEFMSG=
|
||||
DEFSYSID=
|
||||
fi
|
||||
while [ -z "$SYSID" ]
|
||||
do
|
||||
echo PG_OPT_DASH_N_PARAM "Enter user's postgres ID$DEFMSG -> PG_OPT_BACKSLASH_C_PARAM"
|
||||
read SYSID
|
||||
[ -z "$SYSID" ] && SYSID=$DEFSYSID;
|
||||
SYSIDISNUM=`echo $SYSID | egrep '^[0-9]+$'`
|
||||
if [ -z "$SYSIDISNUM" ]
|
||||
then
|
||||
echo "$CMDNAME: the postgres ID must be a number"
|
||||
SYSID=
|
||||
fi
|
||||
done
|
||||
QUERY="select usename from pg_user where usesysid = '$SYSID'::int4"
|
||||
RES=`$PSQL -c "$QUERY" template1`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed."
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$RES" ]
|
||||
then
|
||||
echo
|
||||
echo "$CMDNAME: $SYSID already belongs to $RES, pick another"
|
||||
DEFMSG= DEFSYSID= SYSID=
|
||||
else
|
||||
done=1
|
||||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# get the rest of the user info...
|
||||
#
|
||||
|
||||
#
|
||||
# can the user create databases?
|
||||
#
|
||||
if [ -z "$CANCREATE" ]
|
||||
then
|
||||
yn=f
|
||||
|
||||
while [ "$yn" != y -a "$yn" != n ]
|
||||
do
|
||||
echo PG_OPT_DASH_N_PARAM "Is user \"$NEWUSER\" allowed to create databases (y/n) PG_OPT_BACKSLASH_C_PARAM"
|
||||
read yn
|
||||
done
|
||||
|
||||
if [ "$yn" = y ]
|
||||
then
|
||||
CANCREATE=t
|
||||
else
|
||||
CANCREATE=f
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# can the user add users?
|
||||
#
|
||||
|
||||
if [ -z "$CANADDUSER" ]
|
||||
then
|
||||
yn=f
|
||||
|
||||
while [ "$yn" != y -a "$yn" != n ]
|
||||
do
|
||||
echo PG_OPT_DASH_N_PARAM "Is user \"$NEWUSER\" a superuser? (y/n) PG_OPT_BACKSLASH_C_PARAM"
|
||||
read yn
|
||||
done
|
||||
|
||||
if (test "$yn" = y)
|
||||
then
|
||||
CANADDUSER=t
|
||||
else
|
||||
CANADDUSER=f
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CANCREATE" = "t" -o "$CANADDUSER" = "t" ]
|
||||
then CANCATUPD="t"
|
||||
else CANCATUPD="f"
|
||||
fi
|
||||
|
||||
QUERY="insert into pg_shadow \
|
||||
(usename, usesysid, usecreatedb, usetrace, usesuper, usecatupd) \
|
||||
values \
|
||||
('$NEWUSER', $SYSID, '$CANCREATE', 'f', '$CANADDUSER','$CANCATUPD')"
|
||||
|
||||
RES=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
#
|
||||
# Wrap things up. If the user was created successfully, AND the user was
|
||||
# NOT allowed to create databases, remind the DBA to create one for the user.
|
||||
#
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: $NEWUSER was NOT added successfully"
|
||||
else
|
||||
echo "$CMDNAME: $NEWUSER was successfully added"
|
||||
if [ "$CANCREATE" = f ]
|
||||
then
|
||||
echo PG_OPT_DASH_N_PARAM "Shall I create a database for \"$NEWUSER\" (y/n) PG_OPT_BACKSLASH_C_PARAM"
|
||||
read yn
|
||||
|
||||
if [ "$yn" = y ]
|
||||
then
|
||||
createdb $NEWUSER
|
||||
else
|
||||
echo "don't forget to create a database for $NEWUSER"
|
||||
fi
|
||||
fi
|
||||
fi
|
@ -1,28 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for bin/destroydb
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/Makefile,v 1.8 1998/04/06 16:49:51 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global
|
||||
|
||||
all: destroydb
|
||||
|
||||
destroydb: destroydb.sh
|
||||
cp destroydb.sh destroydb
|
||||
|
||||
install: destroydb
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
|
||||
|
||||
clean:
|
||||
rm -f destroydb
|
||||
|
||||
dep depend:
|
@ -1,85 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# destroydb.sh--
|
||||
# destroy a postgres database
|
||||
#
|
||||
# this program runs the monitor with the ? option to destroy
|
||||
# the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/destroydb.sh,v 1.9 1999/11/18 21:47:37 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
if [ -z "$LOGNAME" ]; then
|
||||
if [ -z "`whoami`" ]; then
|
||||
echo "$CMDNAME: cannot determine user name"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
USER=$LOGNAME
|
||||
export USER
|
||||
fi
|
||||
fi
|
||||
|
||||
dbname=$USER
|
||||
forcedel=t
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
case $1 in
|
||||
-i) forcedel=f;;
|
||||
-a) AUTHSYS=$2; shift;;
|
||||
-h) PGHOST=$2; shift;;
|
||||
-p) PGPORT=$2; shift;;
|
||||
*) dbname=$1;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
if [ -z "$AUTHSYS" ]; then
|
||||
AUTHOPT=""
|
||||
else
|
||||
AUTHOPT="-a $AUTHSYS"
|
||||
fi
|
||||
|
||||
if [ -z "$PGHOST" ]; then
|
||||
PGHOSTOPT=""
|
||||
else
|
||||
PGHOSTOPT="-h $PGHOST"
|
||||
fi
|
||||
|
||||
if [ -z "$PGPORT" ]; then
|
||||
PGPORTOPT=""
|
||||
else
|
||||
PGPORTOPT="-p $PGPORT"
|
||||
fi
|
||||
|
||||
answer=y
|
||||
if [ "$forcedel" = f ]
|
||||
then
|
||||
answer=f
|
||||
|
||||
while [ "$answer" != y -a "$answer" != n ]
|
||||
do
|
||||
echo "Database '$dbname' will be permanently deleted."
|
||||
echo -n "Are you sure? (y/n) "
|
||||
read answer
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$answer" = y ]
|
||||
then
|
||||
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database \"$dbname\"" template1
|
||||
if [ $? -ne 0 ]
|
||||
then echo "$CMDNAME: database destroy failed on $dbname."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,32 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for bin/destroyuser
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/Makefile,v 1.9 1998/08/22 05:19:19 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global
|
||||
|
||||
SEDSCRIPT= \
|
||||
-e "s^PG_OPT_DASH_N_PARAM^$(DASH_N)^g" \
|
||||
-e "s^PG_OPT_BACKSLASH_C_PARAM^$(BACKSLASH_C)^g"
|
||||
|
||||
all: destroyuser
|
||||
|
||||
destroyuser: destroyuser.sh
|
||||
sed $(SEDSCRIPT) <destroyuser.sh >destroyuser
|
||||
|
||||
install: destroyuser
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
|
||||
|
||||
clean:
|
||||
rm -f destroyuser
|
||||
|
||||
dep depend:
|
@ -1,196 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# destroyuser.sh--
|
||||
# utility for destroying a user from the POSTGRES database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/destroyuser/Attic/destroyuser.sh,v 1.11 1999/03/14 16:00:55 momjian Exp $
|
||||
#
|
||||
# Note - this should NOT be setuid.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
if [ -z "$LOGNAME" ]; then
|
||||
if [ -z "`whoami`" ]; then
|
||||
echo "$CMDNAME: cannot determine user name"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
USER=$LOGNAME
|
||||
export USER
|
||||
fi
|
||||
fi
|
||||
|
||||
while (test -n "$1")
|
||||
do
|
||||
case $1 in
|
||||
-a) AUTHSYS=$2; shift;;
|
||||
-h) PGHOST=$2; shift;;
|
||||
-p) PGPORT=$2; shift;;
|
||||
*) DELUSER=$1;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if [ -z "$AUTHSYS" ]; then
|
||||
AUTHOPT=""
|
||||
else
|
||||
AUTHOPT="-a $AUTHSYS"
|
||||
fi
|
||||
|
||||
if [ -z "$PGHOST" ]; then
|
||||
PGHOSTOPT=""
|
||||
else
|
||||
PGHOSTOPT="-h $PGHOST"
|
||||
fi
|
||||
|
||||
if [ -z "$PGPORT" ]; then
|
||||
PGPORTOPT=""
|
||||
else
|
||||
PGPORTOPT="-p $PGPORT"
|
||||
fi
|
||||
|
||||
PARGS="-tq $AUTHOPT $PGHOSTOPT $PGPORTOPT"
|
||||
|
||||
#
|
||||
# generate the first part of the actual monitor command
|
||||
#
|
||||
PSQL="psql $PARGS"
|
||||
|
||||
|
||||
#
|
||||
# see if user $USER is allowed to create new users. Only a user who can
|
||||
# create users can delete them.
|
||||
#
|
||||
|
||||
QUERY="select usesuper from pg_user where usename = '$USER'"
|
||||
ADDUSER=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x$ADDUSER != xt ]
|
||||
then
|
||||
echo "$CMDNAME: $USER cannot delete users."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# get the user name of the user to delete. Make sure it exists.
|
||||
#
|
||||
|
||||
if [ -z "$DELUSER" ]
|
||||
then
|
||||
echo PG_OPT_DASH_N_PARAM "Enter name of user to delete ---> PG_OPT_BACKSLASH_C_PARAM"
|
||||
read DELUSER
|
||||
fi
|
||||
|
||||
QUERY="select usesysid from pg_user where usename = '$DELUSER'"
|
||||
|
||||
RES=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -n "$RES" ]
|
||||
then
|
||||
echo "$CMDNAME: user "\"$DELUSER\"" does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYSID=`echo $RES | sed 's/ //g'`
|
||||
|
||||
#
|
||||
# destroy the databases owned by the deleted user. First, use this query
|
||||
# to find out what they are.
|
||||
#
|
||||
|
||||
QUERY="select datname from pg_database where datdba = '$SYSID'::oid"
|
||||
|
||||
|
||||
ALLDBS=`$PSQL -c "$QUERY" template1`
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: database access failed - exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# don't try to delete template1!
|
||||
#
|
||||
|
||||
for i in $ALLDBS
|
||||
do
|
||||
if [ $i != "template1" ]
|
||||
then
|
||||
DBLIST="$DBLIST $i"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$DBLIST" ]
|
||||
then
|
||||
echo "User $DELUSER owned the following databases:"
|
||||
echo $DBLIST
|
||||
echo
|
||||
|
||||
#
|
||||
# Now we warn the DBA that deleting this user will destroy a bunch of databases
|
||||
#
|
||||
|
||||
yn=f
|
||||
while [ "$yn" != y -a "$yn" != n ]
|
||||
do
|
||||
echo PG_OPT_DASH_N_PARAM "Deleting user $DELUSER will destroy them. Continue (y/n)? PG_OPT_BACKSLASH_C_PARAM"
|
||||
read yn
|
||||
done
|
||||
|
||||
if [ $yn = n ]
|
||||
then
|
||||
echo "$CMDNAME: exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# now actually destroy the databases
|
||||
#
|
||||
|
||||
for i in $DBLIST
|
||||
do
|
||||
echo "destroying database $i"
|
||||
|
||||
QUERY="drop database $i"
|
||||
$PSQL -c "$QUERY" template1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: drop database on $i failed - exiting"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
QUERY="delete from pg_shadow where usename = '$DELUSER'"
|
||||
|
||||
$PSQL -c "$QUERY" template1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "$CMDNAME: delete of user $DELUSER was UNSUCCESSFUL"
|
||||
else
|
||||
echo "$CMDNAME: delete of user $DELUSER was successful."
|
||||
fi
|
||||
|
||||
exit 0
|
33
src/bin/scripts/Makefile
Normal file
33
src/bin/scripts/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for bin/scripts
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
SRCDIR=../..
|
||||
include ../../Makefile.global
|
||||
|
||||
SCRIPTS=createdb dropdb createuser dropuser vacuumdb
|
||||
|
||||
all: $(SCRIPTS)
|
||||
|
||||
createdb:
|
||||
dropdb:
|
||||
createuser:
|
||||
dropuser:
|
||||
vacuumdb:
|
||||
|
||||
install: $(SCRIPTS)
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$(X)$<
|
||||
|
||||
clean:
|
||||
dep depend:
|
112
src/bin/scripts/createdb
Normal file
112
src/bin/scripts/createdb
Normal file
@ -0,0 +1,112 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# createdb.sh--
|
||||
# create a postgres database
|
||||
#
|
||||
# This program runs psql with the "-c" option to create
|
||||
# the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
MB=
|
||||
PSQLOPT=
|
||||
dbname=
|
||||
dbcomment=
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--help|-\?)
|
||||
usage=t
|
||||
break
|
||||
;;
|
||||
# options passed on to psql
|
||||
--host|-h)
|
||||
PSQLOPT="$PSQLOPT -h $2"
|
||||
shift;;
|
||||
--port|-p)
|
||||
PSQLOPT="$PSQLOPT -p $2"
|
||||
shift;;
|
||||
--user|--username|-U)
|
||||
PSQLOPT="$PSQLOPT -U $2"
|
||||
shift;;
|
||||
--password|-W)
|
||||
PSQLOPT="$PSQLOPT -W"
|
||||
;;
|
||||
--echo|-e)
|
||||
PSQLOPT="$PSQLOPT -e"
|
||||
;;
|
||||
--quiet|-q)
|
||||
PSQLOPT="$PSQLOPT -o /dev/null"
|
||||
;;
|
||||
# options converted into SQL command
|
||||
--dbpath|-D)
|
||||
dbpath="$2"
|
||||
shift;;
|
||||
--encoding|-E)
|
||||
MB=$2
|
||||
shift
|
||||
if [ -z `pg_encoding $MB` ]; then
|
||||
echo "$CMDNAME: $MB is not a valid encoding name"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ -z "$dbname" ]; then
|
||||
dbname="$1"
|
||||
else
|
||||
dbcomment="$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-D <path>] \\"
|
||||
echo " [-E <encoding>] [-U <username>] [-W] dbname [description]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$dbname" ]; then
|
||||
echo "$CMDNAME: Missing required argument database name. Try -? for help."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
withstring=
|
||||
[ "$dbpath" ] && withstring="$withstring LOCATION = '$dbpath'"
|
||||
[ "$MB" ] && withstring="$withstring ENCODING = '$MB'"
|
||||
[ "$withstring" ] && withstring=" WITH$withstring"
|
||||
|
||||
psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Database creation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Insert comment as well, if requested
|
||||
[ -z "$dbcomment" ] && exit 0
|
||||
|
||||
psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS \'$dbcomment\'"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Comment creation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
145
src/bin/scripts/createuser
Normal file
145
src/bin/scripts/createuser
Normal file
@ -0,0 +1,145 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# createuser--
|
||||
# Utility for creating a user in the PostgreSQL database
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
# Note - this should NOT be setuid.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
NewUser=
|
||||
SysID=
|
||||
CanAddUser=
|
||||
CanCreateDb=
|
||||
PwPrompt=
|
||||
Password=
|
||||
PSQLOPT=
|
||||
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--help|-\?)
|
||||
usage=t
|
||||
break
|
||||
;;
|
||||
# options passed on to psql
|
||||
--host|-h)
|
||||
PSQLOPT="$PSQLOPT -h $2"
|
||||
shift;;
|
||||
--port|-p)
|
||||
PSQLOPT="$PSQLOPT -p $2"
|
||||
shift;;
|
||||
# Uncomment these lines if you need the -U and -W options.
|
||||
# They are confusing in this context, however.
|
||||
# --user|--username|-U)
|
||||
# PSQLOPT="$PSQLOPT -U $2"
|
||||
# shift;;
|
||||
# --password|-W)
|
||||
# PSQLOPT="$PSQLOPT -W"
|
||||
# ;;
|
||||
--echo|-e)
|
||||
PSQLOPT="$PSQLOPT -e"
|
||||
;;
|
||||
--quiet|-q)
|
||||
PSQLOPT="$PSQLOPT -o /dev/null"
|
||||
;;
|
||||
# options converted into SQL command
|
||||
--createdb|-d)
|
||||
CanCreateDb=t
|
||||
;;
|
||||
--no-createdb|-D)
|
||||
CanCreateDb=f
|
||||
;;
|
||||
--adduser|-a)
|
||||
CanAddUser=t
|
||||
;;
|
||||
--no-adduser|-A)
|
||||
CanAddUser=f
|
||||
;;
|
||||
--pwprompt|--pw|-P)
|
||||
PwPrompt=t
|
||||
;;
|
||||
-*)
|
||||
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
NewUser=$1
|
||||
;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
|
||||
# Help
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-d|-D] [-a|-A] [-P] [username]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Get missing user attributes
|
||||
|
||||
if [ -z "$NewUser" ]; then
|
||||
echo -n "Enter name of user to add: "
|
||||
read -r NewUser
|
||||
[ $? -ne 0 ] && exit 1
|
||||
fi
|
||||
|
||||
if [ "$PwPrompt" ]; then
|
||||
echo -n "Enter password for user $NewUser: "
|
||||
read -r Password
|
||||
fi
|
||||
|
||||
if [ -z "$CanCreateDb" ]; then
|
||||
echo -n "Is the new user allowed to create databases? (y/n) "
|
||||
read -r
|
||||
[ $? -ne 0 ] && exit 1
|
||||
if [ $REPLY = "y" -o $REPLY = "Y" ]; then
|
||||
CanCreateDb=t
|
||||
else
|
||||
CanCreateDb=f
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$CanAddUser" ]; then
|
||||
echo -n "Shall the new user be allowed to create more new users? (y/n) "
|
||||
read -r
|
||||
[ $? -ne 0 ] && exit 1
|
||||
if [ $REPLY = "y" -o $REPLY = "Y" ]; then
|
||||
CanAddUser=t
|
||||
else
|
||||
CanAddUser=f
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# build SQL command
|
||||
#
|
||||
QUERY="CREATE USER \"$NewUser\""
|
||||
|
||||
[ "$Password" ] && QUERY="$QUERY WITH PASSWORD \"$Password\""
|
||||
[ "$CanCreateDb" = t ] && QUERY="$QUERY CREATEDB"
|
||||
[ "$CanCreateDb" = f ] && QUERY="$QUERY NOCREATEDB"
|
||||
[ "$CanAddUser" = t ] && QUERY="$QUERY CREATEUSER"
|
||||
[ "$CanAddUser" = f ] && QUERY="$QUERY NOCREATEUSER"
|
||||
|
||||
psql $PSQLOPT -d template1 -c "$QUERY"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Creation of user \"$NewUser\" failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
92
src/bin/scripts/dropdb
Normal file
92
src/bin/scripts/dropdb
Normal file
@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# dropdb--
|
||||
# destroy a postgres database
|
||||
#
|
||||
# this program runs psql to drop the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
PSQLOPT=
|
||||
dbname=
|
||||
forcedel=t
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--help|-\?)
|
||||
usage=t
|
||||
break
|
||||
;;
|
||||
# options passed on to psql
|
||||
--host|-h)
|
||||
PSQLOPT="$PSQLOPT -h $2"
|
||||
shift;;
|
||||
--port|-p)
|
||||
PSQLOPT="$PSQLOPT -p $2"
|
||||
shift;;
|
||||
--user|--username|-U)
|
||||
PSQLOPT="$PSQLOPT -U $2"
|
||||
shift;;
|
||||
--password|-W)
|
||||
PSQLOPT="$PSQLOPT -W"
|
||||
;;
|
||||
--echo|-e)
|
||||
PSQLOPT="$PSQLOPT -e"
|
||||
;;
|
||||
--quiet|-q)
|
||||
PSQLOPT="$PSQLOPT -o /dev/null"
|
||||
;;
|
||||
# other options
|
||||
--interactive|-i)
|
||||
forcedel=f
|
||||
;;
|
||||
-*)
|
||||
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
dbname="$1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-U <username>] [-W] [-i] dbname"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$dbname" ]; then
|
||||
echo "$CMDNAME: Missing required argument database name. Try -? for help."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$forcedel" = f ]; then
|
||||
echo "Database \"$dbname\" will be permanently deleted."
|
||||
echo -n "Are you sure? (y/n) "
|
||||
read -r
|
||||
|
||||
[ $? -eq 1 ] && exit 1
|
||||
[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
|
||||
fi
|
||||
|
||||
|
||||
psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Database removal failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
98
src/bin/scripts/dropuser
Normal file
98
src/bin/scripts/dropuser
Normal file
@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# dropuser--
|
||||
# Utility for remocing a user from the PostgreSQL database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
# Note - this should NOT be setuid.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
PSQLOPT=
|
||||
forcedel=t
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--help|-\?)
|
||||
usage=t
|
||||
break
|
||||
;;
|
||||
# options passed on to psql
|
||||
--host|-h)
|
||||
PSQLOPT="$PSQLOPT -h $2"
|
||||
shift;;
|
||||
--port|-p)
|
||||
PSQLOPT="$PSQLOPT -p $2"
|
||||
shift;;
|
||||
# Uncomment these lines if you need the -U and -W options.
|
||||
# They are confusing in this context, however.
|
||||
# --user|--username|-U)
|
||||
# PSQLOPT="$PSQLOPT -U $2"
|
||||
# shift;;
|
||||
# --password|-W)
|
||||
# PSQLOPT="$PSQLOPT -W"
|
||||
# ;;
|
||||
--echo|-e)
|
||||
PSQLOPT="$PSQLOPT -e"
|
||||
;;
|
||||
--quiet|-q)
|
||||
PSQLOPT="$PSQLOPT -o /dev/null"
|
||||
;;
|
||||
# other options
|
||||
--interactive|-i)
|
||||
forcedel=f
|
||||
;;
|
||||
-*)
|
||||
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
DelUser="$1"
|
||||
;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
|
||||
# Help
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-i] [username]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prompt for username if missing
|
||||
|
||||
if [ -z "$DelUser" ]; then
|
||||
echo -n "Enter name of user to delete: "
|
||||
read -r NewUser
|
||||
[ $? -ne 0 ] && exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$forcedel" = f ]; then
|
||||
echo "User \"$DelUser\" and any owned databases will be permanently deleted."
|
||||
echo -n "Are you sure? (y/n) "
|
||||
read -r
|
||||
|
||||
[ $? -eq 1 ] && exit 1
|
||||
[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
|
||||
fi
|
||||
|
||||
|
||||
psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Deletion of user \"$DelUser\" failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
96
src/bin/scripts/vacuumdb
Normal file
96
src/bin/scripts/vacuumdb
Normal file
@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# vacuumdb--
|
||||
# vacuum a postgres database
|
||||
#
|
||||
# This script runs psql with the "-c" option to vacuum
|
||||
# the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
PSQLOPT=
|
||||
verbose=
|
||||
analyze=
|
||||
table=
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--help|-\?)
|
||||
usage=t
|
||||
break
|
||||
;;
|
||||
# options passed on to psql
|
||||
--host|-h)
|
||||
PSQLOPT="$PSQLOPT -h $2"
|
||||
shift;;
|
||||
--port|-p)
|
||||
PSQLOPT="$PSQLOPT -p $2"
|
||||
shift;;
|
||||
--user|--username|-U)
|
||||
PSQLOPT="$PSQLOPT -U $2"
|
||||
shift;;
|
||||
--password|-W)
|
||||
PSQLOPT="$PSQLOPT -W"
|
||||
;;
|
||||
--echo|-e)
|
||||
PSQLOPT="$PSQLOPT -e"
|
||||
;;
|
||||
--quiet|-q)
|
||||
PSQLOPT="$PSQLOPT -o /dev/null"
|
||||
;;
|
||||
--dbname|--database|-d)
|
||||
dbname="$2"
|
||||
shift;;
|
||||
# options converted into SQL command
|
||||
--analyze|-z)
|
||||
analyze="analyze"
|
||||
;;
|
||||
--table|-t)
|
||||
table=$2
|
||||
shift;;
|
||||
--verbose|-v)
|
||||
verbose="verbose"
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
dbname="$1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-U <username>] [-W] [-d <dbname>] \\"
|
||||
echo " [-z|--analyze] [-v|--verbose] [-t|--table 'table[(columns)]'] [dbname]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$dbname" ]; then
|
||||
echo "$CMDNAME: Missing required argument database name. Try -? for help."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
psql $PSQLOPT -d "$dbname" -c "VACUUM $verbose $analyze $table"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: Database vacuum failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,24 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile--
|
||||
# Makefile for bin/vacuumdb
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/vacuumdb/Attic/Makefile,v 1.1 1998/11/14 01:58:14 thomas Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SRCDIR= ../..
|
||||
include ../../Makefile.global
|
||||
|
||||
all: vacuumdb
|
||||
|
||||
install: vacuumdb
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
|
||||
|
||||
clean:
|
||||
|
||||
dep depend:
|
@ -1,98 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# vacuumdb--
|
||||
# vacuum a postgres database
|
||||
#
|
||||
# this program runs the monitor with the "-c" option to vacuum
|
||||
# the requested database.
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/vacuumdb/Attic/vacuumdb,v 1.1 1998/11/14 01:58:15 thomas Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
if [ -z "$LOGNAME" ]; then
|
||||
if [ -z "`whoami`" ]; then
|
||||
echo "$CMDNAME: cannot determine user name"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
USER=$LOGNAME
|
||||
export USER
|
||||
fi
|
||||
fi
|
||||
|
||||
dbname=$USER
|
||||
|
||||
PASSWDOPT="";
|
||||
|
||||
while test -n "$1"
|
||||
do
|
||||
case $1 in
|
||||
--help) usage=1;;
|
||||
--analyze) analyze="analyze";;
|
||||
--table) table=$2; shift;;
|
||||
--verbose) verbose="verbose";;
|
||||
|
||||
-a) AUTHSYS=$2; shift;;
|
||||
-h) PGHOST=$2; shift;;
|
||||
-p) PGPORT=$2; shift;;
|
||||
-t) table=$2; shift;;
|
||||
-u) PASSWDOPT=$1;;
|
||||
-v) verbose="verbose";;
|
||||
-z) analyze="analyze";;
|
||||
-*) echo "$CMDNAME: unrecognized parameter $1"; usage=1;;
|
||||
*) dbname=$1;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if [ "$usage" ]; then
|
||||
echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> --analyze --verbose [--table 'table[(cols)]'] [dbname]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$AUTHSYS" ]; then
|
||||
AUTHOPT=""
|
||||
else
|
||||
AUTHOPT="-a $AUTHSYS"
|
||||
fi
|
||||
|
||||
if [ -z "$PGHOST" ]; then
|
||||
PGHOSTOPT=""
|
||||
else
|
||||
PGHOSTOPT="-h $PGHOST"
|
||||
fi
|
||||
|
||||
if [ -z "$PGPORT" ]; then
|
||||
PGPORTOPT=""
|
||||
else
|
||||
PGPORTOPT="-p $PGPORT"
|
||||
fi
|
||||
|
||||
if [ -z "$dbpath" ]; then
|
||||
location=""
|
||||
else
|
||||
# if [ ! -d "$dbpath"/base ]; then
|
||||
# echo "$CMDNAME: database creation failed on $dbname."
|
||||
# echo "directory $dbpath/base not found."
|
||||
# exit 1
|
||||
# fi
|
||||
location="with location = '$dbpath'"
|
||||
fi
|
||||
|
||||
psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "vacuum $verbose $analyze $table" $dbname
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$CMDNAME: database vacuum failed on $dbname."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user