pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Surprisingly forgiving behavior when a case expression is terminated with "end case"
Date: Wed, 10 Aug 2022 15:17:53 -0400
Message-ID: <370703.1660159073@sss.pgh.pa.us> (raw)
In-Reply-To: <5C1A009F-1E4A-4C2B-9142-9B05F2A86225@yugabyte.com>
References: <5C1A009F-1E4A-4C2B-9142-9B05F2A86225@yugabyte.com>

Bryn Llewellyn <bryn@yugabyte.com> writes:
> Moreover CASE is a reserved word—as a "create table case(…)" attempt shows. Yet CASE is tolerated (using PG 14.4) here:

> select 1 as case;

> In fact, any reserved word that I try (like IF, THEN, and so on) is accepted as an alias. This seems to me to be wrong. What do you (all) think?

I think we've spent a great deal of blood, sweat, and tears
making that so, or as nearly so as we could.  We will in
fact take any keyword after "AS", and in recent versions many
non-reserved keywords will work that way without "AS".

(Mind you, I think the SQL spec made a serious design error
in allowing "AS" to be optional.  But we have to live with that
as best we can.)

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <370703.1660159073@sss.pgh.pa.us>
Permalink:  ../370703.1660159073@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/370703.1660159073@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, bryn@yugabyte.com
  Subject: Re: Surprisingly forgiving behavior when a case expression is terminated with "end case"
  In-Reply-To: <370703.1660159073@sss.pgh.pa.us>
  References: <5C1A009F-1E4A-4C2B-9142-9B05F2A86225@yugabyte.com> <370703.1660159073@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