mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Check if ii_AmCache is NULL in aminsertcleanup
Fix a bug introduced by c1ec02be1d. It may happen that the executor
opens indexes on the result relation, but no rows end up being inserted.
Then the index_insert_cleanup still gets executed, but passes down NULL
to the AM callback. The AM callback may not expect this, as is the case
of brininsertcleanup, leading to a crash.
Fixed by only calling the cleanup callback if (ii_AmCache != NULL). This
way the AM can simply assume to only see a valid cache.
Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4-w9qC-o9hQox9UHvdVZAYTp8OrPQOKtwbvzWaRejTT=Q@mail.gmail.com
This commit is contained in:
@@ -207,7 +207,7 @@ index_insert_cleanup(Relation indexRelation,
|
||||
RELATION_CHECKS;
|
||||
Assert(indexInfo);
|
||||
|
||||
if (indexRelation->rd_indam->aminsertcleanup)
|
||||
if (indexRelation->rd_indam->aminsertcleanup && indexInfo->ii_AmCache)
|
||||
indexRelation->rd_indam->aminsertcleanup(indexInfo);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user