BUG #6646: PL/Python spiexceptions raised inside Python do not include sqlstate in external code

From: steve(at)empiricalthought(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6646: PL/Python spiexceptions raised inside Python do not include sqlstate in external code
Date: 2012-05-16 18:49:46
Message-ID: E1SUjIA-0002FA-Bi@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 6646
Logged by: Steven Huwig
Email address: steve(at)empiricalthought(dot)com
PostgreSQL version: 9.1.3
Operating system: Linux
Description:

I am trying to raise standard SQL errors from inside PL/Python code.
However, they do not work as expected. They always have sqlstate = XX000
instead of the appropriate sqlstate value.

create function python_exception_bug()
returns void as $$
raise plpy.spiexceptions.InvalidParameterValue()
$$ language 'plpython3u';

create function python_exception_sql()
returns text as $$
begin
select python_exception_bug();
return 'cannot happen';
exception when invalid_parameter_value then
return 'expected behavior';
when others then
return 'this is a bug';
end
$$ language 'plpgsql';

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2012-05-16 19:20:44 Re: BUG #6642: Spanish collation fault
Previous Message Alex Hunsaker 2012-05-16 18:22:04 Re: [BUGS] Re: [BUGS] BUG #6645: Getting an error with “ERROR: PL/Perl function must return reference to hash or array”?