pgstattuple does not contain CHECK_FOR_INTERRUPTS()

Started by Tatsuhito Kasaharaalmost 16 years ago2 messages
#1Tatsuhito Kasahara
kasahara.tatsuhito@oss.ntt.co.jp
1 attachment(s)

Hi,

pgstattuple (and pgstatindex) does not contain CHECK_FOR_INTERRUPTS().
Therefore, we can not stop pgstattuple() by using the signal while a
large table is processed.

Here is the patch to solve it.

Best regards,

--
NTT OSS Center
Tatsuhito Kasahara

Attachments:

pgstattuple.patchtext/plain; name=pgstattuple.patchDownload
diff -cr pgsql/contrib/pgstattuple/pgstattuple.c pgsql_work/contrib/pgstattuple/pgstattuple.c
*** pgsql/contrib/pgstattuple/pgstattuple.c	2009-06-11 23:48:52.000000000 +0900
--- pgsql_work/contrib/pgstattuple/pgstattuple.c	2010-04-02 18:52:05.000000000 +0900
***************
*** 276,281 ****
--- 276,283 ----
  	/* scan the relation */
  	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
  	{
+ 		CHECK_FOR_INTERRUPTS();
+ 
  		/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
  		LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
  
***************
*** 302,307 ****
--- 304,311 ----
  
  		while (block <= tupblock)
  		{
+ 			CHECK_FOR_INTERRUPTS();
+ 
  			buffer = ReadBuffer(rel, block);
  			LockBuffer(buffer, BUFFER_LOCK_SHARE);
  			stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
***************
*** 313,318 ****
--- 317,324 ----
  
  	while (block < nblocks)
  	{
+ 		CHECK_FOR_INTERRUPTS();
+ 
  		buffer = ReadBuffer(rel, block);
  		LockBuffer(buffer, BUFFER_LOCK_SHARE);
  		stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
***************
*** 454,459 ****
--- 460,467 ----
  	blkno = start;
  	for (;;)
  	{
+ 		CHECK_FOR_INTERRUPTS();
+ 
  		/* Get the current relation length */
  		LockRelationForExtension(rel, ExclusiveLock);
  		nblocks = RelationGetNumberOfBlocks(rel);
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tatsuhito Kasahara (#1)
Re: pgstattuple does not contain CHECK_FOR_INTERRUPTS()

Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp> writes:

pgstattuple (and pgstatindex) does not contain CHECK_FOR_INTERRUPTS().
Therefore, we can not stop pgstattuple() by using the signal while a
large table is processed.

Here is the patch to solve it.

Seems to be a good idea --- will apply. Thanks!

regards, tom lane