Rebased on top of 007491979461ff10d487e1da9bcc87f2fd834f26
Also, I was thinking that lazy_scan_heap doesn't needs to do this:
+ /* Pop the error context stack while calling vacuum */
+ error_context_stack = errcallback.previous;
...
+ /* Set the error context while continuing heap scan */
+ error_context_stack = &errcallback;
It seems to me that's not actually necessary, since lazy_vacuum_heap will just
*push* a context handler onto the stack, and then pop it back off. We don't
need to pop our context beforehand. We also vacuum the FSM, and one might say
that we shouldn't report "...while scanning block number..." if it was
"vacuuming FSM" instead of "scanning heap", to which I would reply that either:
vacuuming FSM could be considered a part of scanning heap?? Or, maybe we
should add an additional callback for that, which is only not very nice since
we'd need to add a PROGRESS enum for which we don't actually report PROGRESS
(or stop using that enum).
I tested using variations on this that works as expected, that context is
correct during vacuum while scanning and after vacuum while scanning:
template1=# SET statement_timeout=0; SET maintenance_work_mem='1MB'; DROP TABLE tt; CREATE UNLOGGED TABLE tt(i int);
INSERTINTO tt SELECT generate_series(1,399999); CREATE INDEX ON tt(i); UPDATE tt SET i=i-1; SET statement_timeout=1222;
VACUUMVERBOSE tt;