dbdimp_virtual_table.inc

filter: Statementstmt 0.0% 0 / 469 Branchbran 0.0% 0 / 254 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 723 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« dbdimp_tokenizer.inc ↑ Summary sqlite3.c »
1 /***********************************************************************
2 ** The set of routines that implement the perl "module"
3 ** (i.e support for virtual tables written in Perl)
4 ************************************************************************/
5  
6 typedef struct perl_vtab {
7 sqlite3_vtab base;
8 SV *perl_vtab_obj;
9 HV *functions;
10 } perl_vtab;
11  
12 typedef struct perl_vtab_cursor {
13 sqlite3_vtab_cursor base;
14 SV *perl_cursor_obj;
15 } perl_vtab_cursor;
16  
17 typedef struct perl_vtab_init {
18 SV *dbh;
19 const char *perl_class;
20 } perl_vtab_init;
21  
22  
23  
24 /* auxiliary routine for generalized method calls. Arg "i" may be unused */
25 0 static int _call_perl_vtab_method(sqlite3_vtab *pVTab,
26 const char *method, int i) {
27 dTHX;
28 0 dSP;
29 int count;
30  
31 0 ENTER;
32 0 SAVETMPS;
33  
34 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
35 0 ▶ XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
36 0 ▶ XPUSHs(sv_2mortal(newSViv(i)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(i))); 0 0 0
37 0 PUTBACK;
38 0 count = call_method (method, G_VOID);
39 0 SPAGAIN;
40 0 SP -= count;
41  
42 0 PUTBACK;
43 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
44 0 LEAVE;
45  
46 0 return SQLITE_OK;
47 }
48  
49  
50 /* RT-124941: it seems better to prefer PV where appropriate */
51 static void
52 0 sqlite_set_result_for_vtable(pTHX_ sqlite3_context *context, SV *result, int is_error)
53 {
54 STRLEN len;
55 char *s;
56 sqlite3_int64 iv;
57  
58 0 ▶ if ( is_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( is_error ) { 0 0 0
59 0 s = SvPV(result, len);
60 0 sqlite3_result_error( context, s, len );
61 0 return;
62 }
63  
64 /* warn("result: %s\n", SvPV_nolen(result)); */
65 0 ▶ if ( !SvOK(result) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( !SvOK(result) ) { 0 0 0
66 0 sqlite3_result_null( context );
67 0 ▶ } else if ( SvPOK(result) ) {
Branch: 1 branch
BranchTrueFalseTotal
} else if ( SvPOK(result) ) { 0 0 0
68 0 s = SvPV(result, len);
69 0 sqlite3_result_text( context, s, len, SQLITE_TRANSIENT );
70 0 ▶ } else if( SvIOK_UV(result) ) {
Branch: 1 branch
BranchTrueFalseTotal
} else if( SvIOK_UV(result) ) { 0 0 0
71 if ((UV)(sqlite3_int64)UV_MAX == UV_MAX)
72 0 sqlite3_result_int64( context, (sqlite3_int64)SvUV(result));
73 else {
74 s = SvPV(result, len);
75 sqlite3_result_text( context, s, len, SQLITE_TRANSIENT );
76 }
77 0 ▶ } else if ( !_sqlite_atoi64(SvPV(result, len), &iv) ) {
Branch: 1 branch
BranchTrueFalseTotal
} else if ( !_sqlite_atoi64(SvPV(result, len), &iv) ) { 0 0 0
78 0 sqlite3_result_int64( context, iv );
79 0 ▶ } else if ( SvNOK(result) && ( sizeof(NV) == sizeof(double) || SvNVX(result) == (double) SvNVX(result) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
} else if ( SvNOK(result) && ( sizeof(NV) == sizeof(double) || SvNVX(result) == (double) SvNVX(result) ) ) { 0 0 0
80 0 sqlite3_result_double( context, SvNV(result));
81 } else {
82 0 s = SvPV(result, len);
83 0 sqlite3_result_text( context, s, len, SQLITE_TRANSIENT );
84 }
85 }
86  
87  
88  
89 0 static int perl_vt_New(const char *method,
90 sqlite3 *db, void *pAux,
91 int argc, const char *const *argv,
92 sqlite3_vtab **ppVTab, char **pzErr){
93 dTHX;
94 0 dSP;
95 perl_vtab *vt;
96 0 perl_vtab_init *init_data = (perl_vtab_init *)pAux;
97 int count, i;
98 0 int rc = SQLITE_ERROR;
99 SV *perl_vtab_obj;
100 SV *sql;
101  
102 /* allocate a perl_vtab structure */
103 0 vt = (perl_vtab *) sqlite3_malloc(sizeof(*vt));
104 0 ▶ if( vt==NULL ) return SQLITE_NOMEM;
Branch: 1 branch
BranchTrueFalseTotal
if( vt==NULL ) return SQLITE_NOMEM; 0 0 0
105 0 memset(vt, 0, sizeof(*vt));
106 0 vt->functions = newHV();
107  
108 0 ENTER;
109 0 SAVETMPS;
110  
111 /* call the ->CREATE/CONNECT() method */
112 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
113 0 ▶ XPUSHs(sv_2mortal(newSVpv(init_data->perl_class, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(init_data->perl_class, 0))); 0 0 0
114 0 ▶ XPUSHs(init_data->dbh);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(init_data->dbh); 0 0 0
115 0 ▶ for(i = 0; i < argc; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < argc; i++) { 0 0 0
116 0 ▶ XPUSHs(newSVpvn_flags(argv[i], strlen(argv[i]), SVs_TEMP|SVf_UTF8));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(newSVpvn_flags(argv[i], strlen(argv[i]), SVs_TEMP|SVf_UTF8)); 0 0 0
117 }
118 0 PUTBACK;
119 0 count = call_method (method, G_SCALAR);
120 0 SPAGAIN;
121  
122 /* check the return value */
123 0 ▶ if ( count != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( count != 1 ) { 0 0 0
124 0 *pzErr = sqlite3_mprintf("vtab->%s() should return one value, got %d",
125 method, count );
126 0 SP -= count; /* Clear the stack */
127 0 goto cleanup;
128 }
129  
130 /* get the VirtualTable instance */
131 0 perl_vtab_obj = POPs;
132 0 ▶ if ( !sv_isobject(perl_vtab_obj) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( !sv_isobject(perl_vtab_obj) ) { 0 0 0
133 0 *pzErr = sqlite3_mprintf("vtab->%s() should return a blessed reference",
134 method);
135 0 goto cleanup;
136 }
137  
138 /* call the ->VTAB_TO_DECLARE() method */
139 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
140 0 ▶ XPUSHs(perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(perl_vtab_obj); 0 0 0
141 0 PUTBACK;
142 0 count = call_method ("VTAB_TO_DECLARE", G_SCALAR);
143 0 SPAGAIN;
144  
145 /* check the return value */
146 0 ▶ if (count != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1 ) { 0 0 0
147 0 *pzErr = sqlite3_mprintf("vtab->VTAB_TO_DECLARE() should return one value, got %d",
148 count );
149 0 SP -= count; /* Clear the stack */
150 0 goto cleanup;
151 }
152  
153 /* call sqlite3_declare_vtab with the sql returned from
154 method VTAB_TO_DECLARE(), converted to utf8 */
155 0 sql = POPs;
156 0 rc = sqlite3_declare_vtab(db, SvPVutf8_nolen(sql));
157  
158 0 cleanup:
159 0 ▶ if (rc == SQLITE_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc == SQLITE_OK) { 0 0 0
160 /* record the VirtualTable perl instance within the vtab structure */
161 0 vt->perl_vtab_obj = SvREFCNT_inc(perl_vtab_obj);
162 0 *ppVTab = &vt->base;
163 }
164 else {
165 0 sqlite3_free(vt);
166 }
167  
168 0 PUTBACK;
169 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
170 0 LEAVE;
171  
172 0 return rc;
173 }
174  
175  
176 0 static int perl_vt_Create(sqlite3 *db, void *pAux,
177 int argc, const char *const *argv,
178 sqlite3_vtab **ppVTab, char **pzErr){
179 0 return perl_vt_New("CREATE", db, pAux, argc, argv, ppVTab, pzErr);
180 }
181  
182 0 static int perl_vt_Connect(sqlite3 *db, void *pAux,
183 int argc, const char *const *argv,
184 sqlite3_vtab **ppVTab, char **pzErr){
185 0 return perl_vt_New("CONNECT", db, pAux, argc, argv, ppVTab, pzErr);
186 }
187  
188  
189 0 static int _free_perl_vtab(perl_vtab *pVTab){
190 dTHX;
191  
192 0 SvREFCNT_dec(pVTab->perl_vtab_obj);
193  
194 /* deallocate coderefs that were declared through FindFunction() */
195 0 hv_undef(pVTab->functions);
196 0 SvREFCNT_dec(pVTab->functions);
197  
198 0 sqlite3_free(pVTab);
199 0 return SQLITE_OK;
200 }
201  
202 0 static int perl_vt_Disconnect(sqlite3_vtab *pVTab){
203 0 _call_perl_vtab_method(pVTab, "DISCONNECT", 0);
204 0 return _free_perl_vtab((perl_vtab *)pVTab);
205 }
206  
207 0 static int perl_vt_Drop(sqlite3_vtab *pVTab){
208 0 _call_perl_vtab_method(pVTab, "DROP", 0);
209 0 return _free_perl_vtab((perl_vtab *)pVTab);
210 }
211  
212  
213 static char *
214 0 _constraint_op_to_string(unsigned char op) {
215 0 switch (op) {
216 0 case SQLITE_INDEX_CONSTRAINT_EQ:
217 0 return "=";
218 0 case SQLITE_INDEX_CONSTRAINT_GT:
219 0 return ">";
220 0 case SQLITE_INDEX_CONSTRAINT_GE:
221 0 return ">=";
222 0 case SQLITE_INDEX_CONSTRAINT_LT:
223 0 return "<";
224 0 case SQLITE_INDEX_CONSTRAINT_LE:
225 0 return "<=";
226 0 case SQLITE_INDEX_CONSTRAINT_MATCH:
227 0 return "MATCH";
228 #if SQLITE_VERSION_NUMBER >= 3010000
229 0 case SQLITE_INDEX_CONSTRAINT_LIKE:
230 0 return "LIKE";
231 0 case SQLITE_INDEX_CONSTRAINT_GLOB:
232 0 return "GLOB";
233 0 case SQLITE_INDEX_CONSTRAINT_REGEXP:
234 0 return "REGEXP";
235 #endif
236 #if SQLITE_VERSION_NUMBER >= 3021000
237 case SQLITE_INDEX_CONSTRAINT_NE:
238 return "NE";
239 case SQLITE_INDEX_CONSTRAINT_ISNOT:
240 return "ISNOT";
241 case SQLITE_INDEX_CONSTRAINT_ISNOTNULL:
242 return "ISNOTNULL";
243 case SQLITE_INDEX_CONSTRAINT_ISNULL:
244 return "ISNULL";
245 case SQLITE_INDEX_CONSTRAINT_IS:
246 return "IS";
247 #endif
248 0 default:
249 0 return "unknown";
250 }
251 }
252  
253  
254 0 static int perl_vt_BestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pIdxInfo){
255 dTHX;
256 0 dSP;
257 int i, count;
258 int argvIndex;
259 AV *constraints;
260 AV *order_by;
261 SV *hashref;
262 SV **val;
263 HV *hv;
264 struct sqlite3_index_constraint_usage *pConsUsage;
265  
266 0 ENTER;
267 0 SAVETMPS;
268  
269 /* build the "where_constraints" datastructure */
270 0 constraints = newAV();
271 0 ▶ for (i=0; i<pIdxInfo->nConstraint; i++){
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i<pIdxInfo->nConstraint; i++){ 0 0 0
272 0 struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[i];
273 0 HV *constraint = newHV();
274 0 char *op_str = _constraint_op_to_string(pCons->op);
275 0 hv_stores(constraint, "col", newSViv(pCons->iColumn));
276 0 hv_stores(constraint, "op", newSVpv(op_str, 0));
277 0 ▶ hv_stores(constraint, "usable", pCons->usable ? &PL_sv_yes : &PL_sv_no);
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(constraint, "usable", pCons->usable ? &PL_sv_yes : &PL_sv_no); 0 0 0
278 0 av_push(constraints, newRV_noinc((SV*) constraint));
279 }
280  
281 /* build the "order_by" datastructure */
282 0 order_by = newAV();
283 0 ▶ for (i=0; i<pIdxInfo->nOrderBy; i++){
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i<pIdxInfo->nOrderBy; i++){ 0 0 0
284 0 struct sqlite3_index_orderby const *pOrder = &pIdxInfo->aOrderBy[i];
285 0 HV *order = newHV();
286 0 hv_stores(order, "col", newSViv(pOrder->iColumn));
287 0 ▶ hv_stores(order, "desc", pOrder->desc ? &PL_sv_yes : &PL_sv_no);
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(order, "desc", pOrder->desc ? &PL_sv_yes : &PL_sv_no); 0 0 0
288 0 av_push( order_by, newRV_noinc((SV*) order));
289 }
290  
291 /* call the ->BEST_INDEX() method */
292 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
293 0 ▶ XPUSHs( ((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs( ((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
294 0 ▶ XPUSHs( sv_2mortal( newRV_noinc((SV*) constraints)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs( sv_2mortal( newRV_noinc((SV*) constraints))); 0 0 0
295 0 ▶ XPUSHs( sv_2mortal( newRV_noinc((SV*) order_by)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs( sv_2mortal( newRV_noinc((SV*) order_by))); 0 0 0
296 0 PUTBACK;
297 0 count = call_method ("BEST_INDEX", G_SCALAR);
298 0 SPAGAIN;
299  
300 /* get values back from the returned hashref */
301 0 ▶ if (count != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) 0 0 0
302 0 croak("BEST_INDEX() method returned %d vals instead of 1", count);
303 0 hashref = POPs;
304 0 ▶ if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV))
Branch: 3 branches
BranchTrueFalseTotal
if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV)) 0 0 0
if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV)) 0 0 0
if (!(hashref && SvROK(hashref) && SvTYPE(SvRV(hashref)) == SVt_PVHV)) 0 0 0
305 0 croak("BEST_INDEX() method did not return a hashref");
306 0 hv = (HV*)SvRV(hashref);
307 0 val = hv_fetch(hv, "idxNum", 6, FALSE);
308 0 ▶ pIdxInfo->idxNum = (val && SvOK(*val)) ? SvIV(*val) : 0;
Branch: 2 branches
BranchTrueFalseTotal
pIdxInfo->idxNum = (val && SvOK(*val)) ? SvIV(*val) : 0; 0 0 0
pIdxInfo->idxNum = (val && SvOK(*val)) ? SvIV(*val) : 0; 0 0 0
309 0 val = hv_fetch(hv, "idxStr", 6, FALSE);
310 0 ▶ if (val && SvOK(*val)) {
Branch: 2 branches
BranchTrueFalseTotal
if (val && SvOK(*val)) { 0 0 0
if (val && SvOK(*val)) { 0 0 0
311 STRLEN len;
312 0 char *str = SvPVutf8(*val, len);
313 0 pIdxInfo->idxStr = sqlite3_malloc(len+1);
314 0 memcpy(pIdxInfo->idxStr, str, len);
315 0 pIdxInfo->idxStr[len] = 0;
316 0 pIdxInfo->needToFreeIdxStr = 1;
317 }
318 0 val = hv_fetch(hv, "orderByConsumed", 15, FALSE);
319 0 ▶ pIdxInfo->orderByConsumed = (val && SvTRUE(*val)) ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
pIdxInfo->orderByConsumed = (val && SvTRUE(*val)) ? 1 : 0; 0 0 0
pIdxInfo->orderByConsumed = (val && SvTRUE(*val)) ? 1 : 0; 0 0 0
320 0 val = hv_fetch(hv, "estimatedCost", 13, FALSE);
321 0 ▶ pIdxInfo->estimatedCost = (val && SvOK(*val)) ? SvNV(*val) : 0;
Branch: 2 branches
BranchTrueFalseTotal
pIdxInfo->estimatedCost = (val && SvOK(*val)) ? SvNV(*val) : 0; 0 0 0
pIdxInfo->estimatedCost = (val && SvOK(*val)) ? SvNV(*val) : 0; 0 0 0
322 #if SQLITE_VERSION_NUMBER >= 3008002
323 0 val = hv_fetch(hv, "estimatedRows", 13, FALSE);
324 0 ▶ pIdxInfo->estimatedRows = (val && SvOK(*val)) ? SvIV(*val) : 0;
Branch: 2 branches
BranchTrueFalseTotal
pIdxInfo->estimatedRows = (val && SvOK(*val)) ? SvIV(*val) : 0; 0 0 0
pIdxInfo->estimatedRows = (val && SvOK(*val)) ? SvIV(*val) : 0; 0 0 0
325 #endif
326  
327 /* loop over constraints to get back the "argvIndex" and "omit" keys
328 that shoud have been added by the best_index() method call */
329 0 ▶ for (i=0; i<pIdxInfo->nConstraint; i++){
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i<pIdxInfo->nConstraint; i++){ 0 0 0
330 0 SV **rv = av_fetch(constraints, i, FALSE);
331 0 ▶ if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV))
Branch: 3 branches
BranchTrueFalseTotal
if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV)) 0 0 0
if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV)) 0 0 0
if (!(rv && SvROK(*rv) && SvTYPE(SvRV(*rv)) == SVt_PVHV)) 0 0 0
332 0 croak("the call to BEST_INDEX() has corrupted constraint data");
333 0 hv = (HV*)SvRV(*rv);
334 0 val = hv_fetch(hv, "argvIndex", 9, FALSE);
335 0 ▶ argvIndex = (val && SvOK(*val)) ? SvIV(*val) + 1: 0;
Branch: 2 branches
BranchTrueFalseTotal
argvIndex = (val && SvOK(*val)) ? SvIV(*val) + 1: 0; 0 0 0
argvIndex = (val && SvOK(*val)) ? SvIV(*val) + 1: 0; 0 0 0
336  
337 0 pConsUsage = &pIdxInfo->aConstraintUsage[i];
338 0 pConsUsage->argvIndex = argvIndex;
339 0 val = hv_fetch(hv, "omit", 4, FALSE);
340 0 ▶ pConsUsage->omit = (val && SvTRUE(*val)) ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
pConsUsage->omit = (val && SvTRUE(*val)) ? 1 : 0; 0 0 0
pConsUsage->omit = (val && SvTRUE(*val)) ? 1 : 0; 0 0 0
341 }
342  
343 0 PUTBACK;
344 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
345 0 LEAVE;
346  
347 0 return SQLITE_OK;
348 }
349  
350  
351  
352 0 static int perl_vt_Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
353 dTHX;
354 0 dSP;
355 int count;
356 0 int rc = SQLITE_ERROR;
357 SV *perl_cursor;
358 perl_vtab_cursor *cursor;
359  
360 0 ENTER;
361 0 SAVETMPS;
362  
363 /* allocate a perl_vtab_cursor structure */
364 0 cursor = (perl_vtab_cursor *) sqlite3_malloc(sizeof(*cursor));
365 0 ▶ if( cursor==NULL ) return SQLITE_NOMEM;
Branch: 1 branch
BranchTrueFalseTotal
if( cursor==NULL ) return SQLITE_NOMEM; 0 0 0
366 0 memset(cursor, 0, sizeof(*cursor));
367  
368 /* call the ->OPEN() method */
369 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
370 0 ▶ XPUSHs( ((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs( ((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
371 0 PUTBACK;
372 0 count = call_method ("OPEN", G_SCALAR);
373 0 SPAGAIN;
374 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
375 0 warn("vtab->OPEN() method returned %d vals instead of 1", count);
376 0 SP -= count;
377 0 goto cleanup;
378  
379 }
380 0 perl_cursor = POPs;
381 0 ▶ if ( !sv_isobject(perl_cursor) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( !sv_isobject(perl_cursor) ) { 0 0 0
382 0 warn("vtab->OPEN() method did not return a blessed cursor");
383 0 goto cleanup;
384 }
385  
386 /* everything went OK */
387 0 rc = SQLITE_OK;
388  
389 0 cleanup:
390  
391 0 ▶ if (rc == SQLITE_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc == SQLITE_OK) { 0 0 0
392 0 cursor->perl_cursor_obj = SvREFCNT_inc(perl_cursor);
393 0 *ppCursor = &cursor->base;
394 }
395 else {
396 0 sqlite3_free(cursor);
397 }
398  
399 0 PUTBACK;
400 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
401 0 LEAVE;
402  
403 0 return rc;
404 }
405  
406 0 static int perl_vt_Close(sqlite3_vtab_cursor *pVtabCursor){
407 dTHX;
408 0 dSP;
409 perl_vtab_cursor *perl_pVTabCursor;
410  
411 0 ENTER;
412 0 SAVETMPS;
413  
414 /* Note : there is no explicit call to a CLOSE() method; if
415 needed, the Perl class can implement a DESTROY() method */
416  
417 0 perl_pVTabCursor = (perl_vtab_cursor *) pVtabCursor;
418 0 SvREFCNT_dec(perl_pVTabCursor->perl_cursor_obj);
419 0 sqlite3_free(perl_pVTabCursor);
420  
421 0 PUTBACK;
422 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
423 0 LEAVE;
424  
425 0 return SQLITE_OK;
426 }
427  
428 0 static int perl_vt_Filter( sqlite3_vtab_cursor *pVtabCursor,
429 int idxNum, const char *idxStr,
430 int argc, sqlite3_value **argv ){
431 dTHX;
432 0 dSP;
433 dMY_CXT;
434 int i, count;
435 0 int is_unicode = MY_CXT.last_dbh_is_unicode;
436  
437 0 ENTER;
438 0 SAVETMPS;
439  
440 /* call the FILTER() method with ($idxNum, $idxStr, @args) */
441 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
442 0 ▶ XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj); 0 0 0
443 0 ▶ XPUSHs(sv_2mortal(newSViv(idxNum)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(idxNum))); 0 0 0
444 0 ▶ XPUSHs(sv_2mortal(newSVpv(idxStr, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(idxStr, 0))); 0 0 0
445 0 ▶ for(i = 0; i < argc; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < argc; i++) { 0 0 0
446 0 ▶ XPUSHs(stacked_sv_from_sqlite3_value(aTHX_ argv[i], is_unicode));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(stacked_sv_from_sqlite3_value(aTHX_ argv[i], is_unicode)); 0 0 0
447 }
448 0 PUTBACK;
449 0 count = call_method("FILTER", G_VOID);
450 0 SPAGAIN;
451 0 SP -= count;
452  
453 0 PUTBACK;
454 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
455 0 LEAVE;
456  
457 0 return SQLITE_OK;
458 }
459  
460  
461 0 static int perl_vt_Next(sqlite3_vtab_cursor *pVtabCursor){
462 dTHX;
463 0 dSP;
464 int count;
465  
466 0 ENTER;
467 0 SAVETMPS;
468  
469 /* call the next() method */
470 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
471 0 ▶ XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj); 0 0 0
472 0 PUTBACK;
473 0 count = call_method ("NEXT", G_VOID);
474 0 SPAGAIN;
475 0 SP -= count;
476  
477 0 PUTBACK;
478 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
479 0 LEAVE;
480  
481 0 return SQLITE_OK;
482 }
483  
484 0 static int perl_vt_Eof(sqlite3_vtab_cursor *pVtabCursor){
485 dTHX;
486 0 dSP;
487 int count, eof;
488  
489 0 ENTER;
490 0 SAVETMPS;
491  
492 /* call the eof() method */
493 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
494 0 ▶ XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj); 0 0 0
495 0 PUTBACK;
496 0 count = call_method ("EOF", G_SCALAR);
497 0 SPAGAIN;
498 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
499 0 warn("cursor->EOF() method returned %d vals instead of 1", count);
500 0 SP -= count;
501 }
502 else {
503 0 SV *sv = POPs; /* need 2 lines, because this doesn't work : */
504 0 eof = SvTRUE(sv); /* eof = SvTRUE(POPs); # I don't understand why :-( */
505 }
506  
507 0 PUTBACK;
508 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
509 0 LEAVE;
510  
511 0 return eof;
512 }
513  
514  
515 0 static int perl_vt_Column(sqlite3_vtab_cursor *pVtabCursor,
516 sqlite3_context* context,
517 int col){
518 dTHX;
519 0 dSP;
520 int count;
521 0 int rc = SQLITE_ERROR;
522  
523 0 ENTER;
524 0 SAVETMPS;
525  
526 /* call the column() method */
527 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
528 0 ▶ XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj); 0 0 0
529 0 ▶ XPUSHs(sv_2mortal(newSViv(col)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(col))); 0 0 0
530 0 PUTBACK;
531 0 count = call_method ("COLUMN", G_SCALAR);
532 0 SPAGAIN;
533 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
534 0 warn("cursor->COLUMN() method returned %d vals instead of 1", count);
535 0 SP -= count;
536 0 sqlite3_result_error(context, "column error", 12);
537 }
538 else {
539 0 SV *result = POPs;
540 0 sqlite_set_result_for_vtable(aTHX_ context, result, 0 );
541 0 rc = SQLITE_OK;
542 }
543  
544 0 PUTBACK;
545 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
546 0 LEAVE;
547  
548 0 return rc;
549 }
550  
551 0 static int perl_vt_Rowid( sqlite3_vtab_cursor *pVtabCursor,
552 sqlite3_int64 *pRowid ){
553 dTHX;
554 0 dSP;
555 int count;
556 0 int rc = SQLITE_ERROR;
557  
558 0 ENTER;
559 0 SAVETMPS;
560  
561 /* call the rowid() method */
562 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
563 0 ▶ XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab_cursor *) pVtabCursor)->perl_cursor_obj); 0 0 0
564 0 PUTBACK;
565 0 count = call_method ("ROWID", G_SCALAR);
566 0 SPAGAIN;
567 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
568 0 warn("cursor->ROWID() returned %d vals instead of 1", count);
569 0 SP -= count;
570 }
571 else {
572 0 *pRowid =POPi;
573 0 rc = SQLITE_OK;
574 }
575  
576 0 PUTBACK;
577 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
578 0 LEAVE;
579  
580 0 return rc;
581 }
582  
583 0 static int perl_vt_Update( sqlite3_vtab *pVTab,
584 int argc, sqlite3_value **argv,
585 sqlite3_int64 *pRowid ){
586 dTHX;
587 0 dSP;
588 dMY_CXT;
589 int count, i;
590 0 int is_unicode = MY_CXT.last_dbh_is_unicode;
591 0 int rc = SQLITE_ERROR;
592 SV *rowidsv;
593  
594 0 ENTER;
595 0 SAVETMPS;
596  
597 /* call the _SQLITE_UPDATE() method */
598 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
599 0 ▶ XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
600 0 ▶ for(i = 0; i < argc; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < argc; i++) { 0 0 0
601 0 ▶ XPUSHs(stacked_sv_from_sqlite3_value(aTHX_ argv[i], is_unicode));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(stacked_sv_from_sqlite3_value(aTHX_ argv[i], is_unicode)); 0 0 0
602 }
603 0 PUTBACK;
604 0 count = call_method ("_SQLITE_UPDATE", G_SCALAR);
605 0 SPAGAIN;
606 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
607 0 warn("cursor->_SQLITE_UPDATE() returned %d vals instead of 1", count);
608 0 SP -= count;
609 }
610 else {
611 0 ▶ if (argc > 1 && sqlite3_value_type(argv[0]) == SQLITE_NULL
Branch: 2 branches
BranchTrueFalseTotal
if (argc > 1 && sqlite3_value_type(argv[0]) == SQLITE_NULL 0 0 0
if (argc > 1 && sqlite3_value_type(argv[0]) == SQLITE_NULL 0 0 0
612 0 ▶ && sqlite3_value_type(argv[1]) == SQLITE_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
&& sqlite3_value_type(argv[1]) == SQLITE_NULL) { 0 0 0
613 /* this was an insert without any given rowid, so the result of
614 the method call must be passed in *pRowid*/
615 0 rowidsv = POPs;
616 0 ▶ if (!SvOK(rowidsv))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(rowidsv)) 0 0 0
617 0 *pRowid = 0;
618 0 ▶ else if (SvUOK(rowidsv))
Branch: 1 branch
BranchTrueFalseTotal
else if (SvUOK(rowidsv)) 0 0 0
619 0 *pRowid = SvUV(rowidsv);
620 0 ▶ else if (SvIOK(rowidsv))
Branch: 1 branch
BranchTrueFalseTotal
else if (SvIOK(rowidsv)) 0 0 0
621 0 *pRowid = SvIV(rowidsv);
622 else
623 0 *pRowid = (sqlite3_int64)SvNV(rowidsv);
624 }
625 0 rc = SQLITE_OK;
626 }
627  
628  
629 0 PUTBACK;
630 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
631 0 LEAVE;
632  
633 0 return rc;
634 }
635  
636 0 static int perl_vt_Begin(sqlite3_vtab *pVTab){
637 0 return _call_perl_vtab_method(pVTab, "BEGIN_TRANSACTION", 0);
638 }
639  
640 0 static int perl_vt_Sync(sqlite3_vtab *pVTab){
641 0 return _call_perl_vtab_method(pVTab, "SYNC_TRANSACTION", 0);
642 }
643  
644 0 static int perl_vt_Commit(sqlite3_vtab *pVTab){
645 0 return _call_perl_vtab_method(pVTab, "COMMIT_TRANSACTION", 0);
646 }
647  
648 0 static int perl_vt_Rollback(sqlite3_vtab *pVTab){
649 0 return _call_perl_vtab_method(pVTab, "ROLLBACK_TRANSACTION", 0);
650 }
651  
652 0 static int perl_vt_FindFunction(sqlite3_vtab *pVTab,
653 int nArg, const char *zName,
654 void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
655 void **ppArg){
656 dTHX;
657 0 dSP;
658 dMY_CXT;
659 int count;
660 0 int is_overloaded = 0;
661 0 char *func_name = sqlite3_mprintf("%s\t%d", zName, nArg);
662 0 STRLEN len = strlen(func_name);
663 0 HV *functions = ((perl_vtab *) pVTab)->functions;
664 0 SV* coderef = NULL;
665 SV** val;
666 SV *result;
667  
668 0 ENTER;
669 0 SAVETMPS;
670  
671 /* check if that function was already in cache */
672 0 ▶ if (hv_exists(functions, func_name, len)) {
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists(functions, func_name, len)) { 0 0 0
673 0 val = hv_fetch(functions, func_name, len, FALSE);
674 0 ▶ if (val && SvOK(*val)) {
Branch: 2 branches
BranchTrueFalseTotal
if (val && SvOK(*val)) { 0 0 0
if (val && SvOK(*val)) { 0 0 0
675 0 coderef = *val;
676 }
677 }
678 else {
679 /* call the FIND_FUNCTION() method */
680 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
681 0 ▶ XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
682 0 ▶ XPUSHs(sv_2mortal(newSViv(nArg)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(nArg))); 0 0 0
683 0 ▶ XPUSHs(sv_2mortal(newSVpv(zName, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(zName, 0))); 0 0 0
684 0 PUTBACK;
685 0 count = call_method ("FIND_FUNCTION", G_SCALAR);
686 0 SPAGAIN;
687 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
688 0 warn("vtab->FIND_FUNCTION() method returned %d vals instead of 1", count);
689 0 SP -= count;
690 0 goto cleanup;
691 }
692 0 result = POPs;
693 0 ▶ if (SvTRUE(result)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(result)) { 0 0 0
694 /* the coderef must be valid for the lifetime of pVTab, so
695 make a copy */
696 0 coderef = newSVsv(result);
697 }
698  
699 /* store result in cache */
700 0 ▶ hv_store(functions, func_name, len, coderef ? coderef : &PL_sv_undef, 0);
Branch: 1 branch
BranchTrueFalseTotal
hv_store(functions, func_name, len, coderef ? coderef : &PL_sv_undef, 0); 0 0 0
701 }
702  
703 /* return function information for sqlite3 within *pxFunc and *ppArg */
704 0 ▶ is_overloaded = coderef && SvTRUE(coderef);
Branch: 2 branches
BranchTrueFalseTotal
is_overloaded = coderef && SvTRUE(coderef); 0 0 0
is_overloaded = coderef && SvTRUE(coderef); 0 0 0
705 0 ▶ if (is_overloaded) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_overloaded) { 0 0 0
706 0 *pxFunc = MY_CXT.last_dbh_is_unicode ? sqlite_db_func_dispatcher_unicode
707 0 ▶ : sqlite_db_func_dispatcher_no_unicode;
Branch: 1 branch
BranchTrueFalseTotal
: sqlite_db_func_dispatcher_no_unicode; 0 0 0
708 0 *ppArg = coderef;
709 }
710  
711 0 cleanup:
712 0 PUTBACK;
713 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
714 0 LEAVE;
715 0 sqlite3_free(func_name);
716 0 return is_overloaded;
717 }
718  
719  
720 0 static int perl_vt_Rename(sqlite3_vtab *pVTab, const char *zNew){
721 dTHX;
722 0 dSP;
723 int count;
724 0 int rc = SQLITE_ERROR;
725  
726 0 ENTER;
727 0 SAVETMPS;
728  
729 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
730 0 ▶ XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(((perl_vtab *) pVTab)->perl_vtab_obj); 0 0 0
731 0 ▶ XPUSHs(sv_2mortal(newSVpv(zNew, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(zNew, 0))); 0 0 0
732 0 PUTBACK;
733 0 count = call_method("RENAME", G_SCALAR);
734 0 SPAGAIN;
735 0 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 0 0
736 0 warn("vtab->RENAME() returned %d args instead of 1", count);
737 0 SP -= count;
738 }
739 else {
740 0 rc = POPi;
741 }
742  
743 0 PUTBACK;
744 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
745 0 LEAVE;
746  
747 0 return rc;
748 }
749  
750 0 static int perl_vt_Savepoint(sqlite3_vtab *pVTab, int point){
751 0 return _call_perl_vtab_method(pVTab, "SAVEPOINT", point);
752 }
753  
754 0 static int perl_vt_Release(sqlite3_vtab *pVTab, int point){
755 0 return _call_perl_vtab_method(pVTab, "RELEASE", point);
756 }
757  
758 0 static int perl_vt_RollbackTo(sqlite3_vtab *pVTab, int point){
759 0 return _call_perl_vtab_method(pVTab, "ROLLBACK_TO", point);
760 }
761  
762 static sqlite3_module perl_vt_Module = {
763 1, /* iVersion */
764 perl_vt_Create, /* xCreate */
765 perl_vt_Connect, /* xConnect */
766 perl_vt_BestIndex, /* xBestIndex */
767 perl_vt_Disconnect, /* xDisconnect */
768 perl_vt_Drop, /* xDestroy */
769 perl_vt_Open, /* xOpen - open a cursor */
770 perl_vt_Close, /* xClose - close a cursor */
771 perl_vt_Filter, /* xFilter - configure scan constraints */
772 perl_vt_Next, /* xNext - advance a cursor */
773 perl_vt_Eof, /* xEof - check for end of scan */
774 perl_vt_Column, /* xColumn - read data */
775 perl_vt_Rowid, /* xRowid - read data */
776 perl_vt_Update, /* xUpdate (optional) */
777 perl_vt_Begin, /* xBegin (optional) */
778 perl_vt_Sync, /* xSync (optional) */
779 perl_vt_Commit, /* xCommit (optional) */
780 perl_vt_Rollback, /* xRollback (optional) */
781 perl_vt_FindFunction, /* xFindFunction (optional) */
782 perl_vt_Rename, /* xRename */
783 #if SQLITE_VERSION_NUMBER >= 3007007
784 perl_vt_Savepoint, /* xSavepoint (optional) */
785 perl_vt_Release, /* xRelease (optional) */
786 perl_vt_RollbackTo /* xRollbackTo (optional) */
787 #endif
788 };
789  
790  
791 void
792 0 sqlite_db_destroy_module_data(void *pAux)
793 {
794 dTHX;
795 0 dSP;
796 int count;
797 0 int rc = SQLITE_ERROR;
798 perl_vtab_init *init_data;
799  
800 0 ENTER;
801 0 SAVETMPS;
802  
803 0 init_data = (perl_vtab_init *)pAux;
804  
805 /* call the DESTROY_MODULE() method */
806 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
807 0 ▶ XPUSHs(sv_2mortal(newSVpv(init_data->perl_class, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(init_data->perl_class, 0))); 0 0 0
808 0 PUTBACK;
809 0 count = call_method("DESTROY_MODULE", G_VOID);
810 0 SPAGAIN;
811 0 SP -= count;
812  
813 /* free module memory */
814 0 SvREFCNT_dec(init_data->dbh);
815 0 sqlite3_free((char *)init_data->perl_class);
816  
817 0 PUTBACK;
818 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
819 0 LEAVE;
820 0 }
821  
822  
823  
824 int
825 0 sqlite_db_create_module(pTHX_ SV *dbh, const char *name, const char *perl_class)
826 {
827 0 dSP;
828 0 D_imp_dbh(dbh);
829 0 int count, rc, retval = TRUE;
830 char *module_ISA;
831 char *loading_code;
832 perl_vtab_init *init_data;
833  
834 0 ENTER;
835 0 SAVETMPS;
836  
837 0 ▶ if (!DBIc_ACTIVE(imp_dbh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!DBIc_ACTIVE(imp_dbh)) { 0 0 0
838 0 sqlite_error(dbh, -2, "attempt to create module on inactive database handle");
839 0 return FALSE;
840 }
841  
842 /* load the module if needed */
843 0 module_ISA = sqlite3_mprintf("%s::ISA", perl_class);
844 0 ▶ if (!get_av(module_ISA, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!get_av(module_ISA, 0)) { 0 0 0
845 0 loading_code = sqlite3_mprintf("use %s", perl_class);
846 0 eval_pv(loading_code, TRUE);
847 0 sqlite3_free(loading_code);
848 }
849 0 sqlite3_free(module_ISA);
850  
851 /* build the init datastructure that will be passed to perl_vt_New() */
852 0 init_data = sqlite3_malloc(sizeof(*init_data));
853 0 init_data->dbh = newRV(dbh);
854 0 sv_rvweaken(init_data->dbh);
855 0 init_data->perl_class = sqlite3_mprintf(perl_class);
856  
857 /* register within sqlite */
858 0 rc = sqlite3_create_module_v2( imp_dbh->db,
859 name,
860 &perl_vt_Module,
861 init_data,
862 sqlite_db_destroy_module_data
863 );
864 0 ▶ if ( rc != SQLITE_OK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( rc != SQLITE_OK ) { 0 0 0
865 0 sqlite_error(dbh, rc, form("sqlite_create_module failed with error %s",
866 sqlite3_errmsg(imp_dbh->db)));
867 0 retval = FALSE;
868 }
869  
870  
871 /* call the CREATE_MODULE() method */
872 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
873 0 ▶ XPUSHs(sv_2mortal(newSVpv(perl_class, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(perl_class, 0))); 0 0 0
874 0 ▶ XPUSHs(sv_2mortal(newSVpv(name, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(name, 0))); 0 0 0
875 0 PUTBACK;
876 0 count = call_method("CREATE_MODULE", G_VOID);
877 0 SPAGAIN;
878 0 SP -= count;
879  
880 0 PUTBACK;
881 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
882 0 LEAVE;
883  
884 0 return retval;
885 }
« dbdimp_tokenizer.inc ↑ Summary sqlite3.c »