Adding one CheckTableNotInUse() for REINDEX CONCURRENTLY

Started by Michael Paquierabout 6 years ago1 messageshackers
Jump to latest
#1Michael Paquier
michael@paquier.xyz

Hi all,

As mentioned on the thread dealing with concurrent indexing for
temporary relations, it sounds like a good thing to make the code more
defensive if attempting to do a REINDEX CONCURRENTLY with a backend
still holding references to the indexes worked on:
/messages/by-id/20191212213709.neopqccvdo724eha@alap3.anarazel.de

One thing is that as REINDEX CONCURRENTLY cannot be used in
transaction blocks, this cannot be triggered in the context of a
function call, say with this patch:
+ERROR:  REINDEX CONCURRENTLY cannot be executed from a function
+CONTEXT:  SQL statement "REINDEX INDEX CONCURRENTLY reindex_ind_ref"
+PL/pgSQL function reindex_func_ref() line 3 at EXECUTE

Attached is a patch to do that. I am not sure if the test added in
the patch has much additional value, but feel free to look at it. Any
thoughts?
--
Michael

Attachments:

reindex_conc_inuse.patchtext/x-diff; charset=us-asciiDownload+42-0