The attached patch will ensure that pg_atoi will return 0 when passed an empty string regardless of what strtol will do with an empty string. Some implementations of strtol will generate an error if passed an emtpy string.