BUG #17706: ALTER TYPE leads to crash - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17706: ALTER TYPE leads to crash
Date
Msg-id 17706-fa10a46c1ac9ce5a@postgresql.org
Whole thread Raw
Responses Re: BUG #17706: ALTER TYPE leads to crash
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17706
Logged by:          Sergey Shinderuk
Email address:      s.shinderuk@postgrespro.ru
PostgreSQL version: 15.1
Operating system:   Ubuntu 22.04
Description:

With PL/pgSQL:

create type foo as (a int, b int);

create function bar() returns record as $$
declare
        r foo := row(123, 2^30);
begin
        alter type foo alter attribute b type text;
        return r;
end;
$$ language plpgsql;

postgres=# select bar();
server closed the connection unexpectedly
  This probably means the server terminated abnormally
  before or while processing the request.

LOG:  server process (PID 394076) was terminated by signal 11: Segmentation
fault

(Here 2^30 is interpreted as a string length.)


With a cursor:

postgres=# create type foo as (a int, b int);
CREATE TYPE
postgres=# begin;
BEGIN
postgres=*# declare c cursor for select (i, 2^30)::foo from
generate_series(1,10) i;
DECLARE CURSOR
postgres=*# fetch c;
      row       
----------------
 (1,1073741824)
(1 row)

postgres=*# fetch c;
      row       
----------------
 (2,1073741824)
(1 row)

postgres=*# alter type foo alter attribute b type text;
ALTER TYPE
postgres=*# fetch c;
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.


pgsql-bugs by date:

Previous
From: Jeff Davis
Date:
Subject: Re: CREATE COLLATION without LOCALE throws error in v15
Next
From: "David G. Johnston"
Date:
Subject: Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling