Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLrDM-00059A-0O for pgsql-general@arkaria.postgresql.org; Wed, 10 Aug 2022 19:18:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLrDK-0004kC-GM for pgsql-general@arkaria.postgresql.org; Wed, 10 Aug 2022 19:17:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLrDK-0004jM-5e for pgsql-general@lists.postgresql.org; Wed, 10 Aug 2022 19:17:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLrDG-0004Oa-Hu for pgsql-general@lists.postgresql.org; Wed, 10 Aug 2022 19:17:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27AJHre2370704; Wed, 10 Aug 2022 15:17:53 -0400 From: Tom Lane To: Bryn Llewellyn cc: pgsql-general list Subject: Re: Surprisingly forgiving behavior when a case expression is terminated with "end case" In-reply-to: <5C1A009F-1E4A-4C2B-9142-9B05F2A86225@yugabyte.com> References: <5C1A009F-1E4A-4C2B-9142-9B05F2A86225@yugabyte.com> Comments: In-reply-to Bryn Llewellyn message dated "Wed, 10 Aug 2022 11:59:52 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <370702.1660159073.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 10 Aug 2022 15:17:53 -0400 Message-ID: <370703.1660159073@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn writes: > Moreover CASE is a reserved word=E2=80=94as a "create table case(=E2=80=A6= )" 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 acce= pted 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