Re: Surprisingly forgiving behavior when a case expression is terminated with "end case"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Surprisingly forgiving behavior when a case expression is terminated with "end case"
Date: 2022-08-10 19:17:53
Message-ID: 370703.1660159073@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bryn Llewellyn <bryn(at)yugabyte(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-08-10 19:18:25 Re: Surprisingly forgiving behavior when a case expression is terminated with "end case"
Previous Message Bryn Llewellyn 2022-08-10 18:59:52 Surprisingly forgiving behavior when a case expression is terminated with "end case"