2014-06-25 12:32 GMT+02:00 Samrat Revagade <revagade.sam...@gmail.com>:
> Hi Pavel, > > After applying patch, on error condition it displays error message two > times as follows: > > ERROR: column "abc" does not exist at character 23 > STATEMENT: insert into ax > values(abc); > psql:a.sql:7: ERROR: column "abc" does not exist > LINE 2: values(abc); > > > user may confuse because of repeated error messages. so I think its better > to display only one message, one of the possible ways is as follows: > > ERROR: column "abc" does not exist at character 23 > STATEMENT: insert into ax > values(abc); > > > Am I missing something ? > LINE info is a part of error message and should be eliminated by terse mode [pavel@localhost ~]$ psql -v ECHO=error -f test.sql postgres > /dev/null psql:test.sql:4: ERROR: syntax error at or near ";" LINE 2: 10 + ; ^ psql:test.sql:4: STATEMENT: select 10 + ; psql:test.sql:8: ERROR: syntax error at end of input LINE 2: 30 + ^ psql:test.sql:8: STATEMENT: select 30 + but you can switch to terse mode: [pavel@localhost ~]$ psql -v ECHO=error -v VERBOSITY=terse -f test.sql postgres > /dev/null psql:test.sql:4: ERROR: syntax error at or near ";" at character 13 psql:test.sql:4: STATEMENT: select 10 + ; psql:test.sql:8: ERROR: syntax error at end of input at character 13 psql:test.sql:8: STATEMENT: select 30 + What is what you would I am sending updated patch - buggy statement is printed via more logical psql_error function instead printf Regards Pavel > > > > On Wed, Jun 4, 2014 at 9:52 PM, Pavel Stehule <pavel.steh...@gmail.com> > wrote: > >> >> >> >> 2014-06-04 18:16 GMT+02:00 Peter Eisentraut <pete...@gmx.net>: >> >> On 6/4/14, 11:54 AM, Pavel Stehule wrote: >>> > updated patch - only one change: query is prefixed by "QUERY: " >>> >>> In the backend server log, this is called "STATEMENT: ". >>> >> >> good idea >> >> updated patch >> >> Pavel >> >> >> -- >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-hackers >> >> > > > -- > Regards, > > Samrat Revgade >
commit b269613e0b261a7a5cfea35594299a0dd093682d Author: Pavel Stehule <pavel.steh...@gooddata.com> Date: Wed Jun 25 20:45:30 2014 +0200 initial diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index ee6ec3a..cf0e78b 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -2812,7 +2812,8 @@ bar <literal>queries</literal>, <application>psql</application> merely prints all queries as they are sent to the server. The switch for this is - <option>-e</option>. + <option>-e</option>. If set to <literal>error</literal> then only + failed queries are displayed. </para> </listitem> </varlistentry> diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 60169a2..69860d7 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -995,6 +995,9 @@ SendQuery(const char *query) results = NULL; /* PQclear(NULL) does nothing */ } + if (!OK && pset.echo == PSQL_ECHO_ERROR) + psql_error("STATEMENT: %s\n", query); + /* If we made a temporary savepoint, possibly release/rollback */ if (on_error_rollback_savepoint) { diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index 0a60e68..e4a18f0 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -31,6 +31,7 @@ typedef enum { PSQL_ECHO_NONE, PSQL_ECHO_QUERIES, + PSQL_ECHO_ERROR, PSQL_ECHO_ALL } PSQL_ECHO; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 45653a1..b59bd59 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -720,6 +720,8 @@ echo_hook(const char *newval) pset.echo = PSQL_ECHO_NONE; else if (strcmp(newval, "queries") == 0) pset.echo = PSQL_ECHO_QUERIES; + else if (strcmp(newval, "error") == 0) + pset.echo = PSQL_ECHO_ERROR; else if (strcmp(newval, "all") == 0) pset.echo = PSQL_ECHO_ALL; else diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index be5c3c5..8611dd2 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3591,6 +3591,23 @@ psql_completion(const char *text, int start, int end) { matches = complete_from_variables(text, "", ""); } + else if (strcmp(prev2_wd, "\\set") == 0) + { + if (strcmp(prev_wd, "ECHO") == 0) + { + static const char *const my_list[] = + {"none", "error", "queries", "all", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "ECHO_HIDDEN") == 0) + { + static const char *const my_list[] = + {"noexec", "off", "on", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + } else if (strcmp(prev_wd, "\\sf") == 0 || strcmp(prev_wd, "\\sf+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL); else if (strcmp(prev_wd, "\\cd") == 0 ||
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers