| From: | Neil Conway <neilc(at)samurai(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | James Robinson <jlrobins(at)socialserve(dot)com>, pgsql-patches(at)postgresql(dot)org |
| Subject: | Re: 2 line patch to allow plpythonu functions to return |
| Date: | 2006-02-26 23:40:21 |
| Message-ID: | 44023C65.1050802@samurai.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-patches |
Tom Lane wrote:
> This sort of thing normally requires more thought than just removing
> the safety check. What happens when the python code does/doesn't return
> a value, in both cases (declared return type void or not)?
Attached is a more complete patch:
- if the function is declared to return void, we only accept "None" as
the return value from Python. Returning anything else produces an error.
- if the function is declared to return void and Python returns "None",
we return this to PG as a void datum (*not* NULL)
- if the function is not declared to return void and Python returns
"None", we return this to PG as a NULL datum
One minor inconsistency is that PL/PgSQL (for example) actually
disallows "RETURN expr;" in void-returning functions: only "RETURN;" can
be used. In PL/Python we don't place any restrictions on the syntax of
the function: "return expr" is allowed in void-returning functions so
long as `expr' evaluates to None. I don't think this is a major problem,
though.
The error message for the first case isn't quite right, and I need to
update the "expected" regression tests and possibly the documentation.
But otherwise I'll apply this patch to HEAD tomorrow, barring any
objections.
-Neil
| Attachment | Content-Type | Size |
|---|---|---|
| plpython_return_void-1.patch | text/x-patch | 4.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-02-27 00:26:19 | Re: Scrollable cursors and Sort performance |
| Previous Message | Neil Conway | 2006-02-26 18:37:13 | Re: TID: <> operator |