From 719461b7a28c04a84b0fb1e5faa9b3cb5ee66605 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 19 Jan 2011 00:03:57 +0200
Subject: [PATCH] Improve message for errors in compiling anonymous PL/Python
 blocks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The previous code would try to print out a null pointer.

Jan UrbaƄski
---
 src/pl/plpython/plpython.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 03d6962ca0..99424d3513 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -1625,7 +1625,11 @@ PLy_procedure_compile(PLyProcedure *proc, const char *src)
 			return;
 	}
 
-	PLy_elog(ERROR, "could not compile PL/Python function \"%s\"", proc->proname);
+	if (proc->proname)
+		PLy_elog(ERROR, "could not compile PL/Python function \"%s\"",
+				 proc->proname);
+	else
+		PLy_elog(ERROR, "could not compile anonymous PL/Python code block");
 }
 
 static char *