From: Justin Pryzby Date: Sat, 1 Feb 2020 22:41:48 -0600 Subject: [PATCH v16 3/3] vacuum error callback for index cleanup --- src/backend/access/heap/vacuumlazy.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 5d4fb3d..c14a917 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -2427,6 +2427,8 @@ lazy_cleanup_index(Relation indrel, IndexVacuumInfo ivinfo; const char *msg; PGRUsage ru0; + vacuum_error_callback_arg errcbarg; + ErrorContextCallback errcallback = { error_context_stack, vacuum_error_callback, &errcbarg, }; pg_rusage_init(&ru0); @@ -2439,8 +2441,18 @@ lazy_cleanup_index(Relation indrel, ivinfo.num_heap_tuples = reltuples; ivinfo.strategy = vac_strategy; + /* Setup error traceback support for ereport() */ + errcbarg.relnamespace = get_namespace_name(RelationGetNamespace(indrel)); + errcbarg.indname = RelationGetRelationName(indrel); + errcbarg.relname = get_rel_name(indrel->rd_index->indexrelid); + errcbarg.phase = PROGRESS_VACUUM_PHASE_INDEX_CLEANUP; + error_context_stack = &errcallback; + *stats = index_vacuum_cleanup(&ivinfo, *stats); + /* Pop the error context stack */ + error_context_stack = errcallback.previous; + if (!(*stats)) return; @@ -3469,5 +3481,10 @@ vacuum_error_callback(void *arg) errcontext(_("while vacuuming index \"%s.%s\" of relation \"%s\""), cbarg->relnamespace, cbarg->indname, cbarg->relname); break; + + case PROGRESS_VACUUM_PHASE_INDEX_CLEANUP: + errcontext(_("while cleaning up index \"%s.%s\" of relation \"%s\""), + cbarg->relnamespace, cbarg->indname, cbarg->relname); + break; } } -- 2.7.4 --Ubca5Sl/zyRO+Ah+--