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 1wfh42-005ayw-1j for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jul 2026 16:48:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfh41-008aCJ-1W for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jul 2026 16:48:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wfh41-008aCB-0Z for pgsql-bugs@lists.postgresql.org; Fri, 03 Jul 2026 16:48:29 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfh3y-00000001UK6-2Hf7 for pgsql-bugs@postgresql.org; Fri, 03 Jul 2026 16:48:28 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-80bab6cf5ebso24151807b3.1 for ; Fri, 03 Jul 2026 09:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783097305; cv=none; d=google.com; s=arc-20260327; b=SdpYQjY3wInUazMEOd6QedMqHLo8Cu4CBv6YHsV9/iFYoy638E0AS5K4KUm98EwRr8 52kZu2eL2/VByJvDXBsskIOAjpkAL3uTZS17YnxoRhsWHsdM1gkXAZ5G7A/pABT44/4F dx4algwemR8fBQAPDLCdeqX0gs2ezAG7hvfiGIdwSGy2D0qQ6Fzmxru3DDqcv/f3ldeG bnOLQfGWDt+WS6FuiimqBiIj2t6xPteIQWFohgclzsrLlCjtHVtcO8ApjlRRqQyigXfw m0+Vhq7rEPd0pFgdcWpK1yQr5diFthNIQWGdInIRcznEQQFOdomeHO4IMAuWzzOzzoLc 22dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=5PJwn+PUAS/OkrKyoT1YXBdMox8W8EKoWL8+eEEI7vs=; fh=cJVHrUXUJ87M5WPptyrye+u5Om4tXkFh2KFaF7XkrBY=; b=FKZI+16Lw+tb8SXKgrVxOlRk0vPLFBj0IIfev8Z4D1Mp1M0NxPAJh53qk9IWlFN5QL nRQbtKV9auiW7AtvP7z/QNK/7/nRqOIFQ2VjqShVMZKz73XlMNIvwvJY4dZkUWn/dm/L tO+wS+ZEyr+TVicLwg2Z8CwcD2RbDHcbfvU9dMsmPtSWWuymNlO+iTYoqkbZZp3b8Oad V98FGfg+zZEtjGgwsNMiP3KAwzJhtgcZT9MkqqEhvbd+unWJCqT1+bIf4BHLKddi4hcV bqDVVsl8emltScszVKcXwD1XbELSYkuGeAoLswXRjASVK9hY5newc66NLwfPSBpnvs4v 1lqw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783097305; x=1783702105; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5PJwn+PUAS/OkrKyoT1YXBdMox8W8EKoWL8+eEEI7vs=; b=fPj44UPa4acOrzKKs+UxpWrQTmqLlzA87JiTiBuaHkoCrVCsXhGrFGuOXlTyUsH1IQ Ra3mbdJgpf/NX9YSP0SGsegEVPl4JfWjydqDDRQEZYEL/QyYQ8f2G3X6ZnRXDcrypO4F TDuplKANcDREnJMmY7M5pOPBh2evifGUxovYTxWOlC0S3NBk4/k7S6EcfrHRqglkCtHO zC2sDVlCjqGT0O29caKBtyELOjhaUrrx6vLSOVU44+9dARS6fGyA6lEoXeTKu39Ksiq4 H6J5aD4XJpSDs4ujfTFFe3qYRcaGvlokDlu1yjT5W3ysKS7ierGBdkbjTbbIafXFlwMI kG7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783097305; x=1783702105; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5PJwn+PUAS/OkrKyoT1YXBdMox8W8EKoWL8+eEEI7vs=; b=RyIk/2JGwIf4EJtHEQjwe1imxlqjbKYxcMjFTf7WwDg4JzNb0uLWsPfzE6gt3j1f81 dZSImw08t57FWu76CCXnEo2Bo4JhrJ+wdUx4jxygljHK2s50ikKqtSbnRo2/KZj72VIo r+1CPS0NgZ8mKs6ktyxritBYZit7dA5ahxTDjlSgxc7XLgR7jUQf3p9DwwHEryPj1nSD 9uP6htrKWhTwcwi/UhCkDVwQlHG3GY5M22VLMJG5DAlL5PViVbtBJYuJQL4Z21z+EzBM c4hmC2O8eFpWEOQRcMYMsr2fLIaI7B6aC4XRc+/vvdSd966ZQCgBEbtcUiMmHIC09zlF 06aA== X-Forwarded-Encrypted: i=1; AHgh+RqLjFkhhuyXG3LFfNH/Ifh9YLXkpqZPwiFnqCOA0HlRu7UgWkwP4NcXmmuDAkufipzv7vQ7xRCTtRuD@postgresql.org X-Gm-Message-State: AOJu0Yy5OE80LDHPugI6ls8Q/HuwIvMftKapumI1mGXfxZBPsi7xT+wa gFr06iymM1YA8nyPNrgineddF2PatQ6qKtjROSJiKQ1QlnJfXgqyCpeJBmsuLno6dGoVH7o3MEB vIBZKYSy9tHXQUyX0laP+3B4HoPYZzHY2lNK/N2I= X-Gm-Gg: AfdE7ckBy2qyJEXgvYGzEW8B38AP1DpuhW8xvjumU6cVlYg/utqoATa2QIjAfOh13Sn bs3/lRI3fwidUpOK68cZFzxxwFkzDmK+6X4t+cT7du3EF1iIKD/EljIG+BoNUJJ52fEb1a8VrdN Hiv1R21TDFwgzjWSlgDyjERKsBUSzqoby3iR2D/+0vqSKTfjZrDR6oVzMeJ3shyIP94AMYoXfCC bhCKUy248FbV0tZOruRAp+eJSODsEWVTbmSEqSXxouz7I20pvpMMWR91SEX4Od3FEblFAyO+fll Co2aRO3wxZV+tR+EWqOCL4m3yLai X-Received: by 2002:a05:690c:e0c2:20b0:7cf:d535:9970 with SMTP id 00721157ae682-815bbf9ac65mr33675297b3.20.1783097304653; Fri, 03 Jul 2026 09:48:24 -0700 (PDT) MIME-Version: 1.0 References: <3748108.1783003096@sss.pgh.pa.us> <3756776.1783011257@sss.pgh.pa.us> <3793780.1783033337@sss.pgh.pa.us> <3854290.1783086630@sss.pgh.pa.us> In-Reply-To: <3854290.1783086630@sss.pgh.pa.us> From: Ayush Tiwari Date: Fri, 3 Jul 2026 22:18:13 +0530 X-Gm-Features: AVVi8CfUWoj14dILvWu3jZNSQvfksXzvHneTzbnWDG3zc1sHc6jQHKnoAW3zSgo Message-ID: Subject: Re: Fw:Re: Fw: gbt_var_consistent in contrib/btree_gist/btree_utils_var.c has internal-node type confusion on the <> strategy, bypassing exclusion constraints To: Tom Lane Cc: =?UTF-8?B?546L6LeD5p6X?= , pgsql-bugs , 3764353996 <3764353996@qq.com> Content-Type: multipart/alternative; boundary="00000000000071a2210655b7b194" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000071a2210655b7b194 Content-Type: text/plain; charset="UTF-8" Hi, On Fri, 3 Jul 2026 at 19:20, Tom Lane wrote: > Ayush Tiwari writes: > > Are you planning on including it in the backpatch or to keep the > > optimization just part of master, and the bug fix backpatched? > > I was intending to back-patch only the bug fixes, ie 0002 and 0003. > If we make additional cosmetic changes to gbt_var_consistent(), > I could go either way on whether to include those in the back-patch. > Sounds good. > BTW, thinking some more about 0004: isn't it pointless to check > gbt_var_node_pf_match in the gbt_var_consistent cases that > only constrain the lower bound, that is LessEqual and Less? In > > retval = tinfo->f_cmp(query, key->lower, collation, > flinfo) >= 0 > || gbt_var_node_pf_match(key, query, tinfo); > > if query >= key->lower then we must search the node, but if it > isn't then the prefix match against upper can't succeed either. Hmm, looks like the || gbt_var_node_pf_match(...) clause isn't needed in the BTLessStrategyNumber and BTLessEqualStrategyNumber cases. Those only compare against the lower bound, and if query sorts before lower then it sorts before upper too, so a prefix match against the (truncated) upper can never succeed there. I tried changing it locally and ran the regression tests, all passed. Regards, Ayush --00000000000071a2210655b7b194 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Fri, 3 Jul 20= 26 at 19:20, Tom Lane <tgl@sss.pgh.= pa.us> wrote:
Ayush Tiwari <ayushtiwari.slg01@gmail.com> writes:
> Are you planning on including it in the backpatch or to keep the
> optimization just part of master, and the bug fix backpatched?

I was intending to back-patch only the bug fixes, ie 0002 and 0003.
If we make additional cosmetic changes to gbt_var_consistent(),
I could go either way on whether to include those in the back-patch.

Sounds good.
=C2=A0
BTW, thinking some more about 0004: isn't it pointless to check
gbt_var_node_pf_match in the gbt_var_consistent cases that
only constrain the lower bound, that is LessEqual and Less?=C2=A0 In

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 retval =3D tinfo-&g= t;f_cmp(query, key->lower, collation, flinfo) >=3D 0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 || gb= t_var_node_pf_match(key, query, tinfo);

if query >=3D key->lower then we must search the node, but if it
isn't then the prefix match against upper can't succeed either.=C2=A0
Hmm, looks like the || gbt_var_node_pf_match(...) clause isn't
need= ed in the BTLessStrategyNumber and BTLessEqualStrategyNumber
cases.=C2= =A0 Those only compare against the lower bound, and if query
sorts befor= e lower then it sorts before upper too, so a prefix
match against the (t= runcated) upper can never succeed there.
I tried changing it locally and= ran the regression tests, all passed.

Regards,
Ayush
=
--00000000000071a2210655b7b194--