Re: age(xid) on hot standby
От | Simon Riggs |
---|---|
Тема | Re: age(xid) on hot standby |
Дата | |
Msg-id | CA+U5nM+3zo_FmprLCCVwhcgZhmCiwyhsfvAYwwSAvrnNe70t0w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: age(xid) on hot standby (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: age(xid) on hot standby
|
Список | pgsql-hackers |
On Wed, Jan 18, 2012 at 7:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Peter Eisentraut <peter_e@gmx.net> writes: >> On mån, 2012-01-16 at 22:59 -0300, Alvaro Herrera wrote: >>> So who's going to work on a patch? Peter, are you? If not, we should >>> add it to the TODO list. > >> Not at this very moment, but maybe in a few weeks. > > BTW, it strikes me that maybe the coding should work about like this: > > if (!TransactionIdIsValid(age_reference_xid)) > { > age_reference_xid = GetTopTransactionIdIfAny(); > if (!TransactionIdIsValid(age_reference_xid)) > age_reference_xid = ReadNewTransactionId(); > } > ... use age_reference_xid to compute result ... > > and of course code somewhere to reset age_reference_xid at end of xact. > > The advantage of this is > > (1) same code works on master and standby > > (2) calling age() no longer requires an otherwise read-only transaction > to acquire an XID. Nice solution. Also it illustrates that some users write code that tries to do things on a Hot Standby that are supposed to be illegal. If the OPs error message had returned the correct SQLCODE then it would have been better able to handle the message. I think we should apply the patch to return the correct SQLCODE in all cases, even if its supposedly not possible. -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-hackers по дате отправления: