pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"?
Date: Wed, 01 Feb 2023 15:10:21 -0500
Message-ID: <1409990.1675282221@sss.pgh.pa.us> (raw)
In-Reply-To: <3833b34a-a4c1-14ee-fcdc-0fa74baa2cd8@gmail.com>
References: <3833b34a-a4c1-14ee-fcdc-0fa74baa2cd8@gmail.com>

Ron <ronljohnsonjr@gmail.com> writes:
> v12.13
> https://www.postgresql.org/docs/12/sql-select.html

> The docs say that one of these are required in the SELECT list.

> [ * |/|expression|/  [ [ AS ]/|output_name|/  ] [, ...] ]

Really?  I don't see anything to that effect in either the syntax
synopsis or the text, plus there's this in the Compatibility section:

    Empty SELECT Lists

    The list of output expressions after SELECT can be empty, producing a
    zero-column result table. This is not valid syntax according to the
    SQL standard. PostgreSQL allows it to be consistent with allowing
    zero-column tables. However, an empty list is not allowed when
    DISTINCT is used.

We probably did say that before 9.4 or so, but if you still find it
in modern releases, please say exactly where.

> However, *not* mentioning anything also works, though acts like COUNT(*).

Well, you get some number of zero-column rows.  psql's display of that is
a bit idiosyncratic, but nobody's bothered to improve it.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <1409990.1675282221@sss.pgh.pa.us>
Permalink:  ../1409990.1675282221@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1409990.1675282221@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com
  Subject: Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"?
  In-Reply-To: <1409990.1675282221@sss.pgh.pa.us>
  References: <3833b34a-a4c1-14ee-fcdc-0fa74baa2cd8@gmail.com> <1409990.1675282221@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox