Re: PL/Python result object str handler

From: Steve Singer <steve(at)ssinger(dot)info>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PL/Python result object str handler
Date: 2013-02-02 20:43:24
Message-ID: BLU0-SMTP11B267EDD511C645F7F56EDC030@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13-01-07 09:58 PM, Peter Eisentraut wrote:
> By implementing a "str" handler for the result object, it now prints
> something like
>
> <PLyResult status=5 nrows=2 rows=[{'foo': 1, 'bar': '11'}, {'foo': 2, 'bar': '22'}]>
>
> Patch attached for review.
>

Here is a review:

This patch adds a function that pl/python functions can call to convert
a query result hash into a string suitable for debug purposes. The use
case for this feature is primarily for debugging and logging purposes.
I feel that this is useful since a lot of debugging of stored functions
is usually done with print/elog style debugging.

There already some discussion on the thread as if the number of rows
printed should be limited, the consensus seemed to be 'no' since someone
would be unhappy with any limit and printing everything is the same
behaviour you get with the standard python print.

I've tested this with python2.6 and 3.1 and it seems to work as described.

I've looked through the code and everything looks fine.

The patch includes no documentation. Adding a few lines to the
"Utility Functions" section of the plpython documentation so people know
about this feature would be good.

Other than that I think it is fine to commit. I am setting this as
ready for committer, I assume you'll commit this yourself and that you
can add a paragraph to the docs as you commit it.

Steve

>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2013-02-02 21:01:36 Re: Setting visibility map in VACUUM's second phase
Previous Message Pavel Stehule 2013-02-02 20:39:02 Re: proposal - assign result of query to psql variable