| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "perlbolt.h" |
|
2
|
|
|
|
|
|
|
#include "ingyINLINE.h" |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include |
|
5
|
|
|
|
|
|
|
#include |
|
6
|
|
|
|
|
|
|
#include "connection.h" |
|
7
|
|
|
|
|
|
|
|
|
8
|
0
|
|
|
|
|
|
SV *run_query_( SV *cxn_ref, const char *cypher_query, SV *params_ref, int send, const char *dbname) |
|
9
|
|
|
|
|
|
|
{ |
|
10
|
|
|
|
|
|
|
neo4j_result_stream_t *res_stream; |
|
11
|
|
|
|
|
|
|
cxn_obj_t *cxn_obj; |
|
12
|
|
|
|
|
|
|
neo4j_connection_t *cxn; |
|
13
|
|
|
|
|
|
|
rs_obj_t *rs_obj; |
|
14
|
|
|
|
|
|
|
const char *evalerr, *evalmsg; |
|
15
|
|
|
|
|
|
|
char *climsg; |
|
16
|
|
|
|
|
|
|
char *s, *t; |
|
17
|
|
|
|
|
|
|
int fail; |
|
18
|
|
|
|
|
|
|
SV *rs; |
|
19
|
|
|
|
|
|
|
SV *rs_ref; |
|
20
|
|
|
|
|
|
|
neo4j_value_t params_p; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
new_rs_obj(&rs_obj); |
|
23
|
|
|
|
|
|
|
// extract connection |
|
24
|
0
|
0
|
|
|
|
|
cxn_obj = C_PTR_OF(cxn_ref,cxn_obj_t); |
|
25
|
0
|
0
|
|
|
|
|
if (!cxn_obj->connected) { |
|
26
|
0
|
|
|
|
|
|
cxn_obj->errnum = ENOTCONN; |
|
27
|
0
|
|
|
|
|
|
cxn_obj->strerror = "Not connected"; |
|
28
|
0
|
|
|
|
|
|
return &PL_sv_undef; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
0
|
|
|
|
|
|
cxn = cxn_obj->connection; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
// extract params |
|
33
|
0
|
0
|
|
|
|
|
if (SvROK(params_ref) && (SvTYPE(SvRV(params_ref))==SVt_PVHV)) { |
|
|
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
params_p = SV_to_neo4j_value(params_ref); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
else { |
|
37
|
0
|
|
|
|
|
|
perror("Parameter arg must be a hash reference\n"); |
|
38
|
0
|
|
|
|
|
|
return &PL_sv_undef; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
0
|
|
|
|
|
if (cxn->version < 4) |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
|
res_stream = (send >= 1 ? |
|
43
|
0
|
0
|
|
|
|
|
neo4j_send(cxn, cypher_query, params_p) : |
|
44
|
|
|
|
|
|
|
neo4j_run(cxn, cypher_query, params_p)); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
else |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
|
|
|
|
|
res_stream = (send >= 1 ? |
|
49
|
0
|
0
|
|
|
|
|
neo4j_send_to_db(cxn, cypher_query, params_p, dbname) : |
|
50
|
|
|
|
|
|
|
neo4j_run_in_db(cxn, cypher_query, params_p, dbname)); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
|
|
|
|
|
rs_obj->res_stream = res_stream; |
|
53
|
0
|
|
|
|
|
|
fail = update_errstate_rs_obj(rs_obj); |
|
54
|
0
|
0
|
|
|
|
|
if (send >= 1) { |
|
55
|
0
|
|
|
|
|
|
rs_obj->fetched = 1; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
|
|
|
|
|
rs = newSViv((IV) rs_obj); |
|
58
|
0
|
|
|
|
|
|
rs_ref = newRV_noinc(rs); |
|
59
|
0
|
|
|
|
|
|
sv_bless(rs_ref, gv_stashpv(RSCLASS, GV_ADD)); |
|
60
|
0
|
|
|
|
|
|
SvREADONLY_on(rs); |
|
61
|
0
|
|
|
|
|
|
return rs_ref; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
bool connected(SV *cxn_ref) { |
|
65
|
0
|
0
|
|
|
|
|
return C_PTR_OF(cxn_ref,cxn_obj_t)->connected; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
int errnum_(SV *cxn_ref) { |
|
69
|
0
|
0
|
|
|
|
|
return C_PTR_OF(cxn_ref,cxn_obj_t)->errnum; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
const char *errmsg_(SV *cxn_ref) { |
|
73
|
0
|
0
|
|
|
|
|
return (const char *) C_PTR_OF(cxn_ref,cxn_obj_t)->strerror; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
void reset_ (SV *cxn_ref) |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
int rc; |
|
79
|
|
|
|
|
|
|
char *climsg; |
|
80
|
|
|
|
|
|
|
cxn_obj_t *cxn_obj; |
|
81
|
0
|
0
|
|
|
|
|
cxn_obj = C_PTR_OF(cxn_ref,cxn_obj_t); |
|
82
|
0
|
|
|
|
|
|
rc = neo4j_reset( cxn_obj->connection ); |
|
83
|
0
|
0
|
|
|
|
|
if (rc < 0) { |
|
84
|
0
|
|
|
|
|
|
cxn_obj->errnum = errno; |
|
85
|
0
|
|
|
|
|
|
Newx(climsg, BUFLEN, char); |
|
86
|
0
|
|
|
|
|
|
cxn_obj->strerror = neo4j_strerror(errno, climsg, BUFLEN-1); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
|
|
|
|
|
return; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
const char *server_id_(SV *cxn_ref) { |
|
92
|
0
|
0
|
|
|
|
|
return neo4j_server_id( C_PTR_OF(cxn_ref,cxn_obj_t)->connection ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
const char *protocol_version_(SV *cxn_ref) { |
|
96
|
0
|
0
|
|
|
|
|
if (C_PTR_OF(cxn_ref,cxn_obj_t)->connected) |
|
|
|
0
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
{ |
|
98
|
0
|
0
|
|
|
|
|
uint32_t V = C_PTR_OF(cxn_ref,cxn_obj_t)->major_version; |
|
99
|
0
|
0
|
|
|
|
|
uint32_t v = C_PTR_OF(cxn_ref,cxn_obj_t)->minor_version; |
|
100
|
|
|
|
|
|
|
char *vstr; |
|
101
|
0
|
|
|
|
|
|
Newx(vstr, 32, char); |
|
102
|
0
|
|
|
|
|
|
snprintf(vstr, 32, "%d.%d",(int)V,(int)v); |
|
103
|
0
|
|
|
|
|
|
return vstr; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
else { |
|
106
|
0
|
|
|
|
|
|
return ""; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
void DESTROY (SV *cxn_ref) |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
0
|
0
|
|
|
|
|
neo4j_close( C_PTR_OF(cxn_ref,cxn_obj_t)->connection ); |
|
113
|
0
|
|
|
|
|
|
return; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
MODULE = Neo4j::Bolt::Cxn PACKAGE = Neo4j::Bolt::Cxn |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
SV * |
|
123
|
|
|
|
|
|
|
run_query_ (cxn_ref, cypher_query, params_ref, send, dbname) |
|
124
|
|
|
|
|
|
|
SV * cxn_ref |
|
125
|
|
|
|
|
|
|
const char * cypher_query |
|
126
|
|
|
|
|
|
|
SV * params_ref |
|
127
|
|
|
|
|
|
|
int send |
|
128
|
|
|
|
|
|
|
const char * dbname |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
int |
|
131
|
|
|
|
|
|
|
connected (cxn_ref) |
|
132
|
|
|
|
|
|
|
SV * cxn_ref |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
int |
|
135
|
|
|
|
|
|
|
errnum_ (cxn_ref) |
|
136
|
|
|
|
|
|
|
SV * cxn_ref |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
const char * |
|
139
|
|
|
|
|
|
|
errmsg_ (cxn_ref) |
|
140
|
|
|
|
|
|
|
SV * cxn_ref |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
void |
|
143
|
|
|
|
|
|
|
reset_ (cxn_ref) |
|
144
|
|
|
|
|
|
|
SV * cxn_ref |
|
145
|
|
|
|
|
|
|
PREINIT: |
|
146
|
|
|
|
|
|
|
I32* temp; |
|
147
|
|
|
|
|
|
|
PPCODE: |
|
148
|
0
|
|
|
|
|
|
temp = PL_markstack_ptr++; |
|
149
|
0
|
|
|
|
|
|
reset_(cxn_ref); |
|
150
|
0
|
0
|
|
|
|
|
if (PL_markstack_ptr != temp) { |
|
151
|
|
|
|
|
|
|
/* truly void, because dXSARGS not invoked */ |
|
152
|
0
|
|
|
|
|
|
PL_markstack_ptr = temp; |
|
153
|
0
|
|
|
|
|
|
XSRETURN_EMPTY; /* return empty stack */ |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
/* must have used dXSARGS; list context implied */ |
|
156
|
0
|
|
|
|
|
|
return; /* assume stack size is correct */ |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
const char * |
|
159
|
|
|
|
|
|
|
server_id_ (cxn_ref) |
|
160
|
|
|
|
|
|
|
SV * cxn_ref |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
const char * |
|
163
|
|
|
|
|
|
|
protocol_version_ (cxn_ref) |
|
164
|
|
|
|
|
|
|
SV * cxn_ref |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
void |
|
167
|
|
|
|
|
|
|
DESTROY (cxn_ref) |
|
168
|
|
|
|
|
|
|
SV * cxn_ref |
|
169
|
|
|
|
|
|
|
PREINIT: |
|
170
|
|
|
|
|
|
|
I32* temp; |
|
171
|
|
|
|
|
|
|
PPCODE: |
|
172
|
0
|
|
|
|
|
|
temp = PL_markstack_ptr++; |
|
173
|
0
|
|
|
|
|
|
DESTROY(cxn_ref); |
|
174
|
0
|
0
|
|
|
|
|
if (PL_markstack_ptr != temp) { |
|
175
|
|
|
|
|
|
|
/* truly void, because dXSARGS not invoked */ |
|
176
|
0
|
|
|
|
|
|
PL_markstack_ptr = temp; |
|
177
|
0
|
|
|
|
|
|
XSRETURN_EMPTY; /* return empty stack */ |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
/* must have used dXSARGS; list context implied */ |
|
180
|
0
|
|
|
|
|
|
return; /* assume stack size is correct */ |
|
181
|
|
|
|
|
|
|
|