SQLite.xsi

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