Re: psql metaqueries with \gexec

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: psql metaqueries with \gexec
Дата
Msg-id 56E5E37A.1040700@BlueTreble.com
обсуждение исходный текст
Ответ на Re: psql metaqueries with \gexec  (Corey Huinker <corey.huinker@gmail.com>)
Ответы Re: psql metaqueries with \gexec
Список pgsql-hackers
On 2/22/16 1:01 PM, Corey Huinker wrote:
>     In the mean time, update patch attached.
>
>
> Really attached this time.

I'm getting a warning from this patch:

common.c:947:8: warning: variable 'success' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
                         if (pset.gexec_flag)
                             ^~~~~~~~~~~~~~~
common.c:995:9: note: uninitialized use occurs here
         return success;
                ^~~~~~~
common.c:947:4: note: remove the 'if' if its condition is always false
                         if (pset.gexec_flag)
                         ^~~~~~~~~~~~~~~~~~~~
common.c:937:15: note: initialize the variable 'success' to silence this
warning
         bool            success;
                                ^
                                 = '\0'
1 warning generated.

(note that I'm using CC='ccache clang -Qunused-arguments
-fcolor-diagnostics')

>     for (r = 0; r < nrows; r++)
>     {
>         for (c = 0; c < ncolumns; c++)
>         {
etc...

Normally we don't use gratuitous {'s, and I don't think it's helping
anything in this case. But I'll let whoever commits this decide.

> diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
> index 5f27120..0f87f29 100644
> --- a/src/bin/psql/tab-complete.c
> +++ b/src/bin/psql/tab-complete.c
> @@ -1280,8 +1280,8 @@ psql_completion(const char *text, int start, int end)
>          "\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\drds", "\\ds", "\\dS",
>          "\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dy",
>          "\\e", "\\echo", "\\ef", "\\encoding", "\\ev",
> -        "\\f", "\\g", "\\gset", "\\h", "\\help", "\\H", "\\i", "\\ir", "\\l",
> -        "\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
> +        "\\f", "\\g", "\\gexec", "\\gset", "\\h", "\\help", "\\H", "\\i", "\\ir",
> +        "\\l", "\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",

FWIW, it's generally better to leave that kind of re-wrapping to the
next pg_indent run.

I added tests for ON_ERROR_STOP. New patch attached.

The patch still needs to document this feature in the psql docs (and
maybe the manpage? not sure how that's generated...)
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

Вложения

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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: multivariate statistics v14
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: psql metaqueries with \gexec