Skip site navigation (1) Skip section navigation (2)

Small change in LockAcquire API

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Small change in LockAcquire API
Date: 2005-05-29 16:06:50
Message-ID: 4232.1117382810@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
I'm thinking of making two small changes in LockAcquire's behavior:

1. Bogus parameters (in particular an invalid locktable id) should
result in elog(ERROR), not a failure return.  The existing API makes
it impossible to tell the difference between an invalid parameter
and an unobtainable lock.  This change will eliminate the need for
testing the return value at all in most of the call sites.

2. Instead of a boolean result, return a three-state result, along
the lines of
	0: could not acquire lock immediately, and dontWait is true
	1: successful lock acquisition
	2: incremented lock count of a lock we already hold
The reason for doing this is that in LockRelation, we can skip the
call to AcceptInvalidationMessages() if we are re-acquiring a lock
already held.  This is a very common scenario --- in particular,
the parser, rewriter, and executor successively acquire the same
lock on each table mentioned in a query.  The "extra" locks are needed
in scenarios where a table reference comes from a rewrite rule, or
when executing a plan that was computed in a prior transaction; so
I don't think we can remove them entirely.  But we can reduce the
number of calls to AcceptInvalidationMessages, which is starting to
look like a hotspot in profiles of simple queries.

Any objections?

			regards, tom lane

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2005-05-29 17:13:55
Subject: Re: Simplifying unknown-literal handling
Previous:From: Tom LaneDate: 2005-05-29 15:47:18
Subject: Simplifying unknown-literal handling

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group