📄 driver.xst
字号:
CODE: D_imp_xxh(h); /* dbd_take_imp_data() returns &sv_no (or other defined but false value) * to indicate "preparations complete, now call SUPER::take_imp_data" for me. * Anything else is returned to the caller via sv_2mortal(sv), typically that * would be &sv_undef for error or an SV holding the imp_data. */ SV *sv = dbd_take_imp_data(h, imp_xxh, NULL); ST(0) = (SvOK(sv) && !SvTRUE(sv)) ? dbixst_bounce_method("DBD::~DRIVER~::db::SUPER::take_imp_data", items) : sv_2mortal(sv);#endif#ifdef dbd_db_data_sourcesvoiddata_sources(dbh, attr = Nullsv) SV *dbh SV *attr PPCODE: { D_imp_dbh(dbh); AV *av = dbd_db_data_sources(dbh, imp_dbh, attr); if (av) { int i; int n = AvFILL(av)+1; EXTEND(sp, n); for (i = 0; i < n; ++i) { PUSHs(AvARRAY(av)[i]); } } }#endif# -- end of DBD::~DRIVER~::db# ------------------------------------------------------------# statement interface# ------------------------------------------------------------MODULE = DBD::~DRIVER~ PACKAGE = DBD::~DRIVER~::stvoid_prepare(sth, statement, attribs=Nullsv) SV * sth SV * statement SV * attribs CODE: { D_imp_sth(sth); DBD_ATTRIBS_CHECK("_prepare", sth, attribs);#ifdef dbd_st_prepare_sv ST(0) = dbd_st_prepare_sv(sth, imp_sth, statement, attribs) ? &sv_yes : &sv_no;#else ST(0) = dbd_st_prepare(sth, imp_sth, SvPV_nolen(statement), attribs) ? &sv_yes : &sv_no;#endif }#ifdef dbd_st_rowsvoidrows(sth) SV * sth CODE: D_imp_sth(sth); XST_mIV(0, dbd_st_rows(sth, imp_sth));#endif /* dbd_st_rows */#ifdef dbd_st_bind_colvoidbind_col(sth, col, ref, attribs=Nullsv) SV * sth SV * col SV * ref SV * attribs CODE: { IV sql_type = 0; D_imp_sth(sth); if (SvGMAGICAL(ref)) mg_get(ref); if (attribs) { if (SvNIOK(attribs)) { sql_type = SvIV(attribs); attribs = Nullsv; } else { SV **svp; DBD_ATTRIBS_CHECK("bind_col", sth, attribs); /* XXX we should perhaps complain if TYPE is not SvNIOK */ DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); } } switch(dbd_st_bind_col(sth, imp_sth, col, ref, sql_type, attribs)) { case 2: ST(0) = &sv_yes; /* job done completely */ break; case 1: /* fallback to DBI default */ ST(0) = (DBIc_DBISTATE(imp_sth)->bind_col(sth, col, ref, attribs)) ? &sv_yes : &sv_no; break; default: ST(0) = &sv_no; /* dbd_st_bind_col has called set_err */ break; } }#endif /* dbd_st_bind_col */voidbind_param(sth, param, value, attribs=Nullsv) SV * sth SV * param SV * value SV * attribs CODE: { IV sql_type = 0; D_imp_sth(sth); if (SvGMAGICAL(value)) mg_get(value); if (attribs) { if (SvNIOK(attribs)) { sql_type = SvIV(attribs); attribs = Nullsv; } else { SV **svp; DBD_ATTRIBS_CHECK("bind_param", sth, attribs); /* XXX we should perhaps complain if TYPE is not SvNIOK */ DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); } } ST(0) = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0) ? &sv_yes : &sv_no; }voidbind_param_inout(sth, param, value_ref, maxlen, attribs=Nullsv) SV * sth SV * param SV * value_ref IV maxlen SV * attribs CODE: { IV sql_type = 0; D_imp_sth(sth); SV *value; if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG) croak("bind_param_inout needs a reference to a scalar value"); value = SvRV(value_ref); if (SvREADONLY(value)) croak("Modification of a read-only value attempted"); if (SvGMAGICAL(value)) mg_get(value); if (attribs) { if (SvNIOK(attribs)) { sql_type = SvIV(attribs); attribs = Nullsv; } else { SV **svp; DBD_ATTRIBS_CHECK("bind_param", sth, attribs); DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); } } ST(0) = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, TRUE, maxlen) ? &sv_yes : &sv_no; }voidexecute(sth, ...) SV * sth CODE: D_imp_sth(sth); int retval; if (items > 1) { /* need to bind params */ if (!dbdxst_bind_params(sth, imp_sth, items, ax) ) { XSRETURN_UNDEF; } } /* XXX this code is duplicated in selectrow_arrayref above */ if (DBIc_ROW_COUNT(imp_sth) > 0) /* reset for re-execute */ DBIc_ROW_COUNT(imp_sth) = 0; retval = dbd_st_execute(sth, imp_sth); /* remember that dbd_st_execute must return <= -2 for error */ if (retval == 0) /* ok with no rows affected */ XST_mPV(0, "0E0"); /* (true but zero) */ else if (retval < -1) /* -1 == unknown number of rows */ XST_mUNDEF(0); /* <= -2 means error */ else XST_mIV(0, retval); /* typically 1, rowcount or -1 */#ifdef dbd_st_execute_for_fetchvoidexecute_for_fetch(sth, fetch_tuple_sub, tuple_status = Nullsv) SV * sth SV * fetch_tuple_sub SV * tuple_status CODE: { D_imp_sth(sth); ST(0) = dbd_st_execute_for_fetch(sth, imp_sth, fetch_tuple_sub, tuple_status); }#endifvoidfetchrow_arrayref(sth) SV * sth ALIAS: fetch = 1 CODE: D_imp_sth(sth); AV *av; if (0) ix = ix; /* avoid unused variable warning */ av = dbd_st_fetch(sth, imp_sth); ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_sv_undef;voidfetchrow_array(sth) SV * sth ALIAS: fetchrow = 1 PPCODE: D_imp_sth(sth); AV *av; av = dbd_st_fetch(sth, imp_sth); if (av) { int i; int num_fields = AvFILL(av)+1; EXTEND(sp, num_fields); for(i=0; i < num_fields; ++i) { PUSHs(AvARRAY(av)[i]); } if (0) ix = ix; /* avoid unused variable warning */ }voidfetchall_arrayref(sth, slice=&PL_sv_undef, batch_row_count=&PL_sv_undef) SV * sth SV * slice SV * batch_row_count CODE: if (SvOK(slice)) { /* fallback to perl implementation */ ST(0) = dbixst_bounce_method("DBD::~DRIVER~::st::SUPER::fetchall_arrayref", 3); } else { ST(0) = dbdxst_fetchall_arrayref(sth, slice, batch_row_count); }voidfinish(sth) SV * sth CODE: D_imp_sth(sth); D_imp_dbh_from_sth; if (!DBIc_ACTIVE(imp_sth)) { /* No active statement to finish */ XSRETURN_YES; } if (!DBIc_ACTIVE(imp_dbh)) { /* Either an explicit disconnect() or global destruction */ /* has disconnected us from the database. Finish is meaningless */ DBIc_ACTIVE_off(imp_sth); XSRETURN_YES; }#ifdef dbd_st_finish3 ST(0) = dbd_st_finish3(sth, imp_sth, 0) ? &sv_yes : &sv_no;#else ST(0) = dbd_st_finish(sth, imp_sth) ? &sv_yes : &sv_no;#endifvoidblob_read(sth, field, offset, len, destrv=Nullsv, destoffset=0) SV * sth int field long offset long len SV * destrv long destoffset CODE: { D_imp_sth(sth); if (!destrv) destrv = sv_2mortal(newRV(sv_2mortal(newSV(0)))); if (dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset)) ST(0) = SvRV(destrv); else ST(0) = &PL_sv_undef; }voidSTORE(sth, keysv, valuesv) SV * sth SV * keysv SV * valuesv CODE: D_imp_sth(sth); if (SvGMAGICAL(valuesv)) mg_get(valuesv); ST(0) = &sv_yes; if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv)) if (!DBIc_DBISTATE(imp_sth)->set_attr(sth, keysv, valuesv)) ST(0) = &sv_no;# FETCH renamed and ALIAS'd to avoid case clash on VMS :-(voidFETCH_attrib(sth, keysv) SV * sth SV * keysv ALIAS: FETCH = 1 CODE: D_imp_sth(sth); SV *valuesv; if (0) ix = ix; /* avoid unused variable warning */ valuesv = dbd_st_FETCH_attrib(sth, imp_sth, keysv); if (!valuesv) valuesv = DBIc_DBISTATE(imp_sth)->get_attr(sth, keysv); ST(0) = valuesv; /* dbd_st_FETCH_attrib did sv_2mortal */voidDESTROY(sth) SV * sth PPCODE: D_imp_sth(sth); ST(0) = &sv_yes; if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */ STRLEN lna; if (DBIc_WARN(imp_sth) && !dirty && DBIc_DBISTATE(imp_sth)->debug >= 2) PerlIO_printf(DBIc_LOGPIO(imp_sth), " DESTROY for %s ignored - handle not initialised\n", SvPV(sth,lna)); } else { if (DBIc_IADESTROY(imp_sth)) { /* want's ineffective destroy */ DBIc_ACTIVE_off(imp_sth); if (DBIc_DBISTATE(imp_sth)->debug) PerlIO_printf(DBIc_LOGPIO(imp_sth), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(sth)); } if (DBIc_ACTIVE(imp_sth)) { D_imp_dbh_from_sth; if (!dirty && DBIc_ACTIVE(imp_dbh)) {#ifdef dbd_st_finish3 dbd_st_finish3(sth, imp_sth, 1);#else dbd_st_finish(sth, imp_sth);#endif } else { DBIc_ACTIVE_off(imp_sth); } } dbd_st_destroy(sth, imp_sth); }# end of ~DRIVER~.xst
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -