txid strtoull fix

Started by Marko Kreenalmost 19 years ago4 messagespatches
Jump to latest
#1Marko Kreen
markokr@gmail.com

I noticed strtoull() causes problems on some buildfarm
machines. As a fix I propose small str2num function inside
txid.c itself. Main reason is that the txid actually does
not need fully-featured strtoull (radixes, whitespace skipping).

We could include strtoull() under port/ in the future, I think
that would be good, but just for txid it is not necessary.

--
marko

Attachments:

txid.strtoull.diffapplication/octet-stream; name=txid.strtoull.diffDownload+52-8
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marko Kreen (#1)
Re: txid strtoull fix

"Marko Kreen" <markokr@gmail.com> writes:

I noticed strtoull() causes problems on some buildfarm
machines. As a fix I propose small str2num function inside
txid.c itself. Main reason is that the txid actually does
not need fully-featured strtoull (radixes, whitespace skipping).

Seems like a sane solution to me --- applied.

(Note that your overflow test didn't actually work; AFAIK there
really isn't any decent solution other than dividing at each step.)

regards, tom lane

#3Marko Kreen
markokr@gmail.com
In reply to: Tom Lane (#2)
Re: txid strtoull fix

On 10/8/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Marko Kreen" <markokr@gmail.com> writes:

I noticed strtoull() causes problems on some buildfarm
machines. As a fix I propose small str2num function inside
txid.c itself. Main reason is that the txid actually does
not need fully-featured strtoull (radixes, whitespace skipping).

Seems like a sane solution to me --- applied.

(Note that your overflow test didn't actually work; AFAIK there
really isn't any decent solution other than dividing at each step.)

Hmm. It did seem to work here. Just in case I peeked into
FreeBSD strtoull() and this patch imitates their method.

This also seems to work, but please review, I'm don't feel
very sharp anymore...

--
marko

Attachments:

txid.overflow.diffapplication/octet-stream; name=txid.overflow.diffDownload+11-7
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marko Kreen (#3)
Re: txid strtoull fix

"Marko Kreen" <markokr@gmail.com> writes:

On 10/8/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:

(Note that your overflow test didn't actually work; AFAIK there
really isn't any decent solution other than dividing at each step.)

Hmm. It did seem to work here. Just in case I peeked into
FreeBSD strtoull() and this patch imitates their method.

Well, it worked for the one specific case you tested, but there are
other cases it would fail to detect overflow for. (When you're
multiplying by ten, the overflow might not be small.) The FreeBSD
way looks OK though --- applied.

regards, tom lane