BUG #17056: Segmentation fault on altering the type of the foreign table column with a default - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17056: Segmentation fault on altering the type of the foreign table column with a default
Date
Msg-id 17056-4f6f7243d322be6b@postgresql.org
Whole thread Raw
Responses Re: BUG #17056: Segmentation fault on altering the type of the foreign table column with a default  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17056
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 14beta1
Operating system:   Ubuntu 20.04
Description:

When executing the following query (based on excerpt from
foreign_data.sql):

CREATE FOREIGN DATA WRAPPER dummy;
CREATE SERVER s0 FOREIGN DATA WRAPPER dummy;
CREATE FOREIGN TABLE ft1 (c1 integer NOT NULL) SERVER s0;
ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer DEFAULT 0;
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10);

The server crashes with the stack trace:

Core was generated by `postgres: law regression [local] ALTER FOREIGN TABLE
                        '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  pg_detoast_datum (datum=0x0) at fmgr.c:1724
1724            if (VARATT_IS_EXTENDED(datum))
(gdb) bt
#0  pg_detoast_datum (datum=0x0) at fmgr.c:1724
#1  0x000055f03f919267 in construct_md_array
(elems=elems@entry=0x7ffc24b6c3f0, nulls=nulls@entry=0x0, 
    ndims=ndims@entry=1, dims=dims@entry=0x7ffc24b6c340,
lbs=lbs@entry=0x7ffc24b6c344, elmtype=elmtype@entry=1042, 
    elmlen=-1, elmbyval=false, elmalign=105 'i') at arrayfuncs.c:3397
#2  0x000055f03f91952f in construct_array (elems=elems@entry=0x7ffc24b6c3f0,
nelems=nelems@entry=1, 
    elmtype=elmtype@entry=1042, elmlen=<optimized out>, elmbyval=<optimized
out>, elmalign=<optimized out>)
    at arrayfuncs.c:3328
#3  0x000055f03f6f3db7 in ATExecAlterColumnType (tab=0x7ffc24b6c400,
tab@entry=0x55f03ff27a20, 
    rel=rel@entry=0x7f2035994618, cmd=<optimized out>,
lockmode=lockmode@entry=8) at tablecmds.c:12276
#4  0x000055f03f705f24 in ATExecCmd (wqueue=wqueue@entry=0x7ffc24b6c700,
tab=tab@entry=0x55f03ff27a20, 
    cmd=<optimized out>, lockmode=lockmode@entry=8,
cur_pass=cur_pass@entry=1, context=context@entry=0x7ffc24b6c810)
    at tablecmds.c:4985
#5  0x000055f03f7063bb in ATRewriteCatalogs
(wqueue=wqueue@entry=0x7ffc24b6c700, lockmode=lockmode@entry=8, 
    context=context@entry=0x7ffc24b6c810) at
../../../src/include/nodes/nodes.h:604
#6  0x000055f03f706618 in ATController
(parsetree=parsetree@entry=0x55f03fe163d8, rel=rel@entry=0x7f2035994618, 
    cmds=0x55f03fe163a0, recurse=true, lockmode=lockmode@entry=8,
context=context@entry=0x7ffc24b6c810)
    at tablecmds.c:4376
#7  0x000055f03f7066a2 in AlterTable (stmt=stmt@entry=0x55f03fe163d8,
lockmode=lockmode@entry=8, 
    context=context@entry=0x7ffc24b6c810) at tablecmds.c:4023
#8  0x000055f03f8f7d47 in ProcessUtilitySlow
(pstate=pstate@entry=0x55f03ff278b0, pstmt=pstmt@entry=0x55f03fe166e8, 
    queryString=queryString@entry=0x55f03fe15690 "ALTER FOREIGN TABLE ft1
ALTER COLUMN c8 TYPE char(10);", 
    context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=params@entry=0x0,
queryEnv=queryEnv@entry=0x0, 
    dest=0x55f03fe167b8, qc=0x7ffc24b6cd20) at utility.c:1284
#9  0x000055f03f8f77bf in standard_ProcessUtility (pstmt=0x55f03fe166e8, 
    queryString=0x55f03fe15690 "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE
char(10);", 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x55f03fe167b8, qc=0x7ffc24b6cd20)
    at utility.c:1034
#10 0x000055f03f8f789e in ProcessUtility (pstmt=pstmt@entry=0x55f03fe166e8,
queryString=<optimized out>, 
    context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=<optimized out>,
queryEnv=<optimized out>, 
    dest=dest@entry=0x55f03fe167b8, qc=0x7ffc24b6cd20) at utility.c:525
#11 0x000055f03f8f3c65 in PortalRunUtility
(portal=portal@entry=0x55f03fe790f0, pstmt=pstmt@entry=0x55f03fe166e8, 
    isTopLevel=isTopLevel@entry=true,
setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x55f03fe167b8,

    qc=qc@entry=0x7ffc24b6cd20) at pquery.c:1159
#12 0x000055f03f8f48c0 in PortalRunMulti
(portal=portal@entry=0x55f03fe790f0, isTopLevel=isTopLevel@entry=true, 
    setHoldSnapshot=setHoldSnapshot@entry=false,
dest=dest@entry=0x55f03fe167b8, altdest=altdest@entry=0x55f03fe167b8, 
    qc=qc@entry=0x7ffc24b6cd20) at pquery.c:1305
#13 0x000055f03f8f559b in PortalRun (portal=portal@entry=0x55f03fe790f0,
count=count@entry=9223372036854775807, 
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true,
dest=dest@entry=0x55f03fe167b8, 
    altdest=altdest@entry=0x55f03fe167b8, qc=0x7ffc24b6cd20) at
pquery.c:779
#14 0x000055f03f8f1825 in exec_simple_query (
    query_string=query_string@entry=0x55f03fe15690 "ALTER FOREIGN TABLE ft1
ALTER COLUMN c8 TYPE char(10);")
    at postgres.c:1214
#15 0x000055f03f8f37f7 in PostgresMain (argc=argc@entry=1,
argv=argv@entry=0x7ffc24b6cf10, dbname=<optimized out>, 
    username=<optimized out>) at postgres.c:4486
#16 0x000055f03f84ee79 in BackendRun (port=port@entry=0x55f03fe36d20) at
postmaster.c:4491
#17 0x000055f03f852008 in BackendStartup (port=port@entry=0x55f03fe36d20) at
postmaster.c:4213
#18 0x000055f03f85224f in ServerLoop () at postmaster.c:1745
#19 0x000055f03f85379c in PostmasterMain (argc=3, argv=<optimized out>) at
postmaster.c:1417
#20 0x000055f03f7949f9 in main (argc=3, argv=0x55f03fe0f950) at main.c:209


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_table_size errors "invalid name syntax" for table names containing spaces
Next
From: PG Bug reporting form
Date:
Subject: BUG #17057: Unexpected error: ERROR: unsupported target type: 0