Skip to content

Commit

Permalink
- preserve callers memory context rather than assuming query memory c…
Browse files Browse the repository at this point in the history
…ontext

- register plr_atexit using atexit() so that when R interpreter exit()'s on
  failure to initialize (e.g. if R_HOME is incorrect) we throw an error
  instead of killing the postgres backend unexpectedly
- replace call to R function lcons() with explicit call to Rf_lcons() since
  postgres also has an lcons() function (Neil Conway)
- use PG_DETOAST_DATUM() on array arguments to ensure they get detoasted
  if needed.
- R and Postgres attempt to define symbols with the same name in their
  header files. Change to alternative that is less of a kludge
  (Neil Conway)
- fix for R_VERSION >= 2.5.0, R_ParseVector has extra arguments
  • Loading branch information
jconway committed Jun 2, 2007
1 parent 2f6f75f commit f7a3640
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
13 changes: 3 additions & 10 deletions plr.c
Expand Up @@ -729,16 +729,9 @@ compile_plr_function(FunctionCallInfo fcinfo)

if (function)
{
bool function_valid;

/* We have a compiled function, but is it still valid? */
if (function->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
ItemPointerEquals(&function->fn_tid, &procTup->t_self))
function_valid = true;
else
function_valid = false;

if (!function_valid)
if (!(function->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
function->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)))
{
/*
* Nope, drop the hashtable entry. XXX someday, free all the
Expand Down Expand Up @@ -843,7 +836,7 @@ do_compile(FunctionCallInfo fcinfo,

function->proname = pstrdup(proname);
function->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
function->fn_tid = procTup->t_self;
function->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);

/* Lookup the pg_language tuple by Oid*/
langTup = SearchSysCache(LANGOID,
Expand Down
6 changes: 3 additions & 3 deletions plr.h
Expand Up @@ -82,11 +82,11 @@

/* working with postgres 7.3 compatible sources */
#if (CATALOG_VERSION_NO <= 200510211)
#error "This version of PL/R only builds with PostgreSQL 8.2 or later"
#error "This version of PL/R only builds with PostgreSQL 8.2"
#elif (CATALOG_VERSION_NO <= 200611241)
#define PG_VERSION_82_COMPAT
#else
#define PG_VERSION_83_COMPAT
#error "This version of PL/R only builds with PostgreSQL 8.2"
#endif

#ifdef DEBUGPROTECT
Expand Down Expand Up @@ -389,7 +389,7 @@ typedef struct plr_function
{
char *proname;
TransactionId fn_xmin;
ItemPointerData fn_tid;
CommandId fn_cmin;
plr_func_hashkey *fn_hashkey; /* back-link to hashtable key */
bool lanpltrusted;
Oid result_typid;
Expand Down

0 comments on commit f7a3640

Please sign in to comment.