From: | Dragos Valentin Moinescu <dragos(dot)moinescu(at)gmail(dot)com> |
---|---|
To: | pgsql-admin(at)postgresql(dot)org |
Subject: | plpythonu: how to catch plpy.execute() exceptions |
Date: | 2010-10-29 13:02:53 |
Message-ID: | AANLkTi=aaz=kv_08QH1tGPhK4b_Q1TwRk1tMbQX3fWVk@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hello all,
I am trying to create a plpythonu function that will execute some SQLs
stored in a table (because it should work much faster than executing
from remote).
The thing is that I cannot catch the exception raised by plpy.execute().
I tried this with the following code:
CREATE OR REPLACE FUNCTION __syncpg_execute() RETURNS boolean
AS $$
try:
plpy.execute("SELECT * FROM not_existing_table", 5)
except Exception, exc:
plpy.notice("Exception %s" % str(exc) )
return True
$$ LANGUAGE plpythonu;
The result is:
# select __syncpg_execute();
WARNING: PL/Python: plpy.SPIError: unrecognized error in PLy_spi_execute_query
CONTEXT: PL/Python function "__syncpg_execute"
NOTICE: Exception error return without exception set
CONTEXT: PL/Python function "__syncpg_execute"
ERROR: relation "not_existing_table" does not exist
LINE 1: SELECT * FROM not_existing_table
^
QUERY: SELECT * FROM not_existing_table
CONTEXT: PL/Python function "__syncpg_execute"
I am using Postgresql9.0 with python 2.4.3
Thank you
--
Best regards,
Dragos Moinescu
From | Date | Subject | |
---|---|---|---|
Next Message | Gerhard Hintermayer | 2010-10-29 13:13:57 | Minor upgrade procedure while DB up & running |
Previous Message | Gémes Géza | 2010-10-29 05:12:04 | Re: Using LDAP with postgresql 8.2 |