From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Noah Misch <noah(at)leadboat(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: COPY FREEZE has no warning |
Date: | 2013-02-02 17:56:33 |
Message-ID: | 20130202175633.GA7812@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Feb 2, 2013 at 12:09:05PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Well, so you are saying that there really isn't any use-visible logic
> > for those messages to be different,
>
> No, and in fact the whole block of code is badly written because it
> conflates two unrelated tests. I guess somebody was trying to save
> a couple of nanoseconds by not calling GetCurrentSubTransactionId
> if a previous test had failed, but really why should we care about
> that number of cycles in COPY preliminaries? The code ought to be
> more like this:
>
> /* comment about skipping FSM or WAL here */
> if (cstate->rel->rd_createSubid != InvalidSubTransactionId ||
> cstate->rel->rd_newRelfilenodeSubid != InvalidSubTransactionId)
> {
> hi_options |= HEAP_INSERT_SKIP_FSM;
> if (!XLogIsNeeded())
> hi_options |= HEAP_INSERT_SKIP_WAL;
> }
> /* comment about when we can perform FREEZE here */
> if (cstate->freeze)
> {
> if (!ThereAreNoPriorRegisteredSnapshots() || !ThereAreNoReadyPortals())
> ereport(ERROR,
> (ERRCODE_INVALID_TRANSACTION_STATE,
> errmsg("cannot perform FREEZE because of prior transaction activity")));
>
> if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
> cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
> ereport(ERROR,
> (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
> errmsg("cannot perform FREEZE because the table was not created or truncated in the current subtransaction")));
> hi_options |= HEAP_INSERT_FROZEN;
> }
Yes, I found the blocking odd too --- the test for
InvalidSubTransactionId is used by hi_options, and for freeze checking.
I assumed "!= InvalidSubTransactionId" and "!=
GetCurrentSubTransactionId()" had different meanings for freeze
checking.
I compounded the problem because originally there was no FREEZE failure
so no action was taken if "!= InvalidSubTransactionId".
Applied patch attached.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachment | Content-Type | Size |
---|---|---|
freeze.diff | text/x-diff | 4.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2013-02-02 18:32:44 | Re: GetOldestXmin going backwards is dangerous after all |
Previous Message | Tom Lane | 2013-02-02 17:38:29 | Re: proposal - assign result of query to psql variable |