Marko Grujic <[email protected]> writes:
> I'm reporting a minor, long-standing, edge case in intarray here.
> Namely, when parsing a query_int, the strtol base is set to 0, which forces
> the base auto-detection mode.
> Consequently, when a zero-padded integer input is provided, the number is
> interpreted as an octal value, which in turn leads to wrong int-query results
Hmm ... of course, "wrong" is in the eye of the beholder. There are a
large number of places where we intentionally use base 0, mostly in
service of allowing hex input. I tend to agree with you that this
case wasn't intentional, since the preceding parsing logic only
accepts a sign and 0-9, not "x" or hex digits. Still, we should
consider whether the right answer is to fix that logic to allow
hex input. A (weak) argument for going that way is we'd stay
bug-compatible with the existing behavior for octal input.
I checked around and couldn't find any other places where it seemed
like base zero was being specified unintentionally: in particular
we intentionally use it for integer GUCs, and the parsing logic
is such that you can put in 0x-whatever in all the related places.
On the whole I agree with you that this is a bug and it should use
base 10, but we should wait to see if anyone disagrees.
regards, tom lane