Re: Is there a good reason why PL languages do not support cstring type arguments and return values ? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Is there a good reason why PL languages do not support cstring type arguments and return values ?
Date
Msg-id 27856.1349883260@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is there a good reason why PL languages do not support cstring type arguments and return values ?  (Hannu Krosing <hannu@krosing.net>)
Responses Re: Is there a good reason why PL languages do not support cstring type arguments and return values ?  (Hannu Krosing <hannu@krosing.net>)
WIP patch for pl/python cstring and type io support (was: Re: Is there a good reason why PL languages do not support cstring type arguments and return values ?)  (Hannu Krosing <hannu@2ndQuadrant.com>)
List pgsql-hackers
Hannu Krosing <hannu@krosing.net> writes:
> One way would be to check that we are in an any --> cstring
> function - perhaps just by setting some static flag et entry and resetting
> it at exit - and pass the original byte representation as "bytes" (or 
> string for py2.x)

Totally aside from the ugliness of driving that off the *other* end
being cstring, it seems quite insufficient to me.  For example, if the
data type in question is toastable, you don't really want to leave the
Python code with the problem of detoasting a toasted value.  Even if
it's just an int, your proposal saddles the Python code with enddianness
problems.

I think my suggestion of a way to pretend the argument or result is of
some specified other type for conversion purposes is quite a lot superior.
In the toastable-type case, referencing bytea would be enough to get the
Python code out from under detoasting and length-word management.  There
might also be cases where the new type is really a skin over some
built-in type, and you can leverage that type's I/O behavior to simplify
what the Python code has to do.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: September 2012 commitfest
Next
From: Heikki Linnakangas
Date:
Subject: Re: [BUGS] BUG #7534: walreceiver takes long time to detect n/w breakdown