proposal: new long psql parameter --on-error-stop

Started by Pavel Stehulealmost 12 years ago26 messages
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

for beginners is relative difficult to set psql variable from command line
and option

-v ON_ERROR_STOP=1 is little bit unclean.

and for any user it is not comfortable. So I propose a new psql option

--on-error-stop

It is clean, and it will be mentioned in psql --help.

Comments, ideas?

Regards

Pavel

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Stehule (#1)
Re: proposal: new long psql parameter --on-error-stop

Pavel Stehule <pavel.stehule@gmail.com> writes:

for beginners is relative difficult to set psql variable from command line
and option
-v ON_ERROR_STOP=1 is little bit unclean.
and for any user it is not comfortable. So I propose a new psql option
--on-error-stop

That saves a whole three characters ... not sure it's really worth it,
especially since it will not work on older versions.

Also, it's not like this will save people from having to know about the
ON_ERROR_STOP variable, because there will still be plenty of contexts
where they need to know that (eg, inspecting the setting or changing it
mid-session). So I don't buy the argument that this simplifies what
beginners need to learn.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#2)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 19:13 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Pavel Stehule <pavel.stehule@gmail.com> writes:

for beginners is relative difficult to set psql variable from command

line

and option
-v ON_ERROR_STOP=1 is little bit unclean.
and for any user it is not comfortable. So I propose a new psql option
--on-error-stop

That saves a whole three characters ... not sure it's really worth it,
especially since it will not work on older versions.

Also, it's not like this will save people from having to know about the
ON_ERROR_STOP variable, because there will still be plenty of contexts
where they need to know that (eg, inspecting the setting or changing it
mid-session). So I don't buy the argument that this simplifies what
beginners need to learn.

three chars is not important

important is a placing in --help output

Regards

Pavel

Show quoted text

regards, tom lane

#4Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Pavel Stehule (#3)
Re: proposal: new long psql parameter --on-error-stop

On Fri, Feb 28, 2014 at 3:17 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

2014-02-28 19:13 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Pavel Stehule <pavel.stehule@gmail.com> writes:

for beginners is relative difficult to set psql variable from command

line

and option
-v ON_ERROR_STOP=1 is little bit unclean.
and for any user it is not comfortable. So I propose a new psql option
--on-error-stop

That saves a whole three characters ... not sure it's really worth it,
especially since it will not work on older versions.

Also, it's not like this will save people from having to know about the
ON_ERROR_STOP variable, because there will still be plenty of contexts
where they need to know that (eg, inspecting the setting or changing it
mid-session). So I don't buy the argument that this simplifies what
beginners need to learn.

three chars is not important

important is a placing in --help output

Well, then we just have to add more info to --help

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#5Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabrízio de Royes Mello (#4)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 19:25 GMT+01:00 Fabrízio de Royes Mello <fabriziomello@gmail.com>
:

On Fri, Feb 28, 2014 at 3:17 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

2014-02-28 19:13 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Pavel Stehule <pavel.stehule@gmail.com> writes:

for beginners is relative difficult to set psql variable from command

line

and option
-v ON_ERROR_STOP=1 is little bit unclean.
and for any user it is not comfortable. So I propose a new psql option
--on-error-stop

That saves a whole three characters ... not sure it's really worth it,
especially since it will not work on older versions.

Also, it's not like this will save people from having to know about the
ON_ERROR_STOP variable, because there will still be plenty of contexts
where they need to know that (eg, inspecting the setting or changing it
mid-session). So I don't buy the argument that this simplifies what
beginners need to learn.

three chars is not important

important is a placing in --help output

Well, then we just have to add more info to --help

it can be solution

Pavel

Show quoted text

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Fabrízio de Royes Mello (#4)
Re: proposal: new long psql parameter --on-error-stop

Fabr�zio de Royes Mello escribi�:

On Fri, Feb 28, 2014 at 3:17 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

important is a placing in --help output

Well, then we just have to add more info to --help

I think psql could do with some lines for the possible options for
--pset (14) and --variable (13). Not sure how to do that without having
it become too cumbersome while not hiding useful variables.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Alvaro Herrera (#6)
Re: proposal: new long psql parameter --on-error-stop

On Fri, Feb 28, 2014 at 3:44 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:

Fabrízio de Royes Mello escribió:

On Fri, Feb 28, 2014 at 3:17 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

important is a placing in --help output

Well, then we just have to add more info to --help

I think psql could do with some lines for the possible options for
--pset (14) and --variable (13). Not sure how to do that without having
it become too cumbersome while not hiding useful variables.

Maybe by adding something like "--help-pset" and "--help-variables".

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#8Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabrízio de Royes Mello (#7)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 19:55 GMT+01:00 Fabrízio de Royes Mello <fabriziomello@gmail.com>
:

On Fri, Feb 28, 2014 at 3:44 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:

Fabrízio de Royes Mello escribió:

On Fri, Feb 28, 2014 at 3:17 PM, Pavel Stehule <

pavel.stehule@gmail.com>

wrote:

important is a placing in --help output

Well, then we just have to add more info to --help

I think psql could do with some lines for the possible options for
--pset (14) and --variable (13). Not sure how to do that without having
it become too cumbersome while not hiding useful variables.

Maybe by adding something like "--help-pset" and "--help-variables".

I dislike it - I afraid so I know too much users, where --help-pset or
--help-variables is too high expert level. --help is a maximum, what they
can do - and you should not use a strange terminology like "variables".

Regards

Pavel

Show quoted text

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#9Andrew Dunstan
andrew@dunslane.net
In reply to: Pavel Stehule (#5)
Re: proposal: new long psql parameter --on-error-stop

On 02/28/2014 01:27 PM, Pavel Stehule wrote:

three chars is not important

important is a placing in --help output

Well, then we just have to add more info to --help

it can be solution

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#9)
Re: proposal: new long psql parameter --on-error-stop

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings? I'm not sure that the main --help output is the place
for this, because that only covers psql's command line switches (and
is plenty long enough already).

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#11Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#10)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 22:38 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings? I'm not sure that the main --help output is the place
for this, because that only covers psql's command line switches (and
is plenty long enough already).

Hard to say -

a special long option in "General option" can be clean.

or new section "Tips"

Tips:
-v ON_ERROR_STOP=1 stops on first error

Show quoted text

regards, tom lane

#12Erik Rijkers
er@xs4all.nl
In reply to: Tom Lane (#10)
Re: proposal: new long psql parameter --on-error-stop

On Fri, February 28, 2014 22:38, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings? I'm not sure that the main --help output is the place
for this, because that only covers psql's command line switches (and
is plenty long enough already).

regards, tom lane

Perhaps this compromise:

-v, --set=, --variable=NAME=VALUE
set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1

this would not lengthen and not broaden the output of psql --help

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#13Pavel Stehule
pavel.stehule@gmail.com
In reply to: Erik Rijkers (#12)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 22:52 GMT+01:00 Erik Rijkers <er@xs4all.nl>:

On Fri, February 28, 2014 22:38, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings? I'm not sure that the main --help output is the place
for this, because that only covers psql's command line switches (and
is plenty long enough already).

regards, tom lane

Perhaps this compromise:

-v, --set=, --variable=NAME=VALUE
set psql variable NAME to VALUE e.g.: -v
ON_ERROR_STOP=1

can be

Show quoted text

this would not lengthen and not broaden the output of psql --help

#14Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#10)
Re: proposal: new long psql parameter --on-error-stop

On 02/28/2014 04:38 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings?

That's a pretty good idea, especially if we give that command a command
line option too, so something like

psql --special-variables

would run that command and exit.

Maybe I'm over-egging the pudding a bit ;-)

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#15Pavel Stehule
pavel.stehule@gmail.com
In reply to: Andrew Dunstan (#14)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 23:01 GMT+01:00 Andrew Dunstan <andrew@dunslane.net>:

On 02/28/2014 04:38 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings?

That's a pretty good idea, especially if we give that command a command
line option too, so something like

psql --special-variables

would run that command and exit.

it can be second one option.

Pavel

Show quoted text

Maybe I'm over-egging the pudding a bit ;-)

cheers

andrew

#16Pavel Stehule
pavel.stehule@gmail.com
In reply to: Erik Rijkers (#12)
Re: proposal: new long psql parameter --on-error-stop

2014-02-28 22:52 GMT+01:00 Erik Rijkers <er@xs4all.nl>:

e.g.: -v ON_ERROR_STOP=1

I checked it and it is not the most long line there, so it can be a good
solution.

Pavel

#17Pavel Stehule
pavel.stehule@gmail.com
In reply to: Andrew Dunstan (#14)
1 attachment(s)
Re: proposal: new long psql parameter --on-error-stop

Hello

here is a prototype:

bash-4.1$ /usr/local/pgsql/bin/psql --help-variables
List of some variables (options) for use from command line.
Complete list you find in psql section in the PostgreSQL documentation.

psql variables:
Usage:
psql --set=NAME=VALUE
or \set NAME VALUE in interactive mode

AUTOCOMMIT when is on, successful SQL command is automatically
commited
COMP_KEYWORD_CASE determines which letter case to use when completing an
SQL key word
ECHO all lines from input can be written to standard output
ECHO_HIDDEN display queries for internal commands (same as -E
option)
FETCH_COUNT how many rows should be for one page (default 0
unlimited)
HISTFILE file name that be used for store history list
HISTSIZE the number of commands to store in the command history
ON_ERROR_ROLLBACK when is on, raise ROLLBACK on error automatically
ON_ERROR_STOP when is set, then batch execution stop immediately
after error
VERBOSITY control verbosity of error reports [default, verbose,
terse]

Printing options:
Usage:
psql --pset=NAME[=VALUE]
or \pset NAME [VALUE] in interactive mode

border number of border style
fieldsep specify field separator for unaligned output
fieldsep_zero field separator in unaligned mode will be zero
format set output format [unaligned, aligned, wrapped, html,
latex, ..]
linestyle sets the border line drawing style [ascii, old-ascii,
unicode]
null sets the string to be printed in place of a null value
pager when the pager option is off, the pager program is not
used
recordsep specifies the record (line) separator to use in
unaligned output format
recordsep_zero record separator be in unaligned output format a zero
byte
title sets the table title for any subsequently printed
tables
tuples_only in tuples-only mode, only actual table data is shown

Environment options:
Usage:
NAME=VALUE, [NAME=VALUE] psql ...
or \setenv NAME [VALUE] in interactive mode

COLUMNS number of columns for wrapped format
PAGER used pager
PGHOST same as the host connection parameter
PGDATABASE same as the dbname connection parameter
PGUSER same as the user connection parameter
PGPASSWORD possibility to set password
PSQL_EDITOR, EDITOR, VISUAL editor used by \e \ef commands
PSQL_EDITOR_LINE_NUMBER_ARG style how to line number is used in editor
PSQL_HISTORY alternative location for the command history file
PSQL_RC alternative location of the user's .psqlrc file
SHELL command executed by the \! command
TMPDIR directory for storing temporary files

For more information consult the psql section in the PostgreSQL
documentation.

Regards

Pavel

2014-02-28 23:01 GMT+01:00 Andrew Dunstan <andrew@dunslane.net>:

Show quoted text

On 02/28/2014 04:38 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Well, then we just have to add more info to --help

+1 for at least doing that. I found it annoying just the other day not
to find it in plsql's --help output, in a moment of brain fade when I
forgot how to spell it. So it's not just beginners who can benefit, it's
people like me whose memory occasionally goes awry.

No objection in principle, but what are we talking about exactly?
Adding some new backslash command that lists all the variables that have
special meanings?

That's a pretty good idea, especially if we give that command a command
line option too, so something like

psql --special-variables

would run that command and exit.

Maybe I'm over-egging the pudding a bit ;-)

cheers

andrew

Attachments:

help-variables-prototype.patchtext/x-patch; charset=US-ASCII; name=help-variables-prototype.patchDownload
commit 82a6a61a11bdb76c00481abeccff42b4b532762e
Author: Pavel Stehule <pavel.stehule@gmail.com>
Date:   Sat Mar 1 09:34:47 2014 +0100

    initial

diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index baa9417..fb77132 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -78,12 +78,13 @@ usage(void)
 	printf(_("  -f, --file=FILENAME      execute commands from file, then exit\n"));
 	printf(_("  -l, --list               list available databases, then exit\n"));
 	printf(_("  -v, --set=, --variable=NAME=VALUE\n"
-			 "                           set psql variable NAME to VALUE\n"));
+			 "                           set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1\n"));
 	printf(_("  -V, --version            output version information, then exit\n"));
 	printf(_("  -X, --no-psqlrc          do not read startup file (~/.psqlrc)\n"));
 	printf(_("  -1 (\"one\"), --single-transaction\n"
 			 "                           execute as a single transaction (if non-interactive)\n"));
 	printf(_("  -?, --help               show this help, then exit\n"));
+	printf(_("      --help-variables     list of available configuration variables (options), then exit\n"));
 
 	printf(_("\nInput and output options:\n"));
 	printf(_("  -a, --echo-all           echo all input from script\n"));
@@ -279,6 +280,68 @@ slashUsage(unsigned short int pager)
 }
 
 
+/*
+ * show list of available variables (options) from command line
+ */
+void
+help_variables(void)
+{
+	printf(_("List of some variables (options) for use from command line.\n"));
+	printf(_("Complete list you find in psql section in the PostgreSQL documentation.\n\n"));
+
+	printf(_("psql variables:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --set=NAME=VALUE\n  or \\set NAME VALUE in interactive mode\n\n"));
+
+	printf(_("  AUTOCOMMIT         when is on, successful SQL command is automatically commited\n"));
+	printf(_("  COMP_KEYWORD_CASE  determines which letter case to use when completing an SQL key word\n"));
+	printf(_("  ECHO               all lines from input can be written to standard output\n"));
+	printf(_("  ECHO_HIDDEN        display queries for internal commands (same as -E option)\n"));
+	printf(_("  FETCH_COUNT        how many rows should be for one page (default 0 unlimited)\n"));
+	printf(_("  HISTFILE           file name that be used for store history list\n"));
+	printf(_("  HISTSIZE           the number of commands to store in the command history\n"));
+	printf(_("  ON_ERROR_ROLLBACK  when is on, raise ROLLBACK on error automatically\n"));
+	printf(_("  ON_ERROR_STOP      when is set, then batch execution stop immediately after error\n"));
+	printf(_("  VERBOSITY          control verbosity of error reports [default, verbose, terse]\n"));
+
+	printf(_("\nPrinting options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --pset=NAME[=VALUE]\n  or \\pset NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  border             number of border style\n"));
+	printf(_("  fieldsep           specify field separator for unaligned output\n"));
+	printf(_("  fieldsep_zero      field separator in unaligned mode will be zero\n"));
+	printf(_("  format             set output format [unaligned, aligned, wrapped, html, latex, ..]\n"));
+	printf(_("  linestyle          sets the border line drawing style [ascii, old-ascii, unicode]\n"));
+	printf(_("  null               sets the string to be printed in place of a null value\n"));
+	printf(_("  pager              when the pager option is off, the pager program is not used\n"));
+	printf(_("  recordsep          specifies the record (line) separator to use in unaligned output format\n"));
+	printf(_("  recordsep_zero     record separator be in unaligned output format a zero byte\n"));
+	printf(_("  title              sets the table title for any subsequently printed tables\n"));
+	printf(_("  tuples_only        in tuples-only mode, only actual table data is shown\n"));
+
+	printf(_("\nEnvironment options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  NAME=VALUE, [NAME=VALUE] psql ...\n  or \\setenv NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  COLUMNS            number of columns for wrapped format\n"));
+	printf(_("  PAGER              used pager\n"));
+	printf(_("  PGHOST             same as the host connection parameter\n"));
+	printf(_("  PGDATABASE         same as the dbname connection parameter\n"));
+	printf(_("  PGUSER             same as the user connection parameter\n"));
+	printf(_("  PGPASSWORD         possibility to set password\n"));
+	printf(_("  PSQL_EDITOR, EDITOR, VISUAL  editor used by \\e \\ef commands\n"));
+	printf(_("  PSQL_EDITOR_LINE_NUMBER_ARG  style how to line number is used in editor\n"));
+	printf(_("  PSQL_HISTORY       alternative location for the command history file\n"));
+	printf(_("  PSQL_RC            alternative location of the user's .psqlrc file\n"));
+	printf(_("  SHELL              command executed by the \\! command\n"));
+	printf(_("  TMPDIR             directory for storing temporary files\n"));
+
+	printf(_("\nFor more information consult the psql section in the PostgreSQL\n"
+			 "documentation.\n\n"));
+	printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
+}
+
 
 /*
  * helpSQL -- help with SQL commands
diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h
index 054d5a4..e7affff 100644
--- a/src/bin/psql/help.h
+++ b/src/bin/psql/help.h
@@ -12,6 +12,8 @@ void		usage(void);
 
 void		slashUsage(unsigned short int pager);
 
+void		help_variables(void);
+
 void		helpSQL(const char *topic, unsigned short int pager);
 
 void		print_copyright(void);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 1061992..22c1976 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -382,6 +382,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"expanded", no_argument, NULL, 'x'},
 		{"no-psqlrc", no_argument, NULL, 'X'},
 		{"help", no_argument, NULL, '?'},
+		{"help-variables", no_argument, 0},
 		{NULL, 0, NULL, 0}
 	};
 
@@ -390,7 +391,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 
 	memset(options, 0, sizeof *options);
 
-	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?01",
+	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?001",
 							long_options, &optindex)) != -1)
 	{
 		switch (c)
@@ -565,6 +566,13 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 					exit(EXIT_FAILURE);
 				}
 				break;
+			case 0:
+				if (strcmp(argv[optind - 1], "--help-variables") == 0)
+				{
+					help_variables();
+					exit(EXIT_SUCCESS);
+				}
+				break;
 			default:
 				fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
 						pset.progname);
#18Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Pavel Stehule (#17)
Re: proposal: new long psql parameter --on-error-stop

On Sat, Mar 1, 2014 at 5:37 AM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

Hello

here is a prototype:

bash-4.1$ /usr/local/pgsql/bin/psql --help-variables
List of some variables (options) for use from command line.
Complete list you find in psql section in the PostgreSQL documentation.

psql variables:
Usage:
psql --set=NAME=VALUE
or \set NAME VALUE in interactive mode

AUTOCOMMIT when is on, successful SQL command is automatically

commited

COMP_KEYWORD_CASE determines which letter case to use when completing

an SQL key word

ECHO all lines from input can be written to standard

output

ECHO_HIDDEN display queries for internal commands (same as -E

option)

FETCH_COUNT how many rows should be for one page (default 0

unlimited)

HISTFILE file name that be used for store history list
HISTSIZE the number of commands to store in the command

history

ON_ERROR_ROLLBACK when is on, raise ROLLBACK on error automatically
ON_ERROR_STOP when is set, then batch execution stop immediately

after error

VERBOSITY control verbosity of error reports [default,

verbose, terse]

Printing options:
Usage:
psql --pset=NAME[=VALUE]
or \pset NAME [VALUE] in interactive mode

border number of border style
fieldsep specify field separator for unaligned output
fieldsep_zero field separator in unaligned mode will be zero
format set output format [unaligned, aligned, wrapped,

html, latex, ..]

linestyle sets the border line drawing style [ascii,

old-ascii, unicode]

null sets the string to be printed in place of a null

value

pager when the pager option is off, the pager program is

not used

recordsep specifies the record (line) separator to use in

unaligned output format

recordsep_zero record separator be in unaligned output format a

zero byte

title sets the table title for any subsequently printed

tables

tuples_only in tuples-only mode, only actual table data is shown

Environment options:
Usage:
NAME=VALUE, [NAME=VALUE] psql ...
or \setenv NAME [VALUE] in interactive mode

COLUMNS number of columns for wrapped format
PAGER used pager
PGHOST same as the host connection parameter
PGDATABASE same as the dbname connection parameter
PGUSER same as the user connection parameter
PGPASSWORD possibility to set password
PSQL_EDITOR, EDITOR, VISUAL editor used by \e \ef commands
PSQL_EDITOR_LINE_NUMBER_ARG style how to line number is used in editor
PSQL_HISTORY alternative location for the command history file
PSQL_RC alternative location of the user's .psqlrc file
SHELL command executed by the \! command
TMPDIR directory for storing temporary files

For more information consult the psql section in the PostgreSQL
documentation.

The patch is ok (apply to master and apply to master without errors).

Maybe we must show the possible values for each variable/option too.

Thinking more about it, would be nice if we have the possibility to show
help for commands too. Some like that:

$ psql -H vacuum
Command: VACUUM
Description: garbage-collect and optionally analyze a database
Syntax:
VACUUM [ ( { FULL | FREEZE | VERBOSE | ANALYZE } [, ...] ) ] [ table_name [
(column_name [, ...] ) ] ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table_name ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ table_name [ (column_name
[, ...] ) ] ]

$ psql --help-command=vacuum
Command: VACUUM
Description: garbage-collect and optionally analyze a database
Syntax:
VACUUM [ ( { FULL | FREEZE | VERBOSE | ANALYZE } [, ...] ) ] [ table_name [
(column_name [, ...] ) ] ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table_name ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ table_name [ (column_name
[, ...] ) ] ]

It's only an idea that occurred to me reading this thread!

Grettings,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#19Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabrízio de Royes Mello (#18)
Re: proposal: new long psql parameter --on-error-stop

2014-03-01 23:53 GMT+01:00 Fabrízio de Royes Mello <fabriziomello@gmail.com>
:

On Sat, Mar 1, 2014 at 5:37 AM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

Hello

here is a prototype:

bash-4.1$ /usr/local/pgsql/bin/psql --help-variables
List of some variables (options) for use from command line.
Complete list you find in psql section in the PostgreSQL documentation.

psql variables:
Usage:
psql --set=NAME=VALUE
or \set NAME VALUE in interactive mode

AUTOCOMMIT when is on, successful SQL command is automatically

commited

COMP_KEYWORD_CASE determines which letter case to use when completing

an SQL key word

ECHO all lines from input can be written to standard

output

ECHO_HIDDEN display queries for internal commands (same as -E

option)

FETCH_COUNT how many rows should be for one page (default 0

unlimited)

HISTFILE file name that be used for store history list
HISTSIZE the number of commands to store in the command

history

ON_ERROR_ROLLBACK when is on, raise ROLLBACK on error automatically
ON_ERROR_STOP when is set, then batch execution stop immediately

after error

VERBOSITY control verbosity of error reports [default,

verbose, terse]

Printing options:
Usage:
psql --pset=NAME[=VALUE]
or \pset NAME [VALUE] in interactive mode

border number of border style
fieldsep specify field separator for unaligned output
fieldsep_zero field separator in unaligned mode will be zero
format set output format [unaligned, aligned, wrapped,

html, latex, ..]

linestyle sets the border line drawing style [ascii,

old-ascii, unicode]

null sets the string to be printed in place of a null

value

pager when the pager option is off, the pager program is

not used

recordsep specifies the record (line) separator to use in

unaligned output format

recordsep_zero record separator be in unaligned output format a

zero byte

title sets the table title for any subsequently printed

tables

tuples_only in tuples-only mode, only actual table data is shown

Environment options:
Usage:
NAME=VALUE, [NAME=VALUE] psql ...
or \setenv NAME [VALUE] in interactive mode

COLUMNS number of columns for wrapped format
PAGER used pager
PGHOST same as the host connection parameter
PGDATABASE same as the dbname connection parameter
PGUSER same as the user connection parameter
PGPASSWORD possibility to set password
PSQL_EDITOR, EDITOR, VISUAL editor used by \e \ef commands
PSQL_EDITOR_LINE_NUMBER_ARG style how to line number is used in editor
PSQL_HISTORY alternative location for the command history file
PSQL_RC alternative location of the user's .psqlrc file
SHELL command executed by the \! command
TMPDIR directory for storing temporary files

For more information consult the psql section in the PostgreSQL
documentation.

The patch is ok (apply to master and apply to master without errors).

Maybe we must show the possible values for each variable/option too.

Not all options are writeable - and too long option list should be less
readable - It should not to supply documentation

Thinking more about it, would be nice if we have the possibility to show
help for commands too. Some like that:

This can be implemented as alias probably, so it is not necessary - but I
agree, so it is interesting and valid idea

Regards

Pavel

Show quoted text

$ psql -H vacuum
Command: VACUUM
Description: garbage-collect and optionally analyze a database
Syntax:
VACUUM [ ( { FULL | FREEZE | VERBOSE | ANALYZE } [, ...] ) ] [ table_name
[ (column_name [, ...] ) ] ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table_name ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ table_name [ (column_name
[, ...] ) ] ]

$ psql --help-command=vacuum
Command: VACUUM
Description: garbage-collect and optionally analyze a database
Syntax:
VACUUM [ ( { FULL | FREEZE | VERBOSE | ANALYZE } [, ...] ) ] [ table_name
[ (column_name [, ...] ) ] ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table_name ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] ANALYZE [ table_name [ (column_name
[, ...] ) ] ]

It's only an idea that occurred to me reading this thread!

Grettings,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Timbira: http://www.timbira.com.br
Blog sobre TI: http://fabriziomello.blogspot.com
Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello

#20MauMau
maumau307@gmail.com
In reply to: Pavel Stehule (#17)
Re: proposal: new long psql parameter --on-error-stop

eFrom: "Pavel Stehule" <pavel.stehule@gmail.com>

here is a prototype:

The patch applied and built with success. There are a few minor things:

(1)
help_variables() lacks description of some variables such as SINGLELINE and
SINGLESTEP. I think this help should list all available variables, because
users may want to know the existence of those missing variables. Based on
this, modify these lines: remove "some" from the first line and the entire
second line.

+ printf(_("List of some variables (options) for use from command 
line.\n"));
+ printf(_("Complete list you find in psql section in the PostgreSQL 
documentation.\n\n"));

(2)
The indent is different from other lines. Leave just two spaces at the
beginning of the line.

+ printf(_(" --help-variables list of available configuration
variables (options), then exit\n"));

(3)
This change is unnecessary. See src/bin/pg_dumpall.c for similar switches.

- while ((c = getopt_long(argc, argv,
"aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?01",
or+ while ((c = getopt_long(argc, argv,
"aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?001",

Regards
MauMau

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#21Pavel Stehule
pavel.stehule@gmail.com
In reply to: MauMau (#20)
1 attachment(s)
Re: proposal: new long psql parameter --on-error-stop

Hello

2014-06-21 15:51 GMT+02:00 MauMau <maumau307@gmail.com>:

eFrom: "Pavel Stehule" <pavel.stehule@gmail.com>

here is a prototype:

The patch applied and built with success. There are a few minor things:

(1)
help_variables() lacks description of some variables such as SINGLELINE
and SINGLESTEP. I think this help should list all available variables,
because users may want to know the existence of those missing variables.
Based on this, modify these lines: remove "some" from the first line and
the entire second line.

+ printf(_("List of some variables (options) for use from command
line.\n"));
+ printf(_("Complete list you find in psql section in the PostgreSQL
documentation.\n\n"));

I fixed it

(2)
The indent is different from other lines. Leave just two spaces at the
beginning of the line.

+ printf(_(" --help-variables list of available configuration
variables (options), then exit\n"));

I am not sure in this point. It is aligned left with all long options:

-?, --help show this help, then exit
--help-variables list of available configuration variables
(options), then exit

Input and output options:
-a, --echo-all echo all input from script
-e, --echo-queries echo commands sent to server
-E, --echo-hidden display queries that internal commands generate

I am thinking so current implementation has sense.

(3)
This change is unnecessary. See src/bin/pg_dumpall.c for similar switches.

- while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:
sStT:U:v:VwWxXz?01",
or+ while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:
sStT:U:v:VwWxXz?001",

fixed

Regards
MauMau

updated patch is in attachment

Regards

Pavel

Attachments:

help-variables-01.patchtext/x-patch; charset=US-ASCII; name=help-variables-01.patchDownload
commit 826bd11fb4e9ac4b26cfe2e3702535f6b9527c12
Author: Pavel Stehule <pavel.stehule@gmail.com>
Date:   Sun Jun 22 00:08:24 2014 +0200

    initial

diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 3aa3c16..aa11808 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -78,12 +78,13 @@ usage(void)
 	printf(_("  -f, --file=FILENAME      execute commands from file, then exit\n"));
 	printf(_("  -l, --list               list available databases, then exit\n"));
 	printf(_("  -v, --set=, --variable=NAME=VALUE\n"
-			 "                           set psql variable NAME to VALUE\n"));
+			 "                           set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1\n"));
 	printf(_("  -V, --version            output version information, then exit\n"));
 	printf(_("  -X, --no-psqlrc          do not read startup file (~/.psqlrc)\n"));
 	printf(_("  -1 (\"one\"), --single-transaction\n"
 			 "                           execute as a single transaction (if non-interactive)\n"));
 	printf(_("  -?, --help               show this help, then exit\n"));
+	printf(_("      --help-variables     list of available configuration variables (options), then exit\n"));
 
 	printf(_("\nInput and output options:\n"));
 	printf(_("  -a, --echo-all           echo all input from script\n"));
@@ -279,6 +280,80 @@ slashUsage(unsigned short int pager)
 }
 
 
+/*
+ * show list of available variables (options) from command line
+ */
+void
+help_variables(void)
+{
+	printf(_("List of variables (options) for use from command line.\n"));
+
+	printf(_("psql variables:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --set=NAME=VALUE\n  or \\set NAME VALUE in interactive mode\n\n"));
+
+	printf(_("  AUTOCOMMIT         when is on, successful SQL command is automatically commited\n"));
+	printf(_("  COMP_KEYWORD_CASE  determines which letter case to use when completing an SQL key word\n"));
+	printf(_("  DBNAME             the name of currently connected database\n"));
+	printf(_("  ECHO               all lines from input can be written to standard output\n"));
+	printf(_("  ECHO_HIDDEN        display queries for internal commands (same as -E option)\n"));
+	printf(_("  ENCODING           the current client character set encoding\n"));
+	printf(_("  FETCH_COUNT        how many rows should be for one page (default 0 unlimited)\n"));
+	printf(_("  HISTCONTROL        when is set, control history list [ignorespace, ignoredups, ignoreboth]\n"));
+	printf(_("  HISTFILE           file name that be used for store history list\n"));
+	printf(_("  HISTSIZE           the number of commands to store in the command history\n"));
+	printf(_("  HOST               the currently connected database server\n"));
+	printf(_("  IGNOREEOF          if unset, sending an EOF to interactive session terminates application\n"));
+	printf(_("  LASTOID            the value of last affected OID\n"));
+	printf(_("  ON_ERROR_ROLLBACK  when is on, raise ROLLBACK on error automatically\n"));
+	printf(_("  ON_ERROR_STOP      when is set, then batch execution stop immediately after error\n"));
+	printf(_("  PORT               the database server port to which is currently used\n"));
+	printf(_("  PROPMPT1, PROPMT2, PROPMPT3  specify a look of psql prompt\n"));
+	printf(_("  QUIET              when is set, run quietly (same as -q option)\n"));
+	printf(_("  SIGLELINE          end of line terminates SQL command mode (same as -S option)\n"));
+	printf(_("  SINGLESTEP         confirm each query mode (same as -s option)\n"));
+	printf(_("  USER               the database user that are currently connected\n"));
+	printf(_("  VERBOSITY          control verbosity of error reports [default, verbose, terse]\n"));
+
+	printf(_("\nPrinting options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --pset=NAME[=VALUE]\n  or \\pset NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  border             number of border style\n"));
+	printf(_("  fieldsep           specify field separator for unaligned output\n"));
+	printf(_("  fieldsep_zero      field separator in unaligned mode will be zero\n"));
+	printf(_("  format             set output format [unaligned, aligned, wrapped, html, latex, ..]\n"));
+	printf(_("  linestyle          sets the border line drawing style [ascii, old-ascii, unicode]\n"));
+	printf(_("  null               sets the string to be printed in place of a null value\n"));
+	printf(_("  pager              when the pager option is off, the pager program is not used\n"));
+	printf(_("  recordsep          specifies the record (line) separator to use in unaligned output format\n"));
+	printf(_("  recordsep_zero     record separator be in unaligned output format a zero byte\n"));
+	printf(_("  title              sets the table title for any subsequently printed tables\n"));
+	printf(_("  tuples_only        in tuples-only mode, only actual table data is shown\n"));
+
+	printf(_("\nEnvironment options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  NAME=VALUE, [NAME=VALUE] psql ...\n  or \\setenv NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  COLUMNS            number of columns for wrapped format\n"));
+	printf(_("  PAGER              used pager\n"));
+	printf(_("  PGDATABASE         same as the dbname connection parameter\n"));
+	printf(_("  PGHOST             same as the host connection parameter\n"));
+        printf(_("  PGPORT             same as the port connection parameter\n"));
+	printf(_("  PGUSER             same as the user connection parameter\n"));
+	printf(_("  PGPASSWORD         possibility to set password\n"));
+	printf(_("  PSQL_EDITOR, EDITOR, VISUAL  editor used by \\e \\ef commands\n"));
+	printf(_("  PSQL_EDITOR_LINE_NUMBER_ARG  style how to line number is used in editor\n"));
+	printf(_("  PSQL_HISTORY       alternative location for the command history file\n"));
+	printf(_("  PSQL_RC            alternative location of the user's .psqlrc file\n"));
+	printf(_("  SHELL              command executed by the \\! command\n"));
+	printf(_("  TMPDIR             directory for storing temporary files\n"));
+
+	printf(_("\nFor more information consult the psql section in the PostgreSQL\n"
+			 "documentation.\n\n"));
+	printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
+}
+
 
 /*
  * helpSQL -- help with SQL commands
diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h
index 054d5a4..e7affff 100644
--- a/src/bin/psql/help.h
+++ b/src/bin/psql/help.h
@@ -12,6 +12,8 @@ void		usage(void);
 
 void		slashUsage(unsigned short int pager);
 
+void		help_variables(void);
+
 void		helpSQL(const char *topic, unsigned short int pager);
 
 void		print_copyright(void);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 45653a1..d911159 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -383,6 +383,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"expanded", no_argument, NULL, 'x'},
 		{"no-psqlrc", no_argument, NULL, 'X'},
 		{"help", no_argument, NULL, '?'},
+		{"help-variables", no_argument, NULL, 1},
 		{NULL, 0, NULL, 0}
 	};
 
@@ -566,6 +567,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 					exit(EXIT_FAILURE);
 				}
 				break;
+			case 1:
+				help_variables();
+				exit(EXIT_SUCCESS);
 			default:
 				fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
 						pset.progname);
#22Erik Rijkers
er@xs4all.nl
In reply to: Pavel Stehule (#21)
1 attachment(s)
Re: proposal: new long psql parameter --on-error-stop

On Sun, June 22, 2014 00:10, Pavel Stehule wrote:

[help-variables-01.patch ]

+1. This patch is a very useful improvement, IMHO.

I edited the text somewhat; and removed some obvious typos.

thanks,

Erik Rijkers

Attachments:

help.c.difftext/x-patch; name=help.c.diffDownload
--- src/bin/psql/help.c.orig	2014-06-22 00:31:55.450860460 +0200
+++ src/bin/psql/help.c	2014-06-22 01:28:23.546375133 +0200
@@ -292,36 +292,36 @@
 	printf(_("Usage:\n"));
 	printf(_("  psql --set=NAME=VALUE\n  or \\set NAME VALUE in interactive mode\n\n"));
 
-	printf(_("  AUTOCOMMIT         when is on, successful SQL command is automatically commited\n"));
+	printf(_("  AUTOCOMMIT         successful SQL commands are automatically committed\n"));
 	printf(_("  COMP_KEYWORD_CASE  determines which letter case to use when completing an SQL key word\n"));
-	printf(_("  DBNAME             the name of currently connected database\n"));
-	printf(_("  ECHO               all lines from input can be written to standard output\n"));
-	printf(_("  ECHO_HIDDEN        display queries for internal commands (same as -E option)\n"));
-	printf(_("  ENCODING           the current client character set encoding\n"));
-	printf(_("  FETCH_COUNT        how many rows should be for one page (default 0 unlimited)\n"));
-	printf(_("  HISTCONTROL        when is set, control history list [ignorespace, ignoredups, ignoreboth]\n"));
-	printf(_("  HISTFILE           file name that be used for store history list\n"));
+	printf(_("  DBNAME             name of currently connected database\n"));
+	printf(_("  ECHO               write all input lines to standard output\n"));
+	printf(_("  ECHO_HIDDEN        display internal queries (same as -E option)\n"));
+	printf(_("  ENCODING           current client character set encoding\n"));
+	printf(_("  FETCH_COUNT        this many rows at a time (use less memory) (default 0 unlimited)\n"));
+	printf(_("  HISTCONTROL        when set, controls history list [ignorespace, ignoredups, ignoreboth]\n"));
+	printf(_("  HISTFILE           file name used to store the history list\n"));
 	printf(_("  HISTSIZE           the number of commands to store in the command history\n"));
 	printf(_("  HOST               the currently connected database server\n"));
 	printf(_("  IGNOREEOF          if unset, sending an EOF to interactive session terminates application\n"));
 	printf(_("  LASTOID            the value of last affected OID\n"));
-	printf(_("  ON_ERROR_ROLLBACK  when is on, raise ROLLBACK on error automatically\n"));
-	printf(_("  ON_ERROR_STOP      when is set, then batch execution stop immediately after error\n"));
-	printf(_("  PORT               the database server port to which is currently used\n"));
-	printf(_("  PROPMPT1, PROPMT2, PROPMPT3  specify a look of psql prompt\n"));
-	printf(_("  QUIET              when is set, run quietly (same as -q option)\n"));
-	printf(_("  SIGLELINE          end of line terminates SQL command mode (same as -S option)\n"));
+	printf(_("  ON_ERROR_ROLLBACK  when on, ROLLBACK on error\n"));
+	printf(_("  ON_ERROR_STOP      stop batch execution after error\n"));
+	printf(_("  PORT               the database server port\n"));
+	printf(_("  PROMPT1, PROMPT2, PROMPT3  specify the psql prompt\n"));
+	printf(_("  QUIET              run quietly (same as -q option)\n"));
+	printf(_("  SINGLELINE         end of line terminates SQL command mode (same as -S option)\n"));
 	printf(_("  SINGLESTEP         confirm each query mode (same as -s option)\n"));
-	printf(_("  USER               the database user that are currently connected\n"));
+	printf(_("  USER               the database user currently connected\n"));
 	printf(_("  VERBOSITY          control verbosity of error reports [default, verbose, terse]\n"));
 
 	printf(_("\nPrinting options:\n"));
 	printf(_("Usage:\n"));
 	printf(_("  psql --pset=NAME[=VALUE]\n  or \\pset NAME [VALUE] in interactive mode\n\n"));
 
-	printf(_("  border             number of border style\n"));
-	printf(_("  fieldsep           specify field separator for unaligned output\n"));
-	printf(_("  fieldsep_zero      field separator in unaligned mode will be zero\n"));
+	printf(_("  border             border style (number)\n"));
+	printf(_("  fieldsep           field separator for unaligned output (default '|')\n"));
+	printf(_("  fieldsep_zero      set field separator in unaligned mode to zero\n"));
 	printf(_("  format             set output format [unaligned, aligned, wrapped, html, latex, ..]\n"));
 	printf(_("  linestyle          sets the border line drawing style [ascii, old-ascii, unicode]\n"));
 	printf(_("  null               sets the string to be printed in place of a null value\n"));
@@ -333,7 +333,7 @@
 
 	printf(_("\nEnvironment options:\n"));
 	printf(_("Usage:\n"));
-	printf(_("  NAME=VALUE, [NAME=VALUE] psql ...\n  or \\setenv NAME [VALUE] in interactive mode\n\n"));
+	printf(_("  NAME=VALUE [NAME=VALUE] psql ...\n  or \\setenv NAME [VALUE] in interactive mode\n\n"));
 
 	printf(_("  COLUMNS            number of columns for wrapped format\n"));
 	printf(_("  PAGER              used pager\n"));
@@ -341,9 +341,10 @@
 	printf(_("  PGHOST             same as the host connection parameter\n"));
         printf(_("  PGPORT             same as the port connection parameter\n"));
 	printf(_("  PGUSER             same as the user connection parameter\n"));
-	printf(_("  PGPASSWORD         possibility to set password\n"));
+	printf(_("  PGPASSWORD         possibility to set password (not recommended)\n"));
+	printf(_("  PGPASSFILE         password file (default ~/.pgpass)\n"));
 	printf(_("  PSQL_EDITOR, EDITOR, VISUAL  editor used by \\e \\ef commands\n"));
-	printf(_("  PSQL_EDITOR_LINE_NUMBER_ARG  style how to line number is used in editor\n"));
+	printf(_("  PSQL_EDITOR_LINE_NUMBER_ARG  style how line number is used in editor\n"));
 	printf(_("  PSQL_HISTORY       alternative location for the command history file\n"));
 	printf(_("  PSQL_RC            alternative location of the user's .psqlrc file\n"));
 	printf(_("  SHELL              command executed by the \\! command\n"));
#23MauMau
maumau307@gmail.com
In reply to: Pavel Stehule (#21)
Re: proposal: new long psql parameter --on-error-stop

From: "Pavel Stehule" <pavel.stehule@gmail.com>

I am not sure in this point. It is aligned left with all long options:

-?, --help show this help, then exit
--help-variables list of available configuration variables
(options), then exit

pg_dumpall aligns all options left with each other, whether they are short
or long.

-x, --no-privileges do not dump privileges (grant/revoke)
--binary-upgrade for use by upgrade utilities only
--column-inserts dump data as INSERT commands with column
names

Regards
MauMau

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#24Pavel Stehule
pavel.stehule@gmail.com
In reply to: MauMau (#23)
1 attachment(s)
Re: proposal: new long psql parameter --on-error-stop

2014-06-22 2:26 GMT+02:00 MauMau <maumau307@gmail.com>:

From: "Pavel Stehule" <pavel.stehule@gmail.com>

I am not sure in this point. It is aligned left with all long options:

-?, --help show this help, then exit
--help-variables list of available configuration variables
(options), then exit

pg_dumpall aligns all options left with each other, whether they are short
or long.

-x, --no-privileges do not dump privileges (grant/revoke)
--binary-upgrade for use by upgrade utilities only
--column-inserts dump data as INSERT commands with column
names

ok

I fixed it

Regards

Pavel

Show quoted text

Regards
MauMau

Attachments:

help-variables-02.patchtext/x-patch; charset=US-ASCII; name=help-variables-02.patchDownload
commit e07af2c24cb8ae85ef6b3ec53baf3444bfa27ad3
Author: Pavel Stehule <pavel.stehule@gmail.com>
Date:   Sun Jun 22 00:08:24 2014 +0200

    show a list of psql internal, psql formatting and system variables used by psql

diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 3aa3c16..59030eb 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -78,12 +78,13 @@ usage(void)
 	printf(_("  -f, --file=FILENAME      execute commands from file, then exit\n"));
 	printf(_("  -l, --list               list available databases, then exit\n"));
 	printf(_("  -v, --set=, --variable=NAME=VALUE\n"
-			 "                           set psql variable NAME to VALUE\n"));
+			 "                           set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1\n"));
 	printf(_("  -V, --version            output version information, then exit\n"));
 	printf(_("  -X, --no-psqlrc          do not read startup file (~/.psqlrc)\n"));
 	printf(_("  -1 (\"one\"), --single-transaction\n"
 			 "                           execute as a single transaction (if non-interactive)\n"));
 	printf(_("  -?, --help               show this help, then exit\n"));
+	printf(_("  --help-variables         list of available configuration variables (options), then exit\n"));
 
 	printf(_("\nInput and output options:\n"));
 	printf(_("  -a, --echo-all           echo all input from script\n"));
@@ -279,6 +280,80 @@ slashUsage(unsigned short int pager)
 }
 
 
+/*
+ * show list of available variables (options) from command line
+ */
+void
+help_variables(void)
+{
+	printf(_("List of variables (options) for use from command line.\n"));
+
+	printf(_("psql variables:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --set=NAME=VALUE\n  or \\set NAME VALUE in interactive mode\n\n"));
+
+	printf(_("  AUTOCOMMIT         when is on, successful SQL command is automatically commited\n"));
+	printf(_("  COMP_KEYWORD_CASE  determines which letter case to use when completing an SQL key word\n"));
+	printf(_("  DBNAME             the name of currently connected database\n"));
+	printf(_("  ECHO               all lines from input can be written to standard output\n"));
+	printf(_("  ECHO_HIDDEN        display queries for internal commands (same as -E option)\n"));
+	printf(_("  ENCODING           the current client character set encoding\n"));
+	printf(_("  FETCH_COUNT        how many rows should be for one page (default 0 unlimited)\n"));
+	printf(_("  HISTCONTROL        when is set, control history list [ignorespace, ignoredups, ignoreboth]\n"));
+	printf(_("  HISTFILE           file name that be used for store history list\n"));
+	printf(_("  HISTSIZE           the number of commands to store in the command history\n"));
+	printf(_("  HOST               the currently connected database server\n"));
+	printf(_("  IGNOREEOF          if unset, sending an EOF to interactive session terminates application\n"));
+	printf(_("  LASTOID            the value of last affected OID\n"));
+	printf(_("  ON_ERROR_ROLLBACK  when is on, raise ROLLBACK on error automatically\n"));
+	printf(_("  ON_ERROR_STOP      when is set, then batch execution stop immediately after error\n"));
+	printf(_("  PORT               the database server port to which is currently used\n"));
+	printf(_("  PROPMPT1, PROPMT2, PROPMPT3  specify a look of psql prompt\n"));
+	printf(_("  QUIET              when is set, run quietly (same as -q option)\n"));
+	printf(_("  SIGLELINE          end of line terminates SQL command mode (same as -S option)\n"));
+	printf(_("  SINGLESTEP         confirm each query mode (same as -s option)\n"));
+	printf(_("  USER               the database user that are currently connected\n"));
+	printf(_("  VERBOSITY          control verbosity of error reports [default, verbose, terse]\n"));
+
+	printf(_("\nPrinting options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  psql --pset=NAME[=VALUE]\n  or \\pset NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  border             number of border style\n"));
+	printf(_("  fieldsep           specify field separator for unaligned output\n"));
+	printf(_("  fieldsep_zero      field separator in unaligned mode will be zero\n"));
+	printf(_("  format             set output format [unaligned, aligned, wrapped, html, latex, ..]\n"));
+	printf(_("  linestyle          sets the border line drawing style [ascii, old-ascii, unicode]\n"));
+	printf(_("  null               sets the string to be printed in place of a null value\n"));
+	printf(_("  pager              when the pager option is off, the pager program is not used\n"));
+	printf(_("  recordsep          specifies the record (line) separator to use in unaligned output format\n"));
+	printf(_("  recordsep_zero     record separator be in unaligned output format a zero byte\n"));
+	printf(_("  title              sets the table title for any subsequently printed tables\n"));
+	printf(_("  tuples_only        in tuples-only mode, only actual table data is shown\n"));
+
+	printf(_("\nEnvironment options:\n"));
+	printf(_("Usage:\n"));
+	printf(_("  NAME=VALUE, [NAME=VALUE] psql ...\n  or \\setenv NAME [VALUE] in interactive mode\n\n"));
+
+	printf(_("  COLUMNS            number of columns for wrapped format\n"));
+	printf(_("  PAGER              used pager\n"));
+	printf(_("  PGDATABASE         same as the dbname connection parameter\n"));
+	printf(_("  PGHOST             same as the host connection parameter\n"));
+        printf(_("  PGPORT             same as the port connection parameter\n"));
+	printf(_("  PGUSER             same as the user connection parameter\n"));
+	printf(_("  PGPASSWORD         possibility to set password\n"));
+	printf(_("  PSQL_EDITOR, EDITOR, VISUAL  editor used by \\e \\ef commands\n"));
+	printf(_("  PSQL_EDITOR_LINE_NUMBER_ARG  style how to line number is used in editor\n"));
+	printf(_("  PSQL_HISTORY       alternative location for the command history file\n"));
+	printf(_("  PSQL_RC            alternative location of the user's .psqlrc file\n"));
+	printf(_("  SHELL              command executed by the \\! command\n"));
+	printf(_("  TMPDIR             directory for storing temporary files\n"));
+
+	printf(_("\nFor more information consult the psql section in the PostgreSQL\n"
+			 "documentation.\n\n"));
+	printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
+}
+
 
 /*
  * helpSQL -- help with SQL commands
diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h
index 054d5a4..e7affff 100644
--- a/src/bin/psql/help.h
+++ b/src/bin/psql/help.h
@@ -12,6 +12,8 @@ void		usage(void);
 
 void		slashUsage(unsigned short int pager);
 
+void		help_variables(void);
+
 void		helpSQL(const char *topic, unsigned short int pager);
 
 void		print_copyright(void);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 45653a1..d911159 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -383,6 +383,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 		{"expanded", no_argument, NULL, 'x'},
 		{"no-psqlrc", no_argument, NULL, 'X'},
 		{"help", no_argument, NULL, '?'},
+		{"help-variables", no_argument, NULL, 1},
 		{NULL, 0, NULL, 0}
 	};
 
@@ -566,6 +567,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
 					exit(EXIT_FAILURE);
 				}
 				break;
+			case 1:
+				help_variables();
+				exit(EXIT_SUCCESS);
 			default:
 				fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
 						pset.progname);
#25Pavel Stehule
pavel.stehule@gmail.com
In reply to: Pavel Stehule (#1)
Re: proposal: new long psql parameter --on-error-stop

2014-06-22 9:32 GMT+02:00 MauMau <maumau307@gmail.com>:

From: "Pavel Stehule" <pavel.stehule@gmail.com>

pg_dumpall aligns all options left with each other, whether they are short

or long.

-x, --no-privileges do not dump privileges (grant/revoke)
--binary-upgrade for use by upgrade utilities only
--column-inserts dump data as INSERT commands with column
names

ok

I fixed it

Thank you. I marked this patch as ready for committer.

Thank you very much

Pavel

Show quoted text

Regards
MauMau

#26MauMau
maumau307@gmail.com
In reply to: Pavel Stehule (#24)
Re: proposal: new long psql parameter --on-error-stop

From: "Pavel Stehule" <pavel.stehule@gmail.com>

pg_dumpall aligns all options left with each other, whether they are
short
or long.

-x, --no-privileges do not dump privileges (grant/revoke)
--binary-upgrade for use by upgrade utilities only
--column-inserts dump data as INSERT commands with column
names

ok

I fixed it

Thank you. I marked this patch as ready for committer.

Regards
MauMau

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers