diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml index e6f54b675a..bbc0a07f56 100644 --- a/doc/src/sgml/array.sgml +++ b/doc/src/sgml/array.sgml @@ -56,16 +56,12 @@ INSERT INTO SAL_EMP whose pay changed in the second quarter: -SELECT name - FROM SAL_EMP - WHERE SAL_EMP.pay_by_quarter[1] <> - SAL_EMP.pay_by_quarter[2]; +SELECT name FROM sal_emp WHERE pay_by_quarter[1] <> pay_by_quarter[2]; -+------+ -|name | -+------+ -|Carol | -+------+ + name +------- + Carol +(1 row) @@ -74,16 +70,13 @@ SELECT name employees: -SELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP; +SELECT pay_by_quarter[3] FROM sal_emp; - -+---------------+ -|pay_by_quarter | -+---------------+ -|10000 | -+---------------+ -|25000 | -+---------------+ + pay_by_quarter +---------------- + 10000 + 25000 +(2 rows) @@ -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. -SELECT SAL_EMP.schedule[1:2][1:1] - FROM SAL_EMP - WHERE SAL_EMP.name = 'Bill'; +SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill'; -+-------------------+ -|schedule | -+-------------------+ -|{{"meeting"},{""}} | -+-------------------+ + schedule +-------------------- + {{"meeting"},{""}} +(1 row) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 1bd7d6125c..1199b20b6a 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -939,7 +939,7 @@ CREATE TABLE tablename (ISO-8601 - 040506-08/entry> + 040506-08 ISO-8601 diff --git a/doc/src/sgml/inherit.sgml b/doc/src/sgml/inherit.sgml index 0593da0915..0a49df2c51 100644 --- a/doc/src/sgml/inherit.sgml +++ b/doc/src/sgml/inherit.sgml @@ -6,7 +6,7 @@ state capitals which are also cities. Naturally, the capitals class should inherit from cities. - + CREATE TABLE cities ( name text, population float, @@ -16,7 +16,7 @@ CREATE TABLE cities ( CREATE TABLE capitals ( state char(2) ) INHERITS (cities); - + In this case, an instance of capitals inherits all attributes (name, population, and altitude) from its @@ -40,19 +40,17 @@ CREATE TABLE capitals ( For example, the following query finds all the cities that are situated at an attitude of 500ft or higher: - + SELECT name, altitude FROM cities WHERE altitude > 500; -+----------+----------+ -|name | altitude | -+----------+----------+ -|Las Vegas | 2174 | -+----------+----------+ -|Mariposa | 1953 | -+----------+----------+ - + name | altitude +-----------+---------- + Las Vegas | 2174 + Mariposa | 1953 +(2 rows) + @@ -60,25 +58,21 @@ SELECT name, altitude including state capitals, that are located at an altitude over 500ft, the query is: - + SELECT c.name, c.altitude FROM cities* c WHERE c.altitude > 500; - + which returns: - -+----------+----------+ -|name | altitude | -+----------+----------+ -|Las Vegas | 2174 | -+----------+----------+ -|Mariposa | 1953 | -+----------+----------+ -|Madison | 845 | -+----------+----------+ - + + name | altitude +-----------+---------- + Las Vegas | 2174 + Mariposa | 1953 + Madison | 845 + Here the * after cities indicates that the query should be run over cities and all classes below cities in the diff --git a/doc/src/sgml/manage-ag.sgml b/doc/src/sgml/manage-ag.sgml index 6f62234313..6b66ff6d14 100644 --- a/doc/src/sgml/manage-ag.sgml +++ b/doc/src/sgml/manage-ag.sgml @@ -65,22 +65,23 @@ to try out the examples in this manual. It can be activated for the dbname database by typing the command: - -% psql dbname - + +psql dbname + You will be greeted with the following message: - -Welcome to the Postgres interactive sql monitor: + +Welcome to psql, the PostgreSQL interactive terminal. - 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: dbname +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 dbname=> - + diff --git a/doc/src/sgml/manage.sgml b/doc/src/sgml/manage.sgml index d4acd9d7bd..c2d44e546f 100644 --- a/doc/src/sgml/manage.sgml +++ b/doc/src/sgml/manage.sgml @@ -43,24 +43,22 @@ To create a new database named mydb from the command line, type - + % createdb mydb - + and to do the same from within psql type - -* CREATE DATABASE mydb; - + +=> CREATE DATABASE mydb; + If you do not have the privileges required to create a database, you will see the following: - -% createdb mydb -WARN:user "your username" is not allowed to create/destroy databases -createdb: database creation failed on mydb. - + +ERROR: CREATE DATABASE: Permission denied. + @@ -123,45 +121,41 @@ createdb: database creation failed on mydb. ensure that /alt/postgres already exists and is writable by the Postgres administrator account. Then, from the command line, type - -% initlocation $PGDATA2 + +% initlocation PGDATA2 Creating Postgres database system directory /alt/postgres/data Creating Postgres database system directory /alt/postgres/data/base - + To create a database in the alternate storage area PGDATA2 from the command line, use the following command: - + % createdb -D PGDATA2 mydb - + and to do the same from within psql type - -* CREATE DATABASE mydb WITH LOCATION = 'PGDATA2'; - + +=> CREATE DATABASE mydb WITH LOCATION = 'PGDATA2'; + If you do not have the privileges required to create a database, you will see the following: - -% createdb mydb -WARN:user "your username" is not allowed to create/destroy databases -createdb: database creation failed on mydb. - + +ERROR: CREATE DATABASE: permission denied + If the specified location does not exist or the database backend does not have permission to access it or to write to directories under it, you will see the following: - -% createdb -D /alt/postgres/data mydb -ERROR: Unable to create database directory /alt/postgres/data/base/mydb -createdb: database creation failed on 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. + @@ -176,9 +170,9 @@ createdb: database creation failed on mydb. -running the Postgres terminal monitor programs (e.g. - psql) which allows you to interactively - enter, edit, and execute SQL commands. +running the PostgreSQL interactive terminal +psql which allows you to interactively +enter, edit, and execute SQL commands. @@ -202,26 +196,26 @@ to try out the examples in this manual. You will be greeted with the following message: -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 +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 mydb=> -This prompt indicates that the terminal monitor is listening +This prompt indicates that psql is listening to you and that you can type SQL queries into a workspace maintained by the terminal monitor. The psql program responds to escape codes that begin with the backslash character, \ For example, you can get help on the syntax of various - Postgres SQL commands by typing: + PostgreSQL SQL commands by typing: mydb=> \h @@ -249,7 +243,7 @@ mydb=> \q and psql will quit and return you to your command - shell. (For more escape codes, type \h at the monitor + shell. (For more escape codes, type \? at the psql prompt.) White space (i.e., spaces, tabs and newlines) may be used freely in SQL queries. Single-line comments are denoted by @@ -280,14 +274,14 @@ TBD Destroying a Database - If you are the database administrator for the database + If you are the owner of the database mydb, you can destroy it using the following Unix command: % dropdb mydb - This action physically removes all of the Unix files + This action physically removes all of the Unix files associated with the database and cannot be undone, so - this should only be done with a great deal of forethought. + this should only be done with a great deal of forethought. diff --git a/doc/src/sgml/ref/abort.sgml b/doc/src/sgml/ref/abort.sgml index c31fcb2acb..062e660332 100644 --- a/doc/src/sgml/ref/abort.sgml +++ b/doc/src/sgml/ref/abort.sgml @@ -1,5 +1,5 @@ @@ -63,7 +63,6 @@ ROLLBACK NOTICE: ROLLBACK: no transaction in progress -ROLLBACK diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml index 5dc6dca9bc..c8de74eee5 100644 --- a/doc/src/sgml/ref/create_database.sgml +++ b/doc/src/sgml/ref/create_database.sgml @@ -1,5 +1,5 @@ @@ -245,13 +245,15 @@ comment from Olly; response from Thomas... Creating Postgres database system directory /home/olly/private_db/base $ psql olly -Welcome to psql, the PostgreSQL interactive terminal. -(Please type \copyright to see the distribution terms of PostgreSQL.) + +Welcome to psql, the PostgreSQL interactive terminal. -Type \h for help with SQL commands, - \? for help on internal slash commands, - \q to quit, - \g or terminate with semicolon to execute query. +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 + olly=> CREATE DATABASE elsewhere WITH LOCATION = '/home/olly/private_db'; CREATE DATABASE @@ -272,7 +274,7 @@ Type \h for help with SQL commands, There is no CREATE DATABASE statement in SQL92. - The equivalent command in standard SQL is CREATE SCHEMA. + Databases are equivalent to catalogs whose creation is implementation-defined. diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index 3fb87b57f8..3333171319 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -1,5 +1,5 @@ @@ -242,18 +242,18 @@ CREATE To create a simple SQL function: - + CREATE FUNCTION one() RETURNS int4 AS 'SELECT 1 AS RESULT' LANGUAGE 'sql'; SELECT one() AS answer; - - answer - ------ - 1 - - + + answer +-------- + 1 + + diff --git a/doc/src/sgml/ref/create_language.sgml b/doc/src/sgml/ref/create_language.sgml index 7cdb403825..580490b357 100644 --- a/doc/src/sgml/ref/create_language.sgml +++ b/doc/src/sgml/ref/create_language.sgml @@ -1,5 +1,5 @@ @@ -231,24 +231,24 @@ ERROR: PL handler function funcname Refer to the table pg_language for further information: - - -Table = pg_language -+--------------------------+--------------------------+-------+ -| Field | Type | Length| -+--------------------------+--------------------------+-------+ -| lanname | name | 32 | -| lancompiler | text | var | -+--------------------------+--------------------------+-------+ + + + Table "pg_language" + Attribute | Type | Modifier +---------------+---------+---------- + lanname | name | + lanispl | boolean | + lanpltrusted | boolean | + lanplcallfoid | oid | + lancompiler | text | -lanname |lancompiler ---------+-------------- -internal|n/a -lisp |/usr/ucb/liszt -C |/bin/cc -sql |postgres - - + lanname | lanispl | lanpltrusted | lanplcallfoid | lancompiler +----------+---------+--------------+---------------+------------- + internal | f | f | 0 | n/a + C | f | f | 0 | /bin/cc + sql | f | f | 0 | postgres + + diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml index dbfdc5261a..aa25b0746d 100644 --- a/doc/src/sgml/ref/create_view.sgml +++ b/doc/src/sgml/ref/create_view.sgml @@ -1,5 +1,5 @@ @@ -160,10 +160,11 @@ CREATE VIEW kinds AS SELECT * FROM kinds; -code |title |did| date_prod|kind |len ------+-------------------------+---+----------+----------+------ -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 + code | title | did | date_prod | kind | len +-------+---------------------------+-----+------------+--------+------- + 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 +(2 rows) diff --git a/doc/src/sgml/ref/delete.sgml b/doc/src/sgml/ref/delete.sgml index c27a4b9a01..f53b87280d 100644 --- a/doc/src/sgml/ref/delete.sgml +++ b/doc/src/sgml/ref/delete.sgml @@ -1,5 +1,5 @@ @@ -131,33 +131,33 @@ DELETE count Remove all films but musicals: - + DELETE FROM films WHERE kind <> 'Musical'; SELECT * FROM films; - -code |title |did| date_prod|kind |len ------+-------------------------+---+----------+----------+------ -UA501|West Side Story |105|1961-01-03|Musical | 02:32 -TC901|The King and I |109|1956-08-11|Musical | 02:13 -WD101|Bed Knobs and Broomsticks|111| |Musical | 01:57 + + code | title | did | date_prod | kind | len +-------+---------------------------+-----+------------+---------+------- + UA501 | West Side Story | 105 | 1961-01-03 | Musical | 02:32 + TC901 | The King and I | 109 | 1956-08-11 | Musical | 02:13 + WD101 | Bed Knobs and Broomsticks | 111 | | Musical | 01:57 (3 rows) - - + + Clear the table films: - + DELETE FROM films; SELECT * FROM films; - -code|title|did|date_prod|kind|len -----+-----+---+---------+----+--- + + code | title | did | date_prod | kind | len +------+-------+-----+-----------+------+----- (0 rows) - - + + diff --git a/doc/src/sgml/ref/fetch.sgml b/doc/src/sgml/ref/fetch.sgml index db072d9f5f..1fa025361e 100644 --- a/doc/src/sgml/ref/fetch.sgml +++ b/doc/src/sgml/ref/fetch.sgml @@ -1,5 +1,5 @@ @@ -299,42 +299,39 @@ FETCH RELATIVE 0 FROM cursor The following examples traverses a table using a cursor. - - --set up and use a cursor: - -- - BEGIN WORK; - DECLARE liahona CURSOR - FOR SELECT * FROM films; + +-- set up and use a cursor: - --Fetch first 5 rows in the cursor liahona: - -- - FETCH FORWARD 5 IN liahona; +BEGIN WORK; +DECLARE liahona CURSOR FOR SELECT * FROM films; - - code |title |did| date_prod|kind |len - -----+-----------------------+---+----------+----------+------ - BL101|The Third Man |101|1949-12-23|Drama | 01:44 - BL102|The African Queen |101|1951-08-11|Romantic | 01:43 - JL201|Une Femme est une Femme|102|1961-03-12|Romantic | 01:25 - P_301|Vertigo |103|1958-11-14|Action | 02:08 - P_302|Becket |103|1964-02-03|Drama | 02:28 - +-- Fetch first 5 rows in the cursor liahona: +FETCH FORWARD 5 IN liahona; - --Fetch previous row: - -- - FETCH BACKWARD 1 IN liahona; + + code | title | did | date_prod | kind | len +-------+-------------------------+-----+------------+----------+------- + BL101 | The Third Man | 101 | 1949-12-23 | Drama | 01:44 + BL102 | The African Queen | 101 | 1951-08-11 | Romantic | 01:43 + JL201 | Une Femme est une Femme | 102 | 1961-03-12 | Romantic | 01:25 + P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08 + P_302 | Becket | 103 | 1964-02-03 | Drama | 02:28 + - - code |title |did| date_prod|kind |len - -----+-----------------------+---+----------+----------+------ - P_301|Vertigo |103|1958-11-14|Action | 02:08 - +-- Fetch previous row: +FETCH BACKWARD 1 IN liahona; - -- close the cursor and commit work: - -- - CLOSE liahona; - COMMIT WORK; - + + code | title | did | date_prod | kind | len +-------+---------+-----+------------+--------+------- + P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08 + + +-- close the cursor and commit work: + +CLOSE liahona; +COMMIT WORK; + diff --git a/doc/src/sgml/ref/initlocation.sgml b/doc/src/sgml/ref/initlocation.sgml index 2a12349866..e5228e8138 100644 --- a/doc/src/sgml/ref/initlocation.sgml +++ b/doc/src/sgml/ref/initlocation.sgml @@ -1,5 +1,5 @@ @@ -96,7 +96,7 @@ initlocation directory $ export PGDATA2=/opt/postgres/data $ initlocation PGDATA2 -$ createdb 'testdb' -D 'PGDATA2/testdb' +$ createdb 'testdb' -D 'PGDATA2' @@ -104,7 +104,7 @@ $ createdb 'testdb' -D 'PGDATA2/testdb' Alternatively, if you allow absolute paths you could write: $ initlocation /opt/postgres/data -$ createdb 'testdb' -D '/opt/postgres/data/testdb' +$ createdb testdb -D '/opt/postgres/data/testdb' diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml index b03ea67808..4908ab44ab 100644 --- a/doc/src/sgml/ref/listen.sgml +++ b/doc/src/sgml/ref/listen.sgml @@ -1,5 +1,5 @@ @@ -166,12 +166,12 @@ NOTICE Async_Listen: We are already listening on Configure and execute a listen/notify sequence from psql: - + LISTEN virtual; NOTIFY virtual; -ASYNC NOTIFY of 'virtual' from backend pid '11239' received - +Asynchronous NOTIFY 'virtual' from backend with pid '8448' received. + diff --git a/doc/src/sgml/ref/move.sgml b/doc/src/sgml/ref/move.sgml index eeb74bd9aa..8e6a3b014d 100644 --- a/doc/src/sgml/ref/move.sgml +++ b/doc/src/sgml/ref/move.sgml @@ -1,5 +1,5 @@ @@ -86,28 +86,28 @@ MOVE [ selector ] [ Set up and use a cursor: - + BEGIN WORK; DECLARE liahona CURSOR FOR SELECT * FROM films; ---Skip first 5 rows: +-- Skip first 5 rows: MOVE FORWARD 5 IN liahona; MOVE ---Fetch 6th row in the cursor liahona: +-- Fetch 6th row in the cursor liahona: FETCH 1 IN liahona; FETCH - code |title |did| date_prod|kind |len - -----+------+---+----------+----------+------ - P_303|48 Hrs|103|1982-10-22|Action | 01:37 - (1 row) + code | title | did | date_prod | kind | len +-------+--------+-----+-----------+--------+------- + P_303 | 48 Hrs | 103 | 1982-10-22| Action | 01:37 +(1 row) -- close the cursor liahona and commit work: CLOSE liahona; COMMIT WORK; - + diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml index 91dc5f4a10..eb50698574 100644 --- a/doc/src/sgml/ref/notify.sgml +++ b/doc/src/sgml/ref/notify.sgml @@ -1,5 +1,5 @@ @@ -208,11 +208,11 @@ NOTIFY Configure and execute a listen/notify sequence from psql: - -LISTEN virtual; -NOTIFY virtual; -ASYNC NOTIFY of 'virtual' from backend pid '11239' received - + +=> LISTEN virtual; +=> NOTIFY virtual; +Asynchronous NOTIFY 'virtual' from backend with pid '8448' received. + diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index c88d9b54f9..2aa6b8369b 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -1,5 +1,5 @@ @@ -609,43 +609,45 @@ SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM distributors d, films f WHERE f.did = d.did -title |did|name | date_prod|kind --------------------------+---+----------------+----------+---------- -The Third Man |101|British Lion |1949-12-23|Drama -The African Queen |101|British Lion |1951-08-11|Romantic -Une Femme est une Femme |102|Jean Luc Godard |1961-03-12|Romantic -Vertigo |103|Paramount |1958-11-14|Action -Becket |103|Paramount |1964-02-03|Drama -48 Hrs |103|Paramount |1982-10-22|Action -War and Peace |104|Mosfilm |1967-02-12|Drama -West Side Story |105|United Artists |1961-01-03|Musical -Bananas |105|United Artists |1971-07-13|Comedy -Yojimbo |106|Toho |1961-06-16|Drama -There's a Girl in my Soup|107|Columbia |1970-06-11|Comedy -Taxi Driver |107|Columbia |1975-05-15|Action -Absence of Malice |107|Columbia |1981-11-15|Action -Storia di una donna |108|Westward |1970-08-15|Romantic -The King and I |109|20th Century Fox|1956-08-11|Musical -Das Boot |110|Bavaria Atelier |1981-11-11|Drama -Bed Knobs and Broomsticks|111|Walt Disney | |Musical - + title | did | name | date_prod | kind +---------------------------+-----+------------------+------------+---------- + The Third Man | 101 | British Lion | 1949-12-23 | Drama + The African Queen | 101 | British Lion | 1951-08-11 | Romantic + Une Femme est une Femme | 102 | Jean Luc Godard | 1961-03-12 | Romantic + Vertigo | 103 | Paramount | 1958-11-14 | Action + Becket | 103 | Paramount | 1964-02-03 | Drama + 48 Hrs | 103 | Paramount | 1982-10-22 | Action + War and Peace | 104 | Mosfilm | 1967-02-12 | Drama + West Side Story | 105 | United Artists | 1961-01-03 | Musical + Bananas | 105 | United Artists | 1971-07-13 | Comedy + Yojimbo | 106 | Toho | 1961-06-16 | Drama + There's a Girl in my Soup | 107 | Columbia | 1970-06-11 | Comedy + Taxi Driver | 107 | Columbia | 1975-05-15 | Action + Absence of Malice | 107 | Columbia | 1981-11-15 | Action + Storia di una donna | 108 | Westward | 1970-08-15 | Romantic + The King and I | 109 | 20th Century Fox | 1956-08-11 | Musical + Das Boot | 110 | Bavaria Atelier | 1981-11-11 | Drama + Bed Knobs and Broomsticks | 111 | Walt Disney | | Musical +(17 rows) + To sum the column len of all films and group the results by kind: - + SELECT kind, SUM(len) AS total FROM films GROUP BY kind; - kind |total - ----------+------ - Action | 07:34 - Comedy | 02:58 - Drama | 14:28 - Musical | 06:42 - Romantic | 04:38 - + kind | total +----------+------- + Action | 07:34 + Comedy | 02:58 + Drama | 14:28 + Musical | 06:42 + Romantic | 04:38 +(5 rows) + @@ -653,17 +655,18 @@ SELECT kind, SUM(len) AS total FROM films GROUP BY kind; the results by kind and show those group totals that are less than 5 hours: - + SELECT kind, SUM(len) AS total FROM films GROUP BY kind HAVING SUM(len) < INTERVAL '5 hour'; - kind |total - ----------+------ - Comedy | 02:58 - Romantic | 04:38 - + kind | total +----------+------- + Comedy | 02:58 + Romantic | 04:38 +(2 rows) + @@ -675,22 +678,23 @@ SELECT kind, SUM(len) AS total SELECT * FROM distributors ORDER BY name; SELECT * FROM distributors ORDER BY 2; - did|name - ---+---------------- - 109|20th Century Fox - 110|Bavaria Atelier - 101|British Lion - 107|Columbia - 102|Jean Luc Godard - 113|Luso films - 104|Mosfilm - 103|Paramount - 106|Toho - 105|United Artists - 111|Walt Disney - 112|Warner Bros. - 108|Westward - + did | name +-----+------------------ + 109 | 20th Century Fox + 110 | Bavaria Atelier + 101 | British Lion + 107 | Columbia + 102 | Jean Luc Godard + 113 | Luso films + 104 | Mosfilm + 103 | Paramount + 106 | Toho + 105 | United Artists + 111 | Walt Disney + 112 | Warner Bros. + 108 | Westward +(13 rows) + @@ -700,14 +704,14 @@ SELECT * FROM distributors ORDER BY 2; with letter W in each table. Only distinct rows are wanted, so the ALL keyword is omitted: - - -- distributors: actors: - -- did|name id|name - -- ---+------------ --+-------------- - -- 108|Westward 1|Woody Allen - -- 111|Walt Disney 2|Warren Beatty - -- 112|Warner Bros. 3|Walter Matthau - -- ... ... + +distributors: actors: + did | name id | name +-----+-------------- ----+---------------- + 108 | Westward 1 | Woody Allen + 111 | Walt Disney 2 | Warren Beatty + 112 | Warner Bros. 3 | Walter Matthau + ... ... SELECT distributors.name FROM distributors @@ -717,15 +721,15 @@ SELECT actors.name FROM actors WHERE actors.name LIKE 'W%' -name --------------- -Walt Disney -Walter Matthau -Warner Bros. -Warren Beatty -Westward -Woody Allen - + name +---------------- + Walt Disney + Walter Matthau + Warner Bros. + Warren Beatty + Westward + Woody Allen + @@ -749,9 +753,9 @@ was retained from the original PostQuel query language: SELECT distributors.* WHERE name = 'Westwood'; - did|name - ---+---------------- - 108|Westward + did | name +-----+---------- + 108 | Westward diff --git a/doc/src/sgml/ref/set.sgml b/doc/src/sgml/ref/set.sgml index cd6265eed6..b02440ecf5 100644 --- a/doc/src/sgml/ref/set.sgml +++ b/doc/src/sgml/ref/set.sgml @@ -1,5 +1,5 @@ @@ -905,25 +905,25 @@ SET GEQO = DEFAULT; Set the timezone for Berkeley, California: - + SET TIME ZONE 'PST8PDT'; SELECT CURRENT_TIMESTAMP AS today; - today - ---------------------- - 1998-03-31 07:41:21-08 - + today +------------------------ + 1998-03-31 07:41:21-08 + - Set the timezone for Italy: +Set the timezone for Italy: - + SET TIME ZONE 'Europe/Rome'; SELECT CURRENT_TIMESTAMP AS today; - today - ---------------------- - 1998-03-31 17:41:31+02 - + today +------------------------ + 1998-03-31 17:41:31+02 + diff --git a/doc/src/sgml/ref/unlisten.sgml b/doc/src/sgml/ref/unlisten.sgml index d872dd98a0..76bd4f805a 100644 --- a/doc/src/sgml/ref/unlisten.sgml +++ b/doc/src/sgml/ref/unlisten.sgml @@ -1,5 +1,5 @@ @@ -142,26 +142,26 @@ UNLISTEN { notifyname | * } To subscribe to an existing registration: - + postgres=> LISTEN virtual; LISTEN postgres=> NOTIFY virtual; NOTIFY -ASYNC NOTIFY of 'virtual' from backend pid '12317' received - +Asynchronous NOTIFY 'virtual' from backend with pid '8448' received + Once UNLISTEN has been executed, further NOTIFY commands will be ignored: - + postgres=> UNLISTEN virtual; UNLISTEN postgres=> NOTIFY virtual; NOTIFY -- notice no NOTIFY event is received - + diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml index 7c33e31e37..8f4858de3b 100644 --- a/doc/src/sgml/ref/update.sgml +++ b/doc/src/sgml/ref/update.sgml @@ -1,5 +1,5 @@ @@ -150,20 +150,18 @@ UPDATE # Change word "Drama" with "Dramatic" on column kind: - -UPDATE films - SET kind = 'Dramatic' - WHERE kind = 'Drama'; + +UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama'; SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama'; - code |title |did| date_prod|kind |len - -----+-------------+---+----------+----------+------ - BL101|The Third Man|101|1949-12-23|Dramatic | 01:44 - P_302|Becket |103|1964-02-03|Dramatic | 02:28 - M_401|War and Peace|104|1967-02-12|Dramatic | 05:57 - T_601|Yojimbo |106|1961-06-16|Dramatic | 01:50 - DA101|Das Boot |110|1981-11-11|Dramatic | 02:29 - + code | title | did | date_prod | kind | len +-------+---------------+-----+------------+----------+------- + BL101 | The Third Man | 101 | 1949-12-23 | Dramatic | 01:44 + P_302 | Becket | 103 | 1964-02-03 | Dramatic | 02:28 + M_401 | War and Peace | 104 | 1967-02-12 | Dramatic | 05:57 + T_601 | Yojimbo | 106 | 1961-06-16 | Dramatic | 01:50 + DA101 | Das Boot | 110 | 1981-11-11 | Dramatic | 02:29 + diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml index 12388f4339..eda42522cc 100644 --- a/doc/src/sgml/typeconv.sgml +++ b/doc/src/sgml/typeconv.sgml @@ -52,9 +52,9 @@ to start the parser down the correct path. For example, the query tgl=> SELECT text 'Origin' AS "Label", point '(0,0)' AS "Value"; -Label |Value -------+----- -Origin|(0,0) + Label | Value +--------+------- + Origin | (0,0) (1 row) @@ -295,9 +295,9 @@ The scanner assigns an initial type of int4 to both arguments of this query expression: tgl=> select 2 ^ 3 AS "Exp"; -Exp ---- - 8 + Exp +----- + 8 (1 row) @@ -306,9 +306,9 @@ is equivalent to tgl=> select float8(2) ^ float8(3) AS "Exp"; -Exp ---- - 8 + Exp +----- + 8 (1 row) @@ -316,9 +316,9 @@ or tgl=> select 2.0 ^ 3.0 AS "Exp"; -Exp ---- - 8 + Exp +----- + 8 (1 row) @@ -345,9 +345,9 @@ Strings with unspecified type are matched with likely operator candidates. One unspecified argument: tgl=> SELECT text 'abc' || 'def' AS "Text and Unknown"; -Text and Unknown ----------------- -abcdef + Text and Unknown +------------------ + abcdef (1 row) @@ -362,9 +362,9 @@ be interpreted as of type text. Concatenation on unspecified types: tgl=> SELECT 'abc' || 'def' AS "Unspecified"; -Unspecified ------------ -abcdef + Unspecified +------------- + abcdef (1 row) @@ -398,9 +398,9 @@ factorial. tgl=> select (4.3 !); -?column? --------- - 24 + ?column? +---------- + 24 (1 row) @@ -481,18 +481,18 @@ to int4: tgl=> select int4fac(int2 '4'); -int4fac -------- - 24 + int4fac +--------- + 24 (1 row) and is actually transformed by the parser to tgl=> select int4fac(int4(int2 '4')); -int4fac -------- - 24 + int4fac +--------- + 24 (1 row) @@ -511,9 +511,9 @@ If called with a string constant of unspecified type, the type is matched up directly with the only candidate function type: tgl=> select substr('1234', 3); -substr ------- - 34 + substr +-------- + 34 (1 row) @@ -523,17 +523,17 @@ If the string is declared to be of type varchar, as might be the ca if it comes from a table, then the parser will try to coerce it to become text: tgl=> select substr(varchar '1234', 3); -substr ------- - 34 + substr +-------- + 34 (1 row) which is transformed by the parser to become tgl=> select substr(text(varchar '1234'), 3); -substr ------- - 34 + substr +-------- + 34 (1 row) @@ -551,17 +551,17 @@ And, if the function is called with an int4, the parser will try to convert that to text: tgl=> select substr(1234, 3); -substr ------- - 34 + substr +-------- + 34 (1 row) actually executes as tgl=> select substr(text(1234), 3); -substr ------- - 34 + substr +-------- + 34 (1 row) @@ -609,11 +609,11 @@ tgl=> CREATE TABLE vv (v varchar(4)); CREATE tgl=> INSERT INTO vv SELECT 'abc' || 'def'; INSERT 392905 1 -tgl=> select * from vv; -v ----- -abcd -(1 row) +tgl=> SELECT * FROM vv; + v +------ + abcd +(1 row) @@ -651,10 +651,10 @@ first SELECT clause or the target column. tgl=> SELECT text 'a' AS "Text" UNION SELECT 'b'; -Text ----- -a -b + Text +------ + a + b (2 rows) @@ -665,11 +665,11 @@ b -tgl=> SELECT 1.2 AS Float8 UNION SELECT 1; -Float8 ------- - 1 - 1.2 +tgl=> SELECT 1.2 AS "Float8" UNION SELECT 1; + Float8 +-------- + 1 + 1.2 (2 rows) @@ -686,11 +686,11 @@ the first/top clause in the union: tgl=> SELECT 1 AS "All integers" tgl-> UNION SELECT '2.2'::float4 tgl-> UNION SELECT 3.3; -All integers ------------- - 1 - 2 - 3 + All integers +-------------- + 1 + 2 + 3 (3 rows) @@ -710,10 +710,10 @@ tgl-> UNION SELECT 3.3; INSERT 0 3 tgl=> SELECT f AS "Floating point" from ff; Floating point ----------------- - 1 -2.20000004768372 - 3.3 +------------------ + 1 + 2.20000004768372 + 3.3 (3 rows) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 5cda0f0791..d4e88ec2dd 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -8,7 +8,7 @@ * * * 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 *loc; + char locbuf[512]; int4 user_id; bool use_super, use_createdb; Relation pg_database_rel; @@ -70,23 +71,25 @@ createdb(const char *dbname, const char *dbpath, int encoding) char new_record_nulls[Natts_pg_database] = { ' ', ' ', ' ', ' ' }; 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) - elog(ERROR, "CREATE DATABASE: Permission denied"); + elog(ERROR, "CREATE DATABASE: permission denied"); 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 */ 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 */ - if (dbpath == NULL) - dbpath = dbname; + if (dbpath == NULL || strcmp(dbpath, dbname)==0) + strcpy(locbuf, dbname); + else + snprintf(locbuf, sizeof(locbuf), "%s/%s", dbpath, dbname); - loc = ExpandDatabasePath(dbpath); + loc = ExpandDatabasePath(locbuf); if (loc == NULL) elog(ERROR, @@ -105,10 +108,10 @@ createdb(const char *dbname, const char *dbpath, int encoding) pg_database_dsc = RelationGetDescr(pg_database_rel); /* 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_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); @@ -137,7 +140,7 @@ createdb(const char *dbname, const char *dbpath, int encoding) /* Copy the template database to the new location */ 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'", @@ -147,7 +150,7 @@ createdb(const char *dbname, const char *dbpath, int encoding) snprintf(buf, sizeof(buf), "rm -rf '%s'", loc); ret = system(buf); if (ret == 0) - elog(ERROR, "CREATE DATABASE: Could not initialize database directory"); + elog(ERROR, "CREATE DATABASE: could not initialize database directory"); else elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well"); } diff --git a/src/bin/initlocation/initlocation.sh b/src/bin/initlocation/initlocation.sh index e9ccf43fa9..d2f7778347 100644 --- a/src/bin/initlocation/initlocation.sh +++ b/src/bin/initlocation/initlocation.sh @@ -8,7 +8,7 @@ # # # 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. if [ "$haveenv" = "t" ]; then echo "You can now create a database using" - echo " CREATE DATABASE WITH LOCATION = '$Location/'" + echo " CREATE DATABASE WITH LOCATION = '$Location'" echo "in SQL, or" - echo " createdb -D '$Location/'" + echo " createdb -D '$Location'" echo "from the shell." fi echo