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 1jagxP-0001kA-Q3 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2020 14:41:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jagxO-0003Nq-OG for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2020 14:41:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jagxO-0003Nj-HR for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2020 14:41:30 +0000 Received: from relay11.mail.gandi.net ([217.70.178.231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jagxK-0005fE-Ma for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2020 14:41:30 +0000 Received: from [172.16.255.146] (unknown [88.124.33.232]) (Authenticated sender: vik@postgresfriends.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 83175100009 for ; Mon, 18 May 2020 14:41:23 +0000 (UTC) To: PostgreSQL Hackers From: Vik Fearing Subject: Missing grammar production for WITH TIES Message-ID: <6aa690ef-551d-e24f-2690-c38c2442947c@postgresfriends.org> Date: Mon, 18 May 2020 16:41:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7BB28A6A002FD5F5CC653DAC" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7BB28A6A002FD5F5CC653DAC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit The syntax for FETCH FIRST allows the to be absent (implying 1). We implement this correctly for ONLY, but WITH TIES didn't get the memo. Patch attached. -- Vik Fearing --------------7BB28A6A002FD5F5CC653DAC Content-Type: text/x-patch; charset=UTF-8; name="with_ties.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="with_ties.diff" diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 3c78f2d1b5..a24b30f06f 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11816,6 +11816,14 @@ limit_clause: n->limitOption = LIMIT_OPTION_COUNT; $$ = n; } + | FETCH first_or_next row_or_rows WITH TIES + { + SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit)); + n->limitOffset = NULL; + n->limitCount = makeIntConst(1, -1); + n->limitOption = LIMIT_OPTION_WITH_TIES; + $$ = n; + } ; offset_clause: --------------7BB28A6A002FD5F5CC653DAC--