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 1viDGv-000jqf-17 for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2026 15:03:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1viDGu-001SEa-1P for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2026 15:03:56 +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 1viDGu-001SES-0P for pgsql-bugs@lists.postgresql.org; Tue, 20 Jan 2026 15:03:56 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1viDGr-001XZt-2H for pgsql-bugs@lists.postgresql.org; Tue, 20 Jan 2026 15:03:55 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4801d7c72a5so29213665e9.0 for ; Tue, 20 Jan 2026 07:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768921432; x=1769526232; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=/gsHYLRx2YeBsV3D4WskiSHNeOftUt2oOAppDGN9EyI=; b=Za+CyNAq/VwrdUabgR9RzcICsPfzNeU/lSmNIaNwU5ws2g+G7xGRh0cP69E9wk1flz HPSBVzUjZvuwrsZkQgyZdtHM7b7/6mmRghkekGRvOlzCk3vW5aun89gVX+tMJHhcbKiN 1ivhzbF7pnN7Ghffevo0LFvzjrDrYj6m6NVwG1pMjxJ9vlUgDcsa/Jy2wTvO/ASvC7ne DajJAOwNRugj7kJVz2L9KFOoHXcZyXVvIt0Cvx8DWMldIhE8D1gFV5WpqQB4jMObmD9q q1QMHuXHXOpL8hTA/CJqoqbfFAwK+I//yP45wbkZ576snTjcvxr0q47jwJ/5/JVb3Ure Z8Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768921432; x=1769526232; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/gsHYLRx2YeBsV3D4WskiSHNeOftUt2oOAppDGN9EyI=; b=oWUdUv+iLYc+eXE/zrslgH+y+zs0PsAhyIbv1ptjpUCbAQScMo5LyFR3FAFqcFl3se 8h6DIQgoXMuQVl4tn+V+gJ2fVbyEmEMORACy9Kce5QCqjcvem4hFsEtVW27eXBB252r9 sze5wk4CF3Fvyq0nVC8P5ThiojRvmGVDPWndgtQcNN1M6vNoZ1C1R9TE3JbHD+BMvNsu CpaNVKWFI9AduurOZ+cQZ69K6GKp9IcyLis8P5vhq4KaqdkCWoPL0N41AW2O5Btarw0p w20/QnFjAODwcQKOhlGv9BMXlwAMXk3CqAZea3uS21IpYxD3wbaLrsivDl5Q7RWyAxmQ zeSQ== X-Forwarded-Encrypted: i=1; AJvYcCWe9TxeZG22SQYfDDjGIaAOkHDhoxxun6HB7rZNgrN0lEsCWExE4XzppeFdyohV5J2RvZDpmcfaU9N6@lists.postgresql.org X-Gm-Message-State: AOJu0Yxx6W1LOJOs5fTBT2Lf5S3laxAuEoAGKnvY0MnzDp7Nec9op+2m xyOe98rPFjdKRDnAuuFSnmnCpESN1/gX8ub0J04bQTqBFASlNhmJhRZ1QSMs9w== X-Gm-Gg: AY/fxX5lfcRuc9FkTFgQSyDpy2mwfY68BG7fjYfSzFkRxugz1A7LKwsuPu46SW1Z18C YKOY6e43pCywV69R5xi3MN6lkCb2Y1fpT2oNxNpgvcIE0IVJnGatop/Ny0VLihG5EIfpnl02/jJ gqSwgP2sVMgpoo8qkUZKT4GGhKwgcm6lgZT0CbfaAiNOIeHnDdUznjKPXRIsCXb7heepS0uraJF wcp89E02BxPruc6pT9QirdFwxJGLSDPRHv6JasX7EjK5it+SPkJ/tu9+XuVTdxTa/3axPGTJnut hcWhvSeQHiB5LYM9+4N8G4s3x3RFYPxZ+EYAda9XuE22tx9Khc4W9iTxSP9wvo0eRu9f4GYeT4c BXDR+gchyl/l/lh5x9a7hFFyKQ8aep6i7TyOW9WMTOzCuAC0m8SsOXxXEj82WCCkpSPWOQXGFv2 TzaB2LEdhnmk5m68Q8RDNgEYZwRd1q2lr9aV4a3FkQK0ZflshNaNaMaXBn1NF7JQ== X-Received: by 2002:a05:600c:a03:b0:45d:dc85:c009 with SMTP id 5b1f17b1804b1-4803d88aa32mr38030365e9.10.1768921431796; Tue, 20 Jan 2026 07:03:51 -0800 (PST) Received: from ?IPV6:2a01:e0a:22d:4d0:1ac0:4dff:fe8b:a3c7? ([2a01:e0a:22d:4d0:1ac0:4dff:fe8b:a3c7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47f4289b789sm309336985e9.1.2026.01.20.07.03.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jan 2026 07:03:51 -0800 (PST) Content-Type: multipart/alternative; boundary="------------Ja7oocFGt09K2g0e0s58CnEJ" Message-ID: <8f46de9a-f292-425a-af5e-50ae1a9979ce@gmail.com> Date: Tue, 20 Jan 2026 16:03:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19384: Server crash at textout To: Rahila Syed , dllggyx@outlook.com, pgsql-bugs@lists.postgresql.org References: <19384-65ff412feef17f06@postgresql.org> Content-Language: en-US From: Pierre Forstmann In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Ja7oocFGt09K2g0e0s58CnEJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit I can also reproduce with 18.1. But if type foo is used in a table, type foo cannot be modified: DROP TYPE IF EXISTS foo CASCADE; psql:bug4.sql:1: NOTICE:  drop cascades to column c of table bar DROP TYPE DROP TABLE if EXISTS bar CASCADE; DROP TABLE CREATE TYPE foo AS (a INT, b INT); CREATE TYPE CREATE TABLE bar(c foo); CREATE TABLE BEGIN; BEGIN INSERT into bar SELECT (i, power(2, 30))::foo FROM generate_series(1,10) i; INSERT 0 10 ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT; psql:bug4.sql:8: ERROR:  cannot alter type "foo" because column "bar.c" uses it Should PG allow to modify a type if this type is used to cast a SELECT list column in the same transaction ? Le 20/01/2026 à 12:15, Rahila Syed a écrit : > Hi, > > On Tue, Jan 20, 2026 at 2:29 PM PG Bug reporting form > wrote: > > The following bug has been logged on the website: > > Bug reference:      19384 > Logged by:          Yuxiao Guo > Email address: dllggyx@outlook.com > PostgreSQL version: 17.7 > Operating system:   Ubuntu 20.04 x86-64, docker image postgres:17.7 > Description: > > Hi, I found a crash in PostgreSQL. Here are the details: > > PoC: > DROP TYPE IF EXISTS foo CASCADE; > CREATE TYPE foo AS (a INT, b INT); > BEGIN; > DECLARE c CURSOR FOR SELECT (i, power(2, 30))::foo FROM > generate_series(1,10) i; > FETCH c; > ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT; > FETCH c; > > > Stacktrace: > #0 0x7ae1c818a00b (gsignal+0xcb) > #1 0x7ae1c8169859 (abort+0x12b) > #2 0x542fa7 (_ZN11__sanitizer5AbortEv+0x47) > #3 0x5414d1 (_ZN11__sanitizer3DieEv+0xc1) > #4 0x528a14 (_ZN6__asan19ScopedInErrorReportD2Ev+0x1c4) > #5 0x52a5da (_ZN6__asan18ReportGenericErrorEmmmmbmjb+0x5ba) > #6 0x523ef6 (__asan_memcpy+0x1d6) > #7 0x17772d5 (textout+0x1b5) > #8 0x1835834 (OutputFunctionCall+0x174) > #9 0x167a568 (record_out+0x828) > #10 0x1835834 (OutputFunctionCall+0x174) > #11 0x595848 (printtup+0x958) > #12 0x1336280 (RunFromStore+0x1d0) > #13 0x1333ec0 (PortalRunSelect+0x150) > #14 0x133321d (PortalRun+0x51d) > #15 0x132f1de (exec_simple_query+0x146e) > #16 0x1328627 (PostgresMain+0x2c57) > #17 0x13192e4 (BackendMain+0xe4) > #18 0x10a26c3 (postmaster_child_launch+0x193) > #19 0x10adb91 (ServerLoop+0x4821) > #20 0x10a76ec (PostmasterMain+0x241c) > #21 0xd5c2b8 (main+0x458) > #22 0x7ae1c816b083 (__libc_start_main+0xf3) > #23 0x4a9c6e (_start+0x2e) > > > > This problem is reproducible, also the issue seems to be linked to cursors > since the type cast with only SELECT statements runs fine. > > CREATE TYPE foo AS (a INT, b INT); > ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT; > > postgres=# SELECT (i, power(2, 30))::foo FROM > generate_series(1,10) i; >        row > ----------------- >  (1,1073741824) >  (2,1073741824) >  (3,1073741824) >  (4,1073741824) >  (5,1073741824) >  (6,1073741824) >  (7,1073741824) >  (8,1073741824) >  (9,1073741824) >  (10,1073741824) > (10 rows) > > Also, it happens only  if ALTER TYPE to TEXT is run after DECLARING > the cursor. > > Another observation is that when I lower the exponent to 10, the crash > no longer occurs, > but the output is different. > > CREATE TYPE foo AS (a INT, b INT); > BEGIN; > DECLARE c CURSOR FOR SELECT (i, power(2, 10))::foo FROM > generate_series(1,10) i; > DECLARE CURSOR > FETCH c; >    row > ---------- >  (1,1024) > (1 row) > > ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT; > FETCH c; >    row > ---------- >  (2,\x10) > (1 row) > > Thank you, > Rahila Syed > --------------Ja7oocFGt09K2g0e0s58CnEJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

I can also reproduce with 18.1.

But if type foo is used in a table, type foo cannot be modified:

DROP TYPE IF EXISTS foo CASCADE;
psql:bug4.sql:1: NOTICE:  drop cascades to column c of table bar
DROP TYPE
DROP TABLE if EXISTS bar CASCADE;
DROP TABLE
CREATE TYPE foo AS (a INT, b INT);
CREATE TYPE
CREATE TABLE bar(c foo);
CREATE TABLE
BEGIN;
BEGIN
INSERT into bar SELECT (i, power(2, 30))::foo FROM generate_series(1,10) i;
INSERT 0 10
ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT;
psql:bug4.sql:8: ERROR:  cannot alter type "foo" because column "bar.c" uses it

Should PG allow to modify a type if this type is used to cast a SELECT list column in the same transaction ?


Le 20/01/2026 à 12:15, Rahila Syed a écrit :
Hi,

On Tue, Jan 20, 2026 at 2:29 PM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      19384
Logged by:          Yuxiao Guo
Email address:      dllggyx@outlook.com
PostgreSQL version: 17.7
Operating system:   Ubuntu 20.04 x86-64, docker image postgres:17.7
Description:       

Hi, I found a crash in PostgreSQL. Here are the details:

PoC:
DROP TYPE IF EXISTS foo CASCADE;
CREATE TYPE foo AS (a INT, b INT);
BEGIN;
DECLARE c CURSOR FOR SELECT (i, power(2, 30))::foo FROM
generate_series(1,10) i;
FETCH c;
ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT;
FETCH c;


Stacktrace:
#0 0x7ae1c818a00b (gsignal+0xcb)
#1 0x7ae1c8169859 (abort+0x12b)
#2 0x542fa7 (_ZN11__sanitizer5AbortEv+0x47)
#3 0x5414d1 (_ZN11__sanitizer3DieEv+0xc1)
#4 0x528a14 (_ZN6__asan19ScopedInErrorReportD2Ev+0x1c4)
#5 0x52a5da (_ZN6__asan18ReportGenericErrorEmmmmbmjb+0x5ba)
#6 0x523ef6 (__asan_memcpy+0x1d6)
#7 0x17772d5 (textout+0x1b5)
#8 0x1835834 (OutputFunctionCall+0x174)
#9 0x167a568 (record_out+0x828)
#10 0x1835834 (OutputFunctionCall+0x174)
#11 0x595848 (printtup+0x958)
#12 0x1336280 (RunFromStore+0x1d0)
#13 0x1333ec0 (PortalRunSelect+0x150)
#14 0x133321d (PortalRun+0x51d)
#15 0x132f1de (exec_simple_query+0x146e)
#16 0x1328627 (PostgresMain+0x2c57)
#17 0x13192e4 (BackendMain+0xe4)
#18 0x10a26c3 (postmaster_child_launch+0x193)
#19 0x10adb91 (ServerLoop+0x4821)
#20 0x10a76ec (PostmasterMain+0x241c)
#21 0xd5c2b8 (main+0x458)
#22 0x7ae1c816b083 (__libc_start_main+0xf3)
#23 0x4a9c6e (_start+0x2e)



This problem is reproducible, also the issue seems to be linked to cursors
since the type cast with only SELECT statements runs fine.

CREATE TYPE foo AS (a INT, b INT);
ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT;

postgres=# SELECT (i, power(2, 30))::foo FROM
generate_series(1,10) i;
       row
-----------------
 (1,1073741824)
 (2,1073741824)
 (3,1073741824)
 (4,1073741824)
 (5,1073741824)
 (6,1073741824)
 (7,1073741824)
 (8,1073741824)
 (9,1073741824)
 (10,1073741824)
(10 rows)

Also, it happens only  if ALTER TYPE to TEXT is run after DECLARING the cursor.

Another observation is that when I lower the exponent to 10, the crash no longer occurs,
but the output is different.

CREATE TYPE foo AS (a INT, b INT);
BEGIN;
DECLARE c CURSOR FOR SELECT (i, power(2, 10))::foo FROM
generate_series(1,10) i;
DECLARE CURSOR
FETCH c;
   row
----------
 (1,1024)
(1 row)

ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT;
FETCH c;
   row
----------
 (2,\x10)
(1 row)

Thank you,
Rahila Syed

--------------Ja7oocFGt09K2g0e0s58CnEJ--