question on bits32 wraparound check - Mailing list pgsql-hackers

From Alvaro Herrera
Subject question on bits32 wraparound check
Date
Msg-id 20090403224539.GQ23023@alvh.no-ip.org
Whole thread Raw
Responses Re: question on bits32 wraparound check  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
So there's a minor issue on Takahiro-san fillfactor-on-toast patch,
which is that it does not hand out the last possible "kind" value.  This
is a bits32 field, so at least theoretically on some platforms it will
be wider than 32 while on others it will be exactly 32.  I'm wondering
if this is the correct way to check for wraparound:

relopt_kind
add_reloption_kind(void)
{relopt_kind        kind;
/* wraparound check */if (last_assigned_kind > RELOPT_KIND_MAX ||    last_assigned_kind == 0)    ereport(ERROR,
  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),             errmsg("user-defined relation parameter types limit
exceeded")));
kind = (relopt_kind) last_assigned_kind;last_assigned_kind <<= 1;return kind;
}


Fixing this I'm ready to commit this patch.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: Saner interval hash function
Next
From: Tom Lane
Date:
Subject: Re: question on bits32 wraparound check