/
Query.xs
87 lines (62 loc) · 1.46 KB
/
Query.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "net_drizzle.h"
=head1 NAME
Net::Drizzle::Query - Query object for Net::Drizzle
=head1 METHODS
=over 4
=cut
MODULE = Net::Drizzle::Query PACKAGE = Net::Drizzle::Query
VERSIONCHECK: DISABLE
=item con
Get a connection for a query.
=cut
SV*
con(SV*self)
CODE:
net_query *query = XS_STATE(net_query*, self);
drizzle_con_st * con = drizzle_query_con(query->query);
assert(con);
RETVAL = _create_con(query->drizzle, con);
OUTPUT:
RETVAL
=item string
Get the string for a query.
=cut
void
string(SV*self)
PPCODE:
net_query *query = XS_STATE(net_query*, self);
size_t size;
const char * str = drizzle_query_string(query->query, &size);
mXPUSHs(newSVpvn(str, size));
XSRETURN(1);
=item result
Get the result for a query.
=back
=cut
SV*
result(SV*self)
CODE:
net_query *query = XS_STATE(net_query*, self);
drizzle_result_st *result = drizzle_query_result(query->query);
if (result != NULL) {
RETVAL = _create_result(query->con, self, result);
} else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
void
DESTROY(SV *self_sv)
CODE:
net_query *self = XS_STATE(net_query*, self_sv);
LOG("DESTROY query 0x%X, drizzle->refcnt=%d\n", (unsigned int)self->drizzle, (int)SvREFCNT(self->drizzle));
if (self->drizzle != NULL) {
SvREFCNT_dec(self->drizzle);
}
if (self->con != NULL) {
SvREFCNT_dec(self->con);
}
Safefree(self);
=head1 SEE ALSO
L<Net::Drizzle>
=cut