Re: Large expressions in indexes can't be stored (non-TOASTable) - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: Large expressions in indexes can't be stored (non-TOASTable)
Date
Msg-id a97d7401-e7c9-f771-6a00-037379f0a8bb@gmail.com
Whole thread Raw
In response to Re: Large expressions in indexes can't be stored (non-TOASTable)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello Nathan,

18.09.2024 22:52, Nathan Bossart wrote:
Committed.  I waffled on whether to add a test for system indexes that used
pg_index's varlena columns, but I ended up leaving it out.  I've attached
it here in case anyone thinks we should add it.

I've discovered that Jonathan's initial script:
CREATE TABLE def (id int);
SELECT array_agg(n) b FROM generate_series(1,10_000) n \gset
CREATE OR REPLACE FUNCTION vec_quantizer (a int, b int[]) RETURNS bool
AS $$ SELECT true $$ LANGUAGE SQL IMMUTABLE;
CREATE INDEX ON def (vec_quantizer(id, :'b'));

completed with:
DROP INDEX CONCURRENTLY def_vec_quantizer_idx;

triggers an assertion failure:
TRAP: failed Assert("HaveRegisteredOrActiveSnapshot()"), File: "toast_internals.c", Line: 668, PID: 3723372

with the following stack trace:
ExceptionalCondition at assert.c:52:13
init_toast_snapshot at toast_internals.c:670:2
toast_delete_datum at toast_internals.c:429:60
toast_tuple_cleanup at toast_helper.c:303:30
heap_toast_insert_or_update at heaptoast.c:335:9
heap_update at heapam.c:3752:14
simple_heap_update at heapam.c:4210:11
CatalogTupleUpdate at indexing.c:324:2
index_set_state_flags at index.c:3522:2
index_concurrently_set_dead at index.c:1848:2
index_drop at index.c:2286:3
doDeletion at dependency.c:1362:5
deleteOneObject at dependency.c:1279:12
deleteObjectsInList at dependency.c:229:3
performMultipleDeletions at dependency.c:393:2
RemoveRelations at tablecmds.c:1594:2
ExecDropStmt at utility.c:2008:4
...

This class of assert failures is not new, see e. g., bugs #13809, #18127,
but this concrete instance (with index_set_state_flags()) emerged with
b52c4fc3c and may be worth fixing while on it...

Best regards,
Alexander

pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Incremental Sort Cost Estimation Instability
Next
From: Marina Polyakova
Date:
Subject: Re: DROP OWNED BY fails to clean out pg_init_privs grants