Re: psql - factor out echo code

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: psql - factor out echo code
Дата
Msg-id 819253.1625238954@sss.pgh.pa.us
обсуждение исходный текст
Ответ на RE: psql - factor out echo code  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: psql - factor out echo code
Список pgsql-hackers
Fabien COELHO <coelho@cri.ensmp.fr> writes:
> [ psql-echo-2.patch ]

I went to commit this, figuring that it was a trivial bit of code
consolidation, but as I looked around in common.c I got rather
unhappy with the inconsistent behavior of things.  Examining
the various places that implement "echo"-related logic, we have
the three places this patch proposes to unify, which log queries
using

    fprintf(out,
            _("********* QUERY **********\n"
              "%s\n"
              "**************************\n\n"), query);

and then we have two more that just do

    puts(query);

plus this:

    if (!OK && pset.echo == PSQL_ECHO_ERRORS)
        pg_log_info("STATEMENT:  %s", query);

So it's exactly fifty-fifty as to whether we add all that decoration
or none at all.  I think if we're going to touch this logic, we
ought to try to unify the behavior.  My vote would be to drop the
decoration everywhere, but perhaps there are votes not to?

A different angle is that the identical decoration is used for both
psql-generated queries that are logged because of ECHO_HIDDEN, and
user-entered queries.  This seems at best rather unhelpful.  If
we keep the decoration, should we make it different for those two
cases?  (Maybe "INTERNAL QUERY" vs "QUERY", for example.)  The
cases with no decoration likewise fall into multiple categories,
both user-entered and generated-by-gexec; if we were going with
a decorated approach I'd think it useful to make a distinction
between those, too.

Thoughts?

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Preventing abort() and exit() calls in libpq
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Preventing abort() and exit() calls in libpq