Re: pgsql: Allow empty target list in SELECT.

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thom Brown <thom(at)linux(dot)com>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Allow empty target list in SELECT.
Date: 2015-03-20 12:25:50
Message-ID: 20150320122550.GH6317@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, Oct 22, 2014 at 04:19:10PM -0400, Tom Lane wrote:
> Thom Brown <thom(at)linux(dot)com> writes:
> > I can see the same output as you if I get it to ignore my .psqlrc file:
>
> > # select * from colours2;
> > --
> > (5 rows)
>
> > Turns out it's "\x auto" causing it.
>
> Ah. Seems like a bug in the expanded-mode printout logic then.
> But, in any case, it's been like that a very long time. You
> could do this at least as far back as 8.4:
>
> regression=# create table foo();
> CREATE TABLE
> regression=# insert into foo default values;
> INSERT 0 1
> regression=# insert into foo default values;
> INSERT 0 1
> regression=# select * from foo;
> --
> (2 rows)
>
> regression=# \x on
> Expanded display is on.
> regression=# select * from foo;
> (No rows)

I have developed a patch to fix this, e.g.:

test=> select * from foo;
--
(2 rows)

test=> \x
Expanded display is on.
test=> select * from foo;
(2 rows)

I used the same footer function every other output format was using.
Patch attached.

I also found that the normal non-expanded output was forcing the use of
a pager for these tests, which seemed odd considering there were no
rows. The problem is that the variable col_count is an unsigned integer,
and there were a few places we were subtracting one from it. When
col_count was zero, subtracting one returned a very larger positive
number, and triggered the pager. That is fixed in this patch as well.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
psql.diff text/x-diff 3.4 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2015-03-20 12:31:48 pgsql: C comment: update lock level mention in comment
Previous Message Andres Freund 2015-03-20 09:30:42 pgsql: Use 128-bit math to accelerate some aggregation functions.