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 1wIsGe-008YIH-2R for pgsql-bugs@arkaria.postgresql.org; Fri, 01 May 2026 18:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIsGd-00Bre7-3C for pgsql-bugs@arkaria.postgresql.org; Fri, 01 May 2026 18:07:11 +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 1wIsGd-00Brdz-1w for pgsql-bugs@lists.postgresql.org; Fri, 01 May 2026 18:07:11 +0000 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wIsGX-00000003jQ1-2XjN for pgsql-bugs@postgresql.org; Fri, 01 May 2026 18:07:09 +0000 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 8369D80772; Fri, 01 May 2026 21:07:01 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6bf:8080:54b::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id x6hIiQ0NGiE0-TSu3Y5KG; Fri, 01 May 2026 21:07:01 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1777658821; bh=OsvuytDN0F8vYU5aMc6HYBAqHIvAL1T9CkE9juW1D4k=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=Ekw6WOm0NVZe5FW9R+Xv/uH631guOSLxpLYLenx7p9PVIYNUDWTrBkbrRzoKkl6EE l61AW0hsTR5ZAy8NrAlRc9Uv4N21SAvKAU0NbYLyOr9lkosX/UdL0T686HnYrhXHiE aBh4NN1a4SbgdodQSmu2ZYCH2bx0iZ71Jw46xEf4= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.500.181\)) Subject: Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum From: Andrey Borodin In-Reply-To: <7ckc7oka4bvafkf5bwlqs6ygrhlsbhz25ppozfch7zbuxcx3rf@e4pr4oqenalc> Date: Fri, 1 May 2026 23:06:49 +0500 Cc: Alexander Korotkov , Alexander Lakhin , Michael Zhilin , pgsql-bugs@postgresql.org, Yura Sokolov Content-Transfer-Encoding: quoted-printable Message-Id: References: <76bc0dc9-4e43-4cd8-8eec-249b254ed1c9@postgrespro.ru> <8C83FCCA-2548-499A-8B1C-96C3D8ADB787@yandex-team.ru> <0b535249-a00c-a38a-85f6-d5a38c62dd55@gmail.com> <7ckc7oka4bvafkf5bwlqs6ygrhlsbhz25ppozfch7zbuxcx3rf@e4pr4oqenalc> To: Andres Freund X-Mailer: Apple Mail (2.3864.500.181) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 1 May 2026, at 22:11, Andres Freund wrote: >=20 > While hacking on something, I added an assertion to VARSIZE() that the > argument is actually a VARATT_4B (which it assumes). Worked = everywhere, except > for this caller: amcheck/regress fails, because sometimes the varlena = is > actually a short/1B varlena. >=20 > Note that VARSIZE_4B on a short datum will give you completely bogus > answers. E.g. in the case that failed the assertion, VARSIZE_1B() is = 2, but > VARSIZE_4B(PTR) is 7681. I remember the original code was taken from somewhere else because there was already some instances like this: /* * If value is above size target, and is of a compressible datatype, * try to compress it in-line. */ if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) && VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET && (att->attstorage =3D=3D TYPSTORAGE_EXTENDED || att->attstorage =3D=3D TYPSTORAGE_MAIN)) { I don't have VARATT_IS_EXTENDED vs VARATT_IS_COMPRESSED vs = VARATT_IS_SHORT business in my warm cache right away, but I'll try to remember what it = means soon. Best regards, Andrey Borodin.=