From 5c6fa5ee3229875d7588e280516da171294bcf27 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Tue, 12 Sep 2000 04:28:30 +0000
Subject: [PATCH] This patch, when applied in src/pl will unbreak plperl in
 7.0.2 release. Sorry, if that's fixed ages ago - I don't track development
 versions of PostgreSQL.

Patch is just a little bit tested (some valid functions created and
successfully run as well as some erroneous ones created and emitted proper
error messages when used).

My platform is FreeBSD 5.0-CURRENT (with perl 5.6.0 provided in the
base system).

Alex Kapranoff
---
 src/pl/Makefile        |  9 ++++-----
 src/pl/plperl/plperl.c | 14 +++++++-------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/pl/Makefile b/src/pl/Makefile
index 5b62ba3d657..a5dd6a92a0f 100644
--- a/src/pl/Makefile
+++ b/src/pl/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.12 2000/08/31 16:12:09 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.13 2000/09/12 04:28:30 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -18,10 +18,9 @@ ifeq ($(USE_TCL), true)
 DIRS += tcl
 endif
 
-# Disabled because it doesn't work
-#ifeq ($(with_perl), yes)
-#DIRS += plperl
-#endif
+ifeq ($(with_perl), yes)
+DIRS += plperl
+endif
 
 all install installdirs uninstall depend distprep:
 	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 687612a64c1..c3a5d5b855d 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -33,7 +33,7 @@
  *	  ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.12 2000/07/05 23:11:55 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.13 2000/09/12 04:28:30 momjian Exp $
  *
  **********************************************************************/
 
@@ -324,13 +324,13 @@ plperl_create_sub(char * s)
 	count = perl_call_pv("mksafefunc", G_SCALAR | G_EVAL | G_KEEPERR);
 	SPAGAIN;
 
-	if (SvTRUE(GvSV(errgv)))
+	if (SvTRUE(ERRSV))
 	{
 		POPs;
 		PUTBACK;
 		FREETMPS;
 		LEAVE;
-		elog(ERROR, "creation of function failed : %s", SvPV(GvSV(errgv), na));
+		elog(ERROR, "creation of function failed : %s", SvPV_nolen(ERRSV));
 	}
 
 	if (count != 1) {
@@ -449,13 +449,13 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
 		elog(ERROR, "plperl : didn't get a return item from function");
 	}
 
-	if (SvTRUE(GvSV(errgv)))
+	if (SvTRUE(ERRSV))
 	{
 		POPs;
 		PUTBACK;
 		FREETMPS;
 		LEAVE;
-		elog(ERROR, "plperl : error from function : %s", SvPV(GvSV(errgv), na));
+		elog(ERROR, "plperl : error from function : %s", SvPV_nolen(ERRSV));
 	}
 
 	retval = newSVsv(POPs);
@@ -661,7 +661,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
 	else
 	{
 		retval = FunctionCall3(&prodesc->result_in_func,
-							   PointerGetDatum(SvPV(perlret, na)),
+							   PointerGetDatum(SvPV_nolen(perlret)),
 							   ObjectIdGetDatum(prodesc->result_in_elem),
 							   Int32GetDatum(prodesc->result_in_len));
 	}
@@ -2184,6 +2184,6 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
 			sv_catpvf(output, "'%s' => undef,", attname);
 	}
 	sv_catpv(output, "}");
-	output = perl_eval_pv(SvPV(output, na), TRUE);
+	output = perl_eval_pv(SvPV_nolen(output), TRUE);
 	return output;
 }
-- 
GitLab