1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-22 23:02:54 +03:00

Updated user's guide to match new psql's output format

Fixed bug in createdb/alternative location
This commit is contained in:
Peter Eisentraut 2000-03-26 18:32:30 +00:00
parent 3871b69ba1
commit 4579e68db2
23 changed files with 382 additions and 399 deletions

View File

@ -56,16 +56,12 @@ INSERT INTO SAL_EMP
whose pay changed in the second quarter: whose pay changed in the second quarter:
<ProgramListing> <ProgramListing>
SELECT name SELECT name FROM sal_emp WHERE pay_by_quarter[1] &lt;&gt; pay_by_quarter[2];
FROM SAL_EMP
WHERE SAL_EMP.pay_by_quarter[1] &lt;&gt;
SAL_EMP.pay_by_quarter[2];
+------+ name
|name | -------
+------+ Carol
|Carol | (1 row)
+------+
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -74,16 +70,13 @@ SELECT name
employees: employees:
<ProgramListing> <ProgramListing>
SELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP; SELECT pay_by_quarter[3] FROM sal_emp;
pay_by_quarter
+---------------+ ----------------
|pay_by_quarter | 10000
+---------------+ 25000
|10000 | (2 rows)
+---------------+
|25000 |
+---------------+
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -93,15 +86,12 @@ SELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP;
Bill's schedule for the first two days of the week. Bill's schedule for the first two days of the week.
<ProgramListing> <ProgramListing>
SELECT SAL_EMP.schedule[1:2][1:1] SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
FROM SAL_EMP
WHERE SAL_EMP.name = 'Bill';
+-------------------+ schedule
|schedule | --------------------
+-------------------+ {{"meeting"},{""}}
|{{"meeting"},{""}} | (1 row)
+-------------------+
</ProgramListing> </ProgramListing>
</Para> </Para>

View File

@ -939,7 +939,7 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (<replaceabl
<entry>ISO-8601</entry> <entry>ISO-8601</entry>
</row> </row>
<row> <row>
<entry>040506-08/entry> <entry>040506-08</entry>
<entry>ISO-8601</entry> <entry>ISO-8601</entry>
</row> </row>
</tbody> </tbody>

View File

@ -45,13 +45,11 @@ SELECT name, altitude
FROM cities FROM cities
WHERE altitude &gt; 500; WHERE altitude &gt; 500;
+----------+----------+ name | altitude
|name | altitude | -----------+----------
+----------+----------+ Las Vegas | 2174
|Las Vegas | 2174 | Mariposa | 1953
+----------+----------+ (2 rows)
|Mariposa | 1953 |
+----------+----------+
</programlisting> </programlisting>
</para> </para>
@ -69,15 +67,11 @@ SELECT c.name, c.altitude
which returns: which returns:
<programlisting> <programlisting>
+----------+----------+ name | altitude
|name | altitude | -----------+----------
+----------+----------+ Las Vegas | 2174
|Las Vegas | 2174 | Mariposa | 1953
+----------+----------+ Madison | 845
|Mariposa | 1953 |
+----------+----------+
|Madison | 845 |
+----------+----------+
</programlisting> </programlisting>
Here the <quote>*</quote> after cities indicates that the query should Here the <quote>*</quote> after cities indicates that the query should

View File

@ -66,18 +66,19 @@
<replaceable class="parameter">dbname</replaceable> database by typing the command: <replaceable class="parameter">dbname</replaceable> database by typing the command:
<programlisting> <programlisting>
% psql <replaceable class="parameter">dbname</replaceable> psql <replaceable class="parameter">dbname</replaceable>
</programlisting> </programlisting>
You will be greeted with the following message: You will be greeted with the following message:
<programlisting> <programlisting>
Welcome to the Postgres interactive sql monitor: Welcome to psql, the PostgreSQL interactive terminal.
type \? for help on slash commands Type: \copyright for distribution terms
type \q to quit \h for help with SQL commands
type \g or terminate with semicolon to execute query \? for help on internal slash commands
You are currently connected to the database: <replaceable>dbname</replaceable> \g or terminate with semicolon to execute query
\q to quit
<replaceable>dbname</replaceable>=&gt; <replaceable>dbname</replaceable>=&gt;
</programlisting> </programlisting>

View File

@ -49,7 +49,7 @@
and to do the same from within <Application>psql</Application> type and to do the same from within <Application>psql</Application> type
<ProgramListing> <ProgramListing>
* CREATE DATABASE mydb; => CREATE DATABASE mydb;
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -57,9 +57,7 @@
If you do not have the privileges required to create a database, you will see If you do not have the privileges required to create a database, you will see
the following: the following:
<ProgramListing> <ProgramListing>
% createdb mydb ERROR: CREATE DATABASE: Permission denied.
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -124,7 +122,7 @@ createdb: database creation failed on mydb.
the Postgres administrator account. the Postgres administrator account.
Then, from the command line, type Then, from the command line, type
<ProgramListing> <ProgramListing>
% initlocation $PGDATA2 % initlocation PGDATA2
Creating Postgres database system directory /alt/postgres/data Creating Postgres database system directory /alt/postgres/data
Creating Postgres database system directory /alt/postgres/data/base Creating Postgres database system directory /alt/postgres/data/base
</ProgramListing> </ProgramListing>
@ -139,7 +137,7 @@ Creating Postgres database system directory /alt/postgres/data/base
and to do the same from within <Application>psql</Application> type and to do the same from within <Application>psql</Application> type
<ProgramListing> <ProgramListing>
* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2'; => CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -147,9 +145,7 @@ Creating Postgres database system directory /alt/postgres/data/base
If you do not have the privileges required to create a database, you will see If you do not have the privileges required to create a database, you will see
the following: the following:
<ProgramListing> <ProgramListing>
% createdb mydb ERROR: CREATE DATABASE: permission denied
WARN:user "your username" is not allowed to create/destroy databases
createdb: database creation failed on mydb.
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -158,9 +154,7 @@ createdb: database creation failed on mydb.
permission to access it or to write to directories under it, you will see permission to access it or to write to directories under it, you will see
the following: the following:
<ProgramListing> <ProgramListing>
% createdb -D /alt/postgres/data mydb ERROR: The database path '/no/where' is invalid. This may be due to a character that is not allowed or because the chosen path isn't permitted for databases.
ERROR: Unable to create database directory /alt/postgres/data/base/mydb
createdb: database creation failed on mydb.
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -176,8 +170,8 @@ createdb: database creation failed on mydb.
<ItemizedList Mark="bullet" Spacing="compact"> <ItemizedList Mark="bullet" Spacing="compact">
<ListItem> <ListItem>
<Para> <Para>
running the <ProductName>Postgres</ProductName> terminal monitor programs (e.g. running the <ProductName>PostgreSQL</ProductName> interactive terminal
<Application>psql</Application>) which allows you to interactively <Application>psql</Application> which allows you to interactively
enter, edit, and execute <Acronym>SQL</Acronym> commands. enter, edit, and execute <Acronym>SQL</Acronym> commands.
</Para> </Para>
</ListItem> </ListItem>
@ -202,26 +196,26 @@ to try out the examples in this manual.
You will be greeted with the following message: You will be greeted with the following message:
<ProgramListing> <ProgramListing>
Welcome to the POSTGRESQL interactive sql monitor: Welcome to psql, the PostgreSQL interactive terminal.
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
type \? for help on slash commands Type: \copyright for distribution terms
type \q to quit \h for help with SQL commands
type \g or terminate with semicolon to execute query \? for help on internal slash commands
You are currently connected to the database: template1 \g or terminate with semicolon to execute query
\q to quit
mydb=> mydb=>
</ProgramListing> </ProgramListing>
</Para> </Para>
<Para> <Para>
This prompt indicates that the terminal monitor is listening This prompt indicates that psql is listening
to you and that you can type <Acronym>SQL</Acronym> queries into a to you and that you can type <Acronym>SQL</Acronym> queries into a
workspace maintained by the terminal monitor. workspace maintained by the terminal monitor.
The <Application>psql</Application> program responds to escape codes that begin The <Application>psql</Application> program responds to escape codes that begin
with the backslash character, <Quote>\</Quote> For example, you with the backslash character, <Quote>\</Quote> For example, you
can get help on the syntax of various can get help on the syntax of various
<ProductName>Postgres</ProductName> <Acronym>SQL</Acronym> commands by typing: <ProductName>PostgreSQL</ProductName> <Acronym>SQL</Acronym> commands by typing:
<ProgramListing> <ProgramListing>
mydb=> \h mydb=> \h
</ProgramListing> </ProgramListing>
@ -249,7 +243,7 @@ mydb=> \q
</ProgramListing> </ProgramListing>
and <Application>psql</Application> will quit and return you to your command and <Application>psql</Application> will quit and return you to your command
shell. (For more escape codes, type <Command>\h</Command> at the monitor shell. (For more escape codes, type <Command>\?</Command> at the psql
prompt.) prompt.)
White space (i.e., spaces, tabs and newlines) may be White space (i.e., spaces, tabs and newlines) may be
used freely in <Acronym>SQL</Acronym> queries. Single-line comments are denoted by used freely in <Acronym>SQL</Acronym> queries. Single-line comments are denoted by
@ -280,7 +274,7 @@ TBD
<Title>Destroying a Database</Title> <Title>Destroying a Database</Title>
<Para> <Para>
If you are the database administrator for the database If you are the owner of the database
<Database>mydb</Database>, you can destroy it using the following Unix command: <Database>mydb</Database>, you can destroy it using the following Unix command:
<ProgramListing> <ProgramListing>
% dropdb mydb % dropdb mydb

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/abort.sgml,v 1.5 2000/01/29 16:58:27 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/abort.sgml,v 1.6 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -63,7 +63,6 @@ ROLLBACK
<varlistentry> <varlistentry>
<term><computeroutput> <term><computeroutput>
NOTICE: ROLLBACK: no transaction in progress NOTICE: ROLLBACK: no transaction in progress
ROLLBACK
</computeroutput></term> </computeroutput></term>
<listitem> <listitem>
<para> <para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.11 1999/12/12 05:15:09 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.12 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -245,13 +245,15 @@ comment from Olly; response from Thomas...
<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput> <computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
<prompt>$</prompt> <userinput>psql olly</userinput> <prompt>$</prompt> <userinput>psql olly</userinput>
<computeroutput>Welcome to psql, the PostgreSQL interactive terminal. <computeroutput>
(Please type \copyright to see the distribution terms of PostgreSQL.) Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
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> <prompt>olly=></prompt></computeroutput> <userinput>CREATE DATABASE elsewhere WITH LOCATION = '/home/olly/private_db';</userinput>
<computeroutput>CREATE DATABASE</computeroutput> <computeroutput>CREATE DATABASE</computeroutput>
</programlisting> </programlisting>
@ -272,7 +274,7 @@ Type \h for help with SQL commands,
</title> </title>
<para> <para>
There is no <command>CREATE DATABASE</command> statement in SQL92. There is no <command>CREATE DATABASE</command> statement in SQL92.
The equivalent command in standard SQL is <command>CREATE SCHEMA</command>. Databases are equivalent to catalogs whose creation is implementation-defined.
</para> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.11 1999/10/02 21:27:49 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.12 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -250,7 +250,7 @@ SELECT one() AS answer;
<computeroutput> <computeroutput>
answer answer
------ --------
1 1
</computeroutput> </computeroutput>
</programlisting> </programlisting>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.8 1999/07/22 15:09:07 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.9 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -233,20 +233,20 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
for further information: for further information:
<programlisting> <programlisting>
<computeroutput> <computeroutput>
Table = pg_language Table "pg_language"
+--------------------------+--------------------------+-------+ Attribute | Type | Modifier
| Field | Type | Length| ---------------+---------+----------
+--------------------------+--------------------------+-------+ lanname | name |
| lanname | name | 32 | lanispl | boolean |
| lancompiler | text | var | lanpltrusted | boolean |
+--------------------------+--------------------------+-------+ lanplcallfoid | oid |
lancompiler | text |
lanname |lancompiler lanname | lanispl | lanpltrusted | lanplcallfoid | lancompiler
--------+-------------- ----------+---------+--------------+---------------+-------------
internal|n/a internal | f | f | 0 | n/a
lisp |/usr/ucb/liszt C | f | f | 0 | /bin/cc
C |/bin/cc sql | f | f | 0 | postgres
sql |postgres
</computeroutput> </computeroutput>
</programlisting> </programlisting>
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.7 1999/07/22 15:09:08 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.8 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -161,9 +161,10 @@ CREATE VIEW kinds AS
SELECT * FROM kinds; SELECT * FROM kinds;
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+-------------------------+---+----------+----------+------ -------+---------------------------+-----+------------+--------+-------
UA502 | Bananas | 105 | 1971-07-13 | Comedy | 01:22 UA502 | Bananas | 105 | 1971-07-13 | Comedy | 01:22
C_701 | There's a Girl in my Soup | 107 | 1970-06-11 | Comedy | 01:36 C_701 | There's a Girl in my Soup | 107 | 1970-06-11 | Comedy | 01:36
(2 rows)
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.9 1999/10/04 04:37:46 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.10 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -137,7 +137,7 @@ SELECT * FROM films;
<computeroutput> <computeroutput>
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+-------------------------+---+----------+----------+------ -------+---------------------------+-----+------------+---------+-------
UA501 | West Side Story | 105 | 1961-01-03 | Musical | 02:32 UA501 | West Side Story | 105 | 1961-01-03 | Musical | 02:32
TC901 | The King and I | 109 | 1956-08-11 | Musical | 02:13 TC901 | The King and I | 109 | 1956-08-11 | Musical | 02:13
WD101 | Bed Knobs and Broomsticks | 111 | | Musical | 01:57 WD101 | Bed Knobs and Broomsticks | 111 | | Musical | 01:57
@ -154,7 +154,7 @@ SELECT * FROM films;
<computeroutput> <computeroutput>
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
----+-----+---+---------+----+--- ------+-------+-----+-----------+------+-----
(0 rows) (0 rows)
</computeroutput> </computeroutput>
</programlisting> </programlisting>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/fetch.sgml,v 1.7 1999/07/22 15:09:12 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/fetch.sgml,v 1.8 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -301,18 +301,16 @@ FETCH RELATIVE 0 FROM <replaceable class="PARAMETER">cursor</replaceable>
<programlisting> <programlisting>
-- set up and use a cursor: -- set up and use a cursor:
--
BEGIN WORK; BEGIN WORK;
DECLARE liahona CURSOR DECLARE liahona CURSOR FOR SELECT * FROM films;
FOR SELECT * FROM films;
-- Fetch first 5 rows in the cursor liahona: -- Fetch first 5 rows in the cursor liahona:
--
FETCH FORWARD 5 IN liahona; FETCH FORWARD 5 IN liahona;
<computeroutput> <computeroutput>
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+-----------------------+---+----------+----------+------ -------+-------------------------+-----+------------+----------+-------
BL101 | The Third Man | 101 | 1949-12-23 | Drama | 01:44 BL101 | The Third Man | 101 | 1949-12-23 | Drama | 01:44
BL102 | The African Queen | 101 | 1951-08-11 | Romantic | 01:43 BL102 | The African Queen | 101 | 1951-08-11 | Romantic | 01:43
JL201 | Une Femme est une Femme | 102 | 1961-03-12 | Romantic | 01:25 JL201 | Une Femme est une Femme | 102 | 1961-03-12 | Romantic | 01:25
@ -321,17 +319,16 @@ FETCH RELATIVE 0 FROM <replaceable class="PARAMETER">cursor</replaceable>
</computeroutput> </computeroutput>
-- Fetch previous row: -- Fetch previous row:
--
FETCH BACKWARD 1 IN liahona; FETCH BACKWARD 1 IN liahona;
<computeroutput> <computeroutput>
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+-----------------------+---+----------+----------+------ -------+---------+-----+------------+--------+-------
P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08 P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08
</computeroutput> </computeroutput>
-- close the cursor and commit work: -- close the cursor and commit work:
--
CLOSE liahona; CLOSE liahona;
COMMIT WORK; COMMIT WORK;
</programlisting> </programlisting>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/initlocation.sgml,v 1.5 2000/01/18 00:03:34 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/initlocation.sgml,v 1.6 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -96,7 +96,7 @@ initlocation <replaceable class="parameter">directory</replaceable>
<programlisting> <programlisting>
$ export PGDATA2=/opt/postgres/data $ export PGDATA2=/opt/postgres/data
$ initlocation PGDATA2 $ initlocation PGDATA2
$ createdb 'testdb' -D 'PGDATA2/testdb' $ createdb 'testdb' -D 'PGDATA2'
</programlisting> </programlisting>
</para> </para>
@ -104,7 +104,7 @@ $ createdb 'testdb' -D 'PGDATA2/testdb'
Alternatively, if you allow absolute paths you could write: Alternatively, if you allow absolute paths you could write:
<programlisting> <programlisting>
$ initlocation /opt/postgres/data $ initlocation /opt/postgres/data
$ createdb 'testdb' -D '/opt/postgres/data/testdb' $ createdb testdb -D '/opt/postgres/data/testdb'
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/listen.sgml,v 1.7 1999/07/22 15:09:12 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/listen.sgml,v 1.8 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -170,7 +170,7 @@ NOTICE Async_Listen: We are already listening on <replaceable class="PARAMETER">
LISTEN virtual; LISTEN virtual;
NOTIFY virtual; NOTIFY virtual;
ASYNC NOTIFY of 'virtual' from backend pid '11239' received Asynchronous NOTIFY 'virtual' from backend with pid '8448' received.
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/move.sgml,v 1.6 1999/07/22 15:09:13 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/move.sgml,v 1.7 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -100,7 +100,7 @@ FETCH 1 IN liahona;
FETCH FETCH
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+------+---+----------+----------+------ -------+--------+-----+-----------+--------+-------
P_303 | 48 Hrs | 103 | 1982-10-22| Action | 01:37 P_303 | 48 Hrs | 103 | 1982-10-22| Action | 01:37
(1 row) (1 row)
</computeroutput> </computeroutput>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/notify.sgml,v 1.10 1999/07/22 15:09:13 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/notify.sgml,v 1.11 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -209,9 +209,9 @@ NOTIFY
<application>psql</application>: <application>psql</application>:
<programlisting> <programlisting>
LISTEN virtual; => LISTEN virtual;
NOTIFY virtual; => NOTIFY virtual;
ASYNC NOTIFY of 'virtual' from backend pid '11239' received Asynchronous NOTIFY 'virtual' from backend with pid '8448' received.
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.26 2000/03/15 23:31:19 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.27 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -610,7 +610,7 @@ SELECT f.title, f.did, d.name, f.date_prod, f.kind
WHERE f.did = d.did WHERE f.did = d.did
title | did | name | date_prod | kind title | did | name | date_prod | kind
-------------------------+---+----------------+----------+---------- ---------------------------+-----+------------------+------------+----------
The Third Man | 101 | British Lion | 1949-12-23 | Drama The Third Man | 101 | British Lion | 1949-12-23 | Drama
The African Queen | 101 | British Lion | 1951-08-11 | Romantic The African Queen | 101 | British Lion | 1951-08-11 | Romantic
Une Femme est une Femme | 102 | Jean Luc Godard | 1961-03-12 | Romantic Une Femme est une Femme | 102 | Jean Luc Godard | 1961-03-12 | Romantic
@ -628,6 +628,7 @@ Storia di una donna |108|Westward |1970-08-15|Romantic
The King and I | 109 | 20th Century Fox | 1956-08-11 | Musical The King and I | 109 | 20th Century Fox | 1956-08-11 | Musical
Das Boot | 110 | Bavaria Atelier | 1981-11-11 | Drama Das Boot | 110 | Bavaria Atelier | 1981-11-11 | Drama
Bed Knobs and Broomsticks | 111 | Walt Disney | | Musical Bed Knobs and Broomsticks | 111 | Walt Disney | | Musical
(17 rows)
</programlisting> </programlisting>
</para> </para>
@ -639,12 +640,13 @@ Bed Knobs and Broomsticks|111|Walt Disney | |Musical
SELECT kind, SUM(len) AS total FROM films GROUP BY kind; SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
kind | total kind | total
----------+------ ----------+-------
Action | 07:34 Action | 07:34
Comedy | 02:58 Comedy | 02:58
Drama | 14:28 Drama | 14:28
Musical | 06:42 Musical | 06:42
Romantic | 04:38 Romantic | 04:38
(5 rows)
</programlisting> </programlisting>
</para> </para>
@ -660,9 +662,10 @@ SELECT kind, SUM(len) AS total
HAVING SUM(len) < INTERVAL '5 hour'; HAVING SUM(len) < INTERVAL '5 hour';
kind | total kind | total
----------+------ ----------+-------
Comedy | 02:58 Comedy | 02:58
Romantic | 04:38 Romantic | 04:38
(2 rows)
</programlisting> </programlisting>
</para> </para>
@ -676,7 +679,7 @@ SELECT * FROM distributors ORDER BY name;
SELECT * FROM distributors ORDER BY 2; SELECT * FROM distributors ORDER BY 2;
did | name did | name
---+---------------- -----+------------------
109 | 20th Century Fox 109 | 20th Century Fox
110 | Bavaria Atelier 110 | Bavaria Atelier
101 | British Lion 101 | British Lion
@ -690,6 +693,7 @@ SELECT * FROM distributors ORDER BY 2;
111 | Walt Disney 111 | Walt Disney
112 | Warner Bros. 112 | Warner Bros.
108 | Westward 108 | Westward
(13 rows)
</programlisting> </programlisting>
</para> </para>
@ -701,13 +705,13 @@ SELECT * FROM distributors ORDER BY 2;
ALL keyword is omitted: ALL keyword is omitted:
<programlisting> <programlisting>
-- distributors: actors: distributors: actors:
-- did|name id|name did | name id | name
-- ---+------------ --+-------------- -----+-------------- ----+----------------
-- 108|Westward 1|Woody Allen 108 | Westward 1 | Woody Allen
-- 111|Walt Disney 2|Warren Beatty 111 | Walt Disney 2 | Warren Beatty
-- 112|Warner Bros. 3|Walter Matthau 112 | Warner Bros. 3 | Walter Matthau
-- ... ... ... ...
SELECT distributors.name SELECT distributors.name
FROM distributors FROM distributors
@ -718,7 +722,7 @@ SELECT actors.name
WHERE actors.name LIKE 'W%' WHERE actors.name LIKE 'W%'
name name
-------------- ----------------
Walt Disney Walt Disney
Walter Matthau Walter Matthau
Warner Bros. Warner Bros.
@ -750,7 +754,7 @@ was retained from the original PostQuel query language:
SELECT distributors.* WHERE name = 'Westwood'; SELECT distributors.* WHERE name = 'Westwood';
did | name did | name
---+---------------- -----+----------
108 | Westward 108 | Westward
</programlisting> </programlisting>
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.32 2000/03/17 05:29:03 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.33 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -910,7 +910,7 @@ SET TIME ZONE 'PST8PDT';
SELECT CURRENT_TIMESTAMP AS today; SELECT CURRENT_TIMESTAMP AS today;
today today
---------------------- ------------------------
1998-03-31 07:41:21-08 1998-03-31 07:41:21-08
</programlisting> </programlisting>
@ -921,7 +921,7 @@ SET TIME ZONE 'Europe/Rome';
SELECT CURRENT_TIMESTAMP AS today; SELECT CURRENT_TIMESTAMP AS today;
today today
---------------------- ------------------------
1998-03-31 17:41:31+02 1998-03-31 17:41:31+02
</programlisting> </programlisting>
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/unlisten.sgml,v 1.8 1999/07/22 15:09:15 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/unlisten.sgml,v 1.9 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -147,7 +147,7 @@ postgres=> LISTEN virtual;
LISTEN LISTEN
postgres=> NOTIFY virtual; postgres=> NOTIFY virtual;
NOTIFY NOTIFY
ASYNC NOTIFY of 'virtual' from backend pid '12317' received Asynchronous NOTIFY 'virtual' from backend with pid '8448' received
</programlisting> </programlisting>
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.7 2000/01/29 16:58:27 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.8 2000/03/26 18:32:27 petere Exp $
Postgres documentation Postgres documentation
--> -->
@ -151,13 +151,11 @@ UPDATE <replaceable class="parameter">#</replaceable>
Change word "Drama" with "Dramatic" on column kind: Change word "Drama" with "Dramatic" on column kind:
<programlisting> <programlisting>
UPDATE films UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
SET kind = 'Dramatic'
WHERE kind = 'Drama';
SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama'; SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama';
code | title | did | date_prod | kind | len code | title | did | date_prod | kind | len
-----+-------------+---+----------+----------+------ -------+---------------+-----+------------+----------+-------
BL101 | The Third Man | 101 | 1949-12-23 | Dramatic | 01:44 BL101 | The Third Man | 101 | 1949-12-23 | Dramatic | 01:44
P_302 | Becket | 103 | 1964-02-03 | Dramatic | 02:28 P_302 | Becket | 103 | 1964-02-03 | Dramatic | 02:28
M_401 | War and Peace | 104 | 1967-02-12 | Dramatic | 05:57 M_401 | War and Peace | 104 | 1967-02-12 | Dramatic | 05:57

View File

@ -53,7 +53,7 @@ to start the parser down the correct path. For example, the query
<programlisting> <programlisting>
tgl=> SELECT text 'Origin' AS "Label", point '(0,0)' AS "Value"; tgl=> SELECT text 'Origin' AS "Label", point '(0,0)' AS "Value";
Label | Value Label | Value
------+----- --------+-------
Origin | (0,0) Origin | (0,0)
(1 row) (1 row)
</programlisting> </programlisting>
@ -296,7 +296,7 @@ of this query expression:
<programlisting> <programlisting>
tgl=> select 2 ^ 3 AS "Exp"; tgl=> select 2 ^ 3 AS "Exp";
Exp Exp
--- -----
8 8
(1 row) (1 row)
</programlisting> </programlisting>
@ -307,7 +307,7 @@ is equivalent to
<programlisting> <programlisting>
tgl=> select float8(2) ^ float8(3) AS "Exp"; tgl=> select float8(2) ^ float8(3) AS "Exp";
Exp Exp
--- -----
8 8
(1 row) (1 row)
</programlisting> </programlisting>
@ -317,7 +317,7 @@ or
<programlisting> <programlisting>
tgl=> select 2.0 ^ 3.0 AS "Exp"; tgl=> select 2.0 ^ 3.0 AS "Exp";
Exp Exp
--- -----
8 8
(1 row) (1 row)
</programlisting> </programlisting>
@ -346,7 +346,7 @@ One unspecified argument:
<programlisting> <programlisting>
tgl=> SELECT text 'abc' || 'def' AS "Text and Unknown"; tgl=> SELECT text 'abc' || 'def' AS "Text and Unknown";
Text and Unknown Text and Unknown
---------------- ------------------
abcdef abcdef
(1 row) (1 row)
</programlisting> </programlisting>
@ -363,7 +363,7 @@ Concatenation on unspecified types:
<programlisting> <programlisting>
tgl=> SELECT 'abc' || 'def' AS "Unspecified"; tgl=> SELECT 'abc' || 'def' AS "Unspecified";
Unspecified Unspecified
----------- -------------
abcdef abcdef
(1 row) (1 row)
</programlisting> </programlisting>
@ -399,7 +399,7 @@ factorial.
<programlisting> <programlisting>
tgl=> select (4.3 !); tgl=> select (4.3 !);
?column? ?column?
-------- ----------
24 24
(1 row) (1 row)
</programlisting> </programlisting>
@ -482,7 +482,7 @@ to <type>int4</type>:
<programlisting> <programlisting>
tgl=> select int4fac(int2 '4'); tgl=> select int4fac(int2 '4');
int4fac int4fac
------- ---------
24 24
(1 row) (1 row)
</programlisting> </programlisting>
@ -491,7 +491,7 @@ and is actually transformed by the parser to
<programlisting> <programlisting>
tgl=> select int4fac(int4(int2 '4')); tgl=> select int4fac(int4(int2 '4'));
int4fac int4fac
------- ---------
24 24
(1 row) (1 row)
</programlisting> </programlisting>
@ -512,7 +512,7 @@ directly with the only candidate function type:
<programlisting> <programlisting>
tgl=> select substr('1234', 3); tgl=> select substr('1234', 3);
substr substr
------ --------
34 34
(1 row) (1 row)
</programlisting> </programlisting>
@ -524,7 +524,7 @@ if it comes from a table, then the parser will try to coerce it to become <type>
<programlisting> <programlisting>
tgl=> select substr(varchar '1234', 3); tgl=> select substr(varchar '1234', 3);
substr substr
------ --------
34 34
(1 row) (1 row)
</programlisting> </programlisting>
@ -532,7 +532,7 @@ which is transformed by the parser to become
<programlisting> <programlisting>
tgl=> select substr(text(varchar '1234'), 3); tgl=> select substr(text(varchar '1234'), 3);
substr substr
------ --------
34 34
(1 row) (1 row)
</programlisting> </programlisting>
@ -552,7 +552,7 @@ try to convert that to <type>text</type>:
<programlisting> <programlisting>
tgl=> select substr(1234, 3); tgl=> select substr(1234, 3);
substr substr
------ --------
34 34
(1 row) (1 row)
</programlisting> </programlisting>
@ -560,7 +560,7 @@ actually executes as
<programlisting> <programlisting>
tgl=> select substr(text(1234), 3); tgl=> select substr(text(1234), 3);
substr substr
------ --------
34 34
(1 row) (1 row)
</programlisting> </programlisting>
@ -609,9 +609,9 @@ tgl=> CREATE TABLE vv (v varchar(4));
CREATE CREATE
tgl=> INSERT INTO vv SELECT 'abc' || 'def'; tgl=> INSERT INTO vv SELECT 'abc' || 'def';
INSERT 392905 1 INSERT 392905 1
tgl=> select * from vv; tgl=> SELECT * FROM vv;
v v
---- ------
abcd abcd
(1 row) (1 row)
</programlisting> </programlisting>
@ -652,7 +652,7 @@ first SELECT clause or the target column.
<programlisting> <programlisting>
tgl=> SELECT text 'a' AS "Text" UNION SELECT 'b'; tgl=> SELECT text 'a' AS "Text" UNION SELECT 'b';
Text Text
---- ------
a a
b b
(2 rows) (2 rows)
@ -665,9 +665,9 @@ b
<para> <para>
<programlisting> <programlisting>
tgl=> SELECT 1.2 AS Float8 UNION SELECT 1; tgl=> SELECT 1.2 AS "Float8" UNION SELECT 1;
Float8 Float8
------ --------
1 1
1.2 1.2
(2 rows) (2 rows)
@ -687,7 +687,7 @@ tgl=> SELECT 1 AS "All integers"
tgl-> UNION SELECT '2.2'::float4 tgl-> UNION SELECT '2.2'::float4
tgl-> UNION SELECT 3.3; tgl-> UNION SELECT 3.3;
All integers All integers
------------ --------------
1 1
2 2
3 3
@ -710,7 +710,7 @@ tgl-> UNION SELECT 3.3;
INSERT 0 3 INSERT 0 3
tgl=> SELECT f AS "Floating point" from ff; tgl=> SELECT f AS "Floating point" from ff;
Floating point Floating point
---------------- ------------------
1 1
2.20000004768372 2.20000004768372
3.3 3.3

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.51 2000/03/15 06:50:51 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.52 2000/03/26 18:32:28 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -61,6 +61,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
{ {
char buf[2 * MAXPGPATH + 100]; char buf[2 * MAXPGPATH + 100];
char *loc; char *loc;
char locbuf[512];
int4 user_id; int4 user_id;
bool use_super, use_createdb; bool use_super, use_createdb;
Relation pg_database_rel; Relation pg_database_rel;
@ -70,23 +71,25 @@ createdb(const char *dbname, const char *dbpath, int encoding)
char new_record_nulls[Natts_pg_database] = { ' ', ' ', ' ', ' ' }; char new_record_nulls[Natts_pg_database] = { ' ', ' ', ' ', ' ' };
if (!get_user_info(GetPgUserName(), &user_id, &use_super, &use_createdb)) if (!get_user_info(GetPgUserName(), &user_id, &use_super, &use_createdb))
elog(ERROR, "Current user name is invalid"); elog(ERROR, "current user name is invalid");
if (!use_createdb && !use_super) if (!use_createdb && !use_super)
elog(ERROR, "CREATE DATABASE: Permission denied"); elog(ERROR, "CREATE DATABASE: permission denied");
if (get_db_info(dbname, NULL, NULL, NULL)) if (get_db_info(dbname, NULL, NULL, NULL))
elog(ERROR, "CREATE DATABASE: Database \"%s\" already exists", dbname); elog(ERROR, "CREATE DATABASE: database \"%s\" already exists", dbname);
/* don't call this in a transaction block */ /* don't call this in a transaction block */
if (IsTransactionBlock()) if (IsTransactionBlock())
elog(ERROR, "CREATE DATABASE: May not be called in a transaction block"); elog(ERROR, "CREATE DATABASE: may not be called in a transaction block");
/* Generate directory name for the new database */ /* Generate directory name for the new database */
if (dbpath == NULL) if (dbpath == NULL || strcmp(dbpath, dbname)==0)
dbpath = dbname; strcpy(locbuf, dbname);
else
snprintf(locbuf, sizeof(locbuf), "%s/%s", dbpath, dbname);
loc = ExpandDatabasePath(dbpath); loc = ExpandDatabasePath(locbuf);
if (loc == NULL) if (loc == NULL)
elog(ERROR, elog(ERROR,
@ -105,10 +108,10 @@ createdb(const char *dbname, const char *dbpath, int encoding)
pg_database_dsc = RelationGetDescr(pg_database_rel); pg_database_dsc = RelationGetDescr(pg_database_rel);
/* Form tuple */ /* Form tuple */
new_record[Anum_pg_database_datname-1] = NameGetDatum(dbname); new_record[Anum_pg_database_datname-1] = NameGetDatum(namein(dbname));
new_record[Anum_pg_database_datdba-1] = Int32GetDatum(user_id); new_record[Anum_pg_database_datdba-1] = Int32GetDatum(user_id);
new_record[Anum_pg_database_encoding-1] = Int32GetDatum(encoding); new_record[Anum_pg_database_encoding-1] = Int32GetDatum(encoding);
new_record[Anum_pg_database_datpath-1] = PointerGetDatum(textin((char *)dbpath)); new_record[Anum_pg_database_datpath-1] = PointerGetDatum(textin(locbuf));
tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls); tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
@ -137,7 +140,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
/* Copy the template database to the new location */ /* Copy the template database to the new location */
if (mkdir(loc, S_IRWXU) != 0) { if (mkdir(loc, S_IRWXU) != 0) {
elog(ERROR, "CREATE DATABASE: Unable to create database directory '%s': %s", loc, strerror(errno)); elog(ERROR, "CREATE DATABASE: unable to create database directory '%s': %s", loc, strerror(errno));
} }
snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'", snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
@ -147,7 +150,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
snprintf(buf, sizeof(buf), "rm -rf '%s'", loc); snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
ret = system(buf); ret = system(buf);
if (ret == 0) if (ret == 0)
elog(ERROR, "CREATE DATABASE: Could not initialize database directory"); elog(ERROR, "CREATE DATABASE: could not initialize database directory");
else else
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well"); elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
} }

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.6 2000/03/25 19:01:48 tgl Exp $ # $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.7 2000/03/26 18:32:30 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -156,9 +156,9 @@ echo "$CMDNAME is complete."
# path, which the backend won't allow by default. # path, which the backend won't allow by default.
if [ "$haveenv" = "t" ]; then if [ "$haveenv" = "t" ]; then
echo "You can now create a database using" echo "You can now create a database using"
echo " CREATE DATABASE <name> WITH LOCATION = '$Location/<name>'" echo " CREATE DATABASE <name> WITH LOCATION = '$Location'"
echo "in SQL, or" echo "in SQL, or"
echo " createdb <name> -D '$Location/<name>'" echo " createdb <name> -D '$Location'"
echo "from the shell." echo "from the shell."
fi fi
echo echo