Casting to int causes parsing error

Hi all,

I’ve noticed an issue with one of our queries when we moved from postgres to crdb. I would like to know if this is expected or a bug with cockroachdb:

postgres

> select '004948'::int;
  int8
----------
    4948
(1 row)

cockroachdb

> select '004948'::int;
ERROR: could not parse "004948" as type int: strconv.ParseInt: parsing "004948": invalid syntax

Interesting that casting to float works:

> select '004948'::float;
  float8
----------
    4948
(1 row)

Any ideas?

EDIT: Forgot to mention, we are using crdb v21.1.6

This does seem like a bug. I’ve filed sql: parsing integers from strings treats leading zeros as octal · Issue #68986 · cockroachdb/cockroach · GitHub and will make sure that the relevant parties have a look.

1 Like