Perl.xsi

filter: Statementstmt 0.0% 0 / 267 Branchbran 0.0% 0 / 380 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 647 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Perl.xs ↑ Summary dbiprof.PL »
1 # $Id$
2 # Copyright (c) 2024-2026 DBI Team
3 # Copyright (c) 1997-2024 Tim Bunce Ireland
4 # Copyright (c) 2002 Jonathan Leffler
5 #
6 # You may distribute under the terms of either the GNU General Public
7 # License or the Artistic License, as specified in the Perl README file.
8  
9  
10 #include "Driver_xst.h"
11  
12 # Historically dbd_db_do4, dbd_st_execute, and dbd_st_rows returned an 'int' type.
13 # That's only 32 bits (31+sign) so isn't sufficient for very large row counts
14 # So now instead of defining those macros, drivers can define dbd_db_do4_iv,
15 # dbd_st_execute_iv, and dbd_st_rows_iv to be the names of functions that
16 # return an 'IV' type. They could also set DBIc_ROW_COUNT(imp_sth).
17 #
18 # To save a mess of #ifdef's we arrange for dbd_st_execute (etc) to work
19 # as dbd_st_execute_iv if that's defined
20 #
21 #if defined(dbd_st_execute_iv)
22 #undef dbd_st_execute
23 #define dbd_st_execute dbd_st_execute_iv
24 #endif
25 #if defined(dbd_st_rows_iv)
26 #undef dbd_st_rows
27 #define dbd_st_rows dbd_st_rows_iv
28 #endif
29 #if defined(dbd_db_do4_iv)
30 #undef dbd_db_do4
31 #define dbd_db_do4 dbd_db_do4_iv
32 #endif
33  
34 MODULE = DBD::Perl PACKAGE = DBD::Perl
35  
36 REQUIRE: 1.929
37 PROTOTYPES: DISABLE
38  
39 BOOT:
40 PERL_UNUSED_VAR(items);
41 0 ▶ DBISTATE_INIT;
Branch: 1 branch
BranchTrueFalseTotal
DBISTATE_INIT; 0 0 0
42 /* XXX this interface will change: */
43 0 DBI_IMP_SIZE("DBD::Perl::dr::imp_data_size", sizeof(imp_drh_t));
44 0 DBI_IMP_SIZE("DBD::Perl::db::imp_data_size", sizeof(imp_dbh_t));
45 0 DBI_IMP_SIZE("DBD::Perl::st::imp_data_size", sizeof(imp_sth_t));
46 0 dbd_init(DBIS);
47  
48  
49 # ------------------------------------------------------------
50 # driver level interface
51 # ------------------------------------------------------------
52 MODULE = DBD::Perl PACKAGE = DBD::Perl::dr
53  
54  
55 void
56 dbixs_revision(...)
57 PPCODE:
58 0 ST(0) = sv_2mortal(newSViv(DBIXS_REVISION));
59  
60  
61 #ifdef dbd_discon_all
62  
63 # disconnect_all renamed and ALIAS'd to avoid length clash on VMS :-(
64 bool
65 discon_all_(drh)
66 SV * drh
67 ALIAS:
68 disconnect_all = 1
69 CODE:
70 0 D_imp_drh(drh);
71 PERL_UNUSED_VAR(ix);
72 0 ▶ RETVAL = dbd_discon_all(drh, imp_drh);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_discon_all(drh, imp_drh); 0 0 0
73 OUTPUT:
74 RETVAL
75  
76 #endif /* dbd_discon_all */
77  
78  
79 #ifdef dbd_dr_data_sources
80  
81 void
82 data_sources(drh, attr = Nullsv)
83 SV *drh
84 SV *attr
85 PPCODE:
86 {
87 0 D_imp_drh(drh);
88 0 AV *av = dbd_dr_data_sources(drh, imp_drh, attr);
89 0 ▶ if (av) {
Branch: 1 branch
BranchTrueFalseTotal
if (av) { 0 0 0
90 int i;
91 0 int n = AvFILL(av)+1;
92 0 ▶ EXTEND(sp, n);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(sp, n); 0 0 0
EXTEND(sp, n); 0 0 0
93 0 ▶ for (i = 0; i < n; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; ++i) { 0 0 0
94 0 PUSHs(AvARRAY(av)[i]);
95 }
96 }
97 }
98  
99 #endif
100  
101  
102 # ------------------------------------------------------------
103 # database level interface
104 # ------------------------------------------------------------
105 MODULE = DBD::Perl PACKAGE = DBD::Perl::db
106  
107  
108 bool
109 _login(dbh, dbname, username, password, attribs=Nullsv)
110 SV * dbh
111 SV * dbname
112 SV * username
113 SV * password
114 SV * attribs
115 CODE:
116 {
117 0 D_imp_dbh(dbh);
118 #if !defined(dbd_db_login6_sv)
119 STRLEN lna;
120 0 ▶ char *u = (SvOK(username)) ? SvPV(username,lna) : (char*)"";
Branch: 1 branch
BranchTrueFalseTotal
char *u = (SvOK(username)) ? SvPV(username,lna) : (char*)""; 0 0 0
121 0 ▶ char *p = (SvOK(password)) ? SvPV(password,lna) : (char*)"";
Branch: 1 branch
BranchTrueFalseTotal
char *p = (SvOK(password)) ? SvPV(password,lna) : (char*)""; 0 0 0
122 #endif
123 #ifdef dbd_db_login6_sv
124 RETVAL = dbd_db_login6_sv(dbh, imp_dbh, dbname, username, password, attribs);
125 #elif defined(dbd_db_login6)
126 RETVAL = dbd_db_login6(dbh, imp_dbh, SvPV_nolen(dbname), u, p, attribs);
127 #else
128 PERL_UNUSED_ARG(attribs);
129 0 ▶ RETVAL = dbd_db_login( dbh, imp_dbh, SvPV_nolen(dbname), u, p);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_db_login( dbh, imp_dbh, SvPV_nolen(dbname), u, p); 0 0 0
130 #endif
131 }
132 OUTPUT:
133 RETVAL
134  
135  
136 void
137 selectall_arrayref(...)
138 PREINIT:
139 SV *sth;
140 SV **maxrows_svp;
141 SV **tmp_svp;
142 SV *tmp_sv;
143 0 SV *attr = &PL_sv_undef;
144 imp_sth_t *imp_sth;
145 CODE:
146 0 ▶ if (items > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 2) { 0 0 0
147 0 attr = ST(2);
148 0 ▶ if (SvROK(attr) &&
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(attr) && 0 0 0
149 0 ▶ (DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp))
Branch: 10 branches
BranchTrueFalseTotal
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp)) 0 0 0
150 ) {
151 /* fallback to perl implementation */
152 0 SV *tmp =dbixst_bounce_method("DBD::Perl::db::SUPER::selectall_arrayref", items);
153 0 SPAGAIN;
154 0 ST(0) = tmp;
155 0 XSRETURN(1);
156 }
157 }
158 /* --- prepare --- */
159 0 ▶ if (SvROK(ST(1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(1))) { 0 0 0
160 MAGIC *mg;
161 0 sth = ST(1);
162 /* switch to inner handle if not already */
163 0 ▶ if ( (mg = mg_find(SvRV(sth),'P')) )
Branch: 1 branch
BranchTrueFalseTotal
if ( (mg = mg_find(SvRV(sth),'P')) ) 0 0 0
164 0 sth = mg->mg_obj;
165 }
166 else {
167 MAGIC *mg;
168 0 sth = dbixst_bounce_method("prepare", 3);
169 0 SPAGAIN; SP -= items; /* because stack might have been realloc'd */
170 0 ▶ if (!SvROK(sth))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(sth)) 0 0 0
171 0 XSRETURN_UNDEF;
172 /* switch to inner handle */
173 0 mg = mg_find(SvRV(sth),'P');
174 0 ▶ if (!mg)
Branch: 1 branch
BranchTrueFalseTotal
if (!mg) 0 0 0
175 0 XSRETURN_UNDEF;
176 0 sth = mg->mg_obj;
177 }
178 0 imp_sth = (imp_sth_t*)(DBIh_COM(sth));
179 /* --- bind_param --- */
180 0 ▶ if (items > 3) { /* need to bind params before execute */
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) { /* need to bind params before execute */ 0 0 0
181 0 ▶ if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) { 0 0 0
182 0 XSRETURN_UNDEF;
183 }
184 }
185 /* --- execute --- */
186 0 DBIc_ROW_COUNT(imp_sth) = 0;
187 0 ▶ if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
Branch: 1 branch
BranchTrueFalseTotal
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */ 0 0 0
188 0 XSRETURN_UNDEF;
189 }
190 /* --- fetchall --- */
191 0 ▶ maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7);
Branch: 3 branches
BranchTrueFalseTotal
maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7); 0 0 0
maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7); 0 0 0
maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7); 0 0 0
192 0 ▶ tmp_sv = dbdxst_fetchall_arrayref(sth, &PL_sv_undef, (maxrows_svp) ? *maxrows_svp : &PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
tmp_sv = dbdxst_fetchall_arrayref(sth, &PL_sv_undef, (maxrows_svp) ? *maxrows_svp : &PL_sv_undef); 0 0 0
193 0 SPAGAIN;
194 0 ST(0) = tmp_sv;
195  
196  
197 void
198 selectrow_arrayref(...)
199 ALIAS:
200 selectrow_array = 1
201 PREINIT:
202 0 int is_selectrow_array = (ix == 1);
203 imp_sth_t *imp_sth;
204 SV *sth;
205 AV *row_av;
206 PPCODE:
207 0 ▶ if (SvROK(ST(1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(1))) { 0 0 0
208 MAGIC *mg;
209 0 sth = ST(1);
210 /* switch to inner handle if not already */
211 0 mg = mg_find(SvRV(sth),'P');
212 0 ▶ if (!mg) {
Branch: 1 branch
BranchTrueFalseTotal
if (!mg) { 0 0 0
213 0 ▶ if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; } 0 0 0
214 }
215 0 sth = mg->mg_obj;
216 }
217 else {
218 MAGIC *mg;
219 /* --- prepare --- */
220 0 sth = dbixst_bounce_method("prepare", 3);
221 0 SPAGAIN; SP -= items; /* because stack might have been realloc'd */
222 0 ▶ if (!SvROK(sth)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(sth)) { 0 0 0
223 0 ▶ if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; } 0 0 0
224 }
225 /* switch to inner handle */
226 0 mg = mg_find(SvRV(sth),'P');
227 0 ▶ if (!mg) {
Branch: 1 branch
BranchTrueFalseTotal
if (!mg) { 0 0 0
228 0 ▶ if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; } 0 0 0
229 }
230 0 sth = mg->mg_obj;
231 }
232 0 imp_sth = (imp_sth_t*)(DBIh_COM(sth));
233 /* --- bind_param --- */
234 0 ▶ if (items > 3) { /* need to bind params before execute */
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) { /* need to bind params before execute */ 0 0 0
235 0 ▶ if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) { 0 0 0
236 0 ▶ if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; } 0 0 0
237 }
238 }
239 /* --- execute --- */
240 0 DBIc_ROW_COUNT(imp_sth) = 0;
241 0 ▶ if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
Branch: 1 branch
BranchTrueFalseTotal
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */ 0 0 0
242 0 ▶ if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; } 0 0 0
243 }
244 /* --- fetchrow_arrayref --- */
245 0 row_av = dbd_st_fetch(sth, imp_sth);
246 0 ▶ if (!row_av) {
Branch: 1 branch
BranchTrueFalseTotal
if (!row_av) { 0 0 0
247 0 ▶ if (GIMME_V == G_SCALAR)
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_SCALAR) 0 0 0
248 0 PUSHs(&PL_sv_undef);
249 }
250 0 ▶ else if (is_selectrow_array) {
Branch: 1 branch
BranchTrueFalseTotal
else if (is_selectrow_array) { 0 0 0
251 int i;
252 0 int num_fields = AvFILL(row_av)+1;
253 0 ▶ if (GIMME_V == G_SCALAR)
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_SCALAR) 0 0 0
254 0 num_fields = 1; /* return just first field */
255 0 ▶ EXTEND(sp, num_fields);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(sp, num_fields); 0 0 0
EXTEND(sp, num_fields); 0 0 0
256 0 ▶ for(i=0; i < num_fields; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for(i=0; i < num_fields; ++i) { 0 0 0
257 0 PUSHs(AvARRAY(row_av)[i]);
258 }
259 }
260 else {
261 0 PUSHs( sv_2mortal(newRV((SV *)row_av)) );
262 }
263 /* --- finish --- */
264 #ifdef dbd_st_finish3
265 dbd_st_finish3(sth, imp_sth, 0);
266 #else
267 0 dbd_st_finish(sth, imp_sth);
268 #endif
269  
270  
271 #if defined(dbd_db_do6) || defined(dbd_db_do4)
272  
273 void
274 do(dbh, statement, params = Nullsv, ...)
275 SV * dbh
276 SV * statement
277 SV * params
278 CODE:
279 {
280 0 D_imp_dbh(dbh);
281 IV retval;
282 #ifdef dbd_db_do6
283 /* items is a number of arguments passed to XSUB, supplied by xsubpp compiler */
284 /* ax contains stack base offset used by ST() macro, supplied by xsubpp compiler */
285 I32 offset = (items >= 3) ? 3 : items;
286 retval = dbd_db_do6(dbh, imp_dbh, statement, params, items-offset, ax+offset);
287 #else
288 0 ▶ if (items > 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) 0 0 0
289 0 croak_xs_usage(cv, "dbh, statement, params = Nullsv");
290 0 retval = dbd_db_do4(dbh, imp_dbh, SvPV_nolen(statement), params); /* might be dbd_db_do4_iv via macro */
291 #endif
292 /* remember that dbd_db_do* must return <= -2 for error */
293 0 ▶ if (retval == 0) /* ok with no rows affected */
Branch: 1 branch
BranchTrueFalseTotal
if (retval == 0) /* ok with no rows affected */ 0 0 0
294 0 XST_mPV(0, "0E0"); /* (true but zero) */
295 0 ▶ else if (retval < -1) /* -1 == unknown number of rows */
Branch: 1 branch
BranchTrueFalseTotal
else if (retval < -1) /* -1 == unknown number of rows */ 0 0 0
296 0 XST_mUNDEF(0); /* <= -2 means error */
297 else
298 0 XST_mIV(0, retval); /* typically 1, rowcount or -1 */
299 }
300  
301 #endif
302  
303  
304 #ifdef dbd_db_last_insert_id
305  
306 void
307 last_insert_id(dbh, catalog=&PL_sv_undef, schema=&PL_sv_undef, table=&PL_sv_undef, field=&PL_sv_undef, attr=Nullsv)
308 SV * dbh
309 SV * catalog
310 SV * schema
311 SV * table
312 SV * field
313 SV * attr
314 CODE:
315 {
316 0 D_imp_dbh(dbh);
317 0 SV *ret = dbd_db_last_insert_id(dbh, imp_dbh, catalog, schema, table, field, attr);
318 0 ST(0) = ret;
319 }
320  
321 #endif
322  
323  
324 bool
325 commit(dbh)
326 SV * dbh
327 CODE:
328 0 D_imp_dbh(dbh);
329 0 ▶ if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
Branch: 2 branches
BranchTrueFalseTotal
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh)) 0 0 0
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh)) 0 0 0
330 0 warn("commit ineffective with AutoCommit enabled");
331 0 ▶ RETVAL = dbd_db_commit(dbh, imp_dbh);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_db_commit(dbh, imp_dbh); 0 0 0
332 OUTPUT:
333 RETVAL
334  
335  
336 bool
337 rollback(dbh)
338 SV * dbh
339 CODE:
340 0 D_imp_dbh(dbh);
341 0 ▶ if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
Branch: 2 branches
BranchTrueFalseTotal
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh)) 0 0 0
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh)) 0 0 0
342 0 warn("rollback ineffective with AutoCommit enabled");
343 0 ▶ RETVAL = dbd_db_rollback(dbh, imp_dbh);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_db_rollback(dbh, imp_dbh); 0 0 0
344 OUTPUT:
345 RETVAL
346  
347  
348 bool
349 disconnect(dbh)
350 SV * dbh
351 CODE:
352 0 D_imp_dbh(dbh);
353 0 ▶ if ( !DBIc_ACTIVE(imp_dbh) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( !DBIc_ACTIVE(imp_dbh) ) { 0 0 0
354 0 XSRETURN_YES;
355 }
356 /* Check for disconnect() being called whilst refs to cursors */
357 /* still exists. This possibly needs some more thought. */
358 0 ▶ if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !PL_dirty) {
Branch: 3 branches
BranchTrueFalseTotal
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !PL_dirty) { 0 0 0
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !PL_dirty) { 0 0 0
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !PL_dirty) { 0 0 0
359 STRLEN lna;
360 0 ▶ char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : (char*)"s";
Branch: 1 branch
BranchTrueFalseTotal
char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" : (char*)"s"; 0 0 0
361 0 warn("%s->disconnect invalidates %d active statement handle%s %s",
362 SvPV(dbh,lna), (int)DBIc_ACTIVE_KIDS(imp_dbh), plural,
363 "(either destroy statement handles or call finish on them before disconnecting)");
364 }
365 0 RETVAL = dbd_db_disconnect(dbh, imp_dbh);
366 0 ▶ DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
Branch: 6 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
367 OUTPUT:
368 RETVAL
369  
370  
371 void
372 STORE(dbh, keysv, valuesv)
373 SV * dbh
374 SV * keysv
375 SV * valuesv
376 CODE:
377 0 D_imp_dbh(dbh);
378 0 ▶ if (SvGMAGICAL(valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(valuesv)) 0 0 0
379 0 mg_get(valuesv);
380 0 ST(0) = &PL_sv_yes;
381 0 ▶ if (!dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (!dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv)) 0 0 0
382 0 ▶ if (!DBIc_DBISTATE(imp_dbh)->set_attr(dbh, keysv, valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_DBISTATE(imp_dbh)->set_attr(dbh, keysv, valuesv)) 0 0 0
383 0 ST(0) = &PL_sv_no;
384  
385  
386 void
387 FETCH(dbh, keysv)
388 SV * dbh
389 SV * keysv
390 CODE:
391 0 D_imp_dbh(dbh);
392 0 SV *valuesv = dbd_db_FETCH_attrib(dbh, imp_dbh, keysv);
393 0 ▶ if (!valuesv)
Branch: 1 branch
BranchTrueFalseTotal
if (!valuesv) 0 0 0
394 0 valuesv = DBIc_DBISTATE(imp_dbh)->get_attr(dbh, keysv);
395 0 ST(0) = valuesv; /* dbd_db_FETCH_attrib did sv_2mortal */
396  
397  
398 void
399 DESTROY(dbh)
400 SV * dbh
401 PPCODE:
402 /* keep in sync with default DESTROY in DBI.xs */
403 0 D_imp_dbh(dbh);
404 0 ST(0) = &PL_sv_yes;
405 0 ▶ if (!DBIc_IMPSET(imp_dbh)) { /* was never fully set up */
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_IMPSET(imp_dbh)) { /* was never fully set up */ 0 0 0
406 STRLEN lna;
407 0 ▶ if (DBIc_WARN(imp_dbh) && !PL_dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2)
Branch: 3 branches
BranchTrueFalseTotal
if (DBIc_WARN(imp_dbh) && !PL_dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2) 0 0 0
if (DBIc_WARN(imp_dbh) && !PL_dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2) 0 0 0
if (DBIc_WARN(imp_dbh) && !PL_dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2) 0 0 0
408 0 PerlIO_printf(DBIc_LOGPIO(imp_dbh),
409 " DESTROY for %s ignored - handle not initialised\n",
410 SvPV(dbh,lna));
411 }
412 else {
413 0 ▶ if (DBIc_IADESTROY(imp_dbh)) { /* wants ineffective destroy */
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_IADESTROY(imp_dbh)) { /* wants ineffective destroy */ 0 0 0
414 0 ▶ DBIc_ACTIVE_off(imp_dbh);
Branch: 5 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_dbh); 0 0 0
DBIc_ACTIVE_off(imp_dbh); 0 0 0
DBIc_ACTIVE_off(imp_dbh); 0 0 0
DBIc_ACTIVE_off(imp_dbh); 0 0 0
DBIc_ACTIVE_off(imp_dbh); 0 0 0
415 0 ▶ if (DBIc_DBISTATE(imp_dbh)->debug)
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_DBISTATE(imp_dbh)->debug) 0 0 0
416 0 PerlIO_printf(DBIc_LOGPIO(imp_dbh), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(dbh));
417 }
418 0 ▶ if (DBIc_ACTIVE(imp_dbh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_ACTIVE(imp_dbh)) { 0 0 0
419 0 ▶ if (!DBIc_has(imp_dbh,DBIcf_AutoCommit)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_has(imp_dbh,DBIcf_AutoCommit)) { 0 0 0
420 /* Application is using transactions and hasn't explicitly disconnected.
421 Some databases will automatically commit on graceful disconnect.
422 Since we're about to gracefully disconnect as part of the DESTROY
423 we want to be sure we're not about to implicitly commit changes
424 that are incomplete and should be rolled back. (The DESTROY may
425 be due to a RaiseError, for example.) So we rollback here.
426 This will be harmless if the application has issued a commit,
427 XXX Could add an attribute flag to indicate that the driver
428 doesn't have this problem. Patches welcome.
429 */
430 0 ▶ if (DBIc_WARN(imp_dbh) /* only warn if likely to be useful... */
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_WARN(imp_dbh) /* only warn if likely to be useful... */ 0 0 0
431 0 ▶ && DBIc_is(imp_dbh, DBIcf_Executed) /* has not just called commit/rollback */
Branch: 1 branch
BranchTrueFalseTotal
&& DBIc_is(imp_dbh, DBIcf_Executed) /* has not just called commit/rollback */ 0 0 0
432 /* && !DBIc_is(imp_dbh, DBIcf_ReadOnly) -- is not read only */
433 0 ▶ && (!PL_dirty || DBIc_DBISTATE(imp_dbh)->debug >= 3)
Branch: 2 branches
BranchTrueFalseTotal
&& (!PL_dirty || DBIc_DBISTATE(imp_dbh)->debug >= 3) 0 0 0
&& (!PL_dirty || DBIc_DBISTATE(imp_dbh)->debug >= 3) 0 0 0
434 ) {
435 0 ▶ warn("Issuing rollback() due to DESTROY without explicit disconnect() of %s handle %s",
Branch: 1 branch
BranchTrueFalseTotal
warn("Issuing rollback() due to DESTROY without explicit disconnect() of %s handle %s", 0 0 0
436 SvPV_nolen(*hv_fetchs((HV*)SvRV(dbh), "ImplementorClass", 1)),
437 SvPV_nolen(*hv_fetchs((HV*)SvRV(dbh), "Name", 1))
438 );
439 }
440 0 dbd_db_rollback(dbh, imp_dbh); /* ROLLBACK! */
441 }
442 0 dbd_db_disconnect(dbh, imp_dbh);
443 0 ▶ DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
Branch: 5 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */ 0 0 0
444 }
445 0 dbd_db_destroy(dbh, imp_dbh);
446 }
447  
448  
449 #ifdef dbd_take_imp_data
450  
451 void
452 take_imp_data(h)
453 SV * h
454 CODE:
455 0 D_imp_xxh(h);
456 /* dbd_take_imp_data() returns &sv_no (or other defined but false value)
457 * to indicate "preparations complete, now call SUPER::take_imp_data" for me.
458 * Anything else is returned to the caller via sv_2mortal(sv), typically that
459 * would be &sv_undef for error or an SV holding the imp_data.
460 */
461 0 SV *sv = dbd_take_imp_data(h, imp_xxh, NULL);
462 0 ▶ if (SvOK(sv) && !SvTRUE(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvOK(sv) && !SvTRUE(sv)) { 0 0 0
if (SvOK(sv) && !SvTRUE(sv)) { 0 0 0
463 0 SV *tmp = dbixst_bounce_method("DBD::Perl::db::SUPER::take_imp_data", items);
464 0 SPAGAIN;
465 0 ST(0) = tmp;
466 } else {
467 0 ST(0) = sv_2mortal(sv);
468 }
469  
470 #endif
471  
472 #ifdef dbd_db_data_sources
473  
474 void
475 data_sources(dbh, attr = Nullsv)
476 SV *dbh
477 SV *attr
478 PPCODE:
479 {
480 D_imp_dbh(dbh);
481 AV *av = dbd_db_data_sources(dbh, imp_dbh, attr);
482 if (av) {
483 int i;
484 int n = AvFILL(av)+1;
485 EXTEND(sp, n);
486 for (i = 0; i < n; ++i) {
487 PUSHs(AvARRAY(av)[i]);
488 }
489 }
490 }
491  
492 #endif
493  
494 # -- end of DBD::Perl::db
495  
496 # ------------------------------------------------------------
497 # statement interface
498 # ------------------------------------------------------------
499 MODULE = DBD::Perl PACKAGE = DBD::Perl::st
500  
501  
502 bool
503 _prepare(sth, statement, attribs=Nullsv)
504 SV * sth
505 SV * statement
506 SV * attribs
507 CODE:
508 {
509 0 D_imp_sth(sth);
510 0 ▶ DBD_ATTRIBS_CHECK("_prepare", sth, attribs);
Branch: 5 branches
BranchTrueFalseTotal
DBD_ATTRIBS_CHECK("_prepare", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("_prepare", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("_prepare", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("_prepare", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("_prepare", sth, attribs); 0 0 0
511 #ifdef dbd_st_prepare_sv
512 RETVAL = dbd_st_prepare_sv(sth, imp_sth, statement, attribs);
513 #else
514 0 ▶ RETVAL = dbd_st_prepare(sth, imp_sth, SvPV_nolen(statement), attribs);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_st_prepare(sth, imp_sth, SvPV_nolen(statement), attribs); 0 0 0
515 #endif
516 }
517 OUTPUT:
518 RETVAL
519  
520  
521 #ifdef dbd_st_rows
522  
523 void
524 rows(sth)
525 SV * sth
526 CODE:
527 D_imp_sth(sth);
528 XST_mIV(0, dbd_st_rows(sth, imp_sth));
529  
530 #endif /* dbd_st_rows */
531  
532  
533 #ifdef dbd_st_bind_col
534  
535 bool
536 bind_col(sth, col, ref, attribs=Nullsv)
537 SV * sth
538 SV * col
539 SV * ref
540 SV * attribs
541 CODE:
542 {
543 0 IV sql_type = 0;
544 0 D_imp_sth(sth);
545 0 ▶ if (SvGMAGICAL(ref))
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(ref)) 0 0 0
546 0 mg_get(ref);
547 0 ▶ if (attribs) {
Branch: 1 branch
BranchTrueFalseTotal
if (attribs) { 0 0 0
548 0 ▶ if (SvNIOK(attribs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvNIOK(attribs)) { 0 0 0
549 0 sql_type = SvIV(attribs);
550 0 attribs = Nullsv;
551 }
552 else {
553 SV **svp;
554 0 ▶ DBD_ATTRIBS_CHECK("bind_col", sth, attribs);
Branch: 5 branches
BranchTrueFalseTotal
DBD_ATTRIBS_CHECK("bind_col", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_col", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_col", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_col", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_col", sth, attribs); 0 0 0
555 /* XXX we should perhaps complain if TYPE is not SvNIOK */
556 0 ▶ DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
Branch: 4 branches
BranchTrueFalseTotal
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
557 }
558 }
559 0 switch(dbd_st_bind_col(sth, imp_sth, col, ref, sql_type, attribs)) {
560 case 2: RETVAL = TRUE; /* job done completely */
561 break;
562 case 1: /* fallback to DBI default */
563 0 RETVAL = DBIc_DBISTATE(imp_sth)->bind_col(sth, col, ref, attribs);
564 0 break;
565 default: RETVAL = FALSE; /* dbd_st_bind_col has called set_err */
566 break;
567 }
568 }
569 OUTPUT:
570 RETVAL
571  
572 #endif /* dbd_st_bind_col */
573  
574 bool
575 bind_param(sth, param, value, attribs=Nullsv)
576 SV * sth
577 SV * param
578 SV * value
579 SV * attribs
580 CODE:
581 {
582 0 IV sql_type = 0;
583 0 D_imp_sth(sth);
584 0 ▶ if (SvGMAGICAL(value))
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(value)) 0 0 0
585 0 mg_get(value);
586 0 ▶ if (attribs) {
Branch: 1 branch
BranchTrueFalseTotal
if (attribs) { 0 0 0
587 0 ▶ if (SvNIOK(attribs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvNIOK(attribs)) { 0 0 0
588 0 sql_type = SvIV(attribs);
589 0 attribs = Nullsv;
590 }
591 else {
592 SV **svp;
593 0 ▶ DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
Branch: 5 branches
BranchTrueFalseTotal
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
594 /* XXX we should perhaps complain if TYPE is not SvNIOK */
595 0 ▶ DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
Branch: 4 branches
BranchTrueFalseTotal
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
596 }
597 }
598 0 ▶ RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0); 0 0 0
599 }
600 OUTPUT:
601 RETVAL
602  
603  
604 bool
605 bind_param_inout(sth, param, value_ref, maxlen, attribs=Nullsv)
606 SV * sth
607 SV * param
608 SV * value_ref
609 IV maxlen
610 SV * attribs
611 CODE:
612 {
613 0 IV sql_type = 0;
614 0 D_imp_sth(sth);
615 SV *value;
616 0 ▶ if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG) 0 0 0
if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG) 0 0 0
617 0 croak("bind_param_inout needs a reference to a scalar value");
618 0 value = SvRV(value_ref);
619 0 ▶ if (SvREADONLY(value))
Branch: 1 branch
BranchTrueFalseTotal
if (SvREADONLY(value)) 0 0 0
620 0 croak("Modification of a read-only value attempted");
621 0 ▶ if (SvGMAGICAL(value))
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(value)) 0 0 0
622 0 mg_get(value);
623 0 ▶ if (attribs) {
Branch: 1 branch
BranchTrueFalseTotal
if (attribs) { 0 0 0
624 0 ▶ if (SvNIOK(attribs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvNIOK(attribs)) { 0 0 0
625 0 sql_type = SvIV(attribs);
626 0 attribs = Nullsv;
627 }
628 else {
629 SV **svp;
630 0 ▶ DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
Branch: 5 branches
BranchTrueFalseTotal
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
DBD_ATTRIBS_CHECK("bind_param", sth, attribs); 0 0 0
631 0 ▶ DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
Branch: 4 branches
BranchTrueFalseTotal
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type); 0 0 0
632 }
633 }
634 0 ▶ RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, TRUE, maxlen);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, TRUE, maxlen); 0 0 0
635 }
636 OUTPUT:
637 RETVAL
638  
639  
640 void
641 execute(sth, ...)
642 SV * sth
643 CODE:
644 0 D_imp_sth(sth);
645 IV retval;
646 0 ▶ if (items > 1) { /* need to bind params */
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { /* need to bind params */ 0 0 0
647 0 ▶ if (!dbdxst_bind_params(sth, imp_sth, items, ax) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!dbdxst_bind_params(sth, imp_sth, items, ax) ) { 0 0 0
648 0 XSRETURN_UNDEF;
649 }
650 }
651 /* XXX this code is duplicated in selectrow_arrayref above */
652 0 DBIc_ROW_COUNT(imp_sth) = 0;
653 0 retval = dbd_st_execute(sth, imp_sth); /* might be dbd_st_execute_iv via macro */
654 /* remember that dbd_st_execute must return <= -2 for error */
655 0 ▶ if (retval == 0) /* ok with no rows affected */
Branch: 1 branch
BranchTrueFalseTotal
if (retval == 0) /* ok with no rows affected */ 0 0 0
656 0 XST_mPV(0, "0E0"); /* (true but zero) */
657 0 ▶ else if (retval < -1) /* -1 == unknown number of rows */
Branch: 1 branch
BranchTrueFalseTotal
else if (retval < -1) /* -1 == unknown number of rows */ 0 0 0
658 0 XST_mUNDEF(0); /* <= -2 means error */
659 else
660 0 XST_mIV(0, retval); /* typically 1, rowcount or -1 */
661  
662  
663 #ifdef dbd_st_execute_for_fetch
664  
665 void
666 execute_for_fetch(sth, fetch_tuple_sub, tuple_status = Nullsv)
667 SV * sth
668 SV * fetch_tuple_sub
669 SV * tuple_status
670 CODE:
671 {
672 0 D_imp_sth(sth);
673 0 SV *ret = dbd_st_execute_for_fetch(sth, imp_sth, fetch_tuple_sub, tuple_status);
674 0 ST(0) = ret;
675 }
676  
677 #endif
678  
679  
680 #ifdef dbd_st_last_insert_id
681  
682 void
683 last_insert_id(sth, catalog=&PL_sv_undef, schema=&PL_sv_undef, table=&PL_sv_undef, field=&PL_sv_undef, attr=Nullsv)
684 SV * sth
685 SV * catalog
686 SV * schema
687 SV * table
688 SV * field
689 SV * attr
690 CODE:
691 {
692 D_imp_sth(sth);
693 SV *ret = dbd_st_last_insert_id(sth, imp_sth, catalog, schema, table, field, attr);
694 ST(0) = ret;
695 }
696  
697 #endif
698  
699  
700 void
701 fetchrow_arrayref(sth)
702 SV * sth
703 ALIAS:
704 fetch = 1
705 CODE:
706 0 D_imp_sth(sth);
707 AV *av;
708 PERL_UNUSED_VAR(ix);
709 0 av = dbd_st_fetch(sth, imp_sth);
710 0 ▶ ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_sv_undef; 0 0 0
711  
712  
713 void
714 fetchrow_array(sth)
715 SV * sth
716 ALIAS:
717 fetchrow = 1
718 PPCODE:
719 0 D_imp_sth(sth);
720 AV *av;
721 0 av = dbd_st_fetch(sth, imp_sth);
722 0 ▶ if (av) {
Branch: 1 branch
BranchTrueFalseTotal
if (av) { 0 0 0
723 int i;
724 0 int num_fields = AvFILL(av)+1;
725 0 ▶ EXTEND(sp, num_fields);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(sp, num_fields); 0 0 0
EXTEND(sp, num_fields); 0 0 0
726 0 ▶ for(i=0; i < num_fields; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for(i=0; i < num_fields; ++i) { 0 0 0
727 0 PUSHs(AvARRAY(av)[i]);
728 }
729 PERL_UNUSED_VAR(ix);
730 }
731  
732  
733 void
734 fetchall_arrayref(sth, slice=&PL_sv_undef, batch_row_count=&PL_sv_undef)
735 SV * sth
736 SV * slice
737 SV * batch_row_count
738 CODE:
739 0 ▶ if (SvOK(slice)) { /* fallback to perl implementation */
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(slice)) { /* fallback to perl implementation */ 0 0 0
740 0 SV *tmp = dbixst_bounce_method("DBD::Perl::st::SUPER::fetchall_arrayref", 3);
741 0 SPAGAIN;
742 0 ST(0) = tmp;
743 }
744 else {
745 0 SV *tmp = dbdxst_fetchall_arrayref(sth, slice, batch_row_count);
746 0 SPAGAIN;
747 0 ST(0) = tmp;
748 }
749  
750  
751 bool
752 finish(sth)
753 SV * sth
754 CODE:
755 0 D_imp_sth(sth);
756 0 D_imp_dbh_from_sth;
757 0 ▶ if (!DBIc_ACTIVE(imp_sth)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_ACTIVE(imp_sth)) { 0 0 0
758 /* No active statement to finish */
759 0 XSRETURN_YES;
760 }
761 0 ▶ if (!DBIc_ACTIVE(imp_dbh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_ACTIVE(imp_dbh)) { 0 0 0
762 /* Either an explicit disconnect() or global destruction */
763 /* has disconnected us from the database. Finish is meaningless */
764 0 ▶ DBIc_ACTIVE_off(imp_sth);
Branch: 5 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
765 0 XSRETURN_YES;
766 }
767 #ifdef dbd_st_finish3
768 RETVAL = dbd_st_finish3(sth, imp_sth, 0);
769 #else
770 0 ▶ RETVAL = dbd_st_finish(sth, imp_sth);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dbd_st_finish(sth, imp_sth); 0 0 0
771 #endif
772 OUTPUT:
773 RETVAL
774  
775  
776 void
777 blob_read(sth, field, offset, len, destrv=Nullsv, destoffset=0)
778 SV * sth
779 int field
780 long offset
781 long len
782 SV * destrv
783 long destoffset
784 CODE:
785 {
786 0 D_imp_sth(sth);
787 0 ▶ if (!destrv)
Branch: 1 branch
BranchTrueFalseTotal
if (!destrv) 0 0 0
788 0 destrv = sv_2mortal(newRV(sv_2mortal(newSV(0))));
789 0 ▶ if (dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset))
Branch: 1 branch
BranchTrueFalseTotal
if (dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset)) 0 0 0
790 0 ST(0) = SvRV(destrv);
791 0 else ST(0) = &PL_sv_undef;
792 }
793  
794  
795 void
796 STORE(sth, keysv, valuesv)
797 SV * sth
798 SV * keysv
799 SV * valuesv
800 CODE:
801 0 D_imp_sth(sth);
802 0 ▶ if (SvGMAGICAL(valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(valuesv)) 0 0 0
803 0 mg_get(valuesv);
804 0 ST(0) = &PL_sv_yes;
805 0 ▶ if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv)) 0 0 0
806 0 ▶ if (!DBIc_DBISTATE(imp_sth)->set_attr(sth, keysv, valuesv))
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_DBISTATE(imp_sth)->set_attr(sth, keysv, valuesv)) 0 0 0
807 0 ST(0) = &PL_sv_no;
808  
809  
810 # FETCH renamed and ALIAS'd to avoid case clash on VMS :-(
811 void
812 FETCH_attrib(sth, keysv)
813 SV * sth
814 SV * keysv
815 ALIAS:
816 FETCH = 1
817 CODE:
818 0 D_imp_sth(sth);
819 SV *valuesv;
820 PERL_UNUSED_VAR(ix);
821 0 valuesv = dbd_st_FETCH_attrib(sth, imp_sth, keysv);
822 0 ▶ if (!valuesv)
Branch: 1 branch
BranchTrueFalseTotal
if (!valuesv) 0 0 0
823 0 valuesv = DBIc_DBISTATE(imp_sth)->get_attr(sth, keysv);
824 0 ST(0) = valuesv; /* dbd_st_FETCH_attrib did sv_2mortal */
825  
826  
827 void
828 DESTROY(sth)
829 SV * sth
830 PPCODE:
831 /* keep in sync with default DESTROY in DBI.xs */
832 0 D_imp_sth(sth);
833 0 ST(0) = &PL_sv_yes;
834 0 ▶ if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */ 0 0 0
835 STRLEN lna;
836 0 ▶ if (DBIc_WARN(imp_sth) && !PL_dirty && DBIc_DBISTATE(imp_sth)->debug >= 2)
Branch: 3 branches
BranchTrueFalseTotal
if (DBIc_WARN(imp_sth) && !PL_dirty && DBIc_DBISTATE(imp_sth)->debug >= 2) 0 0 0
if (DBIc_WARN(imp_sth) && !PL_dirty && DBIc_DBISTATE(imp_sth)->debug >= 2) 0 0 0
if (DBIc_WARN(imp_sth) && !PL_dirty && DBIc_DBISTATE(imp_sth)->debug >= 2) 0 0 0
837 0 PerlIO_printf(DBIc_LOGPIO(imp_sth),
838 " DESTROY for %s ignored - handle not initialised\n",
839 SvPV(sth,lna));
840 }
841 else {
842 0 ▶ if (DBIc_IADESTROY(imp_sth)) { /* wants ineffective destroy */
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_IADESTROY(imp_sth)) { /* wants ineffective destroy */ 0 0 0
843 0 ▶ DBIc_ACTIVE_off(imp_sth);
Branch: 5 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
844 0 ▶ if (DBIc_DBISTATE(imp_sth)->debug)
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_DBISTATE(imp_sth)->debug) 0 0 0
845 0 PerlIO_printf(DBIc_LOGPIO(imp_sth), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(sth));
846 }
847 0 ▶ if (DBIc_ACTIVE(imp_sth)) {
Branch: 1 branch
BranchTrueFalseTotal
if (DBIc_ACTIVE(imp_sth)) { 0 0 0
848 0 D_imp_dbh_from_sth;
849 0 ▶ if (!PL_dirty && DBIc_ACTIVE(imp_dbh)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!PL_dirty && DBIc_ACTIVE(imp_dbh)) { 0 0 0
if (!PL_dirty && DBIc_ACTIVE(imp_dbh)) { 0 0 0
850 #ifdef dbd_st_finish3
851 dbd_st_finish3(sth, imp_sth, 1);
852 #else
853 0 dbd_st_finish(sth, imp_sth);
854 #endif
855 }
856 else {
857 0 ▶ DBIc_ACTIVE_off(imp_sth);
Branch: 5 branches
BranchTrueFalseTotal
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
DBIc_ACTIVE_off(imp_sth); 0 0 0
858 }
859 }
860 0 dbd_st_destroy(sth, imp_sth);
861 }
862  
863 # end of Perl.xst
864 # vim:ts=8:sw=4:et
« Perl.xs ↑ Summary dbiprof.PL »