Commit bd4ae0f3 authored by Andres Freund's avatar Andres Freund

Add interrupt checks to contrib/pg_prewarm.

Currently the extension's pg_prewarm() function didn't check
interrupts once it started "warming" data. Since individual calls can
take a long while it's important for them to be interruptible.

Backpatch to 9.4 where pg_prewarm was introduced.
parent 28245b84
...@@ -159,6 +159,7 @@ pg_prewarm(PG_FUNCTION_ARGS) ...@@ -159,6 +159,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
*/ */
for (block = first_block; block <= last_block; ++block) for (block = first_block; block <= last_block; ++block)
{ {
CHECK_FOR_INTERRUPTS();
PrefetchBuffer(rel, forkNumber, block); PrefetchBuffer(rel, forkNumber, block);
++blocks_done; ++blocks_done;
} }
...@@ -177,6 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS) ...@@ -177,6 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
*/ */
for (block = first_block; block <= last_block; ++block) for (block = first_block; block <= last_block; ++block)
{ {
CHECK_FOR_INTERRUPTS();
smgrread(rel->rd_smgr, forkNumber, block, blockbuffer); smgrread(rel->rd_smgr, forkNumber, block, blockbuffer);
++blocks_done; ++blocks_done;
} }
...@@ -190,6 +192,7 @@ pg_prewarm(PG_FUNCTION_ARGS) ...@@ -190,6 +192,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
{ {
Buffer buf; Buffer buf;
CHECK_FOR_INTERRUPTS();
buf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL); buf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL);
ReleaseBuffer(buf); ReleaseBuffer(buf);
++blocks_done; ++blocks_done;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment