Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7815ca7

Browse files
author
Neil Conway
committed
Rewrite much of psql's \connect code, for the sake of code clarity and
to fix regressions introduced in the recent patch adding additional \connect options. This is based on work by Volkan YAZICI, although this version of the patch doesn't bear much resemblance to Volkan's version. \connect takes 4 optional arguments: database name, user name, host name, and port number. If any of those parameters are omitted or specified as "-", the value of that parameter from the previous connection is used instead; if there is no previous connection, the libpq default is used. Note that this behavior makes it impossible to reuse the libpq defaults without quitting psql and restarting it; I don't really see the use case for needing to do that.
1 parent 23a1f01 commit 7815ca7

File tree

2 files changed

+223
-244
lines changed

2 files changed

+223
-244
lines changed

doc/src/sgml/ref/psql-ref.sgml

+35-42
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.160 2006/02/13 21:29:08 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.161 2006/04/02 20:08:20 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -712,34 +712,28 @@ testdb=&gt;
712712
<term><literal>\connect</literal> (or <literal>\c</literal>) <literal>[ <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">host</replaceable> ] [ <replaceable class="parameter">port</replaceable> ] ]</literal></term>
713713
<listitem>
714714
<para>
715-
Establishes a connection to a new database and/or under a user
716-
name. The previous connection is closed. If <replaceable
717-
class="parameter">dbname</replaceable> is <literal>-</literal>
718-
the current database name is assumed. Similar consideration
719-
applies to <replaceable class="parameter">host</replaceable> and
720-
<replaceable class="parameter">port</replaceable>.
721-
</para>
722-
723-
<para>
724-
If <replaceable class="parameter">username</replaceable> is
725-
omitted the current user name is assumed. </para>
726-
727-
<para>
728-
As a special rule, <command>\connect</command> without any
729-
arguments will connect to the default database as the default
730-
user (as you would have gotten by starting
731-
<application>psql</application> without any arguments).
715+
Establishes a new connection to a <productname>PostgreSQL</>
716+
server. If the new connection is successfully made, the
717+
previous connection is closed. If any of <replaceable
718+
class="parameter">dbname</replaceable>, <replaceable
719+
class="parameter">username</replaceable>, <replaceable
720+
class="parameter">host</replaceable> or <replaceable
721+
class="parameter">port</replaceable> are omitted or specified
722+
as <literal>-</literal>, the value of that parameter from the
723+
previous connection is used. If there is no previous
724+
connection, the <application>libpq</application> default for
725+
the parameter's value is used.
732726
</para>
733727

734728
<para>
735729
If the connection attempt failed (wrong user name, access
736-
denied, etc.), the previous connection will be kept if and only
737-
if <application>psql</application> is in interactive mode. When
738-
executing a non-interactive script, processing will immediately
739-
stop with an error. This distinction was chosen as a user
740-
convenience against typos on the one hand, and a safety
741-
mechanism that scripts are not accidentally acting on the wrong
742-
database on the other hand.
730+
denied, etc.), the previous connection will only be kept if
731+
<application>psql</application> is in interactive mode. When
732+
executing a non-interactive script, processing will
733+
immediately stop with an error. This distinction was chosen as
734+
a user convenience against typos on the one hand, and a safety
735+
mechanism that scripts are not accidentally acting on the
736+
wrong database on the other hand.
743737
</para>
744738
</listitem>
745739
</varlistentry>
@@ -997,15 +991,16 @@ testdb=&gt;
997991
<listitem>
998992
<para>
999993
This is not the actual command name: the letters
1000-
<literal>i</literal>, <literal>s</literal>, <literal>t</literal>,
1001-
<literal>v</literal>, <literal>S</literal> stand for index,
1002-
sequence, table, view, and system table, respectively. You can
1003-
specify any or all of these letters, in any order, to obtain a
1004-
listing of all the matching objects. The letter S restricts the
1005-
listing to system objects; without <literal>S</literal>, only
1006-
non-system objects are shown. If <literal>+</literal> is appended
1007-
to the command name, each object is listed with its associated
1008-
description, if any.
994+
<literal>i</literal>, <literal>s</literal>,
995+
<literal>t</literal>, <literal>v</literal>,
996+
<literal>S</literal> stand for index, sequence, table, view,
997+
and system table, respectively. You can specify any or all of
998+
these letters, in any order, to obtain a listing of all the
999+
matching objects. The letter <literal>S</literal> restricts
1000+
the listing to system objects; without <literal>S</literal>,
1001+
only non-system objects are shown. If <literal>+</literal> is
1002+
appended to the command name, each object is listed with its
1003+
associated description, if any.
10091004
</para>
10101005

10111006
<para>
@@ -1067,10 +1062,9 @@ testdb=&gt;
10671062
</para>
10681063

10691064
<para>
1070-
The commands <command>GRANT</command> and
1071-
<command>REVOKE</command> are used to set access privileges.
1072-
See <xref linkend="sql-grant" endterm="sql-grant-title">
1073-
for more information.
1065+
The <xref linkend="sql-grant" endterm="sql-grant-title"> and
1066+
<xref linkend="sql-revoke" endterm="sql-revoke-title">
1067+
commands are used to set access privileges.
10741068
</para>
10751069
</listitem>
10761070
</varlistentry>
@@ -1785,10 +1779,9 @@ lo_import 152801
17851779
</para>
17861780

17871781
<para>
1788-
The commands <command>GRANT</command> and
1789-
<command>REVOKE</command> are used to set access privileges.
1790-
See <xref linkend="sql-grant" endterm="sql-grant-title"> for
1791-
more information.
1782+
The <xref linkend="sql-grant" endterm="sql-grant-title"> and
1783+
<xref linkend="sql-revoke" endterm="sql-revoke-title">
1784+
commands are used to set access privileges.
17921785
</para>
17931786

17941787
<para>

0 commit comments

Comments
 (0)