Skip to content

Commit

Permalink
Initialize the interpreter only once. This fixes the crashes I've bee…
Browse files Browse the repository at this point in the history
…n having all the time.

Note, in passing, that the recent move of plparrot.c to src, instead of
src/handler, doesn't fix the problem where make installs everything into the
wrong place. PostgreSQL still looks for plparrot.so in $libdir, but the
installer puts it in $libdir/src. This hasn't been failing immediately in my
case, because there's an old plparrot.so already there. That makes debugging
... less simple. :) But that's also a fix for another night.
  • Loading branch information
Joshua Tolley committed Feb 24, 2010
1 parent cda3a3a commit 23de4a5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/plparrot.c
Expand Up @@ -64,6 +64,7 @@ typedef struct plparrot_call_data
} plparrot_call_data;

int execq(text *sql, int cnt);
Parrot_Interp interp;

void
_PG_init(void)
Expand All @@ -74,6 +75,14 @@ _PG_init(void)
if (inited)
return;

interp = Parrot_new(NULL);
imcc_initialize(interp);

if (!interp) {
elog(ERROR,"Could not create a Parrot interpreter!\n");
return 1;
}

inited = true;
}

Expand Down Expand Up @@ -123,17 +132,8 @@ plparrot_call_handler(PG_FUNCTION_ARGS)
Form_pg_proc procstruct;
HeapTuple proctup;
Oid returntype;
Parrot_Interp interp;
plparrot_call_data *save_call_data = current_call_data;

interp = Parrot_new(NULL);
imcc_initialize(interp);

if (!interp) {
elog(ERROR,"Could not create a Parrot interpreter!\n");
return 1;
}

proctup = SearchSysCache(PROCOID, ObjectIdGetDatum(fcinfo->flinfo->fn_oid), 0, 0, 0);
if (!HeapTupleIsValid(proctup))
elog(ERROR, "Failed to look up procedure with OID %u", fcinfo->flinfo->fn_oid);
Expand Down

0 comments on commit 23de4a5

Please sign in to comment.