Small change in LockAcquire API

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Small change in LockAcquire API
Дата
Msg-id 4232.1117382810@sss.pgh.pa.us
обсуждение исходный текст
Список 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 of0: could not acquire lock immediately, and dontWait is true1: successful lock acquisition2: incremented
lockcount 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Simplifying unknown-literal handling
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Simplifying unknown-literal handling