From: | Emre Hasegeli <emre(at)hasegeli(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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 11:35:19 |
Message-ID: | CAE2gYzw1RwONZeHZAJYwpcaecR-KgoBxJWUbcZeO+72bvyHiwQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Got around to looking at this. Attached is a revised version that I think
> is in committable shape. The main non-cosmetic change is that the test
> for "type was created in same transaction as new value" now consists of
> comparing the xmins of the pg_type and pg_enum rows, without consulting
> GetCurrentTransactionId(). I did not like the original coding because
> it would pointlessly disallow references to enum values that were created
> in a parent transaction of the current subxact. This way is still leaving
> some subxact use-cases on the table, as noted in the code comments, but
> it's more flexible than before.
Thank you for picking this up. The patch looks good to me. I think
this is a useful to support adding values to the enum created in the
same transaction.
> + /*
> + * 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().
One risk about this feature is that the future enum functions would
not check if the value is safe to return. Maybe we should append a
warning to the file header about this.
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Berg | 2016-09-04 11:46:03 | Re: pg_hba_file_settings view patch |
Previous Message | Pavel Stehule | 2016-09-04 10:54:57 | Re: IF (NOT) EXISTS in psql-completion |