Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4Ebo-0002o4-St for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Sep 2018 00:20:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4Ebm-0000Wv-6Q for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Sep 2018 00:20:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4Ebl-0000Wj-Ve for pgsql-hackers@lists.postgresql.org; Mon, 24 Sep 2018 00:20:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4Ebj-0000KW-7C for pgsql-hackers@postgresql.org; Mon, 24 Sep 2018 00:20:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8O0K2FJ011684; Sun, 23 Sep 2018 20:20:02 -0400 From: Tom Lane To: Andrew Gierth cc: pgsql-hackers@postgresql.org, david@fetter.org, Oliver Ford , Krasiyan Andreev Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options In-reply-to: <87o9cnhjwh.fsf@news-spur.riddles.org.uk> References: <20180728185958.GP17411@fetter.org> <878t3vj279.fsf@news-spur.riddles.org.uk> <2897.1537737232@sss.pgh.pa.us> <87va6vhoey.fsf@news-spur.riddles.org.uk> <9361.1537744225@sss.pgh.pa.us> <87o9cnhjwh.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Mon, 24 Sep 2018 00:46:40 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11681.1537748402.1@sss.pgh.pa.us> Date: Sun, 23 Sep 2018 20:20:02 -0400 Message-ID: <11683.1537748402@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> If you just think of recognizing FROM FIRST/LAST, you get nowhere > Tom> because that's still legal in other contexts. But if you were to > Tom> look for FROM followed by FIRST/LAST followed by > Tom> IGNORE/RESPECT/OVER, I think that could only validly happen in > Tom> this syntax. > No; you need to go four tokens ahead in total, not three. Assuming > nth_value is unreserved, then > select nth_value(x) from first ignore; > is a valid query that has nth_value(x) as an expression, "first" as a > table name and "ignore" as its alias. No, because once IGNORE is a keyword, even unreserved, it's not legal as an AS-less alias. We'd be breaking queries like that no matter what. (I know there are people around here who'd like to remove that restriction, but it's not happening anytime soon IMO.) regards, tom lane