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 1namvY-0006gP-KB for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Apr 2022 23:13:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1namuY-0004at-8z for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Apr 2022 23:12:02 +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 1namuW-0004ZS-2Z for pgsql-hackers@lists.postgresql.org; Sat, 02 Apr 2022 23:12:01 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1namuQ-0003Cy-SG; Sat, 02 Apr 2022 23:11:58 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id A273A5C00AF; Sat, 2 Apr 2022 19:11:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 02 Apr 2022 19:11:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=qJkRK4m62T1l7aFu46zMvertu8n8xZObZZa8sA uSvtM=; b=3wlaqASNGDW2SuwvihHggk4Arac4+ub8Wq4AvV13bxHsBTIxP2bvDg 6yM8ta1NTTTYwCQ+Lwrc8p6DYWEww9w8ItTmjrR1yZtQ4wj6I/0rMJVoead8myAi fOhKZRtd3o5/bpj2RxdW09e25k0DaWcxH6iB818n4fvzyskMIIFdpfjpGmk9l/c+ bTWb9hFXZ3UiYlogaDIn0KVC3hTmUzc8GwSI4QDwyEkJHK/ScdW8iL8E9AG7nRll 8atvG8l1fVNuhNDFV6wHA6wo6V2D4ncUuN+KvoB5MhJ2z/aDiaqYMjUuTFbGLp2+ Sb6Bcd1WrqPHYmIWLerR9NTifSxngvzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=qJkRK4m62T1l7aFu4 6zMvertu8n8xZObZZa8sAuSvtM=; b=L8YUIbG7mrQ05UuEmBpUSOT8/duUs3B3Z OTciUTB3wVpTK6pB6iOEH3qHU8Jp+TBxctUhLXhRxh1/uDhXlrkjnDaDazbUA4Zl huqXHz+shSrzO+kRT252eFlrtokJVUgghfyWok6Y9fpABHA1pGvNSG27Nk2qqeSg AnVZB/+ScCHt1EszdFLtgd80KKgsmF1QkCTMl46KlKNMwjFckiX0SlvgUf+cr34G UZedy1/tSdTPa0v/8aPU4r1OvN9YgU+VeqiOuHQBFRdE7Jg/o6ZRcvBGvC0Qr1uw PdoeAHqlsXzs/wfSRicYw1VHEsnA04xFP9AhcAzkyaEW+cGk/IovQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeiledgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedukefhkeelueegveetheelffffjeegleeuudelfeefuedtleffueejfffh ueffudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 2 Apr 2022 19:11:52 -0400 (EDT) Date: Sat, 2 Apr 2022 16:11:51 -0700 From: Andres Freund To: Thomas Munro Cc: Justin Pryzby , John Naylor , Peter Geoghegan , pgsql-hackers , Robert Haas Subject: Re: A qsort template Message-ID: <20220402231151.635ohpc4q3gppdzb@alap3.anarazel.de> References: <20220402202027.GG28503@telsasoft.com> <20220402210333.bwf4h375p4fxt5j6@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-04-03 09:45:13 +1200, Thomas Munro wrote: > On Sun, Apr 3, 2022 at 9:03 AM Andres Freund wrote: > > It's certainly not pretty that copytup_cluster() can use SortTuples without > > actually using SortTuples. Afaics it basically only computes isnull1/datum1 if > > state->indexInfo->ii_IndexAttrNumbers[0] == 0. > > I think we just need to decide up front if we're in a situation that > can't provide datum1/isnull1 (in this case because it's an expression > index), and skip the optimised paths. Here's an experimental patch... > still looking into whether there are more cases like this... That's a lot of redundant checks. How about putting all the checks for optimized paths into one if (state->sortKeys && !state->disable_datum1)? I'm a bit worried that none of the !ubsan tests failed on this... Greetings, Andres Freund