against the sources from one hour ago and contain all the portable and
up
to date stuff.
A few other CVS "householding" things you might want to take care of:
* Remove the src/bin/cleardbdir directory
* Remove the file src/bin/psql/sql_help.h from the repository, as it is
a derived file and is build by the release_prep.
Peter Eisentraut
20 files changed:
<para>
Create a database by typing
<ProgramListing>
<para>
Create a database by typing
<ProgramListing>
</ProgramListing>
</para>
</step>
</ProgramListing>
</para>
</step>
<para>
Connect to the new database:
<ProgramListing>
<para>
Connect to the new database:
<ProgramListing>
</ProgramListing>
</para>
</step>
</ProgramListing>
</para>
</step>
<para>
Remove the test database (unless you will want to use it later for other tests):
<ProgramListing>
<para>
Remove the test database (unless you will want to use it later for other tests):
<ProgramListing>
</ProgramListing>
</para>
</step>
</ProgramListing>
</para>
</step>
After running the regression tests, type
<ProgramListing>
After running the regression tests, type
<ProgramListing>
$ cd /usr/src/pgsql/postgresql-6.5.3/src/test/regress
$ gmake clean
</ProgramListing>
$ cd /usr/src/pgsql/postgresql-6.5.3/src/test/regress
$ gmake clean
</ProgramListing>
<ProgramListing>
template1=> create database foo;
<ProgramListing>
template1=> create database foo;
</ProgramListing>
(Get in the habit of including those SQL semicolons. Psql won't execute
</ProgramListing>
(Get in the habit of including those SQL semicolons. Psql won't execute
mydb, you can destroy it using the following Unix command:
<programlisting>
mydb, you can destroy it using the following Unix command:
<programlisting>
-% destroydb <replaceable class="parameter">dbname</replaceable>
+% dropdb <replaceable class="parameter">dbname</replaceable>
</programlisting>
This action physically removes all of the Unix files
</programlisting>
This action physically removes all of the Unix files
If you are the database administrator for the database
<Database>mydb</Database>, you can destroy it using the following Unix command:
<ProgramListing>
If you are the database administrator for the database
<Database>mydb</Database>, you can destroy it using the following Unix command:
<ProgramListing>
</ProgramListing>
This action physically removes all of the Unix files
associated with the database and cannot be undone, so
</ProgramListing>
This action physically removes all of the Unix files
associated with the database and cannot be undone, so
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.7 1999/12/04 04:53:15 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.8 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
</varlistentry>
<varlistentry>
</varlistentry>
<varlistentry>
- <term>-D, --dbpath <replaceable class="parameter">datadir</replaceable></term>
+ <term>-D, --location <replaceable class="parameter">datadir</replaceable></term>
<listitem>
<para>
Specifies the alternate database location for this database installation.
<listitem>
<para>
Specifies the alternate database location for this database installation.
<listitem>
<para>
Specifies the name of the database to be created. The name must be
<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.
+ unique among all <productname>PostgreSQL</productname> databases in this installation.
</para>
</listitem>
</varlistentry>
</para>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
</varlistentry>
<varlistentry>
- <term><computeroutput>createdb: Comment creation failed.</computeroutput></term>
+ <term><computeroutput>createdb: Comment creation failed. (Database was created.)</computeroutput></term>
<listitem>
<para>
The comment/description for the database could not be created.
<listitem>
<para>
The comment/description for the database could not be created.
<para>
To create the database <literal>demo</literal>
using the postmaster on host eden, port 5000, using the <literal>LATIN1</literal>
<para>
To create the database <literal>demo</literal>
using the postmaster on host eden, port 5000, using the <literal>LATIN1</literal>
- encoding scheme and look at the underlying query:
+ encoding scheme with a look at the underlying query:
<programlisting>
$ <userinput>createdb -p 5000 -h eden -E LATIN1 -e demo</userinput>
<programlisting>
$ <userinput>createdb -p 5000 -h eden -E LATIN1 -e demo</userinput>
-QUERY: CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'
+CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'
CREATE DATABASE
</programlisting>
</para>
CREATE DATABASE
</programlisting>
</para>
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.6 1999/12/04 04:53:15 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.7 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
</listitem>
</varlistentry>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-i, --sysid <replaceable class="parameter">uid</replaceable></term>
+ <listitem>
+ <para>
+ Allows you to pick a non-default user id for the new user. This is not
+ necessary, but some people like it.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><replaceable class="parameter">username</replaceable></term>
<listitem>
<varlistentry>
<term><replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
The options <literal>-h</literal>, <literal>-p</literal>, and <literal>-e</literal>,
<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.
+ are passed on literally to <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. The
+ <application>psql</application> options <literal>-U</literal> and <literal>-W</literal>
+ are available as well, but their use can be confusing in this context.
<programlisting>
$ <userinput>createuser -p 5000 -h eden -D -A -e joe</userinput>
<programlisting>
$ <userinput>createuser -p 5000 -h eden -D -A -e joe</userinput>
-QUERY: CREATE USER "joe" NOCREATEDB NOCREATEUSER
+CREATE USER "joe" NOCREATEDB NOCREATEUSER
CREATE USER
</programlisting>
</para>
CREATE USER
</programlisting>
</para>
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_user.sgml,v 1.8 1999/12/04 04:53:15 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_user.sgml,v 1.9 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
user from the database,
along with any databases owned by the user. It
does not remove tables, views, or triggers owned by the
user from the database,
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>dropuser</application>
- script, regardless of how the user was created.
+ named user in databases not owned by the user.
</para>
<refsect2 id="R2-SQL-DROPUSER-3">
</para>
<refsect2 id="R2-SQL-DROPUSER-3">
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.1 1999/12/04 04:53:15 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.2 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
$ <userinput>dropdb -p 5000 -h eden -i -e demo</userinput>
Database "demo" will be permanently deleted.
Are you sure? (y/n) <userinput>y</userinput>
$ <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>
DROP DATABASE
</programlisting>
</para>
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.1 1999/12/04 04:53:15 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.2 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
<para>
The options <literal>-h</literal>, <literal>-p</literal>, and <literal>-e</literal>,
<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.
+ are passed on literally to <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. The
+ <application>psql</application> options <literal>-U</literal> and <literal>-W</literal>
+ are available as well, but they can be confusing in this context.
$ <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>
$ <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>
DROP USER
</programlisting>
</para>
DROP USER
</programlisting>
</para>
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.6 1999/11/28 02:17:04 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.7 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
</refsynopsisdivinfo>
<synopsis>
VACUUM [ VERBOSE ] [ ANALYZE ] [ <replaceable class="PARAMETER">table</replaceable> ]
</refsynopsisdivinfo>
<synopsis>
VACUUM [ VERBOSE ] [ ANALYZE ] [ <replaceable class="PARAMETER">table</replaceable> ]
-VACUUM [ VERBOSE ] ANALYZE [ <replaceable class="PARAMETER">ER">t</replaceable>BLE> [ (<replaceable class="PARAMETER">column</replaceable> [, ...] ) ] ]
+VACUUM [ VERBOSE ] ANALYZE [ <replaceable class="PARAMETER">table</replaceable> [ (<replaceable class="PARAMETER">column</replaceable> [, ...] ) ] ]
</synopsis>
<refsect2 id="R2-SQL-VACUUM-1">
</synopsis>
<refsect2 id="R2-SQL-VACUUM-1">
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.5 1999/07/22 15:09:15 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.6 1999/12/07 22:41:41 momjian Exp $
Postgres documentation
-->
Postgres documentation
-->
<application>vacuumdb</application>
</refname>
<refpurpose>
<application>vacuumdb</application>
</refname>
<refpurpose>
- Clean and analyze a <productname>Postgres</productname> database
+ Clean and analyze a <productname>PostgreSQL</productname> database
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
- <date>1998-10-04</date>
+ <date>1999-12-04</date>
</refsynopsisdivinfo>
<synopsis>
</refsynopsisdivinfo>
<synopsis>
-vacuumdb [ --analyze | -z ] [ --verbose | -v ] [ <replaceable class="parameter">dbname</replaceable> ]
-vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
- [ --table '<replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column</replaceable> [,...] ) ]' ]
- [ <replaceable class="parameter">dbname</replaceable> ]
+vacuumdb [ <replaceable class="parameter">connection options</replaceable> ] [ --analyze | -z ] [ --verbose | -v ]
+ [ --table '<replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column</replaceable> [,...] ) ]' ] [ [-d] <replaceable class="parameter">dbname</replaceable> ]
</synopsis>
<refsect2 id="R2-APP-VACUUMDB-1">
<refsect2info>
</synopsis>
<refsect2 id="R2-APP-VACUUMDB-1">
<refsect2info>
- <date>1998-10-04</date>
+ <date>1999-12-04</date>
</refsect2info>
<title>
Inputs
</refsect2info>
<title>
Inputs
<variablelist>
<varlistentry>
<variablelist>
<varlistentry>
- <term><replaceable class="parameter">dbname</replaceable></term>
+ <term>[-d, --dbname] <replaceable class="parameter">dbname</replaceable></term>
<listitem>
<para>
Specifies the name of the database to be cleaned or analyzed.
<listitem>
<para>
Specifies the name of the database to be cleaned or analyzed.
- <replaceable class="parameter">dbname</replaceable>
- defaults to the value of the
- <envar>USER</envar>
- environment variable.
</para>
</listitem>
</varlistentry>
<varlistentry>
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>--analyze</term>
- <term>-z</term>
+ <term>-z, --analyze</term>
<listitem>
<para>
Calculate statistics on the database for use by the optimizer.
<listitem>
<para>
Calculate statistics on the database for use by the optimizer.
</varlistentry>
<varlistentry>
</varlistentry>
<varlistentry>
- <term>--verbose</term>
- <term>-v</term>
+ <term>-v, --verbose</term>
<listitem>
<para>
Print detailed information during processing.
<listitem>
<para>
Print detailed information during processing.
</varlistentry>
<varlistentry>
</varlistentry>
<varlistentry>
- <term>--table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</term>
- <term>-t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</term>
+ <term>-t, --table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</term>
<listitem>
<para>
Clean or analyze <replaceable class="parameter">table</replaceable> only.
Column names may be specified only in conjunction with
the <option>--analyze</option> option.
</para>
<listitem>
<para>
Clean or analyze <replaceable class="parameter">table</replaceable> only.
Column names may be specified only in conjunction with
the <option>--analyze</option> option.
</para>
+ <tip>
+ <para>
+ If you specify columns to vacuum, you probably have to escape the parentheses
+ from the shell.
+ </para>
+ </tip>
</listitem>
</varlistentry>
</listitem>
</varlistentry>
<variablelist>
<varlistentry>
<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>
<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>
</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>
<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, --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 commands that <application>vacuumdb</application> generates
+ and sends to the backend.
</para>
</listitem>
</varlistentry>
<varlistentry>
</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term>-q, --quiet</term>
- Use password authentication.
- Prompts for
- <replaceable class="parameter">username</replaceable>
- and <replaceable class="parameter">password</replaceable>.
+ Do not display a response.
</para>
</listitem>
</varlistentry>
</para>
</listitem>
</varlistentry>
<refsect2 id="R2-APP-VACUUMDB-2">
<refsect2info>
<refsect2 id="R2-APP-VACUUMDB-2">
<refsect2info>
- <date>1998-10-04</date>
+ <date>1999-12-04</date>
</refsect2info>
<title>
Outputs
</title>
<para>
</refsect2info>
<title>
Outputs
</title>
<para>
- <application>vacuumdb</application> executes a <command>VACUUM</command> command
- on the specified database, so has not explicit external output.
-
<variablelist>
<varlistentry>
<variablelist>
<varlistentry>
- <term><computeroutput>
-ERROR: Can't vacuum columns, only tables. You can 'vacuum analyze' columns.
-vacuumdb: database vacuum failed on <replaceable class="parameter">dbname</replaceable>.
- </computeroutput></term>
+ <term><computeroutput>VACUUM</computeroutput></term>
- The non-analyze mode requires cleaning full tables or databases.
- Individual columns may be specified only when analyzing a specific table.
</para>
</listitem>
</varlistentry>
<varlistentry>
</para>
</listitem>
</varlistentry>
<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>'?
- </computeroutput></term>
+ <term><computeroutput>vacuumdb: Vacuum failed.</computeroutput></term>
- <application>vacuumdb</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.
+ Something went wrong. <application>vacuumdb</application> is only a wrapper
+ script. See <xref linkend="SQL-VACUUM" endterm="SQL-VACUUM-title">
+ and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for a detailed
+ discussion of error messages and potential problems.
</para>
</listitem>
</varlistentry>
</para>
</listitem>
</varlistentry>
- <varlistentry>
- <term><computeroutput>
-Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
-FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
- </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>
- <note>
- <para>
- <application>vacuumdb</application> internally executes a
- <command>VACUUM</command> <acronym>SQL</acronym> statement.
- If you have problems running <application>vacuumdb</application>,
- make sure you are able to run <command>VACUUM</command> on the database using, for
- example, <application>psql</application>.
- </para>
- </note>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-VACUUMDB-1">
<refsect1info>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-VACUUMDB-1">
<refsect1info>
- <date>1998-10-04</date>
+ <date>1999-12-04</date>
</refsect1info>
<title>
Description
</refsect1info>
<title>
Description
<para>
<application>vacuumdb</application> is a utility for cleaning a
<para>
<application>vacuumdb</application> is a utility for cleaning a
- <productname>Postgres</productname> database.
+ <productname>PostgreSQL</productname> database.
<application>vacuumdb</application> will also generate internal statistics
used by the <productname>Postgres</productname> query optimizer.
</para>
<application>vacuumdb</application> will also generate internal statistics
used by the <productname>Postgres</productname> query optimizer.
</para>
- </refsect1>
-
- <refsect1 id="R1-APP-VACUUMDB-2">
- <refsect1info>
- <date>1998-10-04</date>
- </refsect1info>
- <title>
- Notes
- </title>
- See <xref endterm="sql-vacuum-title" linkend="sql-vacuum-title"> for more details.
+ <application>vacuumdb</application> is a shell script wrapper around the
+ backend command
+ <xref linkend="SQL-VACUUM" endterm="SQL-VACUUM-title"> via
+ the <productname>PostgreSQL</productname> interactive terminal
+ <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. There is no effective
+ difference between vacuuming databases via this or other methods.
+ <application>psql</application> must be found by the script and
+ a database server must be 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.
<refsect1 id="R1-APP-VACUUMDB-3">
<refsect1info>
<date>1998-10-04</date>
<refsect1 id="R1-APP-VACUUMDB-3">
<refsect1info>
<date>1998-10-04</date>
- To clean a database of the same name as the user:
-
- <programlisting>
-% vacuumdb
- </programlisting>
+ To clean the database <literal>test</literal>:
+<programlisting>
+$ vacuumdb test
+</programlisting>
</para>
<para>
To analyze a database named <literal>bigdb</literal> for the optimizer:
</para>
<para>
To analyze a database named <literal>bigdb</literal> for the optimizer:
-
- <programlisting>
-% vacuumdb --analyze bigdb
- </programlisting>
+<programlisting>
+$ vacuumdb --analyze bigdb
+</programlisting>
<para>
To analyze a single column <literal>bar</literal> in table <literal>foo</literal>
in a database named <literal>xyzzy</literal> for the optimizer:
<para>
To analyze a single column <literal>bar</literal> in table <literal>foo</literal>
in a database named <literal>xyzzy</literal> for the optimizer:
-
- <programlisting>
-% vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
- </programlisting>
+<programlisting>
+$ vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
+</programlisting>
<Para>
After running the tests and examining the results, type
<ProgramListing>
<Para>
After running the tests and examining the results, type
<ProgramListing>
cd /usr/src/pgsql/src/test/regress
gmake clean
</ProgramListing>
cd /usr/src/pgsql/src/test/regress
gmake clean
</ProgramListing>
<para>
<application>createuser</application> enables specific users to access
<productname>Postgres</productname>.
<para>
<application>createuser</application> enables specific users to access
<productname>Postgres</productname>.
- <application>destroyuser</application> removes users and
+ <application>dropuser</application> removes users and
prevents them from accessing <productname>Postgres</productname>.
</para>
prevents them from accessing <productname>Postgres</productname>.
</para>
<programlisting>
% createdb -D PGDATA2 test
<programlisting>
% createdb -D PGDATA2 test
</programlisting>
</para>
</programlisting>
</para>
If you are the database administrator for the database
<Database>mydb</Database>, you can destroy it using the following Unix command:
<ProgramListing>
If you are the database administrator for the database
<Database>mydb</Database>, you can destroy it using the following Unix command:
<ProgramListing>
</ProgramListing>
This action physically removes all of the Unix files
associated with the database and cannot be undone, so
</ProgramListing>
This action physically removes all of the Unix files
associated with the database and cannot be undone, so
#!/bin/sh
#-------------------------------------------------------------------------
#
#!/bin/sh
#-------------------------------------------------------------------------
#
# create a postgres database
#
# This program runs psql with the "-c" option to create
# create a postgres database
#
# This program runs psql with the "-c" option to create
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.2 1999/12/07 22:41:44 momjian Exp $
#
#-------------------------------------------------------------------------
#
#-------------------------------------------------------------------------
PSQLOPT=
dbname=
dbcomment=
PSQLOPT=
dbname=
dbcomment=
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
+ -h*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --host=*)
+ PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
+ ;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
+ -p*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --port=*)
+ PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
+ ;;
- PSQLOPT="$PSQLOPT -U $2"
+ PSQLOPT="$PSQLOPT -U '$2'"
+ -U*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --user=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
+ ;;
+ --username=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
+ ;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
PSQLOPT="$PSQLOPT -o /dev/null"
;;
# options converted into SQL command
PSQLOPT="$PSQLOPT -o /dev/null"
;;
# options converted into SQL command
+ -D*)
+ dbpath=`echo $1 | sed 's/^-D//'`
+ ;;
+ --location=*)
+ dbpath=`echo $1 | sed 's/^--location=//'`
+ ;;
- shift
- if [ -z `pg_encoding $MB` ]; then
- echo "$CMDNAME: $MB is not a valid encoding name"
- exit 1
- fi
- ;;
-
+ shift;;
+ -E*)
+ MB=`echo $1 | sed 's/^-E//'`
+ ;;
+ --encoding=*)
+ MB=`echo $1 | sed 's/^--encoding=//'`
+ ;;
-*)
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
exit 1
-*)
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
exit 1
- echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-D <path>] \\"
- echo " [-E <encoding>] [-U <username>] [-W] dbname [description]"
+ echo "Usage: $CMDNAME [-h server] [-p port] [-D path] \\"
+ echo " [-E encoding] [-U username] dbname [description]"
+
+if [ "$MB" -a -z "`pg_encoding '$MB'`" ]; then
+ echo "$CMDNAME: \"$MB\" is not a valid encoding name."
+ exit 1
+fi
+
if [ -z "$dbname" ]; then
echo "$CMDNAME: Missing required argument database name. Try -? for help."
exit 1
fi
if [ -z "$dbname" ]; then
echo "$CMDNAME: Missing required argument database name. Try -? for help."
exit 1
fi
+dbpath=`echo $dbpath | sed "s/'/\\\\\'/g"`
+dbname=`echo $dbname | sed 's/\"/\\\"/g'`
+
withstring=
[ "$dbpath" ] && withstring="$withstring LOCATION = '$dbpath'"
[ "$MB" ] && withstring="$withstring ENCODING = '$MB'"
withstring=
[ "$dbpath" ] && withstring="$withstring LOCATION = '$dbpath'"
[ "$MB" ] && withstring="$withstring ENCODING = '$MB'"
# Insert comment as well, if requested
[ -z "$dbcomment" ] && exit 0
# Insert comment as well, if requested
[ -z "$dbcomment" ] && exit 0
-psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS \'$dbcomment\'"
+dbcomment=`echo $dbcomment | sed "s/'/\\\\\'/g"`
+
+psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
- echo "$CMDNAME: Comment creation failed."
+ echo "$CMDNAME: Comment creation failed. (Database was created.)"
-exit 0
\ No newline at end of file
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.1 1999/12/05 20:02:48 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.2 1999/12/07 22:41:44 momjian Exp $
#
#-------------------------------------------------------------------------
#
#-------------------------------------------------------------------------
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.3 1999/12/07 22:41:44 momjian Exp $
#
# Note - this should NOT be setuid.
#
#
# Note - this should NOT be setuid.
#
while [ $# -gt 0 ]
do
case "$1" in
while [ $# -gt 0 ]
do
case "$1" in
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
+ -h*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --host=*)
+ PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
+ ;;
--port|-p)
PSQLOPT="$PSQLOPT -p $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"
-# ;;
+ -p*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --port=*)
+ PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
+ ;;
+# Note: These two specify the user to connect as (like in psql),
+# not the user you're creating.
+ --user|--username|-U)
+ PSQLOPT="$PSQLOPT -U '$2'"
+ shift;;
+ -U*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --user=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
+ ;;
+ --username=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
+ ;;
+ --password|-W)
+ PSQLOPT="$PSQLOPT -W"
+ ;;
--echo|-e)
PSQLOPT="$PSQLOPT -e"
;;
--echo|-e)
PSQLOPT="$PSQLOPT -e"
;;
--no-adduser|-A)
CanAddUser=f
;;
--no-adduser|-A)
CanAddUser=f
;;
+ --sysid|-i)
+ SysID=$2
+ shift;;
+ --sysid=*)
+ SysID=`echo $1 | sed 's/^--sysid=//'`
+ ;;
+ -i*)
+ SysID=`echo $1 | sed 's/^-i//'`
+ ;;
--pwprompt|--pw|-P)
PwPrompt=t
;;
--pwprompt|--pw|-P)
PwPrompt=t
;;
# Help
if [ "$usage" ]; then
# Help
if [ "$usage" ]; then
- echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-d|-D] [-a|-A] [-P] [username]"
+ echo "Usage: $CMDNAME [-h server] [-p port] [-d|-D] [-a|-A] [-P] [-i id] [username]"
+if [ "$SysID" ]; then
+ if [ "$SysID" != "`echo $SysID | sed 's/[^0-9]//g'`" ]; then
+ echo "$CMDNAME: User sysid must be a positive number."
+ exit 1
+ fi
+fi
+
# Get missing user attributes
if [ -z "$NewUser" ]; then
# Get missing user attributes
if [ -z "$NewUser" ]; then
fi
if [ "$PwPrompt" ]; then
fi
if [ "$PwPrompt" ]; then
- $ECHO_N "Enter password for user $NewUser: "$ECHO_C
+ $ECHO_N "Enter password for user \"$NewUser\": "$ECHO_C
read Password
fi
if [ -z "$CanCreateDb" ]; then
read Password
fi
if [ -z "$CanCreateDb" ]; then
- $ECHO_N "Is the new user allowed to create databases? (y/n) "$ECHO_C
+ $ECHO_N "Shall the new user be allowed to create databases? (y/n) "$ECHO_C
read REPLY
[ $? -ne 0 ] && exit 1
if [ $REPLY = "y" -o $REPLY = "Y" ]; then
read REPLY
[ $? -ne 0 ] && exit 1
if [ $REPLY = "y" -o $REPLY = "Y" ]; then
+NewUser=`echo $NewUser | sed 's/\"/\\\"/g'`
+Password=`echo $Password | sed 's/\"/\\\"/g'`
+
QUERY="CREATE USER \"$NewUser\""
QUERY="CREATE USER \"$NewUser\""
-[ "$Password" ] && QUERY="$QUERY WITH PASSWORD \"$Password\""
+SUBQUERY=
+[ "$SysID" ] && SUBQUERY="$SUBQUERY SYSID $SysID"
+[ "$Password" ] && SUBQUERY="$SUBQUERY PASSWORD \"$Password\""
+[ "$SUBQUERY" ] && QUERY="$QUERY WITH $SUBQUERY"
+
[ "$CanCreateDb" = t ] && QUERY="$QUERY CREATEDB"
[ "$CanCreateDb" = f ] && QUERY="$QUERY NOCREATEDB"
[ "$CanAddUser" = t ] && QUERY="$QUERY CREATEUSER"
[ "$CanCreateDb" = t ] && QUERY="$QUERY CREATEDB"
[ "$CanCreateDb" = f ] && QUERY="$QUERY NOCREATEDB"
[ "$CanAddUser" = t ] && QUERY="$QUERY CREATEUSER"
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.2 1999/12/05 20:52:54 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.3 1999/12/07 22:41:44 momjian Exp $
#
#-------------------------------------------------------------------------
#
#-------------------------------------------------------------------------
while [ $# -gt 0 ]
do
case "$1" in
while [ $# -gt 0 ]
do
case "$1" in
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
+ -h*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --host=*)
+ PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
+ ;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
+ -p*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --port=*)
+ PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
+ ;;
- PSQLOPT="$PSQLOPT -U $2"
+ PSQLOPT="$PSQLOPT -U '$2'"
+ -U*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --user=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
+ ;;
+ --username=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
+ ;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
- echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-U <username>] [-W] [-i] dbname"
+ echo "Usage: $CMDNAME [-h server] [-p port] [-U username] [-i] dbname"
+dbname=`echo $dbname | sed 's/\"/\\\"/g'`
+
psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
if [ $? -ne 0 ]; then
echo "$CMDNAME: Database removal failed."
psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
if [ $? -ne 0 ]; then
echo "$CMDNAME: Database removal failed."
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.2 1999/12/05 20:52:54 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.3 1999/12/07 22:41:44 momjian Exp $
#
#-------------------------------------------------------------------------
#
#-------------------------------------------------------------------------
+# Check for echo -n vs echo \c
+
+if echo '\c' | grep -s c >/dev/null 2>&1
+then
+ ECHO_N="echo -n"
+ ECHO_C=""
+else
+ ECHO_N="echo"
+ ECHO_C='\c'
+fi
+
# ----------
# Get options, language name and dbname
# ----------
# Get options, language name and dbname
#-------------------------------------------------------------------------
#
# dropuser--
#-------------------------------------------------------------------------
#
# dropuser--
-# Utility for remocing a user from the PostgreSQL database.
+# Utility for removing a user from the PostgreSQL database.
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.3 1999/12/07 22:41:44 momjian Exp $
#
# Note - this should NOT be setuid.
#
#
# Note - this should NOT be setuid.
#
CMDNAME=`basename $0`
PSQLOPT=
forcedel=t
CMDNAME=`basename $0`
PSQLOPT=
forcedel=t
# Check for echo -n vs echo \c
# Check for echo -n vs echo \c
while [ $# -gt 0 ]
do
case "$1" in
while [ $# -gt 0 ]
do
case "$1" in
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
+ -h*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --host=*)
+ PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
+ ;;
--port|-p)
PSQLOPT="$PSQLOPT -p $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"
-# ;;
+ -p*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --port=*)
+ PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
+ ;;
+# Note: These two specify the user to connect as (like in psql),
+# not the user you're dropping.
+ --user|--username|-U)
+ PSQLOPT="$PSQLOPT -U '$2'"
+ shift;;
+ -U*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --user=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
+ ;;
+ --username=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
+ ;;
+ --password|-W)
+ PSQLOPT="$PSQLOPT -W"
+ ;;
--echo|-e)
PSQLOPT="$PSQLOPT -e"
;;
--echo|-e)
PSQLOPT="$PSQLOPT -e"
;;
# Help
if [ "$usage" ]; then
# Help
if [ "$usage" ]; then
- echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-i] [username]"
+ echo "Usage: $CMDNAME [-h server] [-p port] [-i] [username]"
if [ -z "$DelUser" ]; then
$ECHO_N "Enter name of user to delete: "$ECHO_C
if [ -z "$DelUser" ]; then
$ECHO_N "Enter name of user to delete: "$ECHO_C
[ $? -ne 0 ] && exit 1
fi
[ $? -ne 0 ] && exit 1
fi
+DelUser=`echo $DelUser | sed 's/\"/\\\"/g'`
+
psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
if [ $? -ne 0 ]; then
psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
if [ $? -ne 0 ]; then
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.2 1999/12/05 20:02:49 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.3 1999/12/07 22:41:44 momjian Exp $
#
#-------------------------------------------------------------------------
#
#-------------------------------------------------------------------------
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
+ -h*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --host=*)
+ PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
+ ;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
+ -p*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --port=*)
+ PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
+ ;;
- PSQLOPT="$PSQLOPT -U $2"
+ PSQLOPT="$PSQLOPT -U '$2'"
+ -U*)
+ PSQLOPT="$PSQLOPT $1"
+ ;;
+ --user=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
+ ;;
+ --username=*)
+ PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
+ ;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--quiet|-q)
PSQLOPT="$PSQLOPT -o /dev/null"
;;
--quiet|-q)
PSQLOPT="$PSQLOPT -o /dev/null"
;;
+ --dbname|--database|-d)
+ dbname="$2"
+ shift;;
-d*)
dbname=`echo $1 | sed 's/^-d//'`
;;
-d*)
dbname=`echo $1 | sed 's/^-d//'`
;;
;;
# options converted into SQL command
--analyze|-z)
;;
# options converted into SQL command
--analyze|-z)
+ -t*)
+ table=`echo $1 | sed 's/^-t//'`
+ ;;
+ --table=*)
+ table=`echo $1 | sed 's/^--table=//'`
+ ;;
;;
-*)
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
exit 1
;;
;;
-*)
echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
exit 1
;;
- echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-U <username>] [-W] [-d <dbname>] \\"
+ echo "Usage: $CMDNAME [-h server] [-p port] [-U username] [-d dbname] \\"
echo " [-z|--analyze] [-v|--verbose] [-t|--table 'table[(columns)]'] [dbname]"
exit 0
fi
echo " [-z|--analyze] [-v|--verbose] [-t|--table 'table[(columns)]'] [dbname]"
exit 0
fi
-psql $PSQLOPT -d "$dbname" -c "VACUUM $verbose $analyze $table"
+psql $PSQLOPT -d "$dbname" -c "VACUUM $verbose$analyze$table"
- echo "$CMDNAME: Database vacuum failed."
+ echo "$CMDNAME: Vacuum failed."