| From: | "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | plpython and error catching |
| Date: | 2007-11-19 18:37:25 |
| Message-ID: | 264855a00711191037w52525052nfb13aa39c4f2813a@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
What is the expected behavior of a construct like this:
def insert_xml(elem):
id=int(elem.findtext('PMID'))
try:
plpy.execute(plan,[unicode(ET.tostring(elem)),id])
except:
plpy.execute(plan2,[unicode(ET.tostring(elem)),id])
id is a primary key on the table into which I am inserting. "plan" is
the execute plan for inserting new data. "plan2" is for updating data
already in the database. When I run this, I am not able to catch
errors of this type:
WARNING: plpython: in function insert_medline_file:
DETAIL: plpy.Error: Unknown error in PLy_spi_execute_plan
ERROR: duplicate key value violates unique constraint "medlinexml_pkey"
CONTEXT: SQL statement "insert into medlinexml(content,id) values
(xmlparse(CONTENT $1),$2)"
Why am I not able to catch this error and execute the update plan?
The manual (8.3beta2) implies that errors generated in functions are
genuine python errors that I should be able to catch.
Thanks,
Sean
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Harrison | 2007-11-19 18:53:22 | Re: postgresql storage and performance questions |
| Previous Message | Guy Rouillier | 2007-11-19 18:26:38 | Re: Temporary, In-memory Postgres DB? |