a plpgsql bug - Mailing list pgsql-bugs

From daidewei@highgo.com
Subject a plpgsql bug
Date
Msg-id 202309191058550158453@highgo.com
Whole thread Raw
Responses Re: a plpgsql bug
List pgsql-bugs
hello!
    I found a problem in plpgsql. When there is a large loop in plpgsql, it is found that the change of search_path will cause memory exhaustion and thus disconnect the connection.
  The test examples are as follows:

1 create a schema
create schema test_schema;
2 create a function create or replace function test_schema.test_f(id integer) returns integer as $$ declare var2 integer := 1; begin if id % 4 = 1 then return var2 + 2; elseif id % 4 = 2 then return var2 + 3; elseif id % 4 = 3 then return var2 + 4; else return var2; end if; end; $$ language plpgsql;
3 a loop in plpgsql,which wil result disconnection. do $$ declare var1 integer; begin for id in 1 .. 10000000 LOOP set search_path to test_schema; var1 = test_schema.test_f(id); set search_path to public; var1 = test_schema.test_f(id); end loop; end; $$ language plpgsql;



daidewei@highgo.com
Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #18070: Assertion failed when processing error from plpy's iterator
Next
From: Philip Muturura
Date:
Subject: Re: Installing PostgreSQL 16 on FreeBSD 13.0