Is there some way to prevent finalizers running during a section of code?

I have a package that includes R objects linked to database tables.  To
maintain the call-by-value semantics, tables are copied rather than
modified, and the extra tables are removed by finalizers during garbage
collection.

However, if the garbage collection occurs in the middle of processing
another SQL query (which is relatively likely, since that's where the
memory allocations are) there are problems with the database interface.

Since the guarantees for the finalizer are "at most once, not before the
object is out of scope" it seems harmless to be able to prevent finalizers
from running during a particular code block, but I can't see any way to do
it.

Suggestions?

    -thomas


-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

	[[alternative HTML version deleted]]

