[PATCH] FIx alloc_var() ndigits thinko - Mailing list pgsql-hackers

From Joel Jacobson
Subject [PATCH] FIx alloc_var() ndigits thinko
Date
Msg-id ea480513-371c-4b55-8f23-a7c5e7727ae8@app.fastmail.com
Whole thread Raw
List pgsql-hackers
Hi,

I came across another harmless thinko in numeric.c.

It is harmless since 20/DEC_DIGITS and 40/DEC_DIGITS happens to be exactly 5 and 10 since DEC_DIGITS == 4,
but should be fixed anyway for correctness IMO.

-       alloc_var(var, 20 / DEC_DIGITS);
+       alloc_var(var, (20 + DEC_DIGITS - 1) / DEC_DIGITS);

-       alloc_var(var, 40 / DEC_DIGITS);
+       alloc_var(var, (40 + DEC_DIGITS - 1) / DEC_DIGITS);

/Joel

Attachment

pgsql-hackers by date:

Previous
From: Jelte Fennema
Date:
Subject: Re: run pgindent on a regular basis / scripted manner
Next
From: David Zhang
Date:
Subject: Re: psql: Add role's membership options to the \du+ command