line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "perlbolt.h" |
2
|
|
|
|
|
|
|
#include "ingyINLINE.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include "connection.h" |
8
|
|
|
|
|
|
|
#include "transaction.h" |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
void new_txn_obj( txn_obj_t **txn_obj) { |
11
|
0
|
|
|
|
|
|
Newx(*txn_obj,1,txn_obj_t); |
12
|
0
|
|
|
|
|
|
(*txn_obj)->tx = NULL; |
13
|
0
|
|
|
|
|
|
(*txn_obj)->errnum = 0; |
14
|
0
|
|
|
|
|
|
(*txn_obj)->strerror = ""; |
15
|
0
|
|
|
|
|
|
return; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
// class method |
19
|
0
|
|
|
|
|
|
SV *begin_( const char* classname, SV *cxn_ref, int tx_timeout, const char *mode, const char *dbname) { |
20
|
|
|
|
|
|
|
txn_obj_t *txn_obj; |
21
|
|
|
|
|
|
|
char *climsg; |
22
|
0
|
|
|
|
|
|
new_txn_obj(&txn_obj); |
23
|
0
|
0
|
|
|
|
|
cxn_obj_t *cxn_obj = C_PTR_OF(cxn_ref, cxn_obj_t); |
24
|
0
|
|
|
|
|
|
neo4j_transaction_t *tx = neo4j_begin_tx(cxn_obj->connection, tx_timeout, |
25
|
|
|
|
|
|
|
mode, dbname); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
txn_obj->tx = tx; |
28
|
0
|
0
|
|
|
|
|
if (tx == NULL) { |
29
|
0
|
|
|
|
|
|
txn_obj->errnum = errno; |
30
|
0
|
|
|
|
|
|
Newx(climsg, BUFLEN, char); |
31
|
0
|
|
|
|
|
|
txn_obj->strerror = neo4j_strerror(errno,climsg,BUFLEN); |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
SV *txn = newSViv((IV) txn_obj); |
34
|
0
|
|
|
|
|
|
SV *txn_ref = newRV_noinc(txn); |
35
|
0
|
|
|
|
|
|
sv_bless(txn_ref, gv_stashpv(TXNCLASS, GV_ADD)); |
36
|
0
|
|
|
|
|
|
SvREADONLY_on(txn); |
37
|
0
|
|
|
|
|
|
return txn_ref; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
int commit_(SV *txn_ref) { |
41
|
0
|
0
|
|
|
|
|
txn_obj_t *t = C_PTR_OF(txn_ref,txn_obj_t); |
42
|
0
|
|
|
|
|
|
int i = -1; |
43
|
0
|
0
|
|
|
|
|
if (neo4j_tx_is_open(t->tx)) { |
44
|
0
|
|
|
|
|
|
i = neo4j_commit( t->tx ); |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
return i; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
int rollback_(SV *txn_ref) { |
50
|
0
|
0
|
|
|
|
|
txn_obj_t *t = C_PTR_OF(txn_ref,txn_obj_t); |
51
|
0
|
|
|
|
|
|
int i = -1; |
52
|
0
|
0
|
|
|
|
|
if (neo4j_tx_is_open(t->tx)) { |
53
|
0
|
|
|
|
|
|
i = neo4j_rollback( t->tx ); |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return i; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
SV *run_query_(SV *txn_ref, const char *cypher_query, SV *params_ref, int send) { |
59
|
|
|
|
|
|
|
neo4j_result_stream_t *res_stream; |
60
|
|
|
|
|
|
|
txn_obj_t *txn_obj; |
61
|
|
|
|
|
|
|
neo4j_transaction_t *tx; |
62
|
|
|
|
|
|
|
rs_obj_t *rs_obj; |
63
|
|
|
|
|
|
|
const char *evalerr, *evalmsg; |
64
|
|
|
|
|
|
|
char *climsg; |
65
|
|
|
|
|
|
|
char *s, *t; |
66
|
|
|
|
|
|
|
int fail; |
67
|
|
|
|
|
|
|
SV *rs; |
68
|
|
|
|
|
|
|
SV *rs_ref; |
69
|
|
|
|
|
|
|
neo4j_value_t params_p; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
new_rs_obj(&rs_obj); |
72
|
|
|
|
|
|
|
// extract transaction |
73
|
0
|
0
|
|
|
|
|
txn_obj = C_PTR_OF(txn_ref,txn_obj_t); |
74
|
0
|
|
|
|
|
|
tx = txn_obj->tx; |
75
|
|
|
|
|
|
|
// check tx state: TODO |
76
|
|
|
|
|
|
|
// extract params |
77
|
0
|
0
|
|
|
|
|
if (SvROK(params_ref) && (SvTYPE(SvRV(params_ref))==SVt_PVHV)) { |
|
|
0
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
params_p = SV_to_neo4j_value(params_ref); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
perror("Parameter arg must be a hash reference\n"); |
82
|
0
|
|
|
|
|
|
return &PL_sv_undef; |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
res_stream = (send >= 1 ? |
85
|
0
|
0
|
|
|
|
|
neo4j_send_to_tx(tx, cypher_query, params_p) : |
86
|
|
|
|
|
|
|
neo4j_run_in_tx(tx, cypher_query, params_p)); |
87
|
0
|
|
|
|
|
|
rs_obj->res_stream = res_stream; |
88
|
0
|
|
|
|
|
|
fail = update_errstate_rs_obj(rs_obj); |
89
|
0
|
0
|
|
|
|
|
if (send >= 1) { |
90
|
0
|
|
|
|
|
|
rs_obj->fetched = 1; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
rs = newSViv((IV) rs_obj); |
93
|
0
|
|
|
|
|
|
rs_ref = newRV_noinc(rs); |
94
|
0
|
|
|
|
|
|
sv_bless(rs_ref, gv_stashpv(RSCLASS, GV_ADD)); |
95
|
0
|
|
|
|
|
|
SvREADONLY_on(rs); |
96
|
0
|
|
|
|
|
|
return rs_ref; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
int errnum_(SV *txn_ref) { |
100
|
0
|
0
|
|
|
|
|
return C_PTR_OF(txn_ref,txn_obj_t)->errnum; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
const char *errmsg_(SV *txn_ref) { |
104
|
0
|
0
|
|
|
|
|
return C_PTR_OF(txn_ref,txn_obj_t)->strerror; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
MODULE = Neo4j::Bolt::Txn PACKAGE = Neo4j::Bolt::Txn |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
SV * |
114
|
|
|
|
|
|
|
begin_ (classname, cxn_ref, tx_timeout, mode, dbname) |
115
|
|
|
|
|
|
|
const char * classname |
116
|
|
|
|
|
|
|
SV * cxn_ref |
117
|
|
|
|
|
|
|
int tx_timeout |
118
|
|
|
|
|
|
|
const char * mode |
119
|
|
|
|
|
|
|
const char * dbname |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
int |
122
|
|
|
|
|
|
|
commit_ (txn_ref) |
123
|
|
|
|
|
|
|
SV * txn_ref |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
int |
126
|
|
|
|
|
|
|
rollback_ (txn_ref) |
127
|
|
|
|
|
|
|
SV * txn_ref |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
SV * |
130
|
|
|
|
|
|
|
run_query_ (txn_ref, cypher_query, params_ref, send) |
131
|
|
|
|
|
|
|
SV * txn_ref |
132
|
|
|
|
|
|
|
const char * cypher_query |
133
|
|
|
|
|
|
|
SV * params_ref |
134
|
|
|
|
|
|
|
int send |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
int |
137
|
|
|
|
|
|
|
errnum_ (txn_ref) |
138
|
|
|
|
|
|
|
SV * txn_ref |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
const char * |
141
|
|
|
|
|
|
|
errmsg_ (txn_ref) |
142
|
|
|
|
|
|
|
SV * txn_ref |
143
|
|
|
|
|
|
|
|