Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAOYY-0004YK-Um for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Mar 2019 00:42:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hAOYX-0005C9-2u for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Mar 2019 00:42:37 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAOYW-0005C0-QS for pgsql-hackers@lists.postgresql.org; Sun, 31 Mar 2019 00:42:36 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAOYP-0004nt-Bp for pgsql-hackers@postgresql.org; Sun, 31 Mar 2019 00:42:36 +0000 Received: by mail-wr1-x442.google.com with SMTP id k11so7192284wro.5 for ; Sat, 30 Mar 2019 17:42:28 -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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=22XoVpn+0wMn/6EUJBsnCdTam22iwsk8gB40pQEFGBE=; b=PRPPXauuJhiKBeyIQ+Os73qJM86vILNfqjWncwN47lQtozBrBeRFCMdWOFzeoHRcml yfzIP+gRIQ4dY0dXVMq0aol9pCE3WyBd+iJ7cbbS6wLh0+qiGWyV3REEzcptf/IWhXEY OflX7Mmp4q+8GpwJd4KZ6mIqRaE7lF63SM6W1r8RFWjBb3K4VPueDAS+yacKs//ij2wg RU53DNOVvZmqIO5rq1GaMk/XfKeDkOzjFU5gwqlVySeSxdOzuiiGhTLrp5G90aLlnS3A s1h0BYAazCu8xmlVydVuW0RBt6Yp1H7Fnf39E8vKqDTxR2JjKUt7ypypgb1ioaWyAlOq X30w== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=22XoVpn+0wMn/6EUJBsnCdTam22iwsk8gB40pQEFGBE=; b=SGgF+3vNrnMWiaGOLCDZ/xyJ+ycpGBd5POoJ86+BPVk174GpQXnaF8UvoU9GghtA/Y VlgoELXjVWbaGRrQfLPIcklotPSON988aDcvWxqm6T4EcbuDpqQDRcd34CtsrUNAYQar bYBYW7iLeUXg4lhnjj8n8nMW58iEBIWEOLD4vSmNPnsI/ECcHlPAXGDicHz7B/nG7wRt AB1zxcX/53Ppw4BJQeJX8tAdT6NLylgpZTssjvnWUZZgpMWZXBq12PD2132suWFhwMMo JpeUdVsyt6JueVnnPmruiadpRiM495ep6j7AO7BsBVJTvJmP1DpkrhGxV+jD4vfpcRJr 9wgA== X-Gm-Message-State: APjAAAVppTg29NJUBhYaMkERUyN1cA54fu+UUKGOWzDWcpDhUwysYlUT PeUG0e/vrIwHxCk9VORzbn+cMQ== X-Google-Smtp-Source: APXvYqwpebNJm+fNCR1ws92p9N6gb8ZChWB5V+tna1VBr0kyb+JuLnjsDyK8Lw58evCuuFN8J11yJw== X-Received: by 2002:adf:f1cc:: with SMTP id z12mr12738256wro.180.1553992948218; Sat, 30 Mar 2019 17:42:28 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id l21sm295676wme.4.2019.03.30.17.42.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 30 Mar 2019 17:42:27 -0700 (PDT) Date: Sun, 31 Mar 2019 01:42:25 +0100 From: Tomas Vondra To: Surafel Temesgen Cc: David Steele , Michael Paquier , Robert Haas , andrew@tao11.riddles.org.uk, PostgreSQL Hackers Subject: Re: Re: FETCH FIRST clause WITH TIES option Message-ID: <20190331004225.GB10804@development> References: <20190204052857.GP29064@paquier.xyz> <20190329005648.GA1136@development> <20190331001446.GA10804@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190331001446.GA10804@development> User-Agent: Mutt/1.11.4+135 (aae3e555) (2019-03-21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 31, 2019 at 01:14:46AM +0100, Tomas Vondra wrote: >On Fri, Mar 29, 2019 at 01:56:48AM +0100, Tomas Vondra wrote: >>On Tue, Mar 26, 2019 at 10:46:00AM +0300, Surafel Temesgen wrote: >>>On Mon, Mar 25, 2019 at 11:56 AM David Steele wrote: >>> >>>>This patch no longer passes testing so marked Waiting on Author. >>>> >>>> >>>Thank you for informing. Fixed >> >>Thanks for the updated patch. I do have this on my list of patches that >>I'd like to commit in this CF - likely tomorrow after one more round of >>review, or so. >> > >Hi, > >I got to look at the patch today, with the intent to commit, but sadly I >ran into a couple of minor issues that I don't feel comfortable fixing >on my own. Attached is a patch highlighling some of the places (0001 is >your v7 patch, to keep the cfbot happy). > > >1) the docs documented this as > > ... [ ONLY | WITH TIES ] > >but that's wrong, because it implies those options are optional (i.e. >the user may not specify anything). That's not the case, exactly one >of those options needs to be specified, so it should have been > > ... { ONLY | WITH TIES } > > >2) The comment in ExecLimit() needs to be updated to explain that WITH >TIES changes the behavior. > > >3) Minor code style issues (no space before * on comment lines, {} >around single-line if statements, ...). > > >4) The ExecLimit() does this > > if (node->limitOption == WITH_TIES) > ExecCopySlot(node->last_slot, slot); > >but I think we only really need to do that for the last tuple in the >window, no? Would it be a useful optimization? > > >5) Two issues in _outLimit(). Firstly, when printing uniqCollations the >code actually prints uniqOperators. Secondly, why does the code use >these loops at all, instead of using WRITE_ATTRNUMBER_ARRAY and >WRITE_OID_ARRAY, like other places? Perhaps there's an issue with empty >arrays? I haven't tested this, but looking at the READ_ counterparts, I >don't see why that would be the case. > Actually, two more minor comments: 6) There's some confusing naming - in plannodes.h the fields added to the Limit node are called uniqSomething, but in other places the patch uses sortSomething, ordSomething. I suggest more consistent naming. 7) The LimitOption enum has two items - WITH_ONLY and WITH_TIES. That's a bit strange, because there's nothing like "WITH ONLY". regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services