Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vv184-00H5MM-20 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 22:43:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vv183-003pRG-0C for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 22:43:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vv182-003pR5-2R for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 22:43:42 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vv17z-000000011hp-1lPJ for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 22:43:41 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2aaf9191da3so39098045ad.2 for ; Tue, 24 Feb 2026 14:43:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771973019; x=1772577819; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YrAiZM5wnEbyGSULKfXm4b9w+5iOc9aW08R2JjKz3rA=; b=BdEd7VQJTFT9IZbKMbMAhu7zSSX1NbrGm10nbScl6YOxxrzghnIf8jNpQ8hSzQ33nf Yst/abvsnJyeD4dBqSRZOf0j8QSx7aE8YCHFwCeA7uk3cnemrx/DxEISLDNIbQ2EikuP hbi8Aa8cL/kW3e+jeZgZXeFzO3UflKS10M82xji3JIudWiw4+WwW31kIQO1EIjUIEJda oAl1WsumoWgWIBHuXzho5yBqM5XghUe6RJ9JeBR5Xl5qUISuVn48OpoBnnXvu8abtZDC me/gF7V4wb2wyX1Ctv3U8Bhlxj3GBr1S7TkKRnG6LPu1lPNUUKA3kodtyiyv4R1a4Uym Oj5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771973019; x=1772577819; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YrAiZM5wnEbyGSULKfXm4b9w+5iOc9aW08R2JjKz3rA=; b=ZFMwOtgL4XdVLEM8qLhbfxw/A0chVyxJdmufKfH69t+GRhsFOrsgigcLhzwVUkVDSK FsLAOpnpJKsmnl3pcjTPboJ0tC99YryagDwrVCb3EGzTjR8biCO98YZs4NP2RtrT/XaO AXk5lBZBnVWtNPZLWlQm8QrOOBXKxMEzr7LsP3hL+nAXR6DJf5klEAFRVHPwKcArl4CR 5no2TbKBppz+PNYyjGkJBDbbsiu9I0Ea/mZgzzOT/eKDh0e9k54Vp+oQ6cIgchHYUVOD /z7mb7TMZ3TI2yzc3vOzHbgdT5OFokHBruSWwVdEuLKaqOoxG8uuzIx3P0udFQ5YqJeB vw6g== X-Gm-Message-State: AOJu0YzsxhfSFYTT2gQX7UtjMZDZRMu0XaE3AG9zByotIsfxJXBkPwWq 8gsW+8qZ12hF3ZKilW/IzH2dG1SzrTTu/iipzbYtGIdS9GFoh4YL7dReknHfB8rf X-Gm-Gg: ATEYQzxddVDI2CwOfpwcN5Cu5hrl9OeRDjB3aZlWPcYPmc7kVQ0GcK2t9DCSrtUA8T9 2l+qVzGJuCZKHWqWUjQMPx6/0bHtSSKj0Yg/aTbI3aR7v2DUuiZdui1UyKmwWVFKBndOws4sU44 xR6VS68kWTaFoQ2vKoxpQ3thPrURSVDsr7Lptcri8zSd6uIXpTv6fQJqg30GLXKv8+KLoUgP22C SN+hzmXLlepbJt4rkwXw6u8iWk2D7IE2PtNiGrgSuXymw5In80LqYqXj2KEB9iB83mBit2vMhyw +vHhowxVHD2BdiWTvuXzv8xrv+vWp/9T4J4Mcsy8heJ6N1krnowcknKvQfDhvkdnjJ2/pUjkENf DAv9UMwpT4mDl+k3sp5S1ebAEww25DdWfN5xg3nIqC1R0mHZWG+4dEaLE5okN0ipesUFrtlVdqk 1tDBIZxnzfDtvfkZoI+L6jR0mH3ewemVQ= X-Received: by 2002:a17:903:2a8b:b0:2aa:f098:f9d6 with SMTP id d9443c01a7336-2ad7452f61bmr134027055ad.43.1771973019402; Tue, 24 Feb 2026 14:43:39 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad7500e2a7sm111865545ad.46.2026.02.24.14.43.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2026 14:43:38 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [PATCH] Simplify ExecWithoutOverlapsNotEmpty by removing unused parameter From: Chao Li X-Priority: 3 In-Reply-To: Date: Wed, 25 Feb 2026 06:42:58 +0800 Cc: pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <2422E6F1-685E-4349-AF8A-684C801567B1@gmail.com> References: To: zengman X-Mailer: Apple Mail (2.3864.300.41.1.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Feb 24, 2026, at 23:09, zengman wrote: >=20 > Hi all, >=20 > I noticed that ExecWithoutOverlapsNotEmpty() accepts an atttypid = parameter that isn't actually used. The function only needs typtype to = distinguish between range and multirange types. > Currently lookup_type_cache() is called just to extract typtype, but I = think using get_typtype() directly seems more appropriate. >=20 > ``` > static void ExecWithoutOverlapsNotEmpty(Relation rel, NameData = attname, Datum attval, > - = char typtype, Oid atttypid); > + = char typtype); >=20 > /* ---------------------------------------------------------------- > * ExecOpenIndices > @@ -753,11 +754,10 @@ check_exclusion_or_unique_constraint(Relation = heap, Relation index, > { > TupleDesc tupdesc =3D = RelationGetDescr(heap); > Form_pg_attribute att =3D = TupleDescAttr(tupdesc, attno - 1); > - TypeCacheEntry *typcache =3D = lookup_type_cache(att->atttypid, 0); >=20 > ExecWithoutOverlapsNotEmpty(heap, att->attname, > = values[indnkeyatts - 1], > - = typcache->typtype, att->atttypid); > + = get_typtype(att->atttypid)); > } > } >=20 > @@ -1149,7 +1149,7 @@ index_expression_changed_walker(Node *node, = Bitmapset *allUpdatedCols) > * range or multirange in the given attribute. > */ > static void > -ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum = attval, char typtype, Oid atttypid) > +ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum = attval, char typtype) > { > bool isempty; > RangeType *r; > ``` >=20 > -- > regards, > Man = Zeng<0001-refactor-Simplify-ExecWithoutOverlapsNotEmpty-functi.patch> Removing the parameter atttypid from ExecWithoutOverlapsNotEmpty looks = okay as it=E2=80=99s a static function and is only called once. For the other change, I see a difference between lookup_type_cache and = get_typtype, where lookup_type_cache never returns NULL but = ereport(ERROR) when oid is invalid; while get_typtype will return = =E2=80=98\0'. Though ExecWithoutOverlapsNotEmpty() will end up also = elog(ERROR), the log message is changed. I am not sure if there could be some edge cases where att->atttypid = could be invalid. If yes, then this change will lead to a small behavior = change. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/