| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
2
|
|
|
|
|
|
|
extern "C" { |
|
3
|
|
|
|
|
|
|
#endif |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT /* we want efficiency */ |
|
6
|
|
|
|
|
|
|
#include |
|
7
|
|
|
|
|
|
|
#include |
|
8
|
|
|
|
|
|
|
#include |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
11
|
|
|
|
|
|
|
} /* extern "C" */ |
|
12
|
|
|
|
|
|
|
#endif |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#define NEED_newSVpvn_flags |
|
15
|
|
|
|
|
|
|
#include "ppport.h" |
|
16
|
|
|
|
|
|
|
#include |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#define XS_STATE(type, x) (INT2PTR(type, SvROK(x) ? SvIV(SvRV(x)) : SvIV(x))) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#define XS_STRUCT2OBJ(sv, class, obj) \ |
|
21
|
|
|
|
|
|
|
sv = newSViv(PTR2IV(obj)); \ |
|
22
|
|
|
|
|
|
|
sv_magic(sv, sv_2mortal(newSViv(UNQLITE_OK)), PERL_MAGIC_ext, NULL, 0); \ |
|
23
|
|
|
|
|
|
|
sv = newRV_noinc(sv); \ |
|
24
|
|
|
|
|
|
|
sv_bless(sv, gv_stashpv(class, 1)); \ |
|
25
|
|
|
|
|
|
|
SvREADONLY_on(sv); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#define SETRC(rc, self) \ |
|
28
|
|
|
|
|
|
|
{ \ |
|
29
|
|
|
|
|
|
|
SV * i = get_sv("UnQLite::rc", GV_ADD); \ |
|
30
|
|
|
|
|
|
|
SvIV_set(i, rc); \ |
|
31
|
|
|
|
|
|
|
if (SvROK(self)) { \ |
|
32
|
|
|
|
|
|
|
MAGIC *_mg = mg_find(SvRV(self), PERL_MAGIC_ext); \ |
|
33
|
|
|
|
|
|
|
if (_mg) { \ |
|
34
|
|
|
|
|
|
|
SvIV_set(_mg->mg_obj, rc); \ |
|
35
|
|
|
|
|
|
|
} \ |
|
36
|
|
|
|
|
|
|
} \ |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
MODULE = UnQLite PACKAGE = UnQLite |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
BOOT: |
|
44
|
4
|
|
|
|
|
|
HV* stash = gv_stashpvn("UnQLite", strlen("UnQLite"), TRUE); |
|
45
|
|
|
|
|
|
|
#define _XSTR(s) _STR(s) |
|
46
|
|
|
|
|
|
|
#define _STR(s) #s |
|
47
|
|
|
|
|
|
|
#define UnConst(c) newCONSTSUB(stash, "UNQ"_XSTR(c), newSViv(UNQ##c)) |
|
48
|
4
|
|
|
|
|
|
UnConst(LITE_OK); |
|
49
|
4
|
|
|
|
|
|
UnConst(LITE_NOMEM); |
|
50
|
4
|
|
|
|
|
|
UnConst(LITE_ABORT); |
|
51
|
4
|
|
|
|
|
|
UnConst(LITE_IOERR); |
|
52
|
4
|
|
|
|
|
|
UnConst(LITE_CORRUPT); |
|
53
|
4
|
|
|
|
|
|
UnConst(LITE_LOCKED); |
|
54
|
4
|
|
|
|
|
|
UnConst(LITE_BUSY); |
|
55
|
4
|
|
|
|
|
|
UnConst(LITE_DONE); |
|
56
|
4
|
|
|
|
|
|
UnConst(LITE_PERM); |
|
57
|
4
|
|
|
|
|
|
UnConst(LITE_NOTIMPLEMENTED); |
|
58
|
4
|
|
|
|
|
|
UnConst(LITE_NOTFOUND); |
|
59
|
4
|
|
|
|
|
|
UnConst(LITE_NOOP); |
|
60
|
4
|
|
|
|
|
|
UnConst(LITE_INVALID); |
|
61
|
4
|
|
|
|
|
|
UnConst(LITE_EOF); |
|
62
|
4
|
|
|
|
|
|
UnConst(LITE_UNKNOWN); |
|
63
|
4
|
|
|
|
|
|
UnConst(LITE_LIMIT); |
|
64
|
4
|
|
|
|
|
|
UnConst(LITE_EXISTS); |
|
65
|
4
|
|
|
|
|
|
UnConst(LITE_EMPTY); |
|
66
|
4
|
|
|
|
|
|
UnConst(LITE_COMPILE_ERR); |
|
67
|
4
|
|
|
|
|
|
UnConst(LITE_VM_ERR); |
|
68
|
4
|
|
|
|
|
|
UnConst(LITE_FULL); |
|
69
|
4
|
|
|
|
|
|
UnConst(LITE_CANTOPEN); |
|
70
|
4
|
|
|
|
|
|
UnConst(LITE_READ_ONLY); |
|
71
|
4
|
|
|
|
|
|
UnConst(LITE_LOCKERR); |
|
72
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_READONLY); |
|
73
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_READWRITE); |
|
74
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_CREATE); |
|
75
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_EXCLUSIVE); |
|
76
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_TEMP_DB); |
|
77
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_OMIT_JOURNALING); |
|
78
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_IN_MEMORY); |
|
79
|
4
|
|
|
|
|
|
UnConst(LITE_OPEN_MMAP); |
|
80
|
4
|
|
|
|
|
|
UnConst(LITE_CURSOR_MATCH_EXACT); |
|
81
|
4
|
|
|
|
|
|
UnConst(LITE_CURSOR_MATCH_LE); |
|
82
|
4
|
|
|
|
|
|
UnConst(LITE_CURSOR_MATCH_GE); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
SV* |
|
85
|
|
|
|
|
|
|
open(klass, filename, mode=UNQLITE_OPEN_CREATE) |
|
86
|
|
|
|
|
|
|
const char *klass; |
|
87
|
|
|
|
|
|
|
const char *filename; |
|
88
|
|
|
|
|
|
|
int mode; |
|
89
|
|
|
|
|
|
|
PREINIT: |
|
90
|
|
|
|
|
|
|
SV *sv; |
|
91
|
|
|
|
|
|
|
unqlite *pdb; |
|
92
|
|
|
|
|
|
|
int rc; |
|
93
|
|
|
|
|
|
|
CODE: |
|
94
|
5
|
|
|
|
|
|
rc = unqlite_open(&pdb, filename, mode); |
|
95
|
5
|
50
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
96
|
5
|
|
|
|
|
|
XS_STRUCT2OBJ(sv, klass, pdb); |
|
97
|
5
|
50
|
|
|
|
|
SETRC(rc, sv); |
|
|
|
50
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
RETVAL = sv; |
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
0
|
0
|
|
|
|
|
SETRC(rc, &PL_sv_undef); |
|
|
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
OUTPUT: |
|
104
|
|
|
|
|
|
|
RETVAL |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
SV* _rc(self) |
|
107
|
|
|
|
|
|
|
SV *self |
|
108
|
|
|
|
|
|
|
PREINIT: |
|
109
|
|
|
|
|
|
|
MAGIC *mg; |
|
110
|
|
|
|
|
|
|
CODE: |
|
111
|
7
|
50
|
|
|
|
|
if (SvROK(self)) { |
|
112
|
7
|
|
|
|
|
|
mg = mg_find(SvRV(self), PERL_MAGIC_ext); |
|
113
|
7
|
50
|
|
|
|
|
if (mg) { |
|
114
|
7
|
|
|
|
|
|
RETVAL = newSVsv(mg->mg_obj); |
|
115
|
|
|
|
|
|
|
} else { |
|
116
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} else { |
|
119
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
OUTPUT: |
|
122
|
|
|
|
|
|
|
RETVAL |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
SV* |
|
125
|
|
|
|
|
|
|
kv_store(self, key_sv, data_sv) |
|
126
|
|
|
|
|
|
|
SV *self; |
|
127
|
|
|
|
|
|
|
SV *key_sv; |
|
128
|
|
|
|
|
|
|
SV *data_sv; |
|
129
|
|
|
|
|
|
|
PREINIT: |
|
130
|
|
|
|
|
|
|
char *key_c; |
|
131
|
|
|
|
|
|
|
STRLEN key_l; |
|
132
|
|
|
|
|
|
|
char *data_c; |
|
133
|
|
|
|
|
|
|
STRLEN data_l; |
|
134
|
|
|
|
|
|
|
int rc; |
|
135
|
|
|
|
|
|
|
CODE: |
|
136
|
8
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
137
|
8
|
|
|
|
|
|
key_c = SvPV(key_sv, key_l); |
|
138
|
8
|
|
|
|
|
|
data_c = SvPV(data_sv, data_l); |
|
139
|
8
|
|
|
|
|
|
rc = unqlite_kv_store(pdb, key_c, key_l, data_c, data_l); |
|
140
|
8
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
141
|
8
|
50
|
|
|
|
|
if (rc==UNQLITE_OK) { |
|
142
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
143
|
|
|
|
|
|
|
} else { |
|
144
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
OUTPUT: |
|
147
|
|
|
|
|
|
|
RETVAL |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
SV* |
|
150
|
|
|
|
|
|
|
kv_append(self, key_sv, data_sv) |
|
151
|
|
|
|
|
|
|
SV *self; |
|
152
|
|
|
|
|
|
|
SV *key_sv; |
|
153
|
|
|
|
|
|
|
SV *data_sv; |
|
154
|
|
|
|
|
|
|
PREINIT: |
|
155
|
|
|
|
|
|
|
char *key_c; |
|
156
|
|
|
|
|
|
|
STRLEN key_l; |
|
157
|
|
|
|
|
|
|
char *data_c; |
|
158
|
|
|
|
|
|
|
STRLEN data_l; |
|
159
|
|
|
|
|
|
|
int rc; |
|
160
|
|
|
|
|
|
|
CODE: |
|
161
|
2
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
162
|
2
|
|
|
|
|
|
key_c = SvPV(key_sv, key_l); |
|
163
|
2
|
|
|
|
|
|
data_c = SvPV(data_sv, data_l); |
|
164
|
2
|
|
|
|
|
|
rc = unqlite_kv_append(pdb, key_c, key_l, data_c, data_l); |
|
165
|
2
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
166
|
2
|
50
|
|
|
|
|
if (rc==UNQLITE_OK) { |
|
167
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
168
|
|
|
|
|
|
|
} else { |
|
169
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
OUTPUT: |
|
172
|
|
|
|
|
|
|
RETVAL |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
SV* |
|
175
|
|
|
|
|
|
|
kv_delete(self, key_sv) |
|
176
|
|
|
|
|
|
|
SV *self; |
|
177
|
|
|
|
|
|
|
SV *key_sv; |
|
178
|
|
|
|
|
|
|
PREINIT: |
|
179
|
|
|
|
|
|
|
char *key_c; |
|
180
|
|
|
|
|
|
|
STRLEN key_l; |
|
181
|
|
|
|
|
|
|
int rc; |
|
182
|
|
|
|
|
|
|
CODE: |
|
183
|
3
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
184
|
3
|
|
|
|
|
|
key_c = SvPV(key_sv, key_l); |
|
185
|
3
|
|
|
|
|
|
rc = unqlite_kv_delete(pdb, key_c, key_l); |
|
186
|
3
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
187
|
3
|
50
|
|
|
|
|
if (rc==UNQLITE_OK) { |
|
188
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
189
|
|
|
|
|
|
|
} else { |
|
190
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
OUTPUT: |
|
193
|
|
|
|
|
|
|
RETVAL |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
SV* |
|
196
|
|
|
|
|
|
|
kv_fetch(self, key_sv) |
|
197
|
|
|
|
|
|
|
SV *self; |
|
198
|
|
|
|
|
|
|
SV *key_sv; |
|
199
|
|
|
|
|
|
|
PREINIT: |
|
200
|
|
|
|
|
|
|
char *key_c; |
|
201
|
|
|
|
|
|
|
STRLEN key_l; |
|
202
|
|
|
|
|
|
|
char *buf; |
|
203
|
|
|
|
|
|
|
int rc; |
|
204
|
|
|
|
|
|
|
unqlite_int64 nbytes; |
|
205
|
|
|
|
|
|
|
SV *sv; |
|
206
|
|
|
|
|
|
|
CODE: |
|
207
|
15
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
208
|
15
|
|
|
|
|
|
key_c = SvPV(key_sv, key_l); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
/* Allocate a buffer big enough to hold the record content */ |
|
211
|
15
|
|
|
|
|
|
rc = unqlite_kv_fetch(pdb, key_c, key_l, NULL, &nbytes); |
|
212
|
15
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
213
|
15
|
100
|
|
|
|
|
if (rc!=UNQLITE_OK) { |
|
214
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
215
|
5
|
|
|
|
|
|
goto last; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
10
|
|
|
|
|
|
Newxz(buf, nbytes, char); |
|
218
|
10
|
|
|
|
|
|
rc = unqlite_kv_fetch(pdb, key_c, key_l, buf, &nbytes); |
|
219
|
10
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
220
|
10
|
|
|
|
|
|
sv = newSVpv(buf, nbytes); |
|
221
|
10
|
|
|
|
|
|
Safefree(buf); |
|
222
|
|
|
|
|
|
|
RETVAL = sv; |
|
223
|
15
|
|
|
|
|
|
last: |
|
224
|
|
|
|
|
|
|
OUTPUT: |
|
225
|
|
|
|
|
|
|
RETVAL |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
void |
|
228
|
|
|
|
|
|
|
DESTROY(self) |
|
229
|
|
|
|
|
|
|
SV * self; |
|
230
|
|
|
|
|
|
|
PREINIT: |
|
231
|
|
|
|
|
|
|
int rc; |
|
232
|
|
|
|
|
|
|
CODE: |
|
233
|
5
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
234
|
5
|
|
|
|
|
|
rc = unqlite_close(pdb); |
|
235
|
5
|
50
|
|
|
|
|
SETRC(rc, &PL_sv_undef); |
|
|
|
0
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
SV* |
|
238
|
|
|
|
|
|
|
_cursor_init(self) |
|
239
|
|
|
|
|
|
|
SV * self; |
|
240
|
|
|
|
|
|
|
PREINIT: |
|
241
|
|
|
|
|
|
|
SV * sv; |
|
242
|
|
|
|
|
|
|
int rc; |
|
243
|
|
|
|
|
|
|
unqlite_kv_cursor* cursor; |
|
244
|
|
|
|
|
|
|
CODE: |
|
245
|
5
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, self); |
|
246
|
5
|
|
|
|
|
|
rc = unqlite_kv_cursor_init(pdb, &cursor); |
|
247
|
5
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
248
|
5
|
50
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
249
|
5
|
|
|
|
|
|
sv = newSViv(PTR2IV(cursor)); |
|
250
|
5
|
|
|
|
|
|
sv_magic(sv, sv_2mortal(newSViv(UNQLITE_OK)), PERL_MAGIC_ext, NULL, 0); |
|
251
|
5
|
|
|
|
|
|
sv = newRV_noinc(sv); |
|
252
|
5
|
|
|
|
|
|
SvREADONLY_on(sv); |
|
253
|
|
|
|
|
|
|
RETVAL = sv; |
|
254
|
|
|
|
|
|
|
} else { |
|
255
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
OUTPUT: |
|
258
|
|
|
|
|
|
|
RETVAL |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
MODULE = UnQLite PACKAGE = UnQLite::Cursor |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
SV* _rc(self) |
|
264
|
|
|
|
|
|
|
SV *self |
|
265
|
|
|
|
|
|
|
PREINIT: |
|
266
|
|
|
|
|
|
|
MAGIC *mg; |
|
267
|
|
|
|
|
|
|
CODE: |
|
268
|
0
|
0
|
|
|
|
|
if (SvROK(self)) { |
|
269
|
0
|
|
|
|
|
|
mg = mg_find(SvRV(self), PERL_MAGIC_ext); |
|
270
|
0
|
0
|
|
|
|
|
if (mg) { |
|
271
|
0
|
|
|
|
|
|
RETVAL = newSVsv(mg->mg_obj); |
|
272
|
|
|
|
|
|
|
} else { |
|
273
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
} else { |
|
276
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
OUTPUT: |
|
279
|
|
|
|
|
|
|
RETVAL |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
SV* |
|
282
|
|
|
|
|
|
|
_first_entry(self) |
|
283
|
|
|
|
|
|
|
SV * self; |
|
284
|
|
|
|
|
|
|
PREINIT: |
|
285
|
|
|
|
|
|
|
SV * sv; |
|
286
|
|
|
|
|
|
|
int rc; |
|
287
|
|
|
|
|
|
|
CODE: |
|
288
|
9
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
289
|
9
|
|
|
|
|
|
rc = unqlite_kv_cursor_first_entry(cursor); |
|
290
|
9
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
291
|
9
|
100
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
292
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
293
|
|
|
|
|
|
|
} else { |
|
294
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
OUTPUT: |
|
297
|
|
|
|
|
|
|
RETVAL |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
int |
|
300
|
|
|
|
|
|
|
_valid_entry(self) |
|
301
|
|
|
|
|
|
|
SV * self; |
|
302
|
|
|
|
|
|
|
PREINIT: |
|
303
|
|
|
|
|
|
|
SV * sv; |
|
304
|
|
|
|
|
|
|
int rc; |
|
305
|
|
|
|
|
|
|
CODE: |
|
306
|
14
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
307
|
|
|
|
|
|
|
/* This will return 1 when valid. 0 otherwise */ |
|
308
|
14
|
|
|
|
|
|
rc = unqlite_kv_cursor_valid_entry(cursor); |
|
309
|
|
|
|
|
|
|
RETVAL = rc; |
|
310
|
|
|
|
|
|
|
OUTPUT: |
|
311
|
|
|
|
|
|
|
RETVAL |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
SV* |
|
314
|
|
|
|
|
|
|
_next_entry(self) |
|
315
|
|
|
|
|
|
|
SV * self; |
|
316
|
|
|
|
|
|
|
PREINIT: |
|
317
|
|
|
|
|
|
|
SV * sv; |
|
318
|
|
|
|
|
|
|
int rc; |
|
319
|
|
|
|
|
|
|
CODE: |
|
320
|
10
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
321
|
10
|
|
|
|
|
|
rc = unqlite_kv_cursor_next_entry(cursor); |
|
322
|
10
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
323
|
10
|
100
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
324
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
325
|
|
|
|
|
|
|
} else { |
|
326
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
OUTPUT: |
|
329
|
|
|
|
|
|
|
RETVAL |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
SV* |
|
332
|
|
|
|
|
|
|
_last_entry(self) |
|
333
|
|
|
|
|
|
|
SV * self; |
|
334
|
|
|
|
|
|
|
PREINIT: |
|
335
|
|
|
|
|
|
|
SV * sv; |
|
336
|
|
|
|
|
|
|
int rc; |
|
337
|
|
|
|
|
|
|
CODE: |
|
338
|
1
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
339
|
1
|
|
|
|
|
|
rc = unqlite_kv_cursor_last_entry(cursor); |
|
340
|
1
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
341
|
1
|
50
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
342
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
343
|
|
|
|
|
|
|
} else { |
|
344
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
OUTPUT: |
|
347
|
|
|
|
|
|
|
RETVAL |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
SV* |
|
350
|
|
|
|
|
|
|
_prev_entry(self) |
|
351
|
|
|
|
|
|
|
SV * self; |
|
352
|
|
|
|
|
|
|
PREINIT: |
|
353
|
|
|
|
|
|
|
SV * sv; |
|
354
|
|
|
|
|
|
|
int rc; |
|
355
|
|
|
|
|
|
|
CODE: |
|
356
|
2
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
357
|
2
|
|
|
|
|
|
rc = unqlite_kv_cursor_prev_entry(cursor); |
|
358
|
2
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
359
|
2
|
100
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
360
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
361
|
|
|
|
|
|
|
} else { |
|
362
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
OUTPUT: |
|
365
|
|
|
|
|
|
|
RETVAL |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
SV* |
|
368
|
|
|
|
|
|
|
_key(self) |
|
369
|
|
|
|
|
|
|
SV * self; |
|
370
|
|
|
|
|
|
|
PREINIT: |
|
371
|
|
|
|
|
|
|
SV * sv; |
|
372
|
|
|
|
|
|
|
int rc; |
|
373
|
|
|
|
|
|
|
int nbytes; |
|
374
|
|
|
|
|
|
|
char*buf; |
|
375
|
|
|
|
|
|
|
CODE: |
|
376
|
10
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
377
|
10
|
|
|
|
|
|
rc = unqlite_kv_cursor_key(cursor, NULL, &nbytes); |
|
378
|
10
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
379
|
10
|
50
|
|
|
|
|
if (rc!=UNQLITE_OK) { |
|
380
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
381
|
0
|
|
|
|
|
|
goto last; |
|
382
|
|
|
|
|
|
|
} |
|
383
|
10
|
|
|
|
|
|
Newxz(buf, nbytes, char); |
|
384
|
10
|
|
|
|
|
|
rc = unqlite_kv_cursor_key(cursor, buf, &nbytes); |
|
385
|
10
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
386
|
10
|
|
|
|
|
|
sv = newSVpv(buf, nbytes); |
|
387
|
10
|
|
|
|
|
|
Safefree(buf); |
|
388
|
|
|
|
|
|
|
RETVAL = sv; |
|
389
|
10
|
|
|
|
|
|
last: |
|
390
|
|
|
|
|
|
|
OUTPUT: |
|
391
|
|
|
|
|
|
|
RETVAL |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
SV* |
|
394
|
|
|
|
|
|
|
_data(self) |
|
395
|
|
|
|
|
|
|
SV * self; |
|
396
|
|
|
|
|
|
|
PREINIT: |
|
397
|
|
|
|
|
|
|
SV * sv; |
|
398
|
|
|
|
|
|
|
int rc; |
|
399
|
|
|
|
|
|
|
unqlite_int64 nbytes; |
|
400
|
|
|
|
|
|
|
char*buf; |
|
401
|
|
|
|
|
|
|
CODE: |
|
402
|
6
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
403
|
6
|
|
|
|
|
|
rc = unqlite_kv_cursor_data(cursor, NULL, &nbytes); |
|
404
|
6
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
405
|
6
|
50
|
|
|
|
|
if (rc!=UNQLITE_OK) { |
|
406
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
407
|
0
|
|
|
|
|
|
goto last; |
|
408
|
|
|
|
|
|
|
} |
|
409
|
6
|
|
|
|
|
|
Newxz(buf, nbytes, char); |
|
410
|
6
|
|
|
|
|
|
rc = unqlite_kv_cursor_data(cursor, buf, &nbytes); |
|
411
|
6
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
412
|
6
|
|
|
|
|
|
sv = newSVpv(buf, nbytes); |
|
413
|
6
|
|
|
|
|
|
Safefree(buf); |
|
414
|
|
|
|
|
|
|
RETVAL = sv; |
|
415
|
6
|
|
|
|
|
|
last: |
|
416
|
|
|
|
|
|
|
OUTPUT: |
|
417
|
|
|
|
|
|
|
RETVAL |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
void |
|
420
|
|
|
|
|
|
|
_release(self, db) |
|
421
|
|
|
|
|
|
|
SV * self; |
|
422
|
|
|
|
|
|
|
SV * db; |
|
423
|
|
|
|
|
|
|
CODE: |
|
424
|
5
|
50
|
|
|
|
|
unqlite *pdb = XS_STATE(unqlite*, db); |
|
425
|
5
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
426
|
5
|
|
|
|
|
|
unqlite_kv_cursor_release(pdb, cursor); |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
SV* |
|
429
|
|
|
|
|
|
|
_seek(self, key_s, opt=UNQLITE_CURSOR_MATCH_EXACT) |
|
430
|
|
|
|
|
|
|
SV * self; |
|
431
|
|
|
|
|
|
|
SV * key_s; |
|
432
|
|
|
|
|
|
|
int opt; |
|
433
|
|
|
|
|
|
|
PREINIT: |
|
434
|
|
|
|
|
|
|
STRLEN len; |
|
435
|
|
|
|
|
|
|
char * key; |
|
436
|
|
|
|
|
|
|
int rc; |
|
437
|
|
|
|
|
|
|
CODE: |
|
438
|
2
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
439
|
2
|
|
|
|
|
|
key = SvPV(key_s, len); |
|
440
|
2
|
|
|
|
|
|
rc = unqlite_kv_cursor_seek(cursor, key, len, opt); |
|
441
|
2
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
442
|
2
|
100
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
443
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
444
|
|
|
|
|
|
|
} else { |
|
445
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
OUTPUT: |
|
448
|
|
|
|
|
|
|
RETVAL |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
SV* |
|
451
|
|
|
|
|
|
|
_delete_entry(self) |
|
452
|
|
|
|
|
|
|
SV * self; |
|
453
|
|
|
|
|
|
|
PREINIT: |
|
454
|
|
|
|
|
|
|
int rc; |
|
455
|
|
|
|
|
|
|
CODE: |
|
456
|
3
|
50
|
|
|
|
|
unqlite_kv_cursor *cursor = XS_STATE(unqlite_kv_cursor*, self); |
|
457
|
3
|
|
|
|
|
|
rc = unqlite_kv_cursor_delete_entry(cursor); |
|
458
|
3
|
50
|
|
|
|
|
SETRC(rc, self); |
|
|
|
50
|
|
|
|
|
|
|
459
|
3
|
50
|
|
|
|
|
if (rc == UNQLITE_OK) { |
|
460
|
|
|
|
|
|
|
RETVAL = &PL_sv_yes; |
|
461
|
|
|
|
|
|
|
} else { |
|
462
|
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
463
|
|
|
|
|
|
|
} |
|
464
|
|
|
|
|
|
|
OUTPUT: |
|
465
|
|
|
|
|
|
|
RETVAL |