Re: Transactional enum additions - was Re: Alter or rename enum value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: emre(at)hasegeli(dot)com
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Christophe Pettus <xof(at)thebuild(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Matthias Kurz <m(dot)kurz(at)irregular(dot)at>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Transactional enum additions - was Re: Alter or rename enum value
Date: 2016-09-04 17:01:12
Message-ID: 19053.1473008472@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Emre Hasegeli <emre(at)hasegeli(dot)com> writes:
>> + /*
>> + * If the row is hinted as committed, it's surely safe. This provides a
>> + * fast path for all normal use-cases.
>> + */
>> + if (HeapTupleHeaderXminCommitted(enumval_tup->t_data))
>> + return;
>> +
>> + /*
>> + * Usually, a row would get hinted as committed when it's read or loaded
>> + * into syscache; but just in case not, let's check the xmin directly.
>> + */
>> + xmin = HeapTupleHeaderGetXmin(enumval_tup->t_data);
>> + if (!TransactionIdIsInProgress(xmin) &&
>> + TransactionIdDidCommit(xmin))
>> + return;

> This looks like transaction internal logic inside enum.c to me. Maybe
> it is because I am not much familiar with the internals. I couldn't
> find a similar pattern anywhere else, but it might still be useful to
> invent something like HeapTupleHeaderXminReallyCommitted().

I wondered about that too, but there are no other roughly similar cases
that I could find, and abstracting from a single use-case is perilous ---
especially when there's no compelling reason to think there will ever be
any other similar use-cases. I'd originally wondered whether we could
replace this logic with a call to something in tqual.c, but none of the
available functions there produce the required behavior either.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Emre Hasegeli 2016-09-04 17:42:33 Re: Floating point comparison inconsistencies of the geometric types
Previous Message Pavel Stehule 2016-09-04 16:26:26 Re: Make better use of existing enums in plpgsql