| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
# $Id$ |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2002 Tim Bunce Ireland |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
|
6
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the Perl README file. |
|
7
|
|
|
|
|
|
|
*/ |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
/* This is really just a workaround for SUPER:: not working right for XS code. |
|
11
|
|
|
|
|
|
|
* It would be better if we setup perl's context so SUPER:: did the right thing |
|
12
|
|
|
|
|
|
|
* (borrowing the relevant magic from pp_entersub in perl pp_hot.c). |
|
13
|
|
|
|
|
|
|
* Then we could just use call_method("SUPER::foo") instead. |
|
14
|
|
|
|
|
|
|
* XXX remember to call SPAGAIN in the calling code after calling this! |
|
15
|
|
|
|
|
|
|
*/ |
|
16
|
|
|
|
|
|
|
static SV * |
|
17
|
720
|
|
|
|
|
|
dbixst_bounce_method(char *methname, int params) |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
|
|
|
|
|
|
dTHX; |
|
20
|
|
|
|
|
|
|
/* XXX this 'magic' undoes the dMARK embedded in the dXSARGS of our caller */ |
|
21
|
|
|
|
|
|
|
/* so that the dXSARGS below can set things up as they were for our caller */ |
|
22
|
720
|
|
|
|
|
|
void *xxx = PL_markstack_ptr++; |
|
23
|
720
|
|
|
|
|
|
dXSARGS; /* declares sp, ax, mark, items */ |
|
24
|
|
|
|
|
|
|
int i; |
|
25
|
|
|
|
|
|
|
SV *sv; |
|
26
|
720
|
|
|
|
|
|
int debug = 0; |
|
27
|
720
|
|
|
|
|
|
D_imp_xxh(ST(0)); |
|
28
|
720
|
50
|
|
|
|
|
if (debug >= 3) { |
|
29
|
0
|
|
|
|
|
|
PerlIO_printf(DBIc_LOGPIO(imp_xxh), |
|
30
|
|
|
|
|
|
|
" -> %s (trampoline call with %d (%ld) params)\n", methname, params, (long)items); |
|
31
|
|
|
|
|
|
|
PERL_UNUSED_VAR(xxx); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
720
|
50
|
|
|
|
|
EXTEND(SP, params); |
|
|
|
50
|
|
|
|
|
|
|
34
|
720
|
50
|
|
|
|
|
PUSHMARK(SP); |
|
35
|
2880
|
100
|
|
|
|
|
for (i=0; i < params; ++i) { |
|
36
|
2160
|
100
|
|
|
|
|
sv = (i >= items) ? &PL_sv_undef : ST(i); |
|
37
|
2160
|
|
|
|
|
|
PUSHs(sv); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
720
|
|
|
|
|
|
PUTBACK; |
|
40
|
720
|
|
|
|
|
|
i = call_method(methname, G_SCALAR); |
|
41
|
720
|
|
|
|
|
|
SPAGAIN; |
|
42
|
720
|
50
|
|
|
|
|
sv = (i) ? POPs : &PL_sv_undef; |
|
43
|
720
|
|
|
|
|
|
PUTBACK; |
|
44
|
720
|
50
|
|
|
|
|
if (debug >= 3) |
|
45
|
0
|
|
|
|
|
|
PerlIO_printf(DBIc_LOGPIO(imp_xxh), |
|
46
|
0
|
|
|
|
|
|
" <- %s= %s (trampoline call return)\n", methname, neatsvpv(sv,0)); |
|
47
|
720
|
|
|
|
|
|
return sv; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
static int |
|
52
|
599
|
|
|
|
|
|
dbdxst_bind_params(SV *sth, imp_sth_t *imp_sth, I32 items, I32 ax) |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
|
|
|
|
|
|
/* Handle binding supplied values to placeholders. */ |
|
55
|
|
|
|
|
|
|
/* items = one greater than the number of params */ |
|
56
|
|
|
|
|
|
|
/* ax = ax from calling sub, maybe adjusted to match items */ |
|
57
|
|
|
|
|
|
|
dTHX; |
|
58
|
|
|
|
|
|
|
int i; |
|
59
|
|
|
|
|
|
|
SV *idx; |
|
60
|
599
|
50
|
|
|
|
|
if (items-1 != DBIc_NUM_PARAMS(imp_sth) |
|
61
|
0
|
0
|
|
|
|
|
&& DBIc_NUM_PARAMS(imp_sth) != DBIc_NUM_PARAMS_AT_EXECUTE |
|
62
|
|
|
|
|
|
|
) { |
|
63
|
|
|
|
|
|
|
char errmsg[99]; |
|
64
|
|
|
|
|
|
|
/* clear any previous ParamValues before error is generated */ |
|
65
|
0
|
|
|
|
|
|
SV **svp = hv_fetch((HV*)DBIc_MY_H(imp_sth),"ParamValues",11,FALSE); |
|
66
|
0
|
0
|
|
|
|
|
if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
HV *hv = (HV*)SvRV(*svp); |
|
68
|
0
|
|
|
|
|
|
hv_clear(hv); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
0
|
|
|
|
|
|
sprintf(errmsg,"called with %d bind variables when %d are needed", |
|
71
|
|
|
|
|
|
|
(int)items-1, DBIc_NUM_PARAMS(imp_sth)); |
|
72
|
0
|
|
|
|
|
|
DBIh_SET_ERR_CHAR(sth, (imp_xxh_t*)imp_sth, "-1", -1, errmsg, Nullch, Nullch); |
|
73
|
0
|
|
|
|
|
|
return 0; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
599
|
|
|
|
|
|
idx = sv_2mortal(newSViv(0)); |
|
76
|
1495
|
100
|
|
|
|
|
for(i=1; i < items ; ++i) { |
|
77
|
896
|
|
|
|
|
|
SV* value = ST(i); |
|
78
|
896
|
50
|
|
|
|
|
if (SvGMAGICAL(value)) |
|
79
|
0
|
|
|
|
|
|
mg_get(value); /* trigger magic to FETCH the value */ |
|
80
|
896
|
|
|
|
|
|
sv_setiv(idx, i); |
|
81
|
896
|
50
|
|
|
|
|
if (!dbd_bind_ph(sth, imp_sth, idx, value, 0, Nullsv, FALSE, 0)) { |
|
82
|
0
|
|
|
|
|
|
return 0; /* dbd_bind_ph already registered error */ |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
599
|
|
|
|
|
|
return 1; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#ifndef dbd_fetchall_arrayref |
|
89
|
|
|
|
|
|
|
static SV * |
|
90
|
310
|
|
|
|
|
|
dbdxst_fetchall_arrayref(SV *sth, SV *slice, SV *batch_row_count) |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
|
|
|
|
|
|
dTHX; |
|
93
|
310
|
|
|
|
|
|
D_imp_sth(sth); |
|
94
|
|
|
|
|
|
|
SV *rows_rvav; |
|
95
|
310
|
50
|
|
|
|
|
if (SvOK(slice)) { /* should never get here */ |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
char errmsg[99]; |
|
97
|
0
|
|
|
|
|
|
sprintf(errmsg,"slice param not supported by XS version of fetchall_arrayref"); |
|
98
|
0
|
|
|
|
|
|
DBIh_SET_ERR_CHAR(sth, (imp_xxh_t*)imp_sth, "-1", -1, errmsg, Nullch, Nullch); |
|
99
|
0
|
|
|
|
|
|
return &PL_sv_undef; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
else { |
|
102
|
310
|
50
|
|
|
|
|
IV maxrows = SvOK(batch_row_count) ? SvIV(batch_row_count) : -1; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
AV *fetched_av; |
|
104
|
310
|
|
|
|
|
|
AV *rows_av = newAV(); |
|
105
|
310
|
50
|
|
|
|
|
if ( !DBIc_ACTIVE(imp_sth) && maxrows>0 ) { |
|
|
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
/* to simplify application logic we return undef without an error */ |
|
107
|
|
|
|
|
|
|
/* if we've fetched all the rows and called with a batch_row_count */ |
|
108
|
0
|
|
|
|
|
|
return &PL_sv_undef; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
310
|
50
|
|
|
|
|
av_extend(rows_av, (maxrows>0) ? maxrows : 31); |
|
111
|
688
|
50
|
|
|
|
|
while ( (maxrows < 0 || maxrows-- > 0) |
|
|
|
0
|
|
|
|
|
|
|
112
|
688
|
100
|
|
|
|
|
&& (fetched_av = dbd_st_fetch(sth, imp_sth)) |
|
113
|
|
|
|
|
|
|
) { |
|
114
|
378
|
50
|
|
|
|
|
AV *copy_row_av = av_make(AvFILL(fetched_av)+1, AvARRAY(fetched_av)); |
|
115
|
378
|
|
|
|
|
|
av_push(rows_av, newRV_noinc((SV*)copy_row_av)); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
310
|
|
|
|
|
|
rows_rvav = sv_2mortal(newRV_noinc((SV *)rows_av)); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
310
|
|
|
|
|
|
return rows_rvav; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
#endif |
|
122
|
|
|
|
|
|
|
|