Thread: Confusing comment in TransactionIdIsInProgress

Confusing comment in TransactionIdIsInProgress

From
Jim Nasby
Date:
Shouldn't the comment read "If first time through"?
/* * If not first time through, get workspace to remember main XIDs in. We * malloc it permanently to avoid repeated
palloc/pfreeoverhead. */if (xids == NULL){
 
...    xids = (TransactionId *) malloc(maxxids * sizeof(TransactionId));
--
Jim C. Nasby, Database Architect                   jim@nasby.net
512.569.9461 (cell)                         http://jim.nasby.net




Re: Confusing comment in TransactionIdIsInProgress

From
Heikki Linnakangas
Date:
On 18.01.2011 07:15, Jim Nasby wrote:
> Shouldn't the comment read "If first time through"?
>
>     /*
>      * If not first time through, get workspace to remember main XIDs in. We
>      * malloc it permanently to avoid repeated palloc/pfree overhead.
>      */
>     if (xids == NULL)
>     {
> ...
>         xids = (TransactionId *) malloc(maxxids * sizeof(TransactionId));

Huh, yes, I'm amazed that no-one have noticed. I must've read that piece 
of code dozens of times in the last couple of years myself, and that 
sentence was even copy-pasted to GetConflictingVirtualXIDs() later in 
that file, including that thinko.

Thanks, fixed both copies.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


Re: Confusing comment in TransactionIdIsInProgress

From
Simon Riggs
Date:
On Tue, 2011-01-18 at 10:51 +0200, Heikki Linnakangas wrote:
> On 18.01.2011 07:15, Jim Nasby wrote:
> > Shouldn't the comment read "If first time through"?
> >
> >     /*
> >      * If not first time through, get workspace to remember main XIDs in. We
> >      * malloc it permanently to avoid repeated palloc/pfree overhead.
> >      */
> >     if (xids == NULL)
> >     {
> > ...
> >         xids = (TransactionId *) malloc(maxxids * sizeof(TransactionId));
> 
> Huh, yes, I'm amazed that no-one have noticed. I must've read that piece 
> of code dozens of times in the last couple of years myself, and that 
> sentence was even copy-pasted to GetConflictingVirtualXIDs() later in 
> that file, including that thinko.

Yes, I laughed when I saw that, having camped out in that code many
nights. 

-- Simon Riggs           http://www.2ndQuadrant.com/books/PostgreSQL Development, 24x7 Support, Training and Services