SQLite.xsi

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