From 15f55cc38a82dfa3d7898a7c30a303b1b3e87dc3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 1 Feb 2011 22:53:40 +0200
Subject: Add validator to PL/Python
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Jan Urbański, reviewed by Hitoshi Harada
---
 src/pl/plpython/sql/plpython_error.sql | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

(limited to 'src/pl/plpython/sql/plpython_error.sql')

diff --git a/src/pl/plpython/sql/plpython_error.sql b/src/pl/plpython/sql/plpython_error.sql
index 5ca68495be..6509257b24 100644
--- a/src/pl/plpython/sql/plpython_error.sql
+++ b/src/pl/plpython/sql/plpython_error.sql
@@ -2,6 +2,29 @@
 -- the trigger handler once. the errors and subsequent core dump were
 -- interesting.
 
+/* Flat out Python syntax error
+ */
+CREATE FUNCTION python_syntax_error() RETURNS text
+        AS
+'.syntaxerror'
+        LANGUAGE plpythonu;
+
+/* With check_function_bodies = false the function should get defined
+ * and the error reported when called
+ */
+SET check_function_bodies = false;
+
+CREATE FUNCTION python_syntax_error() RETURNS text
+        AS
+'.syntaxerror'
+        LANGUAGE plpythonu;
+
+SELECT python_syntax_error();
+/* Run the function twice to check if the hashtable entry gets cleaned up */
+SELECT python_syntax_error();
+
+RESET check_function_bodies;
+
 /* Flat out syntax error
  */
 CREATE FUNCTION sql_syntax_error() RETURNS text
-- 
cgit v1.2.1

