BUG #17056: Segmentation fault on altering the type of the foreign table column with a default

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #17056: Segmentation fault on altering the type of the foreign table column with a default
Date: 2021-06-10 20:00:01
Message-ID: 17056-4f6f7243d322be6b@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

The following bug has been logged on the website:

Bug reference: 17056
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)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(at)entry=0x7ffc24b6c3f0, nulls=nulls(at)entry=0x0,
ndims=ndims(at)entry=1, dims=dims(at)entry=0x7ffc24b6c340,
lbs=lbs(at)entry=0x7ffc24b6c344, elmtype=elmtype(at)entry=1042,
elmlen=-1, elmbyval=false, elmalign=105 'i') at arrayfuncs.c:3397
#2 0x000055f03f91952f in construct_array (elems=elems(at)entry=0x7ffc24b6c3f0,
nelems=nelems(at)entry=1,
elmtype=elmtype(at)entry=1042, elmlen=<optimized out>, elmbyval=<optimized
out>, elmalign=<optimized out>)
at arrayfuncs.c:3328
#3 0x000055f03f6f3db7 in ATExecAlterColumnType (tab=0x7ffc24b6c400,
tab(at)entry=0x55f03ff27a20,
rel=rel(at)entry=0x7f2035994618, cmd=<optimized out>,
lockmode=lockmode(at)entry=8) at tablecmds.c:12276
#4 0x000055f03f705f24 in ATExecCmd (wqueue=wqueue(at)entry=0x7ffc24b6c700,
tab=tab(at)entry=0x55f03ff27a20,
cmd=<optimized out>, lockmode=lockmode(at)entry=8,
cur_pass=cur_pass(at)entry=1, context=context(at)entry=0x7ffc24b6c810)
at tablecmds.c:4985
#5 0x000055f03f7063bb in ATRewriteCatalogs
(wqueue=wqueue(at)entry=0x7ffc24b6c700, lockmode=lockmode(at)entry=8,
context=context(at)entry=0x7ffc24b6c810) at
../../../src/include/nodes/nodes.h:604
#6 0x000055f03f706618 in ATController
(parsetree=parsetree(at)entry=0x55f03fe163d8, rel=rel(at)entry=0x7f2035994618,
cmds=0x55f03fe163a0, recurse=true, lockmode=lockmode(at)entry=8,
context=context(at)entry=0x7ffc24b6c810)
at tablecmds.c:4376
#7 0x000055f03f7066a2 in AlterTable (stmt=stmt(at)entry=0x55f03fe163d8,
lockmode=lockmode(at)entry=8,
context=context(at)entry=0x7ffc24b6c810) at tablecmds.c:4023
#8 0x000055f03f8f7d47 in ProcessUtilitySlow
(pstate=pstate(at)entry=0x55f03ff278b0, pstmt=pstmt(at)entry=0x55f03fe166e8,
queryString=queryString(at)entry=0x55f03fe15690 "ALTER FOREIGN TABLE ft1
ALTER COLUMN c8 TYPE char(10);",
context=context(at)entry=PROCESS_UTILITY_TOPLEVEL, params=params(at)entry=0x0,
queryEnv=queryEnv(at)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(at)entry=0x55f03fe166e8,
queryString=<optimized out>,
context=context(at)entry=PROCESS_UTILITY_TOPLEVEL, params=<optimized out>,
queryEnv=<optimized out>,
dest=dest(at)entry=0x55f03fe167b8, qc=0x7ffc24b6cd20) at utility.c:525
#11 0x000055f03f8f3c65 in PortalRunUtility
(portal=portal(at)entry=0x55f03fe790f0, pstmt=pstmt(at)entry=0x55f03fe166e8,
isTopLevel=isTopLevel(at)entry=true,
setHoldSnapshot=setHoldSnapshot(at)entry=false, dest=dest(at)entry=0x55f03fe167b8,

qc=qc(at)entry=0x7ffc24b6cd20) at pquery.c:1159
#12 0x000055f03f8f48c0 in PortalRunMulti
(portal=portal(at)entry=0x55f03fe790f0, isTopLevel=isTopLevel(at)entry=true,
setHoldSnapshot=setHoldSnapshot(at)entry=false,
dest=dest(at)entry=0x55f03fe167b8, altdest=altdest(at)entry=0x55f03fe167b8,
qc=qc(at)entry=0x7ffc24b6cd20) at pquery.c:1305
#13 0x000055f03f8f559b in PortalRun (portal=portal(at)entry=0x55f03fe790f0,
count=count(at)entry=9223372036854775807,
isTopLevel=isTopLevel(at)entry=true, run_once=run_once(at)entry=true,
dest=dest(at)entry=0x55f03fe167b8,
altdest=altdest(at)entry=0x55f03fe167b8, qc=0x7ffc24b6cd20) at
pquery.c:779
#14 0x000055f03f8f1825 in exec_simple_query (
query_string=query_string(at)entry=0x55f03fe15690 "ALTER FOREIGN TABLE ft1
ALTER COLUMN c8 TYPE char(10);")
at postgres.c:1214
#15 0x000055f03f8f37f7 in PostgresMain (argc=argc(at)entry=1,
argv=argv(at)entry=0x7ffc24b6cf10, dbname=<optimized out>,
username=<optimized out>) at postgres.c:4486
#16 0x000055f03f84ee79 in BackendRun (port=port(at)entry=0x55f03fe36d20) at
postmaster.c:4491
#17 0x000055f03f852008 in BackendStartup (port=port(at)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-06-10 21:46:10 BUG #17057: Unexpected error: ERROR: unsupported target type: 0
Previous Message Tom Lane 2021-06-10 13:43:37 Re: pg_table_size errors "invalid name syntax" for table names containing spaces

Browse pgsql-hackers by date

  From Date Subject
Next Message Gavin Flower 2021-06-10 20:10:49 Re: "an SQL" vs. "a SQL"
Previous Message Dean Gibson (DB Administrator) 2021-06-10 19:29:05 Re: AWS forcing PG upgrade from v9.6 a disaster