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 1jM1Lv-0001qG-Ly for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 03:26:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jM1Ls-0004cV-N9 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 03:26:08 +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 1jM1Ls-0004cN-GB for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 03:26:08 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jM1Ll-0002iL-Di for pgsql-hackers@postgresql.org; Wed, 08 Apr 2020 03:26:07 +0000 Received: by mail-qt1-x842.google.com with SMTP id y25so4565437qtv.7 for ; Tue, 07 Apr 2020 20:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=7Tw6e1ndi9HyQx8EA5wAUG1W27CZx+e0vA5q69v/cZ0=; b=B7KmIlVW/QY38lEV1EaqcK//QrpRaa7cUqpKmVR3Bog2AjRdVog5ppfhBs1n5C/kZL OIrppeoVyHkWvXhrNKs4qfmW1BghTfVGgAltUMKcQc98QwKF61mT3nBPwMNoR+vwNdPR bTE7Alsn772HZuratBEaUEiUBwdbmXggDsrKpnJG+doOCnQ2pdB96ddCNSFuM1uDwykk tHKrzBKDLMJWOIt06Up9Ykoj1Wm4sZpifiu8Vx5zMu2txNMMNqGuj6mgd4de2QonDQ+R eBxBU1vKImu/n2F+BjrrlKkAlhOsx97i9N5JkY9eA5O1Rc29JZAPuygmj7un2FNmwp5M j0lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7Tw6e1ndi9HyQx8EA5wAUG1W27CZx+e0vA5q69v/cZ0=; b=bmwRDU9W0DXy65FSB6EM9HJ7uxg3tY85jETTqpm2RLuGce3CRaIbVYax917PWUGqQ6 LPz1xJennjDPr4J6t/hQffC1/FpA37v81RBey6Eiw14RpjdEUY0YS0RLlkcfx963i6oM Ot0ZB+drJD1HMct8R5p2pgERat8fNvSj1/fB2oCTCbGGOxhp8kT3usgF/M3jcmFsKjU4 TbyApy39LmygeuQK5tj7fGi7ou4p3G10tqKw7pdATTsDAp5LlDiy7D0cFKxTpxVO7wyK +GCXCPTnQQu6Fg3t1B4Hb6J8LCutczcgcssYNLCrM7G9QVD0iKfATkrC+z7SBnQ/0yrl XfLA== X-Gm-Message-State: AGi0PuZbhmLuu5vBiI6ZZDHXKGnwesk+kRufCxxTx0G5MHz9fbuZeAbc HQX2XeouI/HhRLywQJvAiKLtEA== X-Google-Smtp-Source: APiQypKSYZ5aAVq3x7Ayh8glZxL01eUTbkLxNJ0aAWxoXxcmrau2bP8MmDbcqVRlQWrqZPC+1kHtpw== X-Received: by 2002:ac8:7396:: with SMTP id t22mr5534702qtp.15.1586316360331; Tue, 07 Apr 2020 20:26:00 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id v49sm13319409qtv.82.2020.04.07.20.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:25:59 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 1E933300A9D; Tue, 7 Apr 2020 23:25:57 -0400 (-04) Date: Tue, 7 Apr 2020 23:25:57 -0400 From: Alvaro Herrera To: Andrew Gierth Cc: Surafel Temesgen , Tomas Vondra , PostgreSQL Hackers Subject: Re: FETCH FIRST clause WITH TIES option Message-ID: <20200408032557.GA29002@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87a73mn4cl.fsf@news-spur.riddles.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Apr-08, Andrew Gierth wrote: > >>>>> "Alvaro" == Alvaro Herrera writes: > > Alvaro> It turns out that the SQL standard is much more limited in what > Alvaro> it will accept there. But our grammar (what we'll accept for > Alvaro> the ancient LIMIT clause) is very lenient -- it'll take just > Alvaro> any expression. I thought about reducing that to NumericOnly > Alvaro> for FETCH FIRST .. WITH TIES, but then I have to pick: 1) > Alvaro> gram.y fails to compile because of a reduce/reduce conflict, or > Alvaro> 2) also restricting FETCH FIRST .. ONLY to NumericOnly. Neither > Alvaro> of those seemed very palatable. > > FETCH FIRST ... ONLY was made _too_ restrictive initially, such that it > didn't allow parameters (which are allowed by the spec); see 1da162e1f. Hmm, oh, I see. > (That change didn't present a problem for ruleutils, because FETCH FIRST > ... ONLY is output as a LIMIT clause instead.) Right, I noticed that and kept it unchanged. > This needs to be fixed in ruleutils, IMO, not by changing what the > grammar accepts. Fair. I didn't change what the grammar accepts. I ended up only throwing an error in parse analysis when a bare NULL const is seen. I guess we could fix ruleutils to add parens when NULL is seen, but I'm not sure it's necessary or useful. (LIMIT uses a null to represent the LIMIT ALL case.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services