in reply to Re^3: Perl XS - is this code required in DBD::Pg? (empty)
in thread Perl XS - is this code required in DBD::Pg?
Thanks again tye. I ended up with the following:
SV * odbc_lob_read(sth, colno, bufsv, length, attr = NULL) SV *sth int colno SV *bufsv UV length SV *attr; PROTOTYPE: $$$$;$ PREINIT: char *buf; UV ret_len; IV sql_type = 0; INIT: if (length == 0) { croak("Cannot retrieve 0 length lob"); } CODE: if (attr) { SV **svp; DBD_ATTRIBS_CHECK("odbc_lob_read", sth, attr); DBD_ATTRIB_GET_IV(attr, "Type", 4, svp, sql_type); } if (SvROK(bufsv)) { bufsv = SvRV(bufsv); } sv_setpvn(bufsv, "", 0); /* ensure we can grow +ok */ buf = SvGROW(bufsv, length + 1); ret_len = odbc_st_lob_read(sth, colno, bufsv, length, sql_type); if (ret_len > 0) { SvCUR_set(bufsv, ret_len); /* set length in SV */ *SvEND(bufsv) = '\0'; /* NUL terminate */ SvSETMAGIC(bufsv); RETVAL = newSViv(ret_len); } else { XSRETURN_UNDEF; } OUTPUT: RETVAL
Thanks again for your suggestions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Perl XS - is this code required in DBD::Pg? (errors)
by tye (Sage) on Jul 22, 2010 at 21:06 UTC | |
by mje (Curate) on Jul 23, 2010 at 09:54 UTC |