Re: Implementing SQL ASSERTION

Поиск
Список
Период
Сортировка
От Joe Wildish
Тема Re: Implementing SQL ASSERTION
Дата
Msg-id BC7C5F21-4681-44FD-AE33-AC509E47D1D2@elusive.cx
обсуждение исходный текст
Ответ на Re: Implementing SQL ASSERTION  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: Implementing SQL ASSERTION
Список pgsql-hackers
Hi Fabien,

* certain combinations of aggregates with comparison operations cannot be invalidating.

As an example of the last point, the expression "CHECK (10 > (SELECT COUNT(*) FROM t))" cannot be invalidated by a delete or an update but can be invalidated by an insert.

I'm wondering about the effect of MVVC on this: if the check is performed when the INSERT is done, concurrent inserting transactions would count the current status which would be ok, but on commit all concurrent inserts would be there and the count could not be ok anymore?

Yes, there was quite a bit of discussion in the original thread about concurrency. See here:


The patch doesn’t attempt to address concurrency (beyond the obvious benefit of reducing the circumstances under which the assertion is checked). I am working under the assumption that we will find some acceptable way for that to be resolved :-) And at the moment, working in serialisable mode addresses this issue. I think that is suggested in the thread actually (essentially, if you want to use assertions, you require that transactions be performed at serialisable isolation level). 

Maybe if the check was deferred, but this is not currently possible with pg (eg the select can simply be put in a function), and I there might be race conditions. ISTM that such a check would imply non trivial locking to be okay, it is not just a matter of deciding whether to invoke the check or not.

I traverse into SQL functions so that the analysis can capture invalidating operations from the expression inside the function. Only internal and SQL functions are considered legal. Other languages are rejected.

-Joe


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: proposal: alternative psql commands quit and exit
Следующее
От: Aleksander Alekseev
Дата:
Сообщение: Re: new function for tsquery creartion