On Wed, Jan 18, 2012 at 7:55 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Peter Eisentraut <pete...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers