question on bits32 wraparound check

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: question on bits32 wraparound check
Date: 2009-04-03 22:45:39
Message-ID: 20090403224539.GQ23023@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-04-03 23:06:29 Re: question on bits32 wraparound check
Previous Message Jaime Casanova 2009-04-03 22:41:12 Re: Saner interval hash function