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 26812.1349880406@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>)
List pgsql-hackers
Hannu Krosing <hannu@krosing.net> writes:
> On 10/10/2012 02:58 PM, Tom Lane wrote:
>> It's hard for me to see how you'd make the above work without
>> circularity, ie the PL manager would end up recursively calling itself
>> trying to construct or deconstruct the value.

> Again, could you be a bit more specific.

If you try to write "foo_out(foo) returns cstring" in Python, the
first thing plpython will try to do is convert the argument value
to a Python object, which for a non-built-in type such as "foo" is
going to reduce to conversion to text, which will result in ...
you guessed it ... calling foo_out to convert the argument value
to text.  Lather, rinse, repeat till stack overflow.

As I was mentioning to Heikki, it's possible that you could work around
that by somehow telling plpython to do the argument conversion as though
the argument were of some bit-compatible built-in type rather than foo.
But without some such type cheat you can't write an I/O function in a
PL, and it's not the cstring end of it that's the problem.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Behavior for crash recovery when it detects a corrupt WAL record
Next
From: Heikki Linnakangas
Date:
Subject: Re: Behavior for crash recovery when it detects a corrupt WAL record