BUG #18492: Adding a toasted column to a table with an inherited temp table fails with Assert - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18492: Adding a toasted column to a table with an inherited temp table fails with Assert
Date
Msg-id 18492-c7a2634bf4968763@postgresql.org
Whole thread Raw
Responses Re: BUG #18492: Adding a toasted column to a table with an inherited temp table fails with Assert
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18492
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 17beta1
Operating system:   Ubuntu 22.04
Description:

The following script:
echo "CREATE TABLE t (a int);" | psql

echo "
CREATE TEMP TABLE tt() INHERITS (t);
select pg_sleep(1);
" | psql &

echo "
select pg_sleep(0.1);
ALTER TABLE t ADD COLUMN b text;
" | psql

triggers an assertion failure with the following stack trace:
TRAP: failed Assert("isTempOrTempToastNamespace(relnamespace)"), File:
"relcache.c", Line: 3619, PID: 1339672
...
#5  0x0000563cd5a466f0 in ExceptionalCondition (conditionName=0x563cd5c9eac8
"isTempOrTempToastNamespace(relnamespace)", fileName=0x563cd5c9e0c8
"relcache.c", lineNumber=3619) at assert.c:66
#6  0x0000563cd5a35131 in RelationBuildLocalRelation (relname=0x7ffc531aff20
"pg_toast_16390", relnamespace=99, tupDesc=0x563cd7622258, relid=16395,
accessmtd=2, relfilenumber=16395, reltablespace=0, shared_relation=false, 
    mapped_relation=false, relpersistence=116 't', relkind=116 't') at
relcache.c:3619
#7  0x0000563cd53bcfc3 in heap_create (relname=0x7ffc531aff20
"pg_toast_16390", relnamespace=99, reltablespace=0, relid=16395,
relfilenumber=16395, accessmtd=2, tupDesc=0x563cd7622258, relkind=116 't',
relpersistence=116 't', 
    shared_relation=false, mapped_relation=false,
allow_system_table_mods=true, relfrozenxid=0x7ffc531afd7c,
relminmxid=0x7ffc531afd80, create_storage=true) at heap.c:367
#8  0x0000563cd53beedc in heap_create_with_catalog (relname=0x7ffc531aff20
"pg_toast_16390", relnamespace=99, reltablespace=0, relid=16395,
reltypeid=0, reloftypeid=0, ownerid=10, accessmtd=2, tupdesc=0x563cd7622258,

    cooked_constraints=0x0, relkind=116 't', relpersistence=116 't',
shared_relation=false, mapped_relation=false, oncommit=ONCOMMIT_NOOP,
reloptions=0, use_user_acl=false, allow_system_table_mods=true,
is_internal=true, relrewrite=0, 
    typaddress=0x0) at heap.c:1288
#9  0x0000563cd5400bfa in create_toast_table (rel=0x7f4c7090c878,
toastOid=0, toastIndexOid=0, reloptions=0, lockmode=8, check=true,
OIDOldToast=0) at toasting.c:246
#10 0x0000563cd54006e2 in CheckAndCreateToastTable (relOid=16390,
reloptions=0, lockmode=8, check=true, OIDOldToast=0) at toasting.c:85
#11 0x0000563cd540060f in AlterTableCreateToastTable (relOid=16390,
reloptions=0, lockmode=8) at toasting.c:59
#12 0x0000563cd550a8d9 in ATRewriteCatalogs (wqueue=0x7ffc531b0108,
lockmode=8, context=0x7ffc531b0300) at tablecmds.c:5180
#13 0x0000563cd5509910 in ATController (parsetree=0x563cd752a140,
rel=0x7f4c70909218, cmds=0x563cd752a0f0, recurse=true, lockmode=8,
context=0x7ffc531b0300) at tablecmds.c:4709
#14 0x0000563cd5509500 in AlterTable (stmt=0x563cd752a140, lockmode=8,
context=0x7ffc531b0300) at tablecmds.c:4347
#15 0x0000563cd5850f94 in ProcessUtilitySlow (pstate=0x563cd7553910,
pstmt=0x563cd752a1f0, queryString=0x563cd75294d0 "ALTER TABLE t ADD COLUMN b
text;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x563cd752a5b0, 
    qc=0x7ffc531b0960) at utility.c:1318
#16 0x0000563cd5850852 in standard_ProcessUtility (pstmt=0x563cd752a1f0,
queryString=0x563cd75294d0 "ALTER TABLE t ADD COLUMN b text;",
readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0,
queryEnv=0x0, 
    dest=0x563cd752a5b0, qc=0x7ffc531b0960) at utility.c:1067
#17 0x0000563cd584f752 in ProcessUtility (pstmt=0x563cd752a1f0,
queryString=0x563cd75294d0 "ALTER TABLE t ADD COLUMN b text;",
readOnlyTree=false, context=PROCESS_UTILITY_TOPLEVEL, params=0x0,
queryEnv=0x0, dest=0x563cd752a5b0, 
    qc=0x7ffc531b0960) at utility.c:523
...

Without asserts enabled, the ALTER TABLE ends up with:
ERROR:  could not open file "base/16384/16396": No such file or directory


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Missing semicolumn in anonymous plpgsql block does not raise syntax error
Next
From: "Haifang Wang (Centific Technologies Inc)"
Date:
Subject: RE: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607