• Neil Conway's avatar
    Implement two new special variables in PL/PgSQL: SQLSTATE and SQLERRM. · d46bc444
    Neil Conway authored
    These contain the SQLSTATE and error message of the current exception,
    respectively. They are scope-local variables that are only defined
    in exception handlers (so attempting to reference them outside an
    exception handler is an error). Update the regression tests and the
    documentation.
    
    Also, do some minor related cleanup: export an unpack_sql_state()
    function from the backend and use it to unpack a SQLSTATE into a
    string, and add a free_var() function to pl_exec.c
    
    Original patch from Pavel Stehule, review by Neil Conway.
    d46bc444
elog.c 50.5 KB