$OpenBSD: patch-plv8_cc,v 1.3 2019/02/19 05:11:36 jeremy Exp $

https://code.google.com/p/plv8js/source/detail?r=094df45dce2a879d1814b792aeb46b38f0f0ef87&name=r1.4

https://github.com/plv8/plv8/commit/0f1915e48d40c99b100cce824da1157995169c67.diff

Index: plv8.cc
--- plv8.cc.orig
+++ plv8.cc
@@ -8,6 +8,13 @@
 #include "plv8.h"
 #include <new>
 
+// XXX this is a horrible hack!!!!
+// plv8 tries to preserve itself from C++ constructs, BUT it includes
+// some postgresql includes that *will* include math.h, and with libc++
+// THAT one contains C++ constructs in C++ mode, so include it *FIRST*
+// (barf, blech, yuck)
+#include <math.h>
+
 extern "C" {
 #define delete		delete_
 #define namespace	namespace_
@@ -47,22 +54,12 @@ PG_FUNCTION_INFO_V1(plcoffee_call_validator);
 PG_FUNCTION_INFO_V1(plls_call_handler);
 PG_FUNCTION_INFO_V1(plls_call_validator);
 
-Datum	plv8_call_handler(PG_FUNCTION_ARGS) throw();
-Datum	plv8_call_validator(PG_FUNCTION_ARGS) throw();
-Datum	plcoffee_call_handler(PG_FUNCTION_ARGS) throw();
-Datum	plcoffee_call_validator(PG_FUNCTION_ARGS) throw();
-Datum	plls_call_handler(PG_FUNCTION_ARGS) throw();
-Datum	plls_call_validator(PG_FUNCTION_ARGS) throw();
-
 void _PG_init(void);
 
 #if PG_VERSION_NUM >= 90000
 PG_FUNCTION_INFO_V1(plv8_inline_handler);
 PG_FUNCTION_INFO_V1(plcoffee_inline_handler);
 PG_FUNCTION_INFO_V1(plls_inline_handler);
-Datum	plv8_inline_handler(PG_FUNCTION_ARGS) throw();
-Datum	plcoffee_inline_handler(PG_FUNCTION_ARGS) throw();
-Datum	plls_inline_handler(PG_FUNCTION_ARGS) throw();
 #endif
 } // extern "C"
 
@@ -307,26 +304,26 @@ common_pl_call_handler(PG_FUNCTION_ARGS, Dialect diale
 }
 
 Datum
-plv8_call_handler(PG_FUNCTION_ARGS) throw()
+plv8_call_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_handler(fcinfo, PLV8_DIALECT_NONE);
 }
 
 Datum
-plcoffee_call_handler(PG_FUNCTION_ARGS) throw()
+plcoffee_call_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_handler(fcinfo, PLV8_DIALECT_COFFEE);
 }
 
 Datum
-plls_call_handler(PG_FUNCTION_ARGS) throw()
+plls_call_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_handler(fcinfo, PLV8_DIALECT_LIVESCRIPT);
 }
 
 #if PG_VERSION_NUM >= 90000
 static Datum
-common_pl_inline_handler(PG_FUNCTION_ARGS, Dialect dialect) throw()
+common_pl_inline_handler(PG_FUNCTION_ARGS, Dialect dialect)
 {
 	InlineCodeBlock *codeblock = (InlineCodeBlock *) DatumGetPointer(PG_GETARG_DATUM(0));
 
@@ -354,19 +351,19 @@ common_pl_inline_handler(PG_FUNCTION_ARGS, Dialect dia
 }
 
 Datum
-plv8_inline_handler(PG_FUNCTION_ARGS) throw()
+plv8_inline_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_inline_handler(fcinfo, PLV8_DIALECT_NONE);
 }
 
 Datum
-plcoffee_inline_handler(PG_FUNCTION_ARGS) throw()
+plcoffee_inline_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_inline_handler(fcinfo, PLV8_DIALECT_COFFEE);
 }
 
 Datum
-plls_inline_handler(PG_FUNCTION_ARGS) throw()
+plls_inline_handler(PG_FUNCTION_ARGS)
 {
 	return common_pl_inline_handler(fcinfo, PLV8_DIALECT_LIVESCRIPT);
 }
@@ -688,7 +685,7 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv)
 }
 
 static Datum
-common_pl_call_validator(PG_FUNCTION_ARGS, Dialect dialect) throw()
+common_pl_call_validator(PG_FUNCTION_ARGS, Dialect dialect)
 {
 	Oid				fn_oid = PG_GETARG_OID(0);
 	HeapTuple		tuple;
@@ -746,19 +743,19 @@ common_pl_call_validator(PG_FUNCTION_ARGS, Dialect dia
 }
 
 Datum
-plv8_call_validator(PG_FUNCTION_ARGS) throw()
+plv8_call_validator(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_validator(fcinfo, PLV8_DIALECT_NONE);
 }
 
 Datum
-plcoffee_call_validator(PG_FUNCTION_ARGS) throw()
+plcoffee_call_validator(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_validator(fcinfo, PLV8_DIALECT_COFFEE);
 }
 
 Datum
-plls_call_validator(PG_FUNCTION_ARGS) throw()
+plls_call_validator(PG_FUNCTION_ARGS)
 {
 	return common_pl_call_validator(fcinfo, PLV8_DIALECT_LIVESCRIPT);
 }
@@ -1442,14 +1439,15 @@ Converter::Init()
 {
 	for (int c = 0; c < m_tupdesc->natts; c++)
 	{
-		if (m_tupdesc->attrs[c]->attisdropped)
+		if (TupleDescAttr(m_tupdesc, c)->attisdropped)
 			continue;
 
-		m_colnames[c] = ToString(NameStr(m_tupdesc->attrs[c]->attname));
+		m_colnames[c] = ToString(NameStr(TupleDescAttr(m_tupdesc, c)->attname));
 
 		PG_TRY();
 		{
 			if (m_memcontext == NULL)
+#if PG_VERSION_NUM < 110000
 				m_memcontext = AllocSetContextCreate(
 									CurrentMemoryContext,
 									"ConverterContext",
@@ -1459,6 +1457,15 @@ Converter::Init()
 			plv8_fill_type(&m_coltypes[c],
 						   m_tupdesc->attrs[c]->atttypid,
 						   m_memcontext);
+#else
+				m_memcontext = AllocSetContextCreate(
+									CurrentMemoryContext,
+									"ConverterContext",
+									ALLOCSET_DEFAULT_SIZES);
+			plv8_fill_type(&m_coltypes[c],
+						   m_tupdesc->attrs[c].atttypid,
+						   m_memcontext);
+#endif
 		}
 		PG_CATCH();
 		{
@@ -1480,7 +1487,7 @@ Converter::ToValue(HeapTuple tuple)
 		Datum		datum;
 		bool		isnull;
 
-		if (m_tupdesc->attrs[c]->attisdropped)
+		if (TupleDescAttr(m_tupdesc, c)->attisdropped)
 			continue;
 
 #if PG_VERSION_NUM >= 90000
@@ -1528,7 +1535,7 @@ Converter::ToDatum(Handle<v8::Value> value, Tuplestore
 
 		for (int c = 0; c < m_tupdesc->natts; c++)
 		{
-			if (m_tupdesc->attrs[c]->attisdropped)
+			if (TupleDescAttr(m_tupdesc, c)->attisdropped)
 				continue;
 
 			bool found = false;
@@ -1549,7 +1556,7 @@ Converter::ToDatum(Handle<v8::Value> value, Tuplestore
 
 	for (int c = 0; c < m_tupdesc->natts; c++)
 	{
-		if (m_tupdesc->attrs[c]->attisdropped)
+		if (TupleDescAttr(m_tupdesc, c)->attisdropped)
 			continue;
 
 		Handle<v8::Value> attr = m_is_scalar ? value : obj->Get(m_colnames[c]);
