mirror of
https://github.com/postgres/postgres.git
synced 2026-05-27 12:00:13 -04:00
Re-add regression tests for ltree and intarray
These tests have been removed by 906ea101d0, due to some of them being
unstable in the buildfarm with low max_stack_depth values. They are now
reworked so as they should be more portable.
The tests to cover the findoprnd() overflows use a balanced tree to
avoid using too much stack, per a suggestion and an investigation by Tom
Lane.
Note: This is initially applied only on HEAD; a backpatch will follow
should the buildfarm be fine with the situation.
Discussion: https://postgr.es/m/agZc6XecyE7E7fep@paquier.xyz
Backpatch-through: 14
This commit is contained in:
parent
6b4de201e8
commit
a6c430cabe
4 changed files with 72 additions and 0 deletions
|
|
@ -398,6 +398,21 @@ SELECT '1&(2&(4&(5|!6)))'::query_int;
|
|||
1 & 2 & 4 & ( 5 | !6 )
|
||||
(1 row)
|
||||
|
||||
-- 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 := '1';
|
||||
BEGIN
|
||||
FOR i IN 1..15 LOOP
|
||||
e := '(' || 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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
-- 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 := '1';
|
||||
BEGIN
|
||||
FOR i IN 1..15 LOOP
|
||||
e := '(' || e || '&' || e || ')';
|
||||
END LOOP;
|
||||
PERFORM ('0|' || e)::query_int;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- test non-error-throwing input
|
||||
|
||||
SELECT str as "query_int",
|
||||
|
|
|
|||
|
|
@ -1281,6 +1281,21 @@ SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery;
|
|||
f
|
||||
(1 row)
|
||||
|
||||
-- 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 := 'a';
|
||||
BEGIN
|
||||
FOR i IN 1..14 LOOP
|
||||
e := '(' || 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?
|
||||
|
|
@ -8200,3 +8215,12 @@ FROM (VALUES ('.2.3', 'ltree'),
|
|||
!tree & aWdf@* | ltxtquery | t | | | |
|
||||
(8 rows)
|
||||
|
||||
-- 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).
|
||||
|
|
|
|||
|
|
@ -252,6 +252,19 @@ SELECT 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquery;
|
|||
SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery;
|
||||
SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery;
|
||||
|
||||
-- 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 := 'a';
|
||||
BEGIN
|
||||
FOR i IN 1..14 LOOP
|
||||
e := '(' || e || '&' || e || ')';
|
||||
END LOOP;
|
||||
PERFORM ('b|' || e)::ltxtquery;
|
||||
END;
|
||||
$$;
|
||||
|
||||
--arrays
|
||||
|
||||
SELECT '{1.2.3}'::ltree[] @> '1.2.3.4';
|
||||
|
|
@ -456,3 +469,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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue