pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: daidewei@highgo.com <daidewei@highgo.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: a plpgsql bug
Date: Tue, 19 Sep 2023 10:59:07 +0800
Message-ID: <202309191058550158453@highgo.com> (raw)

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


Attachments:

Catch.jpg (image/jpeg, 89.4K) download view image

view thread (5+ messages)  latest in thread

Message-ID: <202309191058550158453@highgo.com>
Permalink:  ../202309191058550158453@highgo.com/
Also on:    postgresql.org/message-id/202309191058550158453@highgo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: daidewei@highgo.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: a plpgsql bug
  In-Reply-To: <202309191058550158453@highgo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox