Re: proposal: PL/Pythonu - function ereport

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Catalin Iacob <iacobcatalin(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: PL/Pythonu - function ereport
Date: 2016-01-22 12:41:29
Message-ID: 56A22379.9060703@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/21/16 4:57 PM, Pavel Stehule wrote:
> It is not correct - outside PLPython you got a Error (PostgreSQL error
> has not any classes), and isn't important the raising class (Error or
> SPIError). Inside PL/Python you will got SPIError or successors (based
> on SQLcode).

Right. The closest thing we have to error classes is SQLSTATE. If
someone found a clever way to setup an exception inheritance tree[1] on
that then maybe different exceptions would make sense. Short of that, I
don't see it.

[1] There's a hierarchy to the SQL state codes, based on the first 2
characters. So if there was...

class connection_exception(spi_exception)
__init__
str = 'Connection Exception'

class connection_does_not_exist(connection_exception)
__init__
str = 'Connection Does Not Exist"

...

to map to the small set of errors below, maybe that would make sense.
Obviously that would need to be auto-generated. It seems more trouble
than it's worth though.

Section: Class 08 - Connection Exception

08000 E ERRCODE_CONNECTION_EXCEPTION
connection_exception
08003 E ERRCODE_CONNECTION_DOES_NOT_EXIST
connection_does_not_exist
08006 E ERRCODE_CONNECTION_FAILURE
connection_failure
08001 E ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION
sqlclient_unable_to_establish_sqlconnection
08004 E ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION
sqlserver_rejected_establishment_of_sqlconnection
08007 E ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN
transaction_resolution_unknown
08P01 E ERRCODE_PROTOCOL_VIOLATION
protocol_violation

--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2016-01-22 12:41:58 Re: silent data loss with ext4 / all current versions
Previous Message Jim Nasby 2016-01-22 12:34:48 Re: count_nulls(VARIADIC "any")