Re: pl/python improvements

From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Marti Raudsepp <marti(at)juffo(dot)org>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pl/python improvements
Date: 2010-12-23 11:38:13
Message-ID: 4D1334A5.8020405@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23/12/10 12:16, Marti Raudsepp wrote:
> On Thu, Dec 23, 2010 at 04:08, Jan Urbański <wulczer(at)wulczer(dot)org> wrote:
>> * providing custom exceptions for SPI errors, so you can catch only
>> UniqueViolations and not have to muck around with SQLCODE
>
> py-postgresql already has a mapping from error codes to Python
> exceptions. I think it makes sense to re-use that, instead of
> inventing new names.
> https://github.com/jwp/py-postgresql/blob/v1.1/postgresql/exceptions.py
>
> It also follows the Python convention of ending exception classes with
> "Error", so instead of UniqueViolation they have UniqueError, instead
> of InvalidTextRepresentation, they have TextRepresentationError

Oh, didn't know that. I see that it does some more fancy things, like
defining a inheritance hierarchy for these exceptions and adding some
more into the mix.

The names I used are not really invented, they're just plpgsql condition
names from
http://www.postgresql.org/docs/current/static/errcodes-appendix.html
with underscores changed to camel case. Also, since they're
autogenerated from utils/errcodes.h they don't have any hierarchy, they
just all inherit from SPIError.

Sticking "Error" to every one of them will result in things like
SubstringErrorError, so I'm not really sold on that. Basically I think
more PL/Python users will be familiar with condition names as you use
them in pl/pgsql than with the names from py-postgresql.

>> Meanwhile the code
>> is available at https://github.com/wulczer/postgres. You will find 10
>> branches there, 9 correspond to these features, and the "plpython"
>> branch is the sum of them all.
>
> I tried building the plpython branch, but got an unrelated error. I
> didn't investigate further for now...
>
> make[3]: Entering directory
> `/home/marti/src/postgresql-py/src/backend/bootstrap'
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
> -fwrapv -I. -I. -I../../../src/include -D_GNU_SOURCE -c -o
> bootparse.o bootparse.c
> bootparse.y: In function ‘boot_yyparse’:
> bootparse.y:224:16: error: too few arguments to function ‘heap_create’
> ../../../src/include/catalog/heap.h:37:17: note: declared here
> bootparse.y:249:16: error: too few arguments to function
> ‘heap_create_with_catalog’
> ../../../src/include/catalog/heap.h:48:12: note: declared here
> make[3]: *** [bootparse.o] Error 1

I'm pretty sure it'll go away it you do make maintainer-clean or git
clean -dfx after switching to the plpython branch.

Cheers,
Jan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-12-23 12:09:01 Recovery conflict monitoring
Previous Message Marti Raudsepp 2010-12-23 11:16:51 Re: pl/python improvements