Skip to content
Snippets Groups Projects
  • Bruce Momjian's avatar
    786b1802
    The pg_atoi() function uses strtol() to convert the string to numbers. Some · 786b1802
    Bruce Momjian authored
    implementations of strtol() treat empty strings ("") as invalid arguments
    while others convert this (erroneously, IHMO) to zero (0).  Assuming that the
    expected behaviour of pg_atoi() is to return 0 if it is passed an empty
    string, I am supplying the following patch to explictly check for an empty
    string in pg_atoi() and return 0 if the string is empty.  The patch will also
    trap a NULL character pointer being passed to pg_atoi() and will use elog() to
    print out an error message if the input char pointer is NULL.
    
    
    Billy G. Allie
    786b1802
    History
    The pg_atoi() function uses strtol() to convert the string to numbers. Some
    Bruce Momjian authored
    implementations of strtol() treat empty strings ("") as invalid arguments
    while others convert this (erroneously, IHMO) to zero (0).  Assuming that the
    expected behaviour of pg_atoi() is to return 0 if it is passed an empty
    string, I am supplying the following patch to explictly check for an empty
    string in pg_atoi() and return 0 if the string is empty.  The patch will also
    trap a NULL character pointer being passed to pg_atoi() and will use elog() to
    print out an error message if the input char pointer is NULL.
    
    
    Billy G. Allie