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 1wNfdS-000ygQ-04 for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 23:38:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNfdP-00FVEo-1M for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 23:38:31 +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 1wNfdN-00FVEg-0f for pgsql-hackers@lists.postgresql.org; Thu, 14 May 2026 23:38:31 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wNfdK-00000000etD-168i for pgsql-hackers@lists.postgresql.org; Thu, 14 May 2026 23:38:28 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 24666EC01BF; Thu, 14 May 2026 19:38:23 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Thu, 14 May 2026 19:38:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1778801903; x=1778888303; bh=UeoQCTjDlgkoRzyA0hW4pp7dCUP61zzf Cotwq31ZYdo=; b=UYEwCmNFS2t5H/bfDGGHvWqSJcQUypLOO16tCxE64KejPvkj p+mxut+3GFFQ7fVZ4xrDy/dwgjUzPHP9U6QhV716/9Gntv6iLr4M7uYRQhp2XiMV pUC0xDgGdPrUaoaR/QZLcNHkWLkeHEVCdycZuA9xJzZ+XeUzdN/LsYbZDl2Eh4B4 mPo69oAVw1jf3xgbKam9nTE62H1BmuFZ7HTwaloRPAm2OaC+LFj7OMlZjgRjCPst jFykQZoGK2nDlkNMcHDaIB4f8YuyvnZjViZlO2NFtBXmv1uPy8Mykwaq/E8BFeL6 nrNsKqNREesYvGtyuwq6/S7H70nI9UxTUXDZvQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778801903; x= 1778888303; bh=UeoQCTjDlgkoRzyA0hW4pp7dCUP61zzfCotwq31ZYdo=; b=P 5puLIvwGZ1Jb1FpBNgIVSzFA3kxWyx2roEI/Gm/rnCU1LDJhRGuJAX+mmL/9Zkyt NhoWlb0JRyv1MGQzZ09vy0DqYTwtdUP18sTRcW7x1wbvv8sVRxBGvf97iBQvaJ9c YWeP7k/2LRTtCyJg0awnyUfXq14zndMWq/d9gTctJjT/THiWLBw+Nuazi/ivN/Jd UoLI/hsEhJHG3SVhE6zhVafc16VdWsnQgJ18lbBMLkMd1F0kkgDrppOxPiulXMV6 0s0PXoF6p6SkQfOT8OMKKfr6zkVvKu6YdswyP/LqgHdI1mBXNT3lYQ9qKc7hJQXw wQeuvIjAjqtpyir+ZBYPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduvdekkeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfggtggusehgtderredttddvnecu hfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuih gvrhdrgiihiieqnecuggftrfgrthhtvghrnhepgeffkedufeeutdffteevgeduvdffvedu uefgudffgfelhfeludeghfejfeffteeinecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgs pghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlh dqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthht ohepthhglhesshhsshdrphhghhdrphgrrdhush X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 May 2026 19:38:21 -0400 (EDT) Date: Fri, 15 May 2026 08:38:17 +0900 From: Michael Paquier To: Postgres hackers Cc: Tom Lane Subject: Re-add recently-removed tests for ltree and intarray Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7vsSBdfoCKdJfOhX" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7vsSBdfoCKdJfOhX Content-Type: multipart/mixed; boundary="kykSkjIQOZ7L3M0X" Content-Disposition: inline --kykSkjIQOZ7L3M0X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, Some of you may have noticed that some regression tests have been removed due to some noise in the buildfarm, as of commit 906ea101d0d5. We did not have time to do something for this release, unfortunately. It is possible to reproduce the incompatibility by setting max_stack_depth to a low value, where the first new query of ltree and intarray would fail, when written in their original shape. Tom had the idea to switch these two unstable tests to use a balanced binary tree instead, so as they don't eat the stack still are able to cover the recent fixes pushed into the tree. And this investigation has led me to the attached, to-be-backpatched down to v14. Even under a low max_stack_depth, these new tests are stable. I could not see an issue for the two tests added at the bottom of ltree. Opinions or comments? Thanks, -- Michael --kykSkjIQOZ7L3M0X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-Re-add-regression-tests-for-ltree-and-intarray.patch Content-Transfer-Encoding: quoted-printable =46rom d11a1dc0e8dc8d4838ca81fe8d4aa935cc1ed2df Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Thu, 14 May 2026 13:40:00 +0900 Subject: [PATCH] Re-add regression tests for ltree and intarray These tests have been removed by 906ea101d0d5, due to some of them being unstable in the buildfarm with low max_stack_depth values. These tests are reworked to be more portable. The tests to cover the findoprnd() overflows use a balanced tree to avoid using too much stack, per a suggestion by Tom Lane. Backpatch-through: 14 --- contrib/intarray/expected/_int.out | 15 +++++++++++++++ contrib/intarray/sql/_int.sql | 13 +++++++++++++ contrib/ltree/expected/ltree.out | 24 ++++++++++++++++++++++++ contrib/ltree/sql/ltree.sql | 20 ++++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/contrib/intarray/expected/_int.out b/contrib/intarray/expected= /_int.out index d0e68d0447fb..fb4086a95caf 100644 --- a/contrib/intarray/expected/_int.out +++ b/contrib/intarray/expected/_int.out @@ -398,6 +398,21 @@ SELECT '1&(2&(4&(5|!6)))'::query_int; 1 & 2 & 4 & ( 5 | !6 ) (1 row) =20 +-- Test for overflow of the int16 "left" field in findoprnd(). +-- This query uses a balanced binary tree to avoid using too much stack. +DO $$ +DECLARE + e text :=3D '1'; +BEGIN + FOR i IN 1..15 LOOP + e :=3D '(' || e || '&' || e || ')'; + END LOOP; + PERFORM ('0|' || e)::query_int; +END; +$$; +ERROR: query_int expression is too complex +CONTEXT: SQL statement "SELECT ('0|' || e)::query_int" +PL/pgSQL function inline_code_block line 8 at PERFORM -- test non-error-throwing input SELECT str as "query_int", pg_input_is_valid(str,'query_int') as ok, diff --git a/contrib/intarray/sql/_int.sql b/contrib/intarray/sql/_int.sql index 5668ab407045..0d30914725e1 100644 --- a/contrib/intarray/sql/_int.sql +++ b/contrib/intarray/sql/_int.sql @@ -75,6 +75,19 @@ SELECT '1&2&4&5&6'::query_int; SELECT '1&(2&(4&(5|6)))'::query_int; SELECT '1&(2&(4&(5|!6)))'::query_int; =20 +-- Test for overflow of the int16 "left" field in findoprnd(). +-- This query uses a balanced binary tree to avoid using too much stack. +DO $$ +DECLARE + e text :=3D '1'; +BEGIN + FOR i IN 1..15 LOOP + e :=3D '(' || e || '&' || e || ')'; + END LOOP; + PERFORM ('0|' || e)::query_int; +END; +$$; + -- test non-error-throwing input =20 SELECT str as "query_int", diff --git a/contrib/ltree/expected/ltree.out b/contrib/ltree/expected/ltre= e.out index d2a566284755..15b9131a7506 100644 --- a/contrib/ltree/expected/ltree.out +++ b/contrib/ltree/expected/ltree.out @@ -1283,6 +1283,21 @@ SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'= ::ltxtquery; f (1 row) =20 +-- Test for overflow of the int16 "left" field in findoprnd(). +-- This query uses a balanced binary tree to avoid using too much stack. +DO $$ +DECLARE + e text :=3D 'a'; +BEGIN + FOR i IN 1..14 LOOP + e :=3D '(' || e || '&' || e || ')'; + END LOOP; + PERFORM ('b|' || e)::ltxtquery; +END; +$$; +ERROR: ltxtquery is too large +CONTEXT: SQL statement "SELECT ('b|' || e)::ltxtquery" +PL/pgSQL function inline_code_block line 8 at PERFORM --arrays SELECT '{1.2.3}'::ltree[] @> '1.2.3.4'; ?column?=20 @@ -8202,3 +8217,12 @@ FROM (VALUES ('.2.3', 'ltree'), !tree & aWdf@* | ltxtquery | t | | = | |=20 (8 rows) =20 +-- Test for overflow of lquery_level.totallen. +SELECT (repeat('x', 255) || repeat('|' || repeat('x', 255), 256))::lquery; +ERROR: lquery level is too large +DETAIL: Total size of level exceeds the maximum allowed (65535 bytes). +--- Test for overflow of lquery_level.numvar, with a set of single-char +--- variants in one level. +SELECT (repeat('a|', 65535) || 'a')::lquery; +ERROR: lquery level has too many variants +DETAIL: Number of variants exceeds the maximum allowed (65535). diff --git a/contrib/ltree/sql/ltree.sql b/contrib/ltree/sql/ltree.sql index 77e6958c62a7..d0fade9d17d8 100644 --- a/contrib/ltree/sql/ltree.sql +++ b/contrib/ltree/sql/ltree.sql @@ -253,6 +253,19 @@ SELECT 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquer= y; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery; =20 +-- Test for overflow of the int16 "left" field in findoprnd(). +-- This query uses a balanced binary tree to avoid using too much stack. +DO $$ +DECLARE + e text :=3D 'a'; +BEGIN + FOR i IN 1..14 LOOP + e :=3D '(' || e || '&' || e || ')'; + END LOOP; + PERFORM ('b|' || e)::ltxtquery; +END; +$$; + --arrays =20 SELECT '{1.2.3}'::ltree[] @> '1.2.3.4'; @@ -457,3 +470,10 @@ FROM (VALUES ('.2.3', 'ltree'), ('!tree & aWdf@*','ltxtquery')) AS a(str,typ), LATERAL pg_input_error_info(a.str, a.typ) as errinfo; + +-- Test for overflow of lquery_level.totallen. +SELECT (repeat('x', 255) || repeat('|' || repeat('x', 255), 256))::lquery; + +--- Test for overflow of lquery_level.numvar, with a set of single-char +--- variants in one level. +SELECT (repeat('a|', 65535) || 'a')::lquery; --=20 2.54.0 --kykSkjIQOZ7L3M0X-- --7vsSBdfoCKdJfOhX Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmoGXOkACgkQnvQgOdby QH1tyw//RDzuFXZBAzJ1TnqmiA3EBDYuJzB97G/qKiWucgiUQPda4CFz8O6UmoI9 daD7IIFlQ7LSvNgy1ju/BrXRHwvquP9DZUDua0GLuHCL24kBFQz54VhI+Ftyc0Vc CsGPvn98aLUiJ8+q4Mefi8OFRuV7MAo2B/LGsGzaK7K4XcyY7mEsOSRpglZlVAhg BCU+sEQu6g8zxPfVeupbZlrt12/+Xj+AHH3wtem2uHr3GDMf5NUAcsmp+EzSslKk 02SeNhs8yyPz8sUp9fQP+uO+Cv/ecfD04XbHiE063yMRs/aC/edCReymEqIeXetG 7jXz03WNzDwgLwrkPJuJqxiP94nAaQ/iqMieZaKntK6/isax89BJ1q6EJGZPjuIc frCNoORDOB9Wz+Ht/tycueDxjM45q2HbIRCNAUsfLyVY9Xq7CBrwkVfjZcFWQf3Q ERoPSRib9pCHXnYH0j6pMRu5FRATQTAS8qGCai7Mxb0AT1AJSUgJocNDeXNdzLL1 pN39rVoaZi2IMnh3oLlZwAlFuCLvaf+426pw5FVHz+sVEc9YReZRFuWW9uEiD2yi 9aPFqkZFCUjCCevsT1SMzigPCLTo36NhECQLlYMIN2P/qLwTisfRwTCZtZDQeylX RsIeKOQS1nnSBDlx7t5LnHBYV6L1Mbh998mL9BQd95rFV3DYdDE= =zzq3 -----END PGP SIGNATURE----- --7vsSBdfoCKdJfOhX--