diff -Nru plv8-1.5.0.ds/Changes plv8-1.4.6.ds/Changes --- plv8-1.5.0.ds/Changes 2016-03-18 11:06:37.000000000 +0000 +++ plv8-1.4.6.ds/Changes 2016-03-27 19:49:02.000000000 +0000 @@ -1,16 +1,5 @@ Revision history for plv8 -1.5.0 2016-02-26 - - Adaptions for current V8 version, e.g. 4.1.0.x - 4.3.66 - (see http://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/ - for an overview of the V8 changes which break existing code bases) - - GUC plv8.v8_flags for V8 engine initialization flags - - Fixed crash in ArrayBuffer - - Fixed encoding issues with elog - - Fixed memory leak in cursor fetch - - Errors return full error context as an object now - - Fixed crash bug in cursor fetch - 1.4.4 2015-05-26 - Add jsonb type coercion in function boundary. - Fix crash related to FLEXIBLE_ARRAY_MEMBER changes. diff -Nru plv8-1.5.0.ds/debian/changelog plv8-1.4.6.ds/debian/changelog --- plv8-1.5.0.ds/debian/changelog 2016-03-18 11:19:02.000000000 +0000 +++ plv8-1.4.6.ds/debian/changelog 2016-03-28 14:48:07.000000000 +0000 @@ -1,3 +1,11 @@ +plv8 (1:1.4.6.ds-1) unstable; urgency=medium + + * New 1.4 upstream release supporting v8 3.14. Thanks to Jerry Sievert! + (The 1.5 series needs v8 4.x that isn't available in sid yet.) + * Add "expected" files for PG versions <= 9.3. + + -- Christoph Berg Mon, 28 Mar 2016 16:48:05 +0200 + plv8 (1.5.0.ds-1) unstable; urgency=medium [ Christoph Berg ] diff -Nru plv8-1.5.0.ds/debian/patches/make-it-compile-with-v8-3.14-again plv8-1.4.6.ds/debian/patches/make-it-compile-with-v8-3.14-again --- plv8-1.5.0.ds/debian/patches/make-it-compile-with-v8-3.14-again 2016-03-18 11:06:37.000000000 +0000 +++ plv8-1.4.6.ds/debian/patches/make-it-compile-with-v8-3.14-again 1970-01-01 00:00:00.000000000 +0000 @@ -1,1922 +0,0 @@ -From c569039c5144ca56e3c1e12c832aa08c0aae84c6 Mon Sep 17 00:00:00 2001 -From: Evgeni Golov -Date: Sat, 27 Feb 2016 09:18:56 +0100 -Subject: [PATCH] make it compile with v8 3.14 again - ---- - Makefile | 4 +- - plv8.cc | 307 +++++++++++++---------------------------- - plv8.h | 19 +-- - plv8_func.cc | 442 ++++++++++++++++++++++++++--------------------------------- - plv8_type.cc | 49 +++---- - 5 files changed, 322 insertions(+), 499 deletions(-) - -diff --git a/Makefile b/Makefile -index 97ab802..dc18db7 100644 ---- a/Makefile -+++ b/Makefile -@@ -37,7 +37,7 @@ DATA += plcoffee.control plcoffee--$(PLV8_VERSION).sql \ - endif - DATA_built = plv8.sql - REGRESS = init-extension plv8 plv8-errors inline json startup_pre startup varparam json_conv \ -- jsonb_conv window guc es6 arraybuffer composites -+ jsonb_conv window composites - ifndef DISABLE_DIALECT - REGRESS += dialect - endif -@@ -45,8 +45,6 @@ endif - SHLIB_LINK += -lv8 - ifdef V8_OUTDIR - SHLIB_LINK += -L$(V8_OUTDIR) --else --SHLIB_LINK += -lv8_libplatform - endif - - -diff --git a/plv8.cc b/plv8.cc -index e8fb17f..f819779 100644 ---- a/plv8.cc -+++ b/plv8.cc -@@ -6,8 +6,6 @@ - *------------------------------------------------------------------------- - */ - #include "plv8.h" --#include "libplatform/libplatform.h" -- - #include - - extern "C" { -@@ -88,8 +86,6 @@ typedef struct plv8_proc_cache - Oid argtypes[FUNC_MAX_ARGS]; - } plv8_proc_cache; - --Isolate* plv8_isolate = NULL; -- - /* - * The function and context are created at the first invocation. Their - * lifetime is same as plv8_proc, but they are not palloc'ed memory, -@@ -99,7 +95,6 @@ typedef struct plv8_exec_env - { - Persistent recv; - Persistent context; -- Local localContext() { return Local::New(plv8_isolate, context) ; } - struct plv8_exec_env *next; - } plv8_exec_env; - -@@ -123,7 +118,6 @@ typedef struct plv8_proc - typedef struct plv8_context - { - Persistent context; -- Local localContext() { return Local::New(plv8_isolate, context) ; } - Oid user_id; - } plv8_context; - -@@ -134,40 +128,6 @@ static plv8_exec_env *exec_env_head = NULL; - extern const unsigned char coffee_script_binary_data[]; - extern const unsigned char livescript_binary_data[]; - --class Plv8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { -- public: -- virtual void* Allocate(size_t length) { -- void* data = AllocateUninitialized(length); -- return data == NULL ? data : memset(data, 0, length); -- } -- virtual void* AllocateUninitialized(size_t length) { -- void *data = NULL; -- -- PG_TRY(); -- { -- data = palloc(length); -- } -- PG_CATCH(); -- { -- throw pg_error(); -- } -- PG_END_TRY(); -- -- return data; -- } -- virtual void Free(void* data, size_t) { -- PG_TRY(); -- { -- pfree(data); -- } -- PG_CATCH(); -- { -- throw pg_error(); -- } -- PG_END_TRY(); -- } --}; -- - /* - * lower_case_functions are postgres-like C functions. - * They could raise errors with elog/ereport(ERROR). -@@ -181,10 +141,9 @@ static void plv8_xact_cb(XactEvent event, void *arg); - * They could raise errors with C++ throw statements, or never throw exceptions. - */ - static plv8_exec_env *CreateExecEnv(Handle script); --static plv8_exec_env *CreateExecEnv(Persistent& script); - static plv8_proc *Compile(Oid fn_oid, FunctionCallInfo fcinfo, - bool validate, bool is_trigger, Dialect dialect); --static Local CompileFunction(Persistent& global_context, -+static Local CompileFunction(Handle global_context, - const char *proname, int proarglen, - const char *proargs[], const char *prosrc, - bool is_trigger, bool retset, Dialect dialect); -@@ -193,15 +152,12 @@ static Datum CallFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - static Datum CallSRFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - int nargs, plv8_type argtypes[], plv8_type *rettype); - static Datum CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv); --static void GetGlobalContext(Persistent& global_context); --static Local GetGlobalObjectTemplate(); -+static Persistent GetGlobalContext(); -+static Persistent GetGlobalObjectTemplate(); - - /* A GUC to specify a custom start up function to call */ - static char *plv8_start_proc = NULL; - --/* A GUC to specify V8 flags (e.g. --es_staging) */ --static char *plv8_v8_flags = NULL; -- - /* A GUC to specify the remote debugger port */ - static int plv8_debugger_port; - /* -@@ -235,7 +191,7 @@ void - _PG_init(void) - { - HASHCTL hash_ctl = { 0 }; -- -+ - hash_ctl.keysize = sizeof(Oid); - hash_ctl.entrysize = sizeof(plv8_proc_cache); - hash_ctl.hash = oid_hash; -@@ -254,18 +210,6 @@ _PG_init(void) - NULL, - NULL); - -- DefineCustomStringVariable("plv8.v8_flags", -- gettext_noop("V8 engine initialization flags (e.g. --es_staging for additional ES6 features)."), -- NULL, -- &plv8_v8_flags, -- NULL, -- PGC_USERSET, 0, --#if PG_VERSION_NUM >= 90100 -- NULL, --#endif -- NULL, -- NULL); -- - DefineCustomIntVariable("plv8.debugger_port", - gettext_noop("V8 remote debug port."), - gettext_noop("The default value is 35432. " -@@ -283,17 +227,6 @@ _PG_init(void) - - EmitWarningsOnPlaceholders("plv8"); - -- V8::SetArrayBufferAllocator(new Plv8ArrayBufferAllocator); -- -- V8::InitializeICU(); -- Platform* platform = platform::CreateDefaultPlatform(); -- V8::InitializePlatform(platform); -- V8::Initialize(); -- if (plv8_v8_flags != NULL) { -- V8::SetFlagsFromString(plv8_v8_flags, strlen(plv8_v8_flags)); -- } -- plv8_isolate = Isolate::New(); -- plv8_isolate->Enter(); - - } - -@@ -306,7 +239,8 @@ plv8_xact_cb(XactEvent event, void *arg) - { - if (!env->recv.IsEmpty()) - { -- env->recv.Reset(); -+ env->recv.Dispose(); -+ env->recv.Clear(); - } - env = env->next; - /* -@@ -346,7 +280,7 @@ common_pl_call_handler(PG_FUNCTION_ARGS, Dialect dialect) throw() - #ifdef ENABLE_DEBUGGER_SUPPORT - Locker lock; - #endif // ENABLE_DEBUGGER_SUPPORT -- HandleScope handle_scope(plv8_isolate); -+ HandleScope handle_scope; - - if (!fcinfo->flinfo->fn_extra) - { -@@ -405,12 +339,11 @@ common_pl_inline_handler(PG_FUNCTION_ARGS, Dialect dialect) throw() - #ifdef ENABLE_DEBUGGER_SUPPORT - Locker lock; - #endif // ENABLE_DEBUGGER_SUPPORT -- HandleScope handle_scope(plv8_isolate); -+ HandleScope handle_scope; - char *source_text = codeblock->source_text; - -- Persistent global_context; -- GetGlobalContext(global_context); -- Local function = CompileFunction(global_context, -+ Handle global_context = GetGlobalContext(); -+ Handle function = CompileFunction(global_context, - NULL, 0, NULL, - source_text, false, false, dialect); - plv8_exec_env *xenv = CreateExecEnv(function); -@@ -470,7 +403,7 @@ static Datum - CallFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - int nargs, plv8_type argtypes[], plv8_type *rettype) - { -- Local context = xenv->localContext(); -+ Handle context = xenv->context; - Context::Scope context_scope(context); - Handle args[FUNC_MAX_ARGS]; - Handle plv8obj; -@@ -497,11 +430,10 @@ CallFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - args[i] = ToValue(fcinfo->arg[i], fcinfo->argnull[i], &argtypes[i]); - } - -- Local recv = Local::New(plv8_isolate, xenv->recv); - Local fn = -- Local::Cast(recv->GetInternalField(0)); -+ Local::Cast(xenv->recv->GetInternalField(0)); - Local result = -- DoCall(fn, recv, nargs, args); -+ DoCall(fn, xenv->recv, nargs, args); - - if (rettype) - return ToDatum(result, &fcinfo->isnull, rettype); -@@ -579,7 +511,7 @@ CallSRFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - - tupstore = CreateTupleStore(fcinfo, &tupdesc); - -- Handle context = xenv->localContext(); -+ Handle context = xenv->context; - Context::Scope context_scope(context); - Converter conv(tupdesc, proc->functypclass == TYPEFUNC_SCALAR); - Handle args[FUNC_MAX_ARGS + 1]; -@@ -593,11 +525,10 @@ CallSRFunction(PG_FUNCTION_ARGS, plv8_exec_env *xenv, - for (int i = 0; i < nargs; i++) - args[i] = ToValue(fcinfo->arg[i], fcinfo->argnull[i], &argtypes[i]); - -- Local recv = Local::New(plv8_isolate, xenv->recv); - Local fn = -- Local::Cast(recv->GetInternalField(0)); -+ Local::Cast(xenv->recv->GetInternalField(0)); - -- Handle result = DoCall(fn, recv, nargs, args); -+ Handle result = DoCall(fn, xenv->recv, nargs, args); - - if (result->IsUndefined()) - { -@@ -643,7 +574,7 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv) - Handle args[10]; - Datum result = (Datum) 0; - -- Handle context = xenv->localContext(); -+ Handle context = xenv->context; - Context::Scope context_scope(context); - - if (TRIGGER_FIRED_FOR_ROW(event)) -@@ -657,13 +588,13 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv) - // NEW - args[0] = conv.ToValue(trig->tg_trigtuple); - // OLD -- args[1] = Undefined(plv8_isolate); -+ args[1] = Undefined(); - } - else if (TRIGGER_FIRED_BY_DELETE(event)) - { - result = PointerGetDatum(trig->tg_trigtuple); - // NEW -- args[0] = Undefined(plv8_isolate); -+ args[0] = Undefined(); - // OLD - args[1] = conv.ToValue(trig->tg_trigtuple); - } -@@ -678,7 +609,7 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv) - } - else - { -- args[0] = args[1] = Undefined(plv8_isolate); -+ args[0] = args[1] = Undefined(); - } - - // 2: TG_NAME -@@ -686,32 +617,32 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv) - - // 3: TG_WHEN - if (TRIGGER_FIRED_BEFORE(event)) -- args[3] = String::NewFromUtf8(plv8_isolate, "BEFORE"); -+ args[3] = String::New("BEFORE"); - else -- args[3] = String::NewFromUtf8(plv8_isolate, "AFTER"); -+ args[3] = String::New("AFTER"); - - // 4: TG_LEVEL - if (TRIGGER_FIRED_FOR_ROW(event)) -- args[4] = String::NewFromUtf8(plv8_isolate, "ROW"); -+ args[4] = String::New("ROW"); - else -- args[4] = String::NewFromUtf8(plv8_isolate, "STATEMENT"); -+ args[4] = String::New("STATEMENT"); - - // 5: TG_OP - if (TRIGGER_FIRED_BY_INSERT(event)) -- args[5] = String::NewFromUtf8(plv8_isolate, "INSERT"); -+ args[5] = String::New("INSERT"); - else if (TRIGGER_FIRED_BY_DELETE(event)) -- args[5] = String::NewFromUtf8(plv8_isolate, "DELETE"); -+ args[5] = String::New("DELETE"); - else if (TRIGGER_FIRED_BY_UPDATE(event)) -- args[5] = String::NewFromUtf8(plv8_isolate, "UPDATE"); -+ args[5] = String::New("UPDATE"); - #ifdef TRIGGER_FIRED_BY_TRUNCATE - else if (TRIGGER_FIRED_BY_TRUNCATE(event)) -- args[5] = String::NewFromUtf8(plv8_isolate, "TRUNCATE"); -+ args[5] = String::New("TRUNCATE"); - #endif - else -- args[5] = String::NewFromUtf8(plv8_isolate, "?"); -+ args[5] = String::New("?"); - - // 6: TG_RELID -- args[6] = Uint32::New(plv8_isolate, RelationGetRelid(rel)); -+ args[6] = Uint32::New(RelationGetRelid(rel)); - - // 7: TG_TABLE_NAME - args[7] = ToString(RelationGetRelationName(rel)); -@@ -720,17 +651,16 @@ CallTrigger(PG_FUNCTION_ARGS, plv8_exec_env *xenv) - args[8] = ToString(get_namespace_name(RelationGetNamespace(rel))); - - // 9: TG_ARGV -- Handle tgargs = Array::New(plv8_isolate, trig->tg_trigger->tgnargs); -+ Handle tgargs = Array::New(trig->tg_trigger->tgnargs); - for (int i = 0; i < trig->tg_trigger->tgnargs; i++) - tgargs->Set(i, ToString(trig->tg_trigger->tgargs[i])); - args[9] = tgargs; - - TryCatch try_catch; -- Local recv = Local::New(plv8_isolate, xenv->recv); - Local fn = -- Local::Cast(recv->GetInternalField(0)); -+ Local::Cast(xenv->recv->GetInternalField(0)); - Handle newtup = -- DoCall(fn, recv, lengthof(args), args); -+ DoCall(fn, xenv->recv, lengthof(args), args); - - if (newtup.IsEmpty()) - throw js_error(try_catch); -@@ -876,7 +806,8 @@ plv8_get_proc(Oid fn_oid, FunctionCallInfo fcinfo, bool validate, char ***argnam - pfree(cache->prosrc); - cache->prosrc = NULL; - } -- cache->function.Reset(); -+ cache->function.Dispose(); -+ cache->function.Clear(); - } - else - { -@@ -985,46 +916,10 @@ plv8_get_proc(Oid fn_oid, FunctionCallInfo fcinfo, bool validate, char ***argnam - } - - static plv8_exec_env * --CreateExecEnv(Persistent& function) --{ -- plv8_exec_env *xenv; -- HandleScope handle_scope(plv8_isolate); -- -- PG_TRY(); -- { -- xenv = plv8_new_exec_env(); -- } -- PG_CATCH(); -- { -- throw pg_error(); -- } -- PG_END_TRY(); -- -- GetGlobalContext(xenv->context); -- Context::Scope scope(xenv->localContext()); -- -- static Persistent recv_templ; -- if (recv_templ.IsEmpty()) -- { -- Local templ = ObjectTemplate::New(plv8_isolate); -- templ->SetInternalFieldCount(1); -- recv_templ.Reset(plv8_isolate, templ); -- } -- Local templ = Local::New(plv8_isolate, recv_templ); -- Local obj = templ->NewInstance(); -- Local f = Local::New(plv8_isolate, function); -- obj->SetInternalField(0, f); -- xenv->recv.Reset(plv8_isolate, obj); -- -- -- return xenv; --} -- --static plv8_exec_env * - CreateExecEnv(Handle function) - { - plv8_exec_env *xenv; -- HandleScope handle_scope(plv8_isolate); -+ HandleScope handle_scope; - - PG_TRY(); - { -@@ -1036,22 +931,18 @@ CreateExecEnv(Handle function) - } - PG_END_TRY(); - -- GetGlobalContext(xenv->context); -- Context::Scope scope(xenv->localContext()); -+ xenv->context = GetGlobalContext(); -+ Context::Scope scope(xenv->context); - - static Persistent recv_templ; - if (recv_templ.IsEmpty()) - { -- Local templ = ObjectTemplate::New(plv8_isolate); -- templ->SetInternalFieldCount(1); -- recv_templ.Reset(plv8_isolate, templ); -+ recv_templ = Persistent::New(ObjectTemplate::New()); -+ recv_templ->SetInternalFieldCount(1); - } -- Local templ = Local::New(plv8_isolate, recv_templ); -- Local obj = templ->NewInstance(); -- Local f = Local::New(plv8_isolate, function); -- obj->SetInternalField(0, f); -- xenv->recv.Reset(plv8_isolate, obj); -+ xenv->recv = Persistent::New(recv_templ->NewInstance()); - -+ xenv->recv->SetInternalField(0, function); - - return xenv; - } -@@ -1060,14 +951,9 @@ CreateExecEnv(Handle function) - static char * - CompileDialect(const char *src, Dialect dialect) - { -- HandleScope handle_scope(plv8_isolate); -- static Persistent context; -- if (context.IsEmpty()) { -- Local ctx = Context::New(plv8_isolate, (ExtensionConfiguration*)NULL); -- context.Reset(plv8_isolate, ctx); -- } -- Local ctx = Local::New(plv8_isolate, context); -- Context::Scope context_scope(ctx); -+ HandleScope handle_scope; -+ static Persistent context = Context::New((ExtensionConfiguration*)NULL); -+ Context::Scope context_scope(context); - TryCatch try_catch; - Local key; - char *cresult; -@@ -1078,24 +964,24 @@ CompileDialect(const char *src, Dialect dialect) - case PLV8_DIALECT_COFFEE: - if (coffee_script_binary_data[0] == '\0') - throw js_error("CoffeeScript is not enabled"); -- key = String::NewFromUtf8(plv8_isolate, "CoffeeScript", String::kInternalizedString); -+ key = String::NewSymbol("CoffeeScript"); - dialect_binary_data = (const char *) coffee_script_binary_data; - break; - case PLV8_DIALECT_LIVESCRIPT: - if (livescript_binary_data[0] == '\0') - throw js_error("LiveScript is not enabled"); -- key = String::NewFromUtf8(plv8_isolate, "LiveScript", String::kInternalizedString); -+ key = String::NewSymbol("LiveScript"); - dialect_binary_data = (const char *) livescript_binary_data; - break; - default: - throw js_error("Unknown Dialect"); - } - -- if (ctx->Global()->Get(key)->IsUndefined()) -+ if (context->Global()->Get(key)->IsUndefined()) - { -- HandleScope handle_scope(plv8_isolate); -+ HandleScope handle_scope; - Local