Re: psql metaqueries with \gexec

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: PostgreSQL <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql metaqueries with \gexec
Date: 2016-03-13 22:02:34
Message-ID: 56E5E37A.1040700@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Attachment Content-Type Size
psql_gexec_v3.diff text/plain 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2016-03-13 22:03:08 Re: psql metaqueries with \gexec
Previous Message Tomas Vondra 2016-03-13 21:59:38 Re: multivariate statistics v14