include/dbil_abi_impl.h

filter: Statementstmt 92.0% 277 / 301 Branchbran 50.3% 158 / 314 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 70.7% 435 / 615 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/loop.xs ↑ Summary include/dbil_obs.h »
1 #ifndef DBIL_ABI_IMPL_H
2 #define DBIL_ABI_IMPL_H
3  
4 /* Provider side of the public C ABI (dbil_abi.h): thin wrappers translating
5 * the stable table entries onto the dbil_* internals, plus the filled table
6 * itself and a selftest that drives it end to end. Consumers reach it via
7 * DBIx::Loop::_abi_ptr (xs/abi.xs).
8 *
9 * Include after dbil_future.h, dbil_pool.h (for the magic-CV closures) and
10 * dbil_loop.h (for dbil_new / dbil_exec). */
11  
12 /* The public shape numbers are the internal ones. Checked here rather than
13 * trusted, because dbil_abi.h ships to consumers and the two sets are edited
14 * in different files. */
15 #if DBIL_ABI_ALL_ARRAYREF != DBIL_T_ALL_ARRAYREF \
16 || DBIL_ABI_ROW_ARRAYREF != DBIL_T_ROW_ARRAYREF \
17 || DBIL_ABI_ROW_ARRAY != DBIL_T_ROW_ARRAY \
18 || DBIL_ABI_ROW_HASHREF != DBIL_T_ROW_HASHREF \
19 || DBIL_ABI_COL_ARRAYREF != DBIL_T_COL_ARRAYREF \
20 || DBIL_ABI_ALL_HASHREF != DBIL_T_ALL_HASHREF \
21 || DBIL_ABI_ALL_ROWHASH != DBIL_T_ALL_ROWHASH
22 # error "dbil_abi.h shape constants have drifted from dbil_future.h"
23 #endif
24  
25 /* the future struct without the croak, so is_future can answer for any SV */
26 24 static dbil_future *dbil_future_peek(pTHX_ SV *sv) {
27 MAGIC *mg;
28 24 ▶ if (!sv || !SvROK(sv)) return NULL;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv || !SvROK(sv)) return NULL; 24 0 24
if (!sv || !SvROK(sv)) return NULL; 2 22 24
29 22 mg = mg_findext(SvRV(sv), PERL_MAGIC_ext, &dbil_future_vtbl);
30 22 ▶ return mg ? (dbil_future *)mg->mg_ptr : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return mg ? (dbil_future *)mg->mg_ptr : NULL; 21 1 22
31 }
32  
33 4 static int dbil_abi_is_future(pTHX_ SV *sv) {
34 4 return dbil_future_peek(aTHX_ sv) != NULL;
35 }
36  
37 9 static IV dbil_abi_future_state(pTHX_ SV *f) {
38 9 dbil_future *p = dbil_future_peek(aTHX_ f);
39 9 ▶ return p ? (IV)p->state : (IV)DBIL_ABI_PENDING;
Branch: 1 branch
BranchTrueFalseTotal
return p ? (IV)p->state : (IV)DBIL_ABI_PENDING; 9 0 9
40 }
41  
42 /* borrowed values of a done future, into the caller's array */
43 4 static SSize_t dbil_abi_future_values(pTHX_ SV *f, SV **out, SSize_t max) {
44 4 dbil_future *p = dbil_future_peek(aTHX_ f);
45 AV *res;
46 SSize_t i, n;
47 4 ▶ if (!p || p->state != 1 || !p->result || !SvROK(p->result)) return 0;
Branch: 4 branches
BranchTrueFalseTotal
if (!p || p->state != 1 || !p->result || !SvROK(p->result)) return 0; 4 0 4
if (!p || p->state != 1 || !p->result || !SvROK(p->result)) return 0; 3 1 4
if (!p || p->state != 1 || !p->result || !SvROK(p->result)) return 0; 3 0 3
if (!p || p->state != 1 || !p->result || !SvROK(p->result)) return 0; 0 3 3
48 3 res = (AV *)SvRV(p->result);
49 3 n = av_len(res) + 1;
50 3 ▶ if (n > max) n = max;
Branch: 1 branch
BranchTrueFalseTotal
if (n > max) n = max; 0 3 3
51 6 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 3 3 6
52 3 SV **e = av_fetch(res, i, 0);
53 3 ▶ out[i] = (e && *e) ? *e : &PL_sv_undef;
Branch: 2 branches
BranchTrueFalseTotal
out[i] = (e && *e) ? *e : &PL_sv_undef; 3 0 3
out[i] = (e && *e) ? *e : &PL_sv_undef; 3 0 3
54 }
55 3 return n;
56 }
57  
58 4 static SV *dbil_abi_future_error(pTHX_ SV *f) {
59 4 dbil_future *p = dbil_future_peek(aTHX_ f);
60 4 ▶ return (p && p->state == 2) ? p->error : NULL;
Branch: 2 branches
BranchTrueFalseTotal
return (p && p->state == 2) ? p->error : NULL; 4 0 4
return (p && p->state == 2) ? p->error : NULL; 3 1 4
61 }
62  
63 2 static SV *dbil_abi_future_new(pTHX) {
64 2 return dbil_future_new(aTHX_ "DBIx::Loop::Future");
65 }
66  
67 2 static void dbil_abi_future_done1(pTHX_ SV *f, SV *val) {
68 2 dbil_future_settle_done1(aTHX_ f, val);
69 2 }
70  
71 1 static void dbil_abi_future_fail(pTHX_ SV *f, SV *err) {
72 1 dbil_future_settle_fail(aTHX_ f, err);
73 1 }
74  
75 /* on_ready continuation body: unbox the C fn + ud from the closure captures
76 * and call it with the future (ST(0), pushed by the fire loop). */
77 XS_INTERNAL(dbil_xs_abi_ready_cb);
78 2 XS_INTERNAL(dbil_xs_abi_ready_cb) {
79 2 dXSARGS;
80 2 AV *cap = dbil_clos_cap(aTHX_ cv);
81 SV **fn, **ud;
82 2 ▶ if (!cap || items < 1) XSRETURN_EMPTY;
Branch: 2 branches
BranchTrueFalseTotal
if (!cap || items < 1) XSRETURN_EMPTY; 2 0 2
if (!cap || items < 1) XSRETURN_EMPTY; 0 2 2
83 2 fn = av_fetch(cap, 0, 0);
84 2 ud = av_fetch(cap, 1, 0);
85 2 ▶ if (!(fn && *fn)) XSRETURN_EMPTY;
Branch: 2 branches
BranchTrueFalseTotal
if (!(fn && *fn)) XSRETURN_EMPTY; 2 0 2
if (!(fn && *fn)) XSRETURN_EMPTY; 0 2 2
86 4 ▶ ((dbil_abi_ready_cb)INT2PTR(void *, SvIV(*fn)))
Branch: 1 branch
BranchTrueFalseTotal
((dbil_abi_ready_cb)INT2PTR(void *, SvIV(*fn))) 2 0 2
87 4 ▶ (aTHX_ ST(0), (ud && *ud) ? INT2PTR(void *, SvIV(*ud)) : NULL);
Branch: 1 branch
BranchTrueFalseTotal
(aTHX_ ST(0), (ud && *ud) ? INT2PTR(void *, SvIV(*ud)) : NULL); 2 0 2
88 2 XSRETURN_EMPTY;
89 }
90  
91 3 static void dbil_abi_future_on_ready(pTHX_ SV *f, dbil_abi_ready_cb cb,
92 void *ud) {
93 3 dbil_future *p = dbil_future_peek(aTHX_ f);
94 3 ▶ if (!p || !cb) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!p || !cb) return; 3 0 3
if (!p || !cb) return; 0 3 3
95 /* already settled: fire now, as on_ready does, and never queue */
96 3 ▶ if (p->state) { cb(aTHX_ f, ud); return; }
Branch: 1 branch
BranchTrueFalseTotal
if (p->state) { cb(aTHX_ f, ud); return; } 1 2 3
97 {
98 2 AV *cap = newAV();
99 SV *cv;
100 2 av_push(cap, newSViv(PTR2IV(cb)));
101 2 av_push(cap, newSViv(PTR2IV(ud)));
102 2 cv = dbil_closure(aTHX_ dbil_xs_abi_ready_cb, cap);
103 2 av_push(p->cbs, cv); /* the queue owns it */
104 }
105 }
106  
107 8 static SV *dbil_abi_reshape(pTHX_ int shape, SV *result, SV *arg, AV *out) {
108 8 return dbil_then_builtin(aTHX_ (IV)shape, result, arg, out);
109 }
110  
111 4 static SV *dbil_abi_exec(pTHX_ SV *db, int is_query, SV *sql, AV *bind) {
112 4 return dbil_exec(aTHX_ db, is_query, sql, bind);
113 }
114  
115 /* query + one builtin reshape as a single call: the intermediate future is
116 * still built (the reshape has to run when the rows land, not now), but no
117 * Perl closure is compiled and no Perl frame runs on the settle path. */
118 2 static SV *dbil_abi_exec_shaped(pTHX_ SV *db, SV *sql, AV *bind,
119 int shape, SV *arg) {
120 2 SV *qf = sv_2mortal(dbil_exec(aTHX_ db, 1, sql, bind));
121 2 SV *next = dbil_future_new(aTHX_ "DBIx::Loop::Future");
122 2 dbil_then_attach4(aTHX_ qf, next, sv_2mortal(newSViv((IV)shape)),
123 NULL, arg);
124 2 return next;
125 }
126  
127 /* Call a class method with `n` already-mortal args, under eval. Returns the
128 * result (+1) or NULL with *err set (+1). The boot paths (connect, adapter)
129 * use this so a consumer gets an error SV to fall back on rather than a
130 * croak through its own boot code. */
131 2 static SV *dbil_abi_try_method(pTHX_ const char *cls, const char *meth,
132 SV **args, int n, SV **err) {
133 2 dSP;
134 int count;
135 2 SV *out = NULL;
136 2 ▶ ENTER; SAVETMPS; PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
ENTER; SAVETMPS; PUSHMARK(SP); 0 2 2
137 2 ▶ EXTEND(SP, n + 1);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, n + 1); 2 0 2
EXTEND(SP, n + 1); 0 2 2
138 2 mPUSHp(cls, strlen(cls));
139 10 ▶ { int i; for (i = 0; i < n; i++) PUSHs(args[i]); }
Branch: 1 branch
BranchTrueFalseTotal
{ int i; for (i = 0; i < n; i++) PUSHs(args[i]); } 8 2 10
140 2 PUTBACK;
141 2 count = call_method(meth, G_SCALAR | G_EVAL);
142 2 SPAGAIN;
143 2 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 2 0 2
if (SvTRUE(ERRSV)) { 1 1 2
144 /* NOT mortal: FREETMPS below would free it before the caller reads it */
145 2 ▶ if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0);
Branch: 2 branches
BranchTrueFalseTotal
if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0); 1 0 1
if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0); 1 0 1
146 1 ▶ if (count > 0) (void)POPs;
Branch: 1 branch
BranchTrueFalseTotal
if (count > 0) (void)POPs; 1 0 1
147 }
148 1 ▶ else if (count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if (count > 0) { 1 0 1
149 1 SV *r = POPs;
150 1 ▶ if (SvOK(r)) out = newSVsv(r);
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(r)) out = newSVsv(r); 1 0 1
151 0 ▶ else if (err) *err = newSVpvf("DBIx::Loop: %s->%s returned undef",
Branch: 1 branch
BranchTrueFalseTotal
else if (err) *err = newSVpvf("DBIx::Loop: %s->%s returned undef", 0 0 0
152 cls, meth);
153 }
154 0 ▶ else if (err) *err = newSVpvf("DBIx::Loop: %s->%s returned nothing",
Branch: 1 branch
BranchTrueFalseTotal
else if (err) *err = newSVpvf("DBIx::Loop: %s->%s returned nothing", 0 0 0
155 cls, meth);
156 2 ▶ PUTBACK; FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
PUTBACK; FREETMPS; LEAVE; 2 0 2
157 2 return out;
158 }
159  
160 /* DBI->connect + dbil_new, without croaking. The DBI connect is irreducibly
161 * DBI's Perl API; everything after it is C. */
162 3 static SV *dbil_abi_connect(pTHX_ SV *dsn, SV *user, SV *pass, SV *attr,
163 SV *adapter, int workers, int max_queue,
164 SV **err) {
165 3 SV *args[4], *dbh, *self = NULL;
166 3 ▶ if (err) *err = NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (err) *err = NULL; 3 0 3
167 3 ▶ if (!adapter || !SvOK(adapter)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!adapter || !SvOK(adapter)) { 2 1 3
if (!adapter || !SvOK(adapter)) { 0 2 2
168 1 ▶ if (err) *err = newSVpvs("DBIx::Loop: connect needs a loop adapter - "
Branch: 1 branch
BranchTrueFalseTotal
if (err) *err = newSVpvs("DBIx::Loop: connect needs a loop adapter - " 1 0 1
169 "DBIx::Loop is not an event loop, it runs "
170 "on one");
171 1 return NULL;
172 }
173 2 ▶ args[0] = dsn ? dsn : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
args[0] = dsn ? dsn : &PL_sv_undef; 2 0 2
174 2 ▶ args[1] = user ? user : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
args[1] = user ? user : &PL_sv_undef; 0 2 2
175 2 ▶ args[2] = pass ? pass : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
args[2] = pass ? pass : &PL_sv_undef; 0 2 2
176 2 ▶ args[3] = attr ? attr : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
args[3] = attr ? attr : &PL_sv_undef; 1 1 2
177 2 dbh = dbil_abi_try_method(aTHX_ "DBI", "connect", args, 4, err);
178 2 ▶ if (!dbh) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!dbh) return NULL; 1 1 2
179  
180 /* dbil_new croaks on a handle that is not a reference. Check that here
181 * rather than trapping the croak, so this entry keeps its no-croak
182 * contract by never reaching the croak at all - a driver that returns
183 * something odd becomes an error SV like any other failure. */
184 1 ▶ if (!SvROK(dbh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(dbh)) { 0 1 1
185 0 ▶ if (err) *err = newSVpvs("DBIx::Loop: DBI->connect returned a "
Branch: 1 branch
BranchTrueFalseTotal
if (err) *err = newSVpvs("DBIx::Loop: DBI->connect returned a " 0 0 0
186 "non-reference");
187 0 SvREFCNT_dec(dbh);
188 0 return NULL;
189 }
190 1 self = dbil_new(aTHX_ "DBIx::Loop", dbh, adapter,
191 dsn, user, pass, attr, workers, max_queue);
192 1 SvREFCNT_dec(dbh);
193 1 return self;
194 }
195  
196 /* The Hyperman adapter on a loop the caller names. Requiring the module here
197 * rather than at boot keeps DBIx::Loop loadable without Hyperman. */
198 0 static SV *dbil_abi_hyperman_adapter(pTHX_ SV *loop_sv, SV **err) {
199 SV *args[2];
200 0 int n = 0;
201 0 ▶ if (err) *err = NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (err) *err = NULL; 0 0 0
202 0 ▶ if (!gv_stashpvs("DBIx::Loop::Loop::Hyperman", 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!gv_stashpvs("DBIx::Loop::Loop::Hyperman", 0)) { 0 0 0
203 0 eval_pv("require DBIx::Loop::Loop::Hyperman;", FALSE);
204 0 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 0 0 0
if (SvTRUE(ERRSV)) { 0 0 0
205 0 ▶ if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0);
Branch: 2 branches
BranchTrueFalseTotal
if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0); 0 0 0
if (err) *err = newSVpv(SvPV_nolen(ERRSV), 0); 0 0 0
206 0 return NULL;
207 }
208 }
209 0 ▶ if (loop_sv && SvOK(loop_sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (loop_sv && SvOK(loop_sv)) { 0 0 0
if (loop_sv && SvOK(loop_sv)) { 0 0 0
210 0 args[0] = sv_2mortal(newSVpvs("loop"));
211 0 args[1] = loop_sv;
212 0 n = 2;
213 }
214 0 return dbil_abi_try_method(aTHX_ "DBIx::Loop::Loop::Hyperman", "new",
215 args, n, err);
216 }
217  
218 static const dbil_abi dbil_abi_table = {
219 DBIL_ABI_VERSION,
220 dbil_abi_connect,
221 dbil_abi_hyperman_adapter,
222 dbil_abi_exec,
223 dbil_abi_exec_shaped,
224 dbil_abi_is_future,
225 dbil_abi_future_state,
226 dbil_abi_future_values,
227 dbil_abi_future_error,
228 dbil_abi_future_on_ready,
229 dbil_abi_future_new,
230 dbil_abi_future_done1,
231 dbil_abi_future_fail,
232 dbil_abi_reshape,
233 dbil_obs_add, /* v2 */
234 };
235  
236 /* ---- the v2 observer, driven from C (t/13-observer.t) ------------------- *
237 * A Perl test cannot register a C callback, so the observable half lives
238 * here: the counters and the last statement seen. */
239 static IV DBIL_OBS_ST_STARTS = 0;
240 static IV DBIL_OBS_ST_DONES = 0;
241 static IV DBIL_OBS_ST_OK = 0;
242 static IV DBIL_OBS_ST_ERR = 0;
243 static IV DBIL_OBS_ST_BIND = -1;
244 static IV DBIL_OBS_ST_QUERY = -1;
245 static char DBIL_OBS_ST_SQL[512];
246  
247 14 static void *dbil_obs_st_start(pTHX_ int is_query, const char *sql,
248 STRLEN sql_len, int nbind, void *ud) {
249 PERL_UNUSED_ARG(ud);
250 PERL_UNUSED_CONTEXT;
251 14 DBIL_OBS_ST_STARTS++;
252 14 DBIL_OBS_ST_BIND = nbind;
253 14 DBIL_OBS_ST_QUERY = is_query;
254 14 ▶ if (sql_len >= sizeof(DBIL_OBS_ST_SQL)) sql_len = sizeof(DBIL_OBS_ST_SQL) - 1;
Branch: 1 branch
BranchTrueFalseTotal
if (sql_len >= sizeof(DBIL_OBS_ST_SQL)) sql_len = sizeof(DBIL_OBS_ST_SQL) - 1; 0 14 14
255 14 memcpy(DBIL_OBS_ST_SQL, sql, sql_len);
256 14 DBIL_OBS_ST_SQL[sql_len] = '\0';
257 14 return INT2PTR(void *, DBIL_OBS_ST_STARTS);
258 }
259  
260 14 static void dbil_obs_st_done(pTHX_ void *token, SV *res, SV *err, void *ud) {
261 PERL_UNUSED_ARG(ud);
262 PERL_UNUSED_CONTEXT;
263 14 DBIL_OBS_ST_DONES++;
264 14 ▶ if (res) DBIL_OBS_ST_OK++;
Branch: 1 branch
BranchTrueFalseTotal
if (res) DBIL_OBS_ST_OK++; 12 2 14
265 14 ▶ if (err) DBIL_OBS_ST_ERR++;
Branch: 1 branch
BranchTrueFalseTotal
if (err) DBIL_OBS_ST_ERR++; 2 12 14
266 14 ▶ if (PTR2IV(token) < 1 || PTR2IV(token) > DBIL_OBS_ST_STARTS)
Branch: 2 branches
BranchTrueFalseTotal
if (PTR2IV(token) < 1 || PTR2IV(token) > DBIL_OBS_ST_STARTS) 14 0 14
if (PTR2IV(token) < 1 || PTR2IV(token) > DBIL_OBS_ST_STARTS) 0 14 14
267 0 DBIL_OBS_ST_ERR = -1; /* correlation broke */
268 14 }
269  
270 1 static int dbil_obs_selftest_install(pTHX) {
271 1 const dbil_abi *A = INT2PTR(const dbil_abi *, PTR2IV(&dbil_abi_table));
272 1 ▶ if (!A || A->abi_version != DBIL_ABI_VERSION) return 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!A || A->abi_version != DBIL_ABI_VERSION) return 0; 1 0 1
if (!A || A->abi_version != DBIL_ABI_VERSION) return 0; 0 1 1
273 1 return A->on_exec(aTHX_ dbil_obs_st_start, dbil_obs_st_done, NULL);
274 }
275  
276 /* ---- _abi_selftest: drive the table from C (t/16-abi.t) ------------------ */
277  
278 3 static void dbil_abi_st_ready(pTHX_ SV *f, void *ud) {
279 PERL_UNUSED_VAR(f);
280 3 *(int *)ud += 1;
281 3 }
282  
283 /* a query result as the backends produce it: { rows => [[..]], columns => [] } */
284 1 static SV *dbil_abi_st_result(pTHX) {
285 1 HV *h = newHV();
286 1 AV *rows = newAV();
287 1 AV *cols = newAV();
288 1 AV *r1 = newAV();
289 1 AV *r2 = newAV();
290 1 av_push(cols, newSVpvs("id"));
291 1 av_push(cols, newSVpvs("v"));
292 1 av_push(r1, newSViv(1)); av_push(r1, newSVpvs("one"));
293 1 av_push(r2, newSViv(2)); av_push(r2, newSVpvs("two"));
294 1 av_push(rows, newRV_noinc((SV *)r1));
295 1 av_push(rows, newRV_noinc((SV *)r2));
296 1 (void)hv_stores(h, "rows", newRV_noinc((SV *)rows));
297 1 (void)hv_stores(h, "columns", newRV_noinc((SV *)cols));
298 1 return newRV_noinc((SV *)h);
299 }
300  
301 1 static int dbil_abi_selftest(pTHX) {
302 1 const dbil_abi *A = &dbil_abi_table;
303 1 int ok = 1;
304 1 ▶ if (A->abi_version != DBIL_ABI_VERSION) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->abi_version != DBIL_ABI_VERSION) return 0; 0 1 1
305  
306 /* future lifecycle: new -> pending -> on_ready (C) -> done -> fired once */
307 {
308 1 SV *f = A->future_new(aTHX);
309 1 int fired = 0;
310 1 SV *val = sv_2mortal(newSViv(42));
311 SV *vals[4];
312 1 ▶ if (!A->is_future(aTHX_ f)) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!A->is_future(aTHX_ f)) ok = 0; 0 1 1
313 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_PENDING) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_PENDING) ok = 0; 0 1 1
314 1 A->future_on_ready(aTHX_ f, dbil_abi_st_ready, &fired);
315 1 A->future_done1(aTHX_ f, val);
316 1 A->future_done1(aTHX_ f, val); /* second settle: no-op */
317 1 ▶ if (fired != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (fired != 1) ok = 0; 0 1 1
318 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0; 0 1 1
319 1 ▶ if (A->future_values(aTHX_ f, vals, 4) != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_values(aTHX_ f, vals, 4) != 1) ok = 0; 0 1 1
320 1 ▶ else if (SvIV(vals[0]) != 42) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (SvIV(vals[0]) != 42) ok = 0; 0 1 1
321 1 ▶ if (A->future_error(aTHX_ f) != NULL) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_error(aTHX_ f) != NULL) ok = 0; 0 1 1
322  
323 /* on_ready on an ALREADY settled future fires immediately */
324 1 A->future_on_ready(aTHX_ f, dbil_abi_st_ready, &fired);
325 1 ▶ if (fired != 2) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (fired != 2) ok = 0; 0 1 1
326 1 SvREFCNT_dec(f);
327 }
328  
329 /* failure path */
330 {
331 1 SV *f = A->future_new(aTHX);
332 1 SV *err = sv_2mortal(newSVpvs("nope"));
333 SV *vals[2];
334 1 A->future_fail(aTHX_ f, err);
335 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_FAILED) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_FAILED) ok = 0; 0 1 1
336 1 ▶ if (A->future_values(aTHX_ f, vals, 2) != 0) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_values(aTHX_ f, vals, 2) != 0) ok = 0; 0 1 1
337 1 ▶ if (!A->future_error(aTHX_ f)) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!A->future_error(aTHX_ f)) ok = 0; 0 1 1
338 2 ▶ else if (strNE(SvPV_nolen(A->future_error(aTHX_ f)), "nope")) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (strNE(SvPV_nolen(A->future_error(aTHX_ f)), "nope")) ok = 0; 0 1 1
339 1 SvREFCNT_dec(f);
340 }
341  
342 /* is_future never dereferences what it was handed */
343 {
344 1 ▶ if (A->is_future(aTHX_ &PL_sv_undef)) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->is_future(aTHX_ &PL_sv_undef)) ok = 0; 0 1 1
345 1 ▶ if (A->is_future(aTHX_ sv_2mortal(newSViv(7)))) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->is_future(aTHX_ sv_2mortal(newSViv(7)))) ok = 0; 0 1 1
346 1 ▶ if (A->is_future(aTHX_ sv_2mortal(newRV_noinc((SV *)newHV())))) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->is_future(aTHX_ sv_2mortal(newRV_noinc((SV *)newHV())))) ok = 0; 0 1 1
347 }
348  
349 /* every reshape, against one synthetic result */
350 {
351 1 SV *res = sv_2mortal(dbil_abi_st_result(aTHX));
352 1 AV *out = (AV *)sv_2mortal((SV *)newAV());
353 SV *e;
354  
355 /* ALL_ARRAYREF: two rows */
356 1 e = A->reshape(aTHX_ DBIL_ABI_ALL_ARRAYREF, res, NULL, out);
357 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
358 else {
359 1 SV **v = av_fetch(out, 0, 0);
360 1 ▶ if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0;
Branch: 4 branches
BranchTrueFalseTotal
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 0 1 1
361 }
362 1 av_clear(out);
363  
364 /* ROW_HASHREF: the first row by name */
365 1 e = A->reshape(aTHX_ DBIL_ABI_ROW_HASHREF, res, NULL, out);
366 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
367 else {
368 1 SV **v = av_fetch(out, 0, 0);
369 1 ▶ SV **c = (v && *v && SvROK(*v))
Branch: 2 branches
BranchTrueFalseTotal
SV **c = (v && *v && SvROK(*v)) 1 0 1
SV **c = (v && *v && SvROK(*v)) 1 0 1
370 2 ▶ ? hv_fetchs((HV *)SvRV(*v), "v", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? hv_fetchs((HV *)SvRV(*v), "v", 0) : NULL; 1 0 1
371 2 ▶ if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0;
Branch: 3 branches
BranchTrueFalseTotal
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 0 1 1
372 }
373 1 av_clear(out);
374  
375 /* ROW_ARRAY: the first row as a list of two */
376 1 e = A->reshape(aTHX_ DBIL_ABI_ROW_ARRAY, res, NULL, out);
377 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
378 1 ▶ else if (av_len(out) != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (av_len(out) != 1) ok = 0; 0 1 1
379 1 av_clear(out);
380  
381 /* COL_ARRAYREF: the first column of both rows */
382 1 e = A->reshape(aTHX_ DBIL_ABI_COL_ARRAYREF, res, NULL, out);
383 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
384 else {
385 1 SV **v = av_fetch(out, 0, 0);
386 1 ▶ if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0;
Branch: 4 branches
BranchTrueFalseTotal
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 0 1 1
387 }
388 1 av_clear(out);
389  
390 /* ALL_HASHREF without a key field fails rather than croaking */
391 1 e = A->reshape(aTHX_ DBIL_ABI_ALL_HASHREF, res, NULL, out);
392 1 ▶ if (!e) ok = 0; else SvREFCNT_dec(e);
Branch: 1 branch
BranchTrueFalseTotal
if (!e) ok = 0; else SvREFCNT_dec(e); 0 1 1
393 1 av_clear(out);
394  
395 /* ALL_HASHREF naming a column that is not there, likewise */
396 1 e = A->reshape(aTHX_ DBIL_ABI_ALL_HASHREF, res,
397 sv_2mortal(newSVpvs("nope")), out);
398 1 ▶ if (!e) ok = 0; else SvREFCNT_dec(e);
Branch: 1 branch
BranchTrueFalseTotal
if (!e) ok = 0; else SvREFCNT_dec(e); 0 1 1
399 1 av_clear(out);
400  
401 /* ALL_HASHREF keyed by id */
402 1 e = A->reshape(aTHX_ DBIL_ABI_ALL_HASHREF, res,
403 sv_2mortal(newSVpvs("id")), out);
404 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
405 else {
406 1 SV **v = av_fetch(out, 0, 0);
407 1 ▶ if (!(v && *v && SvROK(*v)
Branch: 3 branches
BranchTrueFalseTotal
if (!(v && *v && SvROK(*v) 1 0 1
if (!(v && *v && SvROK(*v) 1 0 1
if (!(v && *v && SvROK(*v) 1 0 1
408 1 ▶ && HvUSEDKEYS((HV *)SvRV(*v)) == 2)) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
&& HvUSEDKEYS((HV *)SvRV(*v)) == 2)) ok = 0; 0 1 1
&& HvUSEDKEYS((HV *)SvRV(*v)) == 2)) ok = 0; 0 1 1
409 }
410 1 av_clear(out);
411  
412 /* ALL_ROWHASH: both rows as hashrefs, in order */
413 1 e = A->reshape(aTHX_ DBIL_ABI_ALL_ROWHASH, res, NULL, out);
414 1 ▶ if (e) { ok = 0; SvREFCNT_dec(e); }
Branch: 1 branch
BranchTrueFalseTotal
if (e) { ok = 0; SvREFCNT_dec(e); } 0 1 1
415 else {
416 1 SV **v = av_fetch(out, 0, 0);
417 1 ▶ if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0;
Branch: 4 branches
BranchTrueFalseTotal
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 1 0 1
if (!(v && *v && SvROK(*v) && av_len((AV *)SvRV(*v)) == 1)) ok = 0; 0 1 1
418 else {
419 1 AV *a = (AV *)SvRV(*v);
420 1 SV **r0 = av_fetch(a, 0, 0);
421 1 SV **r1 = av_fetch(a, 1, 0);
422 1 ▶ SV **c0 = (r0 && *r0 && SvROK(*r0))
Branch: 2 branches
BranchTrueFalseTotal
SV **c0 = (r0 && *r0 && SvROK(*r0)) 1 0 1
SV **c0 = (r0 && *r0 && SvROK(*r0)) 1 0 1
423 2 ▶ ? hv_fetchs((HV *)SvRV(*r0), "v", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? hv_fetchs((HV *)SvRV(*r0), "v", 0) : NULL; 1 0 1
424 1 ▶ SV **c1 = (r1 && *r1 && SvROK(*r1))
Branch: 2 branches
BranchTrueFalseTotal
SV **c1 = (r1 && *r1 && SvROK(*r1)) 1 0 1
SV **c1 = (r1 && *r1 && SvROK(*r1)) 1 0 1
425 2 ▶ ? hv_fetchs((HV *)SvRV(*r1), "v", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? hv_fetchs((HV *)SvRV(*r1), "v", 0) : NULL; 1 0 1
426 2 ▶ if (!(c0 && *c0 && strEQ(SvPV_nolen(*c0), "one"))) ok = 0;
Branch: 3 branches
BranchTrueFalseTotal
if (!(c0 && *c0 && strEQ(SvPV_nolen(*c0), "one"))) ok = 0; 1 0 1
if (!(c0 && *c0 && strEQ(SvPV_nolen(*c0), "one"))) ok = 0; 1 0 1
if (!(c0 && *c0 && strEQ(SvPV_nolen(*c0), "one"))) ok = 0; 0 1 1
427 2 ▶ if (!(c1 && *c1 && strEQ(SvPV_nolen(*c1), "two"))) ok = 0;
Branch: 3 branches
BranchTrueFalseTotal
if (!(c1 && *c1 && strEQ(SvPV_nolen(*c1), "two"))) ok = 0; 1 0 1
if (!(c1 && *c1 && strEQ(SvPV_nolen(*c1), "two"))) ok = 0; 1 0 1
if (!(c1 && *c1 && strEQ(SvPV_nolen(*c1), "two"))) ok = 0; 0 1 1
428 }
429 }
430 1 av_clear(out);
431 }
432  
433 /* connect refuses to croak: no adapter is an error SV, not a die */
434 {
435 1 SV *err = NULL;
436 1 SV *db = A->connect(aTHX_ sv_2mortal(newSVpvs("dbi:NoSuch:")),
437 NULL, NULL, NULL, NULL, 0, 0, &err);
438 1 ▶ if (db) { ok = 0; SvREFCNT_dec(db); }
Branch: 1 branch
BranchTrueFalseTotal
if (db) { ok = 0; SvREFCNT_dec(db); } 0 1 1
439 1 ▶ if (!err) ok = 0; else SvREFCNT_dec(err);
Branch: 1 branch
BranchTrueFalseTotal
if (!err) ok = 0; else SvREFCNT_dec(err); 0 1 1
440 }
441  
442 /* and a dsn no driver can serve fails the same way */
443 {
444 1 SV *err = NULL;
445 1 SV *db = A->connect(aTHX_ sv_2mortal(newSVpvs("dbi:NoSuchDriver:x")),
446 NULL, NULL, NULL,
447 sv_2mortal(newSVpvs("not-an-adapter")),
448 0, 0, &err);
449 1 ▶ if (db) { ok = 0; SvREFCNT_dec(db); }
Branch: 1 branch
BranchTrueFalseTotal
if (db) { ok = 0; SvREFCNT_dec(db); } 0 1 1
450 1 ▶ if (!err) ok = 0; else SvREFCNT_dec(err);
Branch: 1 branch
BranchTrueFalseTotal
if (!err) ok = 0; else SvREFCNT_dec(err); 0 1 1
451 }
452  
453 1 return ok;
454 }
455  
456 /* ---- _abi_dbtest: the table against a real database ---------------------- *
457 * The selftest above covers the table's own arithmetic; this drives it end to
458 * end - connect, exec, exec_shaped, a C on_ready that fires when rows land,
459 * and the failure path - against whatever dsn and loop adapter the test hands
460 * in. Everything below the await is C: no Perl frame runs when a result
461 * settles, which is the entire point of the table. */
462  
463 6 static void dbil_abi_await(pTHX_ SV *adapter, SV *f) {
464 6 dSP;
465 6 ▶ ENTER; SAVETMPS; PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
ENTER; SAVETMPS; PUSHMARK(SP); 0 6 6
466 6 ▶ EXTEND(SP, 2); PUSHs(adapter); PUSHs(f); PUTBACK;
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); PUSHs(adapter); PUSHs(f); PUTBACK; 0 6 6
467 6 (void)call_method("await", G_VOID | G_DISCARD | G_EVAL);
468 6 ▶ SPAGAIN; PUTBACK; FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
SPAGAIN; PUTBACK; FREETMPS; LEAVE; 6 0 6
469 6 }
470  
471 /* run one statement to completion; 1 if it settled done */
472 3 static int dbil_abi_dbt_do(pTHX_ const dbil_abi *A, SV *adapter, SV *db,
473 const char *sql) {
474 3 SV *f = A->exec(aTHX_ db, 0, sv_2mortal(newSVpv(sql, 0)), NULL);
475 int ok;
476 3 dbil_abi_await(aTHX_ adapter, f);
477 3 ok = (A->future_state(aTHX_ f) == DBIL_ABI_DONE);
478 3 SvREFCNT_dec(f);
479 3 return ok;
480 }
481  
482 1 static int dbil_abi_dbtest(pTHX_ SV *adapter, SV *dsn) {
483 1 const dbil_abi *A = &dbil_abi_table;
484 1 SV *err = NULL, *db, *attr;
485 1 int ok = 1, fired = 0;
486  
487 { /* RaiseError so a failure reaches the future, PrintError off so the
488 * deliberate bad query below does not write to the test's stderr */
489 1 HV *a = newHV();
490 1 (void)hv_stores(a, "RaiseError", newSViv(1));
491 1 (void)hv_stores(a, "PrintError", newSViv(0));
492 1 attr = sv_2mortal(newRV_noinc((SV *)a));
493 }
494 1 db = A->connect(aTHX_ dsn, NULL, NULL,
495 attr, adapter, 2, 0, &err);
496 1 ▶ if (!db) {
Branch: 1 branch
BranchTrueFalseTotal
if (!db) { 0 1 1
497 0 ▶ if (err) SvREFCNT_dec(err);
Branch: 1 branch
BranchTrueFalseTotal
if (err) SvREFCNT_dec(err); 0 0 0
498 0 return 0;
499 }
500  
501 1 ▶ if (!dbil_abi_dbt_do(aTHX_ A, adapter, db,
Branch: 1 branch
BranchTrueFalseTotal
if (!dbil_abi_dbt_do(aTHX_ A, adapter, db, 0 1 1
502 0 "CREATE TABLE t (id INTEGER PRIMARY KEY, v TEXT)")) ok = 0;
503 1 ▶ if (!dbil_abi_dbt_do(aTHX_ A, adapter, db,
Branch: 1 branch
BranchTrueFalseTotal
if (!dbil_abi_dbt_do(aTHX_ A, adapter, db, 0 1 1
504 0 "INSERT INTO t (id, v) VALUES (1, 'one')")) ok = 0;
505 1 ▶ if (!dbil_abi_dbt_do(aTHX_ A, adapter, db,
Branch: 1 branch
BranchTrueFalseTotal
if (!dbil_abi_dbt_do(aTHX_ A, adapter, db, 0 1 1
506 0 "INSERT INTO t (id, v) VALUES (2, 'two')")) ok = 0;
507  
508 /* exec_shaped + a C on_ready: rows arrive already reshaped */
509 {
510 1 SV *f = A->exec_shaped(aTHX_ db,
511 sv_2mortal(newSVpvs("SELECT id, v FROM t ORDER BY id")),
512 NULL, DBIL_ABI_ALL_ROWHASH, NULL);
513 SV *vals[2];
514 1 A->future_on_ready(aTHX_ f, dbil_abi_st_ready, &fired);
515 1 dbil_abi_await(aTHX_ adapter, f);
516 1 ▶ if (fired != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (fired != 1) ok = 0; 0 1 1
517 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0; 0 1 1
518 1 ▶ else if (A->future_values(aTHX_ f, vals, 2) != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (A->future_values(aTHX_ f, vals, 2) != 1) ok = 0; 0 1 1
519 1 ▶ else if (!(SvROK(vals[0]) && av_len((AV *)SvRV(vals[0])) == 1)) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
else if (!(SvROK(vals[0]) && av_len((AV *)SvRV(vals[0])) == 1)) ok = 0; 1 0 1
else if (!(SvROK(vals[0]) && av_len((AV *)SvRV(vals[0])) == 1)) ok = 0; 0 1 1
520 else {
521 1 SV **r0 = av_fetch((AV *)SvRV(vals[0]), 0, 0);
522 1 ▶ SV **c = (r0 && *r0 && SvROK(*r0))
Branch: 2 branches
BranchTrueFalseTotal
SV **c = (r0 && *r0 && SvROK(*r0)) 1 0 1
SV **c = (r0 && *r0 && SvROK(*r0)) 1 0 1
523 2 ▶ ? hv_fetchs((HV *)SvRV(*r0), "v", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? hv_fetchs((HV *)SvRV(*r0), "v", 0) : NULL; 1 0 1
524 2 ▶ if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0;
Branch: 3 branches
BranchTrueFalseTotal
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "one"))) ok = 0; 0 1 1
525 }
526 1 SvREFCNT_dec(f);
527 }
528  
529 /* a bind value, and the single-row shape */
530 {
531 1 AV *bind = (AV *)sv_2mortal((SV *)newAV());
532 SV *f, *vals[2];
533 1 av_push(bind, newSViv(2));
534 1 f = A->exec_shaped(aTHX_ db,
535 sv_2mortal(newSVpvs("SELECT id, v FROM t WHERE id = ?")),
536 bind, DBIL_ABI_ROW_HASHREF, NULL);
537 1 dbil_abi_await(aTHX_ adapter, f);
538 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_DONE) ok = 0; 0 1 1
539 1 ▶ else if (A->future_values(aTHX_ f, vals, 2) != 1) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (A->future_values(aTHX_ f, vals, 2) != 1) ok = 0; 0 1 1
540 else {
541 2 SV **c = SvROK(vals[0])
542 1 ▶ ? hv_fetchs((HV *)SvRV(vals[0]), "v", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? hv_fetchs((HV *)SvRV(vals[0]), "v", 0) : NULL; 1 0 1
543 2 ▶ if (!(c && *c && strEQ(SvPV_nolen(*c), "two"))) ok = 0;
Branch: 3 branches
BranchTrueFalseTotal
if (!(c && *c && strEQ(SvPV_nolen(*c), "two"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "two"))) ok = 0; 1 0 1
if (!(c && *c && strEQ(SvPV_nolen(*c), "two"))) ok = 0; 0 1 1
544 }
545 1 SvREFCNT_dec(f);
546 }
547  
548 /* the failure path carries an error rather than croaking out of settle */
549 {
550 1 SV *f = A->exec(aTHX_ db, 1,
551 sv_2mortal(newSVpvs("SELECT * FROM no_such_table")), NULL);
552 1 dbil_abi_await(aTHX_ adapter, f);
553 1 ▶ if (A->future_state(aTHX_ f) != DBIL_ABI_FAILED) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (A->future_state(aTHX_ f) != DBIL_ABI_FAILED) ok = 0; 0 1 1
554 1 ▶ if (!A->future_error(aTHX_ f)) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!A->future_error(aTHX_ f)) ok = 0; 0 1 1
555 1 SvREFCNT_dec(f);
556 }
557  
558 { /* tear the pool down deterministically rather than at destruction */
559 1 dSP;
560 1 ▶ ENTER; SAVETMPS; PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
ENTER; SAVETMPS; PUSHMARK(SP); 0 1 1
561 1 ▶ EXTEND(SP, 1); PUSHs(db); PUTBACK;
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 1); PUSHs(db); PUTBACK; 0 1 1
562 1 (void)call_method("disconnect", G_VOID | G_DISCARD | G_EVAL);
563 1 ▶ SPAGAIN; PUTBACK; FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
SPAGAIN; PUTBACK; FREETMPS; LEAVE; 1 0 1
564 }
565 1 SvREFCNT_dec(db);
566 1 return ok;
567 }
568  
569 #endif /* DBIL_ABI_IMPL_H */
« xs/loop.xs ↑ Summary include/dbil_obs.h »