Permalink
Browse files

- detoast input datum before copying it into an R object

  • Loading branch information...
1 parent b4f99fb commit ddf1535fa4d2fc04e406a4c45e3ed9950ce5d0e9 jconway committed Apr 2, 2010
Showing with 7 additions and 4 deletions.
  1. +7 −4 pg_conversion.c
View
11 pg_conversion.c
@@ -93,19 +93,22 @@ pg_scalar_get_r(Datum dvalue, Oid arg_typid, FmgrInfo arg_out_func)
{
SEXP s, t, obj;
int status;
+ Datum dt_dvalue = PointerGetDatum(PG_DETOAST_DATUM(dvalue));
+ int bsize = VARSIZE((bytea *) dt_dvalue);
- PROTECT(obj = get_r_vector(arg_typid, VARSIZE((bytea *) dvalue)));
+ PROTECT(obj = get_r_vector(arg_typid, bsize));
memcpy((char *) RAW(obj),
- VARDATA((bytea *) dvalue),
- VARSIZE((bytea *) dvalue));
+ VARDATA((bytea *) dt_dvalue),
+ bsize);
/*
* Need to construct a call to
* unserialize(rval)
*/
PROTECT(t = s = allocList(2));
SET_TYPEOF(s, LANGSXP);
- SETCAR(t, install("unserialize")); t = CDR(t);
+ SETCAR(t, install("unserialize"));
+ t = CDR(t);
SETCAR(t, obj);
PROTECT(result = R_tryEval(s, R_GlobalEnv, &status));

0 comments on commit ddf1535

Please sign in to comment.