Currently the PL/Python documentation claims that:
"raise plpy.ERROR(msg) and raise plpy.FATAL(msg) are equivalent to
calling plpy.error and plpy.fatal, respectively"

However, the actual names are Error and Fatal, not ERROR or FATAL
(Python is case-sensitive). Patch to fix documentation attached.

postgres=# CREATE OR REPLACE FUNCTION public.foo() RETURNS void
LANGUAGE plpythonu AS 'raise plpy.ERROR("foobar happened!")';
CREATE FUNCTION
postgres=# select foo();
ERROR:  PL/Python: AttributeError: 'module' object has no attribute 'ERROR'
CONTEXT:  PL/Python function "foo"

postgres=# CREATE OR REPLACE FUNCTION public.foo() RETURNS void
LANGUAGE plpythonu AS 'raise plpy.Error("foobar happened!")';
CREATE FUNCTION
postgres=# select foo();
ERROR:  PL/Python: plpy.Error: foobar happened!
CONTEXT:  PL/Python function "foo"

Regards,
Marti
From b058cb36433aabc34325ce7eb8f5fb67aa2441cb Mon Sep 17 00:00:00 2001
From: Marti Raudsepp <[email protected]>
Date: Tue, 9 Nov 2010 12:15:39 +0200
Subject: [PATCH] docs: plpython has plpy.Error instead of plpy.ERROR

---
 doc/src/sgml/plpython.sgml |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index 6eb884e..9fc8808 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -954,8 +954,8 @@ $$ LANGUAGE plpythonu;
    <function>plpy.fatal</function> actually raise a Python exception
    which, if uncaught, propagates out to the calling query, causing
    the current transaction or subtransaction to be aborted.
-   <literal>raise plpy.ERROR(<replaceable>msg</>)</literal> and
-   <literal>raise plpy.FATAL(<replaceable>msg</>)</literal> are
+   <literal>raise plpy.Error(<replaceable>msg</>)</literal> and
+   <literal>raise plpy.Fatal(<replaceable>msg</>)</literal> are
    equivalent to calling
    <function>plpy.error</function> and
    <function>plpy.fatal</function>, respectively.
-- 
1.7.3.2

-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Reply via email to