|
|
1 | #include <sys/user.h> |
|
|
2 | #include <sys/ptrace.h> |
|
|
3 | |
|
|
4 | #define X_STACKSIZE 1024 * 128 + sizeof (long) * 64 * 1024 / 4 |
|
|
5 | |
1 | #include "xthread.h" |
6 | #include "xthread.h" |
2 | |
7 | |
3 | #include <errno.h> |
8 | #include <errno.h> |
4 | |
9 | |
5 | #include "EXTERN.h" |
10 | #include "EXTERN.h" |
… | |
… | |
27 | # include <unistd.h> |
32 | # include <unistd.h> |
28 | #endif |
33 | #endif |
29 | |
34 | |
30 | #include <db.h> |
35 | #include <db.h> |
31 | |
36 | |
32 | #if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 4) |
37 | #if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) |
33 | # error you need Berkeley DB 4.4 or newer installed |
38 | # error you need Berkeley DB 4.3 or a newer 4.x version installed |
34 | #endif |
39 | #endif |
35 | |
40 | |
36 | /* number of seconds after which idle threads exit */ |
41 | /* number of seconds after which idle threads exit */ |
37 | #define IDLE_TIMEOUT 10 |
42 | #define IDLE_TIMEOUT 10 |
38 | |
43 | |
39 | typedef DB_ENV DB_ENV_ornull; |
44 | typedef DB_ENV DB_ENV_ornull; |
40 | typedef DB_TXN DB_TXN_ornull; |
45 | typedef DB_TXN DB_TXN_ornull; |
41 | typedef DBC DBC_ornull; |
46 | typedef DBC DBC_ornull; |
42 | typedef DB DB_ornull; |
47 | typedef DB DB_ornull; |
|
|
48 | |
|
|
49 | typedef DB_ENV DB_ENV_ornuked; |
|
|
50 | typedef DB_TXN DB_TXN_ornuked; |
|
|
51 | typedef DBC DBC_ornuked; |
|
|
52 | typedef DB DB_ornuked; |
|
|
53 | |
|
|
54 | #if DB_VERSION_MINOR >= 3 |
43 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
55 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
|
|
56 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
|
|
57 | #endif |
44 | |
58 | |
45 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
59 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
46 | typedef char *octetstring; |
60 | typedef char *bdb_filename; |
47 | |
61 | |
48 | static SV *prepare_cb; |
62 | static SV *prepare_cb; |
49 | |
63 | |
50 | #if DB_VERSION_MINOR >= 6 |
64 | #if DB_VERSION_MINOR >= 6 |
51 | # define c_close close |
65 | # define c_close close |
… | |
… | |
55 | # define c_get get |
69 | # define c_get get |
56 | # define c_pget pget |
70 | # define c_pget pget |
57 | # define c_put put |
71 | # define c_put put |
58 | #endif |
72 | #endif |
59 | |
73 | |
|
|
74 | static char * |
|
|
75 | get_bdb_filename (SV *sv) |
|
|
76 | { |
|
|
77 | if (!SvOK (sv)) |
|
|
78 | return 0; |
|
|
79 | |
|
|
80 | #if _WIN32 |
|
|
81 | /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */ |
|
|
82 | { |
|
|
83 | STRLEN len; |
|
|
84 | char *src = SvPVbyte (sv, len); |
|
|
85 | SV *t1 = sv_newmortal (); |
|
|
86 | SV *t2 = sv_newmortal (); |
|
|
87 | |
|
|
88 | sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1); |
|
|
89 | sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1); |
|
|
90 | |
|
|
91 | len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR)); |
|
|
92 | len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0); |
|
|
93 | SvPOK_only (t2); |
|
|
94 | SvPVX (t2)[len] = 0; |
|
|
95 | SvCUR_set (t2, len); |
|
|
96 | |
|
|
97 | return SvPVX (t2); |
|
|
98 | } |
|
|
99 | #else |
|
|
100 | return SvPVbyte_nolen (sv); |
|
|
101 | #endif |
|
|
102 | } |
|
|
103 | |
60 | static void |
104 | static void |
61 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
105 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
62 | { |
106 | { |
63 | printf ("err[%s]\n", msg); |
107 | printf ("err[%s]\n", msg); |
64 | } |
108 | } |
… | |
… | |
91 | dbt_to_sv (SV *sv, DBT *dbt) |
135 | dbt_to_sv (SV *sv, DBT *dbt) |
92 | { |
136 | { |
93 | if (sv) |
137 | if (sv) |
94 | { |
138 | { |
95 | SvREADONLY_off (sv); |
139 | SvREADONLY_off (sv); |
96 | sv_setpvn_mg (sv, dbt->data, dbt->size); |
140 | sv_setsv_mg (sv, dbt->data ? newSVpvn (dbt->data, dbt->size) : &PL_sv_undef); |
97 | SvREFCNT_dec (sv); |
141 | SvREFCNT_dec (sv); |
98 | } |
142 | } |
99 | |
143 | |
|
|
144 | //assert (dbt->flags & DBT_MALLOC || !dbt->data); |
100 | free (dbt->data); |
145 | free (dbt->data); |
101 | } |
146 | } |
102 | |
147 | |
103 | enum { |
148 | enum { |
104 | REQ_QUIT, |
149 | REQ_QUIT, |
105 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
150 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
106 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, |
151 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
107 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, |
152 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, |
108 | REQ_DB_PUT, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
153 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
109 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
154 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
110 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
155 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
111 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
156 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
112 | }; |
157 | }; |
113 | |
158 | |
114 | typedef struct aio_cb |
159 | typedef struct bdb_cb |
115 | { |
160 | { |
116 | struct aio_cb *volatile next; |
161 | struct bdb_cb *volatile next; |
117 | SV *callback; |
162 | SV *callback; |
118 | int type, pri, result; |
163 | int type, pri, result; |
119 | |
164 | |
120 | DB_ENV *env; |
165 | DB_ENV *env; |
121 | DB *db; |
166 | DB *db; |
… | |
… | |
123 | DBC *dbc; |
168 | DBC *dbc; |
124 | |
169 | |
125 | UV uv1; |
170 | UV uv1; |
126 | int int1, int2; |
171 | int int1, int2; |
127 | U32 uint1, uint2; |
172 | U32 uint1, uint2; |
128 | char *buf1, *buf2; |
173 | char *buf1, *buf2, *buf3; |
129 | SV *sv1, *sv2, *sv3; |
174 | SV *sv1, *sv2, *sv3; |
130 | |
175 | |
131 | DBT dbt1, dbt2, dbt3; |
176 | DBT dbt1, dbt2, dbt3; |
132 | DB_KEY_RANGE key_range; |
177 | DB_KEY_RANGE key_range; |
|
|
178 | #if DB_VERSION_MINOR >= 3 |
133 | DB_SEQUENCE *seq; |
179 | DB_SEQUENCE *seq; |
134 | db_seq_t seq_t; |
180 | db_seq_t seq_t; |
135 | } aio_cb; |
181 | #endif |
|
|
182 | } bdb_cb; |
136 | |
183 | |
137 | typedef aio_cb *aio_req; |
184 | typedef bdb_cb *bdb_req; |
138 | |
185 | |
139 | enum { |
186 | enum { |
140 | PRI_MIN = -4, |
187 | PRI_MIN = -4, |
141 | PRI_MAX = 4, |
188 | PRI_MAX = 4, |
142 | |
189 | |
… | |
… | |
145 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
192 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
146 | }; |
193 | }; |
147 | |
194 | |
148 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
195 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
149 | |
196 | |
|
|
197 | static SV *on_next_submit; |
|
|
198 | |
150 | static unsigned int max_poll_time = 0; |
199 | static unsigned int max_poll_time = 0; |
151 | static unsigned int max_poll_reqs = 0; |
200 | static unsigned int max_poll_reqs = 0; |
152 | |
201 | |
153 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
202 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
154 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
203 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
… | |
… | |
169 | struct worker *prev, *next; |
218 | struct worker *prev, *next; |
170 | |
219 | |
171 | thread_t tid; |
220 | thread_t tid; |
172 | |
221 | |
173 | /* locked by reslock, reqlock or wrklock */ |
222 | /* locked by reslock, reqlock or wrklock */ |
174 | aio_req req; /* currently processed request */ |
223 | bdb_req req; /* currently processed request */ |
175 | void *dbuf; |
224 | void *dbuf; |
176 | DIR *dirp; |
225 | DIR *dirp; |
177 | } worker; |
226 | } worker; |
178 | |
227 | |
179 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
228 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
… | |
… | |
199 | static mutex_t reqlock = X_MUTEX_INIT; |
248 | static mutex_t reqlock = X_MUTEX_INIT; |
200 | static cond_t reqwait = X_COND_INIT; |
249 | static cond_t reqwait = X_COND_INIT; |
201 | |
250 | |
202 | #if WORDACCESS_UNSAFE |
251 | #if WORDACCESS_UNSAFE |
203 | |
252 | |
204 | static unsigned int get_nready () |
253 | static unsigned int get_nready (void) |
205 | { |
254 | { |
206 | unsigned int retval; |
255 | unsigned int retval; |
207 | |
256 | |
208 | X_LOCK (reqlock); |
257 | X_LOCK (reqlock); |
209 | retval = nready; |
258 | retval = nready; |
210 | X_UNLOCK (reqlock); |
259 | X_UNLOCK (reqlock); |
211 | |
260 | |
212 | return retval; |
261 | return retval; |
213 | } |
262 | } |
214 | |
263 | |
215 | static unsigned int get_npending () |
264 | static unsigned int get_npending (void) |
216 | { |
265 | { |
217 | unsigned int retval; |
266 | unsigned int retval; |
218 | |
267 | |
219 | X_LOCK (reslock); |
268 | X_LOCK (reslock); |
220 | retval = npending; |
269 | retval = npending; |
221 | X_UNLOCK (reslock); |
270 | X_UNLOCK (reslock); |
222 | |
271 | |
223 | return retval; |
272 | return retval; |
224 | } |
273 | } |
225 | |
274 | |
226 | static unsigned int get_nthreads () |
275 | static unsigned int get_nthreads (void) |
227 | { |
276 | { |
228 | unsigned int retval; |
277 | unsigned int retval; |
229 | |
278 | |
230 | X_LOCK (wrklock); |
279 | X_LOCK (wrklock); |
231 | retval = started; |
280 | retval = started; |
… | |
… | |
246 | * a somewhat faster data structure might be nice, but |
295 | * a somewhat faster data structure might be nice, but |
247 | * with 8 priorities this actually needs <20 insns |
296 | * with 8 priorities this actually needs <20 insns |
248 | * per shift, the most expensive operation. |
297 | * per shift, the most expensive operation. |
249 | */ |
298 | */ |
250 | typedef struct { |
299 | typedef struct { |
251 | aio_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
300 | bdb_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
252 | int size; |
301 | int size; |
253 | } reqq; |
302 | } reqq; |
254 | |
303 | |
255 | static reqq req_queue; |
304 | static reqq req_queue; |
256 | static reqq res_queue; |
305 | static reqq res_queue; |
257 | |
306 | |
258 | int reqq_push (reqq *q, aio_req req) |
307 | int reqq_push (reqq *q, bdb_req req) |
259 | { |
308 | { |
260 | int pri = req->pri; |
309 | int pri = req->pri; |
261 | req->next = 0; |
310 | req->next = 0; |
262 | |
311 | |
263 | if (q->qe[pri]) |
312 | if (q->qe[pri]) |
… | |
… | |
269 | q->qe[pri] = q->qs[pri] = req; |
318 | q->qe[pri] = q->qs[pri] = req; |
270 | |
319 | |
271 | return q->size++; |
320 | return q->size++; |
272 | } |
321 | } |
273 | |
322 | |
274 | aio_req reqq_shift (reqq *q) |
323 | bdb_req reqq_shift (reqq *q) |
275 | { |
324 | { |
276 | int pri; |
325 | int pri; |
277 | |
326 | |
278 | if (!q->size) |
327 | if (!q->size) |
279 | return 0; |
328 | return 0; |
280 | |
329 | |
281 | --q->size; |
330 | --q->size; |
282 | |
331 | |
283 | for (pri = NUM_PRI; pri--; ) |
332 | for (pri = NUM_PRI; pri--; ) |
284 | { |
333 | { |
285 | aio_req req = q->qs[pri]; |
334 | bdb_req req = q->qs[pri]; |
286 | |
335 | |
287 | if (req) |
336 | if (req) |
288 | { |
337 | { |
289 | if (!(q->qs[pri] = req->next)) |
338 | if (!(q->qs[pri] = req->next)) |
290 | q->qe[pri] = 0; |
339 | q->qe[pri] = 0; |
… | |
… | |
294 | } |
343 | } |
295 | |
344 | |
296 | abort (); |
345 | abort (); |
297 | } |
346 | } |
298 | |
347 | |
299 | static int poll_cb (); |
348 | static int poll_cb (void); |
300 | static void req_free (aio_req req); |
349 | static void req_free (bdb_req req); |
301 | static void req_cancel (aio_req req); |
350 | static void req_cancel (bdb_req req); |
302 | |
351 | |
303 | static int req_invoke (aio_req req) |
352 | static int req_invoke (bdb_req req) |
304 | { |
353 | { |
305 | dSP; |
354 | dSP; |
306 | |
355 | |
307 | if (SvOK (req->callback)) |
356 | if (req->callback) |
308 | { |
357 | { |
309 | ENTER; |
358 | ENTER; |
310 | SAVETMPS; |
359 | SAVETMPS; |
311 | PUSHMARK (SP); |
360 | PUSHMARK (SP); |
312 | |
361 | |
… | |
… | |
326 | dbt_to_sv (req->sv1, &req->dbt1); |
375 | dbt_to_sv (req->sv1, &req->dbt1); |
327 | dbt_to_sv (req->sv2, &req->dbt2); |
376 | dbt_to_sv (req->sv2, &req->dbt2); |
328 | dbt_to_sv (req->sv3, &req->dbt3); |
377 | dbt_to_sv (req->sv3, &req->dbt3); |
329 | break; |
378 | break; |
330 | |
379 | |
|
|
380 | case REQ_DB_PUT: |
|
|
381 | case REQ_C_PUT: |
|
|
382 | dbt_to_sv (0, &req->dbt1); |
|
|
383 | dbt_to_sv (0, &req->dbt2); |
|
|
384 | break; |
|
|
385 | |
331 | case REQ_DB_KEY_RANGE: |
386 | case REQ_DB_KEY_RANGE: |
332 | { |
387 | { |
333 | AV *av = newAV (); |
388 | AV *av = newAV (); |
334 | |
389 | |
335 | av_push (av, newSVnv (req->key_range.less)); |
390 | av_push (av, newSVnv (req->key_range.less)); |
… | |
… | |
340 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
395 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
341 | SvREFCNT_dec (req->sv1); |
396 | SvREFCNT_dec (req->sv1); |
342 | } |
397 | } |
343 | break; |
398 | break; |
344 | |
399 | |
|
|
400 | #if DB_VERSION_MINOR >= 3 |
345 | case REQ_SEQ_GET: |
401 | case REQ_SEQ_GET: |
346 | SvREADONLY_off (req->sv1); |
402 | SvREADONLY_off (req->sv1); |
347 | |
403 | |
348 | if (sizeof (IV) > 4) |
404 | if (sizeof (IV) > 4) |
349 | sv_setiv_mg (req->sv1, req->seq_t); |
405 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
350 | else |
406 | else |
351 | sv_setnv_mg (req->sv1, req->seq_t); |
407 | sv_setnv_mg (req->sv1, (NV)req->seq_t); |
352 | |
408 | |
353 | SvREFCNT_dec (req->sv1); |
409 | SvREFCNT_dec (req->sv1); |
354 | break; |
410 | break; |
|
|
411 | #endif |
355 | } |
412 | } |
356 | |
413 | |
357 | errno = req->result; |
414 | errno = req->result; |
358 | |
415 | |
359 | PUTBACK; |
416 | PUTBACK; |
… | |
… | |
365 | } |
422 | } |
366 | |
423 | |
367 | return !SvTRUE (ERRSV); |
424 | return !SvTRUE (ERRSV); |
368 | } |
425 | } |
369 | |
426 | |
370 | static void req_free (aio_req req) |
427 | static void req_free (bdb_req req) |
371 | { |
428 | { |
|
|
429 | SvREFCNT_dec (req->callback); |
|
|
430 | |
372 | free (req->buf1); |
431 | free (req->buf1); |
373 | free (req->buf2); |
432 | free (req->buf2); |
|
|
433 | free (req->buf3); |
|
|
434 | |
374 | Safefree (req); |
435 | Safefree (req); |
375 | } |
436 | } |
376 | |
437 | |
377 | #ifdef USE_SOCKETS_AS_HANDLES |
438 | #ifdef USE_SOCKETS_AS_HANDLES |
378 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
439 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
379 | #else |
440 | #else |
380 | # define TO_SOCKET(x) (x) |
441 | # define TO_SOCKET(x) (x) |
381 | #endif |
442 | #endif |
382 | |
443 | |
383 | static void |
444 | static void |
384 | create_respipe () |
445 | create_respipe (void) |
385 | { |
446 | { |
|
|
447 | #ifdef _WIN32 |
|
|
448 | int arg; /* argg */ |
|
|
449 | #endif |
386 | int old_readfd = respipe [0]; |
450 | int old_readfd = respipe [0]; |
387 | |
451 | |
388 | if (respipe [1] >= 0) |
452 | if (respipe [1] >= 0) |
389 | respipe_close (TO_SOCKET (respipe [1])); |
453 | respipe_close (TO_SOCKET (respipe [1])); |
390 | |
454 | |
… | |
… | |
403 | respipe_close (respipe [0]); |
467 | respipe_close (respipe [0]); |
404 | respipe [0] = old_readfd; |
468 | respipe [0] = old_readfd; |
405 | } |
469 | } |
406 | |
470 | |
407 | #ifdef _WIN32 |
471 | #ifdef _WIN32 |
408 | int arg = 1; |
472 | arg = 1; |
409 | if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg) |
473 | if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg) |
410 | || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg)) |
474 | || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg)) |
411 | #else |
475 | #else |
412 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK) |
476 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK) |
413 | || fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
477 | || fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
… | |
… | |
440 | free (wrk); |
504 | free (wrk); |
441 | |
505 | |
442 | X_UNLOCK (wrklock); |
506 | X_UNLOCK (wrklock); |
443 | } |
507 | } |
444 | |
508 | |
445 | static void maybe_start_thread () |
509 | static void maybe_start_thread (void) |
446 | { |
510 | { |
447 | if (get_nthreads () >= wanted) |
511 | if (get_nthreads () >= wanted) |
448 | return; |
512 | return; |
449 | |
513 | |
450 | /* todo: maybe use idle here, but might be less exact */ |
514 | /* todo: maybe use idle here, but might be less exact */ |
… | |
… | |
452 | return; |
516 | return; |
453 | |
517 | |
454 | start_thread (); |
518 | start_thread (); |
455 | } |
519 | } |
456 | |
520 | |
457 | static void req_send (aio_req req) |
521 | static void req_send (bdb_req req) |
458 | { |
522 | { |
459 | SV *wait_callback = 0; |
523 | SV *wait_callback = 0; |
460 | |
524 | |
|
|
525 | if (on_next_submit) |
|
|
526 | { |
|
|
527 | dSP; |
|
|
528 | SV *cb = sv_2mortal (on_next_submit); |
|
|
529 | |
|
|
530 | on_next_submit = 0; |
|
|
531 | |
|
|
532 | PUSHMARK (SP); |
|
|
533 | PUTBACK; |
|
|
534 | call_sv (cb, G_DISCARD | G_EVAL); |
|
|
535 | SPAGAIN; |
|
|
536 | } |
|
|
537 | |
461 | // synthesize callback if none given |
538 | // synthesize callback if none given |
462 | if (!SvOK (req->callback)) |
539 | if (!req->callback) |
463 | { |
540 | { |
464 | int count; |
541 | int count; |
465 | |
542 | |
466 | dSP; |
543 | dSP; |
467 | PUSHMARK (SP); |
544 | PUSHMARK (SP); |
… | |
… | |
470 | SPAGAIN; |
547 | SPAGAIN; |
471 | |
548 | |
472 | if (count != 2) |
549 | if (count != 2) |
473 | croak ("prepare callback must return exactly two values\n"); |
550 | croak ("prepare callback must return exactly two values\n"); |
474 | |
551 | |
475 | wait_callback = SvREFCNT_inc (POPs); |
552 | wait_callback = POPs; |
476 | SvREFCNT_dec (req->callback); |
|
|
477 | req->callback = SvREFCNT_inc (POPs); |
553 | req->callback = SvREFCNT_inc (POPs); |
478 | } |
554 | } |
479 | |
555 | |
480 | ++nreqs; |
556 | ++nreqs; |
481 | |
557 | |
… | |
… | |
491 | { |
567 | { |
492 | dSP; |
568 | dSP; |
493 | PUSHMARK (SP); |
569 | PUSHMARK (SP); |
494 | PUTBACK; |
570 | PUTBACK; |
495 | call_sv (wait_callback, G_DISCARD); |
571 | call_sv (wait_callback, G_DISCARD); |
496 | SvREFCNT_dec (wait_callback); |
|
|
497 | } |
572 | } |
498 | } |
573 | } |
499 | |
574 | |
500 | static void end_thread (void) |
575 | static void end_thread (void) |
501 | { |
576 | { |
502 | aio_req req; |
577 | bdb_req req; |
503 | |
578 | |
504 | Newz (0, req, 1, aio_cb); |
579 | Newz (0, req, 1, bdb_cb); |
505 | |
580 | |
506 | req->type = REQ_QUIT; |
581 | req->type = REQ_QUIT; |
507 | req->pri = PRI_MAX + PRI_BIAS; |
582 | req->pri = PRI_MAX + PRI_BIAS; |
508 | |
583 | |
509 | X_LOCK (reqlock); |
584 | X_LOCK (reqlock); |
… | |
… | |
536 | |
611 | |
537 | while (started > wanted) |
612 | while (started > wanted) |
538 | end_thread (); |
613 | end_thread (); |
539 | } |
614 | } |
540 | |
615 | |
541 | static void poll_wait () |
616 | static void poll_wait (void) |
542 | { |
617 | { |
543 | fd_set rfd; |
618 | fd_set rfd; |
544 | |
619 | |
545 | while (nreqs) |
620 | while (nreqs) |
546 | { |
621 | { |
… | |
… | |
559 | |
634 | |
560 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
635 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
561 | } |
636 | } |
562 | } |
637 | } |
563 | |
638 | |
564 | static int poll_cb () |
639 | static int poll_cb (void) |
565 | { |
640 | { |
566 | dSP; |
641 | dSP; |
567 | int count = 0; |
642 | int count = 0; |
568 | int maxreqs = max_poll_reqs; |
643 | int maxreqs = max_poll_reqs; |
569 | int do_croak = 0; |
644 | int do_croak = 0; |
570 | struct timeval tv_start, tv_now; |
645 | struct timeval tv_start, tv_now; |
571 | aio_req req; |
646 | bdb_req req; |
572 | |
647 | |
573 | if (max_poll_time) |
648 | if (max_poll_time) |
574 | gettimeofday (&tv_start, 0); |
649 | gettimeofday (&tv_start, 0); |
575 | |
650 | |
576 | for (;;) |
651 | for (;;) |
… | |
… | |
637 | |
712 | |
638 | /*****************************************************************************/ |
713 | /*****************************************************************************/ |
639 | |
714 | |
640 | X_THREAD_PROC (bdb_proc) |
715 | X_THREAD_PROC (bdb_proc) |
641 | { |
716 | { |
642 | aio_req req; |
717 | bdb_req req; |
643 | struct timespec ts; |
718 | struct timespec ts; |
644 | worker *self = (worker *)thr_arg; |
719 | worker *self = (worker *)thr_arg; |
645 | |
720 | |
646 | /* try to distribute timeouts somewhat evenly */ |
721 | /* try to distribute timeouts somewhat evenly */ |
647 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
722 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
… | |
… | |
683 | } |
758 | } |
684 | |
759 | |
685 | --nready; |
760 | --nready; |
686 | |
761 | |
687 | X_UNLOCK (reqlock); |
762 | X_UNLOCK (reqlock); |
688 | |
763 | |
689 | switch (req->type) |
764 | switch (req->type) |
690 | { |
765 | { |
691 | case REQ_QUIT: |
766 | case REQ_QUIT: |
692 | req->result = ENOSYS; |
767 | req->result = ENOSYS; |
693 | goto quit; |
768 | goto quit; |
… | |
… | |
714 | |
789 | |
715 | case REQ_ENV_MEMP_TRICKLE: |
790 | case REQ_ENV_MEMP_TRICKLE: |
716 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
791 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
717 | break; |
792 | break; |
718 | |
793 | |
|
|
794 | case REQ_ENV_DBREMOVE: |
|
|
795 | req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1); |
|
|
796 | break; |
|
|
797 | |
|
|
798 | case REQ_ENV_DBRENAME: |
|
|
799 | req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1); |
|
|
800 | break; |
|
|
801 | |
719 | case REQ_DB_OPEN: |
802 | case REQ_DB_OPEN: |
720 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
803 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
721 | break; |
804 | break; |
722 | |
805 | |
723 | case REQ_DB_CLOSE: |
806 | case REQ_DB_CLOSE: |
724 | req->result = req->db->close (req->db, req->uint1); |
807 | req->result = req->db->close (req->db, req->uint1); |
725 | break; |
808 | break; |
726 | |
809 | |
|
|
810 | #if DB_VERSION_MINOR >= 4 |
727 | case REQ_DB_COMPACT: |
811 | case REQ_DB_COMPACT: |
728 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
812 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
729 | break; |
813 | break; |
|
|
814 | #endif |
730 | |
815 | |
731 | case REQ_DB_SYNC: |
816 | case REQ_DB_SYNC: |
732 | req->result = req->db->sync (req->db, req->uint1); |
817 | req->result = req->db->sync (req->db, req->uint1); |
733 | break; |
818 | break; |
734 | |
819 | |
|
|
820 | case REQ_DB_UPGRADE: |
|
|
821 | req->result = req->db->upgrade (req->db, req->buf1, req->uint1); |
|
|
822 | break; |
|
|
823 | |
735 | case REQ_DB_PUT: |
824 | case REQ_DB_PUT: |
736 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
825 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
737 | break; |
826 | break; |
738 | |
827 | |
|
|
828 | #if DB_VERSION_MINOR >= 6 |
|
|
829 | case REQ_DB_EXISTS: |
|
|
830 | req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
|
|
831 | break; |
|
|
832 | #endif |
739 | case REQ_DB_GET: |
833 | case REQ_DB_GET: |
740 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
834 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
741 | break; |
835 | break; |
742 | |
836 | |
743 | case REQ_DB_PGET: |
837 | case REQ_DB_PGET: |
… | |
… | |
797 | |
891 | |
798 | case REQ_C_DEL: |
892 | case REQ_C_DEL: |
799 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
893 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
800 | break; |
894 | break; |
801 | |
895 | |
|
|
896 | #if DB_VERSION_MINOR >= 3 |
802 | case REQ_SEQ_OPEN: |
897 | case REQ_SEQ_OPEN: |
803 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
898 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
804 | break; |
899 | break; |
805 | |
900 | |
806 | case REQ_SEQ_CLOSE: |
901 | case REQ_SEQ_CLOSE: |
… | |
… | |
812 | break; |
907 | break; |
813 | |
908 | |
814 | case REQ_SEQ_REMOVE: |
909 | case REQ_SEQ_REMOVE: |
815 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
910 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
816 | break; |
911 | break; |
|
|
912 | #endif |
817 | |
913 | |
818 | default: |
914 | default: |
819 | req->result = ENOSYS; |
915 | req->result = ENOSYS; |
820 | break; |
916 | break; |
821 | } |
917 | } |
… | |
… | |
861 | X_UNLOCK (wrklock); |
957 | X_UNLOCK (wrklock); |
862 | } |
958 | } |
863 | |
959 | |
864 | static void atfork_child (void) |
960 | static void atfork_child (void) |
865 | { |
961 | { |
866 | aio_req prv; |
962 | bdb_req prv; |
867 | |
963 | |
868 | while (prv = reqq_shift (&req_queue)) |
964 | while (prv = reqq_shift (&req_queue)) |
869 | req_free (prv); |
965 | req_free (prv); |
870 | |
966 | |
871 | while (prv = reqq_shift (&res_queue)) |
967 | while (prv = reqq_shift (&res_queue)) |
… | |
… | |
892 | |
988 | |
893 | atfork_parent (); |
989 | atfork_parent (); |
894 | } |
990 | } |
895 | |
991 | |
896 | #define dREQ(reqtype) \ |
992 | #define dREQ(reqtype) \ |
897 | aio_req req; \ |
993 | bdb_req req; \ |
898 | int req_pri = next_pri; \ |
994 | int req_pri = next_pri; \ |
899 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
995 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
900 | \ |
996 | \ |
901 | if (SvOK (callback) && !SvROK (callback)) \ |
997 | if (callback && SvOK (callback)) \ |
902 | croak ("callback must be undef or of reference type"); \ |
998 | croak ("callback has illegal type or extra arguments"); \ |
903 | \ |
999 | \ |
904 | Newz (0, req, 1, aio_cb); \ |
1000 | Newz (0, req, 1, bdb_cb); \ |
905 | if (!req) \ |
1001 | if (!req) \ |
906 | croak ("out of memory during aio_req allocation"); \ |
1002 | croak ("out of memory during bdb_req allocation"); \ |
907 | \ |
1003 | \ |
908 | req->callback = newSVsv (callback); \ |
1004 | req->callback = cb ? SvREFCNT_inc (cb) : 0; \ |
909 | req->type = (reqtype); \ |
1005 | req->type = (reqtype); \ |
910 | req->pri = req_pri |
1006 | req->pri = req_pri |
911 | |
1007 | |
912 | #define REQ_SEND \ |
1008 | #define REQ_SEND \ |
913 | req_send (req) |
1009 | req_send (req) |
914 | |
1010 | |
915 | #define SvPTR(var, arg, type, class, nullok) \ |
1011 | #define SvPTR(var, arg, type, class, nullok) \ |
916 | if (!SvOK (arg)) \ |
1012 | if (!SvOK (arg)) \ |
917 | { \ |
1013 | { \ |
918 | if (!nullok) \ |
1014 | if (nullok != 1) \ |
919 | croak (# var " must be a " # class " object, not undef"); \ |
1015 | croak (# var " must be a " # class " object, not undef"); \ |
920 | \ |
1016 | \ |
921 | (var) = 0; \ |
1017 | (var) = 0; \ |
922 | } \ |
1018 | } \ |
923 | else if (sv_derived_from ((arg), # class)) \ |
1019 | else if (sv_derived_from ((arg), # class)) \ |
924 | { \ |
1020 | { \ |
925 | IV tmp = SvIV ((SV*) SvRV (arg)); \ |
1021 | IV tmp = SvIV ((SV*) SvRV (arg)); \ |
926 | (var) = INT2PTR (type, tmp); \ |
1022 | (var) = INT2PTR (type, tmp); \ |
927 | if (!var) \ |
1023 | if (!var && nullok != 2) \ |
928 | croak (# var " is not a valid " # class " object anymore"); \ |
1024 | croak (# var " is not a valid " # class " object anymore"); \ |
929 | } \ |
1025 | } \ |
930 | else \ |
1026 | else \ |
931 | croak (# var " is not of type " # class); \ |
1027 | croak (# var " is not of type " # class); |
932 | \ |
|
|
933 | |
1028 | |
934 | static void |
1029 | static void |
935 | ptr_nuke (SV *sv) |
1030 | ptr_nuke (SV *sv) |
936 | { |
1031 | { |
937 | assert (SvROK (sv)); |
1032 | assert (SvROK (sv)); |
938 | sv_setiv (SvRV (sv), 0); |
1033 | sv_setiv (SvRV (sv), 0); |
939 | } |
1034 | } |
|
|
1035 | |
|
|
1036 | static int |
|
|
1037 | errno_get (pTHX_ SV *sv, MAGIC *mg) |
|
|
1038 | { |
|
|
1039 | if (*mg->mg_ptr == '!') // should always be the case |
|
|
1040 | if (-30999 <= errno && errno <= -30800) |
|
|
1041 | { |
|
|
1042 | sv_setnv (sv, (NV)errno); |
|
|
1043 | sv_setpv (sv, db_strerror (errno)); |
|
|
1044 | SvNOK_on (sv); /* what a wonderful hack! */ |
|
|
1045 | // ^^^ copied from perl sources |
|
|
1046 | return 0; |
|
|
1047 | } |
|
|
1048 | |
|
|
1049 | return PL_vtbl_sv.svt_get (aTHX_ sv, mg); |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | static MGVTBL vtbl_errno; |
|
|
1053 | |
|
|
1054 | // this wonderful hack :( patches perl's $! variable to support our errno values |
|
|
1055 | static void |
|
|
1056 | patch_errno (void) |
|
|
1057 | { |
|
|
1058 | SV *sv; |
|
|
1059 | MAGIC *mg; |
|
|
1060 | |
|
|
1061 | if (!(sv = get_sv ("!", 1))) |
|
|
1062 | return; |
|
|
1063 | |
|
|
1064 | if (!(mg = mg_find (sv, PERL_MAGIC_sv))) |
|
|
1065 | return; |
|
|
1066 | |
|
|
1067 | if (mg->mg_virtual != &PL_vtbl_sv) |
|
|
1068 | return; |
|
|
1069 | |
|
|
1070 | vtbl_errno = PL_vtbl_sv; |
|
|
1071 | vtbl_errno.svt_get = errno_get; |
|
|
1072 | mg->mg_virtual = &vtbl_errno; |
|
|
1073 | } |
|
|
1074 | |
|
|
1075 | #if __GNUC__ >= 4 |
|
|
1076 | # define noinline __attribute__ ((noinline)) |
|
|
1077 | #else |
|
|
1078 | # define noinline |
|
|
1079 | #endif |
|
|
1080 | |
|
|
1081 | static noinline SV * |
|
|
1082 | pop_callback (I32 *ritems, SV *sv) |
|
|
1083 | { |
|
|
1084 | if (SvROK (sv)) |
|
|
1085 | { |
|
|
1086 | HV *st; |
|
|
1087 | GV *gvp; |
|
|
1088 | CV *cv; |
|
|
1089 | const char *name; |
|
|
1090 | |
|
|
1091 | /* forgive me */ |
|
|
1092 | if (SvTYPE (SvRV (sv)) == SVt_PVMG |
|
|
1093 | && (st = SvSTASH (SvRV (sv))) |
|
|
1094 | && (name = HvNAME_get (st)) |
|
|
1095 | && (name [0] == 'B' && name [1] == 'D' && name [2] == 'B' && name [3] == ':')) |
|
|
1096 | return 0; |
|
|
1097 | |
|
|
1098 | if ((cv = sv_2cv (sv, &st, &gvp, 0))) |
|
|
1099 | { |
|
|
1100 | --*ritems; |
|
|
1101 | return (SV *)cv; |
|
|
1102 | } |
|
|
1103 | } |
|
|
1104 | |
|
|
1105 | return 0; |
|
|
1106 | } |
|
|
1107 | |
|
|
1108 | /* stupid windoes defined CALLBACK as well */ |
|
|
1109 | #undef CALLBACK |
|
|
1110 | #define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); |
940 | |
1111 | |
941 | MODULE = BDB PACKAGE = BDB |
1112 | MODULE = BDB PACKAGE = BDB |
942 | |
1113 | |
943 | PROTOTYPES: ENABLE |
1114 | PROTOTYPES: ENABLE |
944 | |
1115 | |
… | |
… | |
965 | const_iv (RDONLY) |
1136 | const_iv (RDONLY) |
966 | const_iv (USE_ENVIRON) |
1137 | const_iv (USE_ENVIRON) |
967 | const_iv (USE_ENVIRON_ROOT) |
1138 | const_iv (USE_ENVIRON_ROOT) |
968 | const_iv (LOCKDOWN) |
1139 | const_iv (LOCKDOWN) |
969 | const_iv (PRIVATE) |
1140 | const_iv (PRIVATE) |
970 | const_iv (REGISTER) |
|
|
971 | const_iv (SYSTEM_MEM) |
1141 | const_iv (SYSTEM_MEM) |
972 | const_iv (AUTO_COMMIT) |
1142 | const_iv (AUTO_COMMIT) |
973 | const_iv (CDB_ALLDB) |
1143 | const_iv (CDB_ALLDB) |
974 | const_iv (DIRECT_DB) |
1144 | const_iv (DIRECT_DB) |
975 | const_iv (DIRECT_LOG) |
|
|
976 | const_iv (DSYNC_DB) |
|
|
977 | const_iv (DSYNC_LOG) |
|
|
978 | const_iv (LOG_AUTOREMOVE) |
|
|
979 | const_iv (LOG_INMEMORY) |
|
|
980 | const_iv (NOLOCKING) |
1145 | const_iv (NOLOCKING) |
981 | const_iv (NOMMAP) |
1146 | const_iv (NOMMAP) |
982 | const_iv (NOPANIC) |
1147 | const_iv (NOPANIC) |
983 | const_iv (OVERWRITE) |
1148 | const_iv (OVERWRITE) |
984 | const_iv (PANIC_ENVIRONMENT) |
1149 | const_iv (PANIC_ENVIRONMENT) |
… | |
… | |
995 | const_iv (HASH) |
1160 | const_iv (HASH) |
996 | const_iv (QUEUE) |
1161 | const_iv (QUEUE) |
997 | const_iv (RECNO) |
1162 | const_iv (RECNO) |
998 | const_iv (UNKNOWN) |
1163 | const_iv (UNKNOWN) |
999 | const_iv (EXCL) |
1164 | const_iv (EXCL) |
1000 | const_iv (READ_COMMITTED) |
|
|
1001 | const_iv (READ_UNCOMMITTED) |
|
|
1002 | const_iv (TRUNCATE) |
1165 | const_iv (TRUNCATE) |
1003 | const_iv (NOSYNC) |
1166 | const_iv (NOSYNC) |
1004 | const_iv (CHKSUM) |
1167 | const_iv (CHKSUM) |
1005 | const_iv (ENCRYPT) |
1168 | const_iv (ENCRYPT) |
1006 | const_iv (DUP) |
1169 | const_iv (DUP) |
1007 | const_iv (DUPSORT) |
1170 | const_iv (DUPSORT) |
1008 | const_iv (RECNUM) |
1171 | const_iv (RECNUM) |
1009 | const_iv (RENUMBER) |
1172 | const_iv (RENUMBER) |
1010 | const_iv (REVSPLITOFF) |
1173 | const_iv (REVSPLITOFF) |
1011 | const_iv (INORDER) |
|
|
1012 | const_iv (CONSUME) |
1174 | const_iv (CONSUME) |
1013 | const_iv (CONSUME_WAIT) |
1175 | const_iv (CONSUME_WAIT) |
1014 | const_iv (GET_BOTH) |
1176 | const_iv (GET_BOTH) |
1015 | const_iv (GET_BOTH_RANGE) |
1177 | const_iv (GET_BOTH_RANGE) |
1016 | //const_iv (SET_RECNO) |
1178 | //const_iv (SET_RECNO) |
1017 | //const_iv (MULTIPLE) |
1179 | //const_iv (MULTIPLE) |
1018 | const_iv (SNAPSHOT) |
1180 | const_iv (SNAPSHOT) |
1019 | const_iv (JOIN_ITEM) |
1181 | const_iv (JOIN_ITEM) |
|
|
1182 | const_iv (JOIN_NOSORT) |
1020 | const_iv (RMW) |
1183 | const_iv (RMW) |
1021 | |
1184 | |
1022 | const_iv (NOTFOUND) |
1185 | const_iv (NOTFOUND) |
1023 | const_iv (KEYEMPTY) |
1186 | const_iv (KEYEMPTY) |
1024 | const_iv (LOCK_DEADLOCK) |
1187 | const_iv (LOCK_DEADLOCK) |
1025 | const_iv (LOCK_NOTGRANTED) |
1188 | const_iv (LOCK_NOTGRANTED) |
1026 | const_iv (RUNRECOVERY) |
1189 | const_iv (RUNRECOVERY) |
1027 | const_iv (OLD_VERSION) |
1190 | const_iv (OLD_VERSION) |
1028 | const_iv (REP_HANDLE_DEAD) |
1191 | const_iv (REP_HANDLE_DEAD) |
1029 | const_iv (REP_LOCKOUT) |
|
|
1030 | const_iv (SECONDARY_BAD) |
1192 | const_iv (SECONDARY_BAD) |
1031 | |
|
|
1032 | const_iv (FREE_SPACE) |
|
|
1033 | const_iv (FREELIST_ONLY) |
|
|
1034 | |
1193 | |
1035 | const_iv (APPEND) |
1194 | const_iv (APPEND) |
1036 | const_iv (NODUPDATA) |
1195 | const_iv (NODUPDATA) |
1037 | const_iv (NOOVERWRITE) |
1196 | const_iv (NOOVERWRITE) |
1038 | |
1197 | |
… | |
… | |
1040 | const_iv (TXN_SYNC) |
1199 | const_iv (TXN_SYNC) |
1041 | |
1200 | |
1042 | const_iv (SET_LOCK_TIMEOUT) |
1201 | const_iv (SET_LOCK_TIMEOUT) |
1043 | const_iv (SET_TXN_TIMEOUT) |
1202 | const_iv (SET_TXN_TIMEOUT) |
1044 | |
1203 | |
1045 | const_iv (JOIN_ITEM) |
|
|
1046 | const_iv (FIRST) |
1204 | const_iv (FIRST) |
1047 | const_iv (NEXT) |
1205 | const_iv (NEXT) |
1048 | const_iv (NEXT_DUP) |
1206 | const_iv (NEXT_DUP) |
1049 | const_iv (NEXT_NODUP) |
1207 | const_iv (NEXT_NODUP) |
1050 | const_iv (PREV) |
1208 | const_iv (PREV) |
… | |
… | |
1062 | const_iv (FORCE) |
1220 | const_iv (FORCE) |
1063 | |
1221 | |
1064 | const_iv (LOCK_DEFAULT) |
1222 | const_iv (LOCK_DEFAULT) |
1065 | const_iv (LOCK_EXPIRE) |
1223 | const_iv (LOCK_EXPIRE) |
1066 | const_iv (LOCK_MAXLOCKS) |
1224 | const_iv (LOCK_MAXLOCKS) |
1067 | const_iv (LOCK_MAXWRITE) |
|
|
1068 | const_iv (LOCK_MINLOCKS) |
1225 | const_iv (LOCK_MINLOCKS) |
1069 | const_iv (LOCK_MINWRITE) |
1226 | const_iv (LOCK_MINWRITE) |
1070 | const_iv (LOCK_OLDEST) |
1227 | const_iv (LOCK_OLDEST) |
1071 | const_iv (LOCK_RANDOM) |
1228 | const_iv (LOCK_RANDOM) |
1072 | const_iv (LOCK_YOUNGEST) |
1229 | const_iv (LOCK_YOUNGEST) |
1073 | |
1230 | |
1074 | const_iv (SEQ_DEC) |
|
|
1075 | const_iv (SEQ_INC) |
|
|
1076 | const_iv (SEQ_WRAP) |
|
|
1077 | |
|
|
1078 | const_iv (BUFFER_SMALL) |
|
|
1079 | const_iv (DONOTINDEX) |
1231 | const_iv (DONOTINDEX) |
1080 | const_iv (KEYEMPTY ) |
1232 | const_iv (KEYEMPTY ) |
1081 | const_iv (KEYEXIST ) |
1233 | const_iv (KEYEXIST ) |
1082 | const_iv (LOCK_DEADLOCK) |
1234 | const_iv (LOCK_DEADLOCK) |
1083 | const_iv (LOCK_NOTGRANTED) |
1235 | const_iv (LOCK_NOTGRANTED) |
1084 | const_iv (LOG_BUFFER_FULL) |
|
|
1085 | const_iv (NOSERVER) |
1236 | const_iv (NOSERVER) |
1086 | const_iv (NOSERVER_HOME) |
1237 | const_iv (NOSERVER_HOME) |
1087 | const_iv (NOSERVER_ID) |
1238 | const_iv (NOSERVER_ID) |
1088 | const_iv (NOTFOUND) |
1239 | const_iv (NOTFOUND) |
1089 | const_iv (OLD_VERSION) |
|
|
1090 | const_iv (PAGE_NOTFOUND) |
1240 | const_iv (PAGE_NOTFOUND) |
1091 | const_iv (REP_DUPMASTER) |
1241 | const_iv (REP_DUPMASTER) |
1092 | const_iv (REP_HANDLE_DEAD) |
1242 | const_iv (REP_HANDLE_DEAD) |
1093 | const_iv (REP_HOLDELECTION) |
1243 | const_iv (REP_HOLDELECTION) |
1094 | const_iv (REP_IGNORE) |
|
|
1095 | const_iv (REP_ISPERM) |
1244 | const_iv (REP_ISPERM) |
1096 | const_iv (REP_JOIN_FAILURE) |
|
|
1097 | const_iv (REP_LOCKOUT) |
|
|
1098 | const_iv (REP_NEWMASTER) |
1245 | const_iv (REP_NEWMASTER) |
1099 | const_iv (REP_NEWSITE) |
1246 | const_iv (REP_NEWSITE) |
1100 | const_iv (REP_NOTPERM) |
1247 | const_iv (REP_NOTPERM) |
1101 | const_iv (REP_UNAVAIL) |
1248 | const_iv (REP_UNAVAIL) |
1102 | const_iv (RUNRECOVERY) |
1249 | const_iv (RUNRECOVERY) |
1103 | const_iv (SECONDARY_BAD) |
1250 | const_iv (SECONDARY_BAD) |
1104 | const_iv (VERIFY_BAD) |
1251 | const_iv (VERIFY_BAD) |
1105 | const_iv (VERSION_MISMATCH) |
|
|
1106 | |
1252 | |
1107 | const_iv (VERB_DEADLOCK) |
1253 | const_iv (VERB_DEADLOCK) |
1108 | const_iv (VERB_RECOVERY) |
1254 | const_iv (VERB_RECOVERY) |
1109 | const_iv (VERB_REGISTER) |
|
|
1110 | const_iv (VERB_REPLICATION) |
1255 | const_iv (VERB_REPLICATION) |
1111 | const_iv (VERB_WAITSFOR) |
1256 | const_iv (VERB_WAITSFOR) |
1112 | |
1257 | |
1113 | const_iv (VERSION_MAJOR) |
1258 | const_iv (VERSION_MAJOR) |
1114 | const_iv (VERSION_MINOR) |
1259 | const_iv (VERSION_MINOR) |
1115 | const_iv (VERSION_PATCH) |
1260 | const_iv (VERSION_PATCH) |
|
|
1261 | #if DB_VERSION_MINOR >= 3 |
|
|
1262 | const_iv (INORDER) |
|
|
1263 | const_iv (LOCK_MAXWRITE) |
|
|
1264 | const_iv (SEQ_DEC) |
|
|
1265 | const_iv (SEQ_INC) |
|
|
1266 | const_iv (SEQ_WRAP) |
|
|
1267 | const_iv (BUFFER_SMALL) |
|
|
1268 | const_iv (LOG_BUFFER_FULL) |
|
|
1269 | const_iv (VERSION_MISMATCH) |
|
|
1270 | #endif |
|
|
1271 | #if DB_VERSION_MINOR >= 4 |
|
|
1272 | const_iv (REGISTER) |
|
|
1273 | const_iv (DSYNC_DB) |
|
|
1274 | const_iv (READ_COMMITTED) |
|
|
1275 | const_iv (READ_UNCOMMITTED) |
|
|
1276 | const_iv (REP_IGNORE) |
|
|
1277 | const_iv (REP_LOCKOUT) |
|
|
1278 | const_iv (REP_JOIN_FAILURE) |
|
|
1279 | const_iv (FREE_SPACE) |
|
|
1280 | const_iv (FREELIST_ONLY) |
|
|
1281 | const_iv (VERB_REGISTER) |
|
|
1282 | #endif |
1116 | #if DB_VERSION_MINOR >= 5 |
1283 | #if DB_VERSION_MINOR >= 5 |
1117 | const_iv (MULTIVERSION) |
1284 | const_iv (MULTIVERSION) |
1118 | const_iv (TXN_SNAPSHOT) |
1285 | const_iv (TXN_SNAPSHOT) |
1119 | #endif |
1286 | #endif |
1120 | #if DB_VERSION_MINOR >= 6 |
1287 | #if DB_VERSION_MINOR >= 6 |
1121 | const_iv (PREV_DUP) |
1288 | const_iv (PREV_DUP) |
1122 | # if 0 |
|
|
1123 | const_iv (PRIORITY_UNCHANGED) |
1289 | const_iv (PRIORITY_UNCHANGED) |
1124 | const_iv (PRIORITY_VERY_LOW) |
1290 | const_iv (PRIORITY_VERY_LOW) |
1125 | const_iv (PRIORITY_LOW) |
1291 | const_iv (PRIORITY_LOW) |
1126 | const_iv (PRIORITY_DEFAULT) |
1292 | const_iv (PRIORITY_DEFAULT) |
1127 | const_iv (PRIORITY_HIGH) |
1293 | const_iv (PRIORITY_HIGH) |
1128 | const_iv (PRIORITY_VERY_HIGH) |
1294 | const_iv (PRIORITY_VERY_HIGH) |
|
|
1295 | #endif |
|
|
1296 | #if DB_VERSION_MINOR >= 7 |
|
|
1297 | const_iv (LOG_DIRECT) |
|
|
1298 | const_iv (LOG_DSYNC) |
|
|
1299 | const_iv (LOG_AUTO_REMOVE) |
|
|
1300 | const_iv (LOG_IN_MEMORY) |
|
|
1301 | const_iv (LOG_ZERO) |
|
|
1302 | #else |
|
|
1303 | const_iv (DIRECT_LOG) |
|
|
1304 | const_iv (LOG_AUTOREMOVE) |
|
|
1305 | # if DB_VERSION_MINOR >= 3 |
|
|
1306 | const_iv (DSYNC_LOG) |
|
|
1307 | const_iv (LOG_INMEMORY) |
1129 | # endif |
1308 | # endif |
1130 | #endif |
1309 | #endif |
1131 | }; |
1310 | }; |
1132 | |
1311 | |
1133 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1312 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1134 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1313 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1135 | |
1314 | |
1136 | newCONSTSUB (stash, "DB_VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1)); |
1315 | { |
|
|
1316 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
|
|
1317 | char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; |
|
|
1318 | |
|
|
1319 | newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); |
|
|
1320 | } |
|
|
1321 | |
1137 | newCONSTSUB (stash, "DB_VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1322 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1138 | |
1323 | |
1139 | create_respipe (); |
1324 | create_respipe (); |
1140 | |
1325 | |
1141 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1326 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1142 | #ifdef _WIN32 |
1327 | patch_errno (); |
1143 | X_MUTEX_CHECK (wrklock); |
|
|
1144 | X_MUTEX_CHECK (reslock); |
|
|
1145 | X_MUTEX_CHECK (reqlock); |
|
|
1146 | |
|
|
1147 | X_COND_CHECK (reqwait); |
|
|
1148 | #endif |
|
|
1149 | } |
1328 | } |
1150 | |
1329 | |
1151 | void |
1330 | void |
1152 | max_poll_reqs (int nreqs) |
1331 | max_poll_reqs (int nreqs) |
1153 | PROTOTYPE: $ |
1332 | PROTOTYPE: $ |
… | |
… | |
1293 | CODE: |
1472 | CODE: |
1294 | RETVAL = db_strerror (errorno); |
1473 | RETVAL = db_strerror (errorno); |
1295 | OUTPUT: |
1474 | OUTPUT: |
1296 | RETVAL |
1475 | RETVAL |
1297 | |
1476 | |
|
|
1477 | void _on_next_submit (SV *cb) |
|
|
1478 | CODE: |
|
|
1479 | SvREFCNT_dec (on_next_submit); |
|
|
1480 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
|
|
1481 | |
1298 | DB_ENV * |
1482 | DB_ENV * |
1299 | db_env_create (U32 env_flags = 0) |
1483 | db_env_create (U32 env_flags = 0) |
1300 | CODE: |
1484 | CODE: |
1301 | { |
1485 | { |
1302 | errno = db_env_create (&RETVAL, env_flags); |
1486 | errno = db_env_create (&RETVAL, env_flags); |
… | |
… | |
1311 | } |
1495 | } |
1312 | OUTPUT: |
1496 | OUTPUT: |
1313 | RETVAL |
1497 | RETVAL |
1314 | |
1498 | |
1315 | void |
1499 | void |
1316 | db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) |
1500 | db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) |
|
|
1501 | PREINIT: |
|
|
1502 | CALLBACK |
1317 | CODE: |
1503 | CODE: |
1318 | { |
1504 | { |
1319 | dREQ (REQ_ENV_OPEN); |
1505 | dREQ (REQ_ENV_OPEN); |
1320 | |
|
|
1321 | env->set_thread_count (env, wanted + 2); |
|
|
1322 | |
|
|
1323 | req->env = env; |
1506 | req->env = env; |
1324 | req->uint1 = open_flags | DB_THREAD; |
1507 | req->uint1 = open_flags | DB_THREAD; |
1325 | req->int1 = mode; |
1508 | req->int1 = mode; |
1326 | req->buf1 = strdup_ornull (db_home); |
1509 | req->buf1 = strdup_ornull (db_home); |
1327 | REQ_SEND; |
1510 | REQ_SEND; |
1328 | } |
1511 | } |
1329 | |
1512 | |
1330 | void |
1513 | void |
1331 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = &PL_sv_undef) |
1514 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) |
|
|
1515 | PREINIT: |
|
|
1516 | CALLBACK |
1332 | CODE: |
1517 | CODE: |
1333 | { |
1518 | { |
1334 | dREQ (REQ_ENV_CLOSE); |
1519 | dREQ (REQ_ENV_CLOSE); |
1335 | req->env = env; |
1520 | req->env = env; |
1336 | req->uint1 = flags; |
1521 | req->uint1 = flags; |
1337 | REQ_SEND; |
1522 | REQ_SEND; |
1338 | ptr_nuke (ST (0)); |
1523 | ptr_nuke (ST (0)); |
1339 | } |
1524 | } |
1340 | |
1525 | |
1341 | void |
1526 | void |
1342 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1527 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) |
|
|
1528 | PREINIT: |
|
|
1529 | CALLBACK |
1343 | CODE: |
1530 | CODE: |
1344 | { |
1531 | { |
1345 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1532 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1346 | req->env = env; |
1533 | req->env = env; |
1347 | req->uint1 = kbyte; |
1534 | req->uint1 = kbyte; |
… | |
… | |
1349 | req->uint2 = flags; |
1536 | req->uint2 = flags; |
1350 | REQ_SEND; |
1537 | REQ_SEND; |
1351 | } |
1538 | } |
1352 | |
1539 | |
1353 | void |
1540 | void |
1354 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1541 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) |
|
|
1542 | PREINIT: |
|
|
1543 | CALLBACK |
1355 | CODE: |
1544 | CODE: |
1356 | { |
1545 | { |
1357 | dREQ (REQ_ENV_LOCK_DETECT); |
1546 | dREQ (REQ_ENV_LOCK_DETECT); |
1358 | req->env = env; |
1547 | req->env = env; |
1359 | req->uint1 = flags; |
1548 | req->uint1 = flags; |
1360 | req->uint2 = atype; |
1549 | req->uint2 = atype; |
|
|
1550 | /* req->int2 = 0; dummy */ |
1361 | REQ_SEND; |
1551 | REQ_SEND; |
1362 | } |
1552 | } |
1363 | |
1553 | |
1364 | void |
1554 | void |
1365 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1555 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
|
|
1556 | PREINIT: |
|
|
1557 | CALLBACK |
1366 | CODE: |
1558 | CODE: |
1367 | { |
1559 | { |
1368 | dREQ (REQ_ENV_MEMP_SYNC); |
1560 | dREQ (REQ_ENV_MEMP_SYNC); |
1369 | req->env = env; |
1561 | req->env = env; |
1370 | REQ_SEND; |
1562 | REQ_SEND; |
1371 | } |
1563 | } |
1372 | |
1564 | |
1373 | void |
1565 | void |
1374 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1566 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
|
|
1567 | PREINIT: |
|
|
1568 | CALLBACK |
1375 | CODE: |
1569 | CODE: |
1376 | { |
1570 | { |
1377 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1571 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1378 | req->env = env; |
1572 | req->env = env; |
1379 | req->int1 = percent; |
1573 | req->int1 = percent; |
1380 | REQ_SEND; |
1574 | REQ_SEND; |
1381 | } |
1575 | } |
1382 | |
1576 | |
|
|
1577 | void |
|
|
1578 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
|
|
1579 | PREINIT: |
|
|
1580 | CALLBACK |
|
|
1581 | CODE: |
|
|
1582 | { |
|
|
1583 | dREQ (REQ_ENV_DBREMOVE); |
|
|
1584 | req->env = env; |
|
|
1585 | req->buf1 = strdup_ornull (file); |
|
|
1586 | req->buf2 = strdup_ornull (database); |
|
|
1587 | req->uint1 = flags; |
|
|
1588 | REQ_SEND; |
|
|
1589 | } |
|
|
1590 | |
|
|
1591 | void |
|
|
1592 | db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) |
|
|
1593 | PREINIT: |
|
|
1594 | CALLBACK |
|
|
1595 | CODE: |
|
|
1596 | { |
|
|
1597 | dREQ (REQ_ENV_DBRENAME); |
|
|
1598 | req->env = env; |
|
|
1599 | req->buf1 = strdup_ornull (file); |
|
|
1600 | req->buf2 = strdup_ornull (database); |
|
|
1601 | req->buf3 = strdup_ornull (newname); |
|
|
1602 | req->uint1 = flags; |
|
|
1603 | REQ_SEND; |
|
|
1604 | } |
1383 | |
1605 | |
1384 | DB * |
1606 | DB * |
1385 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1607 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1386 | CODE: |
1608 | CODE: |
1387 | { |
1609 | { |
… | |
… | |
1394 | } |
1616 | } |
1395 | OUTPUT: |
1617 | OUTPUT: |
1396 | RETVAL |
1618 | RETVAL |
1397 | |
1619 | |
1398 | void |
1620 | void |
1399 | db_open (DB *db, DB_TXN_ornull *txnid, octetstring file, octetstring database, int type, U32 flags, int mode, SV *callback = &PL_sv_undef) |
1621 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
|
|
1622 | PREINIT: |
|
|
1623 | CALLBACK |
1400 | CODE: |
1624 | CODE: |
1401 | { |
1625 | { |
1402 | dREQ (REQ_DB_OPEN); |
1626 | dREQ (REQ_DB_OPEN); |
1403 | req->db = db; |
1627 | req->db = db; |
1404 | req->txn = txnid; |
1628 | req->txn = txnid; |
… | |
… | |
1409 | req->int2 = mode; |
1633 | req->int2 = mode; |
1410 | REQ_SEND; |
1634 | REQ_SEND; |
1411 | } |
1635 | } |
1412 | |
1636 | |
1413 | void |
1637 | void |
1414 | db_close (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1638 | db_close (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1639 | PREINIT: |
|
|
1640 | CALLBACK |
1415 | CODE: |
1641 | CODE: |
1416 | { |
1642 | { |
1417 | dREQ (REQ_DB_CLOSE); |
1643 | dREQ (REQ_DB_CLOSE); |
1418 | req->db = db; |
1644 | req->db = db; |
1419 | req->uint1 = flags; |
1645 | req->uint1 = flags; |
1420 | req->sv1 = (SV *)db->app_private; |
1646 | req->sv1 = (SV *)db->app_private; |
1421 | REQ_SEND; |
1647 | REQ_SEND; |
1422 | ptr_nuke (ST (0)); |
1648 | ptr_nuke (ST (0)); |
1423 | } |
1649 | } |
1424 | |
1650 | |
|
|
1651 | #if DB_VERSION_MINOR >= 4 |
|
|
1652 | |
1425 | void |
1653 | void |
1426 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = &PL_sv_undef) |
1654 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = 0) |
|
|
1655 | PREINIT: |
|
|
1656 | CALLBACK |
1427 | CODE: |
1657 | CODE: |
1428 | { |
1658 | { |
1429 | dREQ (REQ_DB_COMPACT); |
1659 | dREQ (REQ_DB_COMPACT); |
1430 | req->db = db; |
1660 | req->db = db; |
1431 | req->txn = txn; |
1661 | req->txn = txn; |
… | |
… | |
1433 | sv_to_dbt (&req->dbt2, stop); |
1663 | sv_to_dbt (&req->dbt2, stop); |
1434 | req->uint1 = flags; |
1664 | req->uint1 = flags; |
1435 | REQ_SEND; |
1665 | REQ_SEND; |
1436 | } |
1666 | } |
1437 | |
1667 | |
|
|
1668 | #endif |
|
|
1669 | |
1438 | void |
1670 | void |
1439 | db_sync (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1671 | db_sync (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1672 | PREINIT: |
|
|
1673 | CALLBACK |
1440 | CODE: |
1674 | CODE: |
1441 | { |
1675 | { |
1442 | dREQ (REQ_DB_SYNC); |
1676 | dREQ (REQ_DB_SYNC); |
1443 | req->db = db; |
1677 | req->db = db; |
1444 | req->uint1 = flags; |
1678 | req->uint1 = flags; |
1445 | REQ_SEND; |
1679 | REQ_SEND; |
1446 | } |
1680 | } |
1447 | |
1681 | |
1448 | void |
1682 | void |
|
|
1683 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
|
|
1684 | PREINIT: |
|
|
1685 | CALLBACK |
|
|
1686 | CODE: |
|
|
1687 | { |
|
|
1688 | dREQ (REQ_DB_SYNC); |
|
|
1689 | req->db = db; |
|
|
1690 | req->buf1 = strdup (file); |
|
|
1691 | req->uint1 = flags; |
|
|
1692 | REQ_SEND; |
|
|
1693 | } |
|
|
1694 | |
|
|
1695 | void |
1449 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = &PL_sv_undef) |
1696 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = 0) |
|
|
1697 | PREINIT: |
|
|
1698 | CALLBACK |
1450 | CODE: |
1699 | CODE: |
1451 | { |
1700 | { |
1452 | dREQ (REQ_DB_KEY_RANGE); |
1701 | dREQ (REQ_DB_KEY_RANGE); |
1453 | req->db = db; |
1702 | req->db = db; |
1454 | req->txn = txn; |
1703 | req->txn = txn; |
… | |
… | |
1457 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1706 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1458 | REQ_SEND; |
1707 | REQ_SEND; |
1459 | } |
1708 | } |
1460 | |
1709 | |
1461 | void |
1710 | void |
1462 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1711 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1712 | PREINIT: |
|
|
1713 | CALLBACK |
1463 | CODE: |
1714 | CODE: |
1464 | { |
1715 | { |
1465 | dREQ (REQ_DB_PUT); |
1716 | dREQ (REQ_DB_PUT); |
1466 | req->db = db; |
1717 | req->db = db; |
1467 | req->txn = txn; |
1718 | req->txn = txn; |
… | |
… | |
1469 | sv_to_dbt (&req->dbt2, data); |
1720 | sv_to_dbt (&req->dbt2, data); |
1470 | req->uint1 = flags; |
1721 | req->uint1 = flags; |
1471 | REQ_SEND; |
1722 | REQ_SEND; |
1472 | } |
1723 | } |
1473 | |
1724 | |
|
|
1725 | #if DB_VERSION_MINOR >= 6 |
|
|
1726 | |
1474 | void |
1727 | void |
|
|
1728 | db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1729 | PREINIT: |
|
|
1730 | CALLBACK |
|
|
1731 | CODE: |
|
|
1732 | { |
|
|
1733 | dREQ (REQ_DB_EXISTS); |
|
|
1734 | req->db = db; |
|
|
1735 | req->txn = txn; |
|
|
1736 | req->uint1 = flags; |
|
|
1737 | sv_to_dbt (&req->dbt1, key); |
|
|
1738 | REQ_SEND; |
|
|
1739 | } |
|
|
1740 | |
|
|
1741 | #endif |
|
|
1742 | |
|
|
1743 | void |
1475 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1744 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1745 | PREINIT: |
|
|
1746 | CALLBACK |
1476 | CODE: |
1747 | CODE: |
|
|
1748 | if (SvREADONLY (data)) |
|
|
1749 | croak ("can't modify read-only data scalar in db_get"); |
1477 | { |
1750 | { |
1478 | dREQ (REQ_DB_GET); |
1751 | dREQ (REQ_DB_GET); |
1479 | req->db = db; |
1752 | req->db = db; |
1480 | req->txn = txn; |
1753 | req->txn = txn; |
1481 | req->uint1 = flags; |
1754 | req->uint1 = flags; |
… | |
… | |
1484 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1757 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1485 | REQ_SEND; |
1758 | REQ_SEND; |
1486 | } |
1759 | } |
1487 | |
1760 | |
1488 | void |
1761 | void |
1489 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1762 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1763 | PREINIT: |
|
|
1764 | CALLBACK |
1490 | CODE: |
1765 | CODE: |
|
|
1766 | if (SvREADONLY (data)) |
|
|
1767 | croak ("can't modify read-only data scalar in db_pget"); |
1491 | { |
1768 | { |
1492 | dREQ (REQ_DB_PGET); |
1769 | dREQ (REQ_DB_PGET); |
1493 | req->db = db; |
1770 | req->db = db; |
1494 | req->txn = txn; |
1771 | req->txn = txn; |
1495 | req->uint1 = flags; |
1772 | req->uint1 = flags; |
… | |
… | |
1499 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1776 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1500 | REQ_SEND; |
1777 | REQ_SEND; |
1501 | } |
1778 | } |
1502 | |
1779 | |
1503 | void |
1780 | void |
1504 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1781 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1782 | PREINIT: |
|
|
1783 | CALLBACK |
1505 | CODE: |
1784 | CODE: |
1506 | { |
1785 | { |
1507 | dREQ (REQ_DB_DEL); |
1786 | dREQ (REQ_DB_DEL); |
1508 | req->db = db; |
1787 | req->db = db; |
1509 | req->txn = txn; |
1788 | req->txn = txn; |
… | |
… | |
1511 | sv_to_dbt (&req->dbt1, key); |
1790 | sv_to_dbt (&req->dbt1, key); |
1512 | REQ_SEND; |
1791 | REQ_SEND; |
1513 | } |
1792 | } |
1514 | |
1793 | |
1515 | void |
1794 | void |
1516 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1795 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1796 | PREINIT: |
|
|
1797 | CALLBACK |
1517 | CODE: |
1798 | CODE: |
1518 | { |
1799 | { |
1519 | dREQ (REQ_TXN_COMMIT); |
1800 | dREQ (REQ_TXN_COMMIT); |
1520 | req->txn = txn; |
1801 | req->txn = txn; |
1521 | req->uint1 = flags; |
1802 | req->uint1 = flags; |
1522 | REQ_SEND; |
1803 | REQ_SEND; |
1523 | ptr_nuke (ST (0)); |
1804 | ptr_nuke (ST (0)); |
1524 | } |
1805 | } |
1525 | |
1806 | |
1526 | void |
1807 | void |
1527 | db_txn_abort (DB_TXN *txn, SV *callback = &PL_sv_undef) |
1808 | db_txn_abort (DB_TXN *txn, SV *callback = 0) |
|
|
1809 | PREINIT: |
|
|
1810 | CALLBACK |
1528 | CODE: |
1811 | CODE: |
1529 | { |
1812 | { |
1530 | dREQ (REQ_TXN_ABORT); |
1813 | dREQ (REQ_TXN_ABORT); |
1531 | req->txn = txn; |
1814 | req->txn = txn; |
1532 | REQ_SEND; |
1815 | REQ_SEND; |
1533 | ptr_nuke (ST (0)); |
1816 | ptr_nuke (ST (0)); |
1534 | } |
1817 | } |
1535 | |
1818 | |
1536 | void |
1819 | void |
1537 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1820 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1821 | PREINIT: |
|
|
1822 | CALLBACK |
1538 | CODE: |
1823 | CODE: |
1539 | { |
1824 | { |
1540 | dREQ (REQ_TXN_FINISH); |
1825 | dREQ (REQ_TXN_FINISH); |
1541 | req->txn = txn; |
1826 | req->txn = txn; |
1542 | req->uint1 = flags; |
1827 | req->uint1 = flags; |
1543 | REQ_SEND; |
1828 | REQ_SEND; |
1544 | ptr_nuke (ST (0)); |
1829 | ptr_nuke (ST (0)); |
1545 | } |
1830 | } |
1546 | |
1831 | |
1547 | void |
1832 | void |
1548 | db_c_close (DBC *dbc, SV *callback = &PL_sv_undef) |
1833 | db_c_close (DBC *dbc, SV *callback = 0) |
|
|
1834 | PREINIT: |
|
|
1835 | CALLBACK |
1549 | CODE: |
1836 | CODE: |
1550 | { |
1837 | { |
1551 | dREQ (REQ_C_CLOSE); |
1838 | dREQ (REQ_C_CLOSE); |
1552 | req->dbc = dbc; |
1839 | req->dbc = dbc; |
1553 | REQ_SEND; |
1840 | REQ_SEND; |
1554 | ptr_nuke (ST (0)); |
1841 | ptr_nuke (ST (0)); |
1555 | } |
1842 | } |
1556 | |
1843 | |
1557 | void |
1844 | void |
1558 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = &PL_sv_undef) |
1845 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) |
|
|
1846 | PREINIT: |
|
|
1847 | CALLBACK |
1559 | CODE: |
1848 | CODE: |
1560 | { |
1849 | { |
1561 | dREQ (REQ_C_COUNT); |
1850 | dREQ (REQ_C_COUNT); |
1562 | req->dbc = dbc; |
1851 | req->dbc = dbc; |
1563 | req->sv1 = SvREFCNT_inc (count); |
1852 | req->sv1 = SvREFCNT_inc (count); |
1564 | REQ_SEND; |
1853 | REQ_SEND; |
1565 | } |
1854 | } |
1566 | |
1855 | |
1567 | void |
1856 | void |
1568 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1857 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1858 | PREINIT: |
|
|
1859 | CALLBACK |
1569 | CODE: |
1860 | CODE: |
1570 | { |
1861 | { |
1571 | dREQ (REQ_C_PUT); |
1862 | dREQ (REQ_C_PUT); |
1572 | req->dbc = dbc; |
1863 | req->dbc = dbc; |
1573 | sv_to_dbt (&req->dbt1, key); |
1864 | sv_to_dbt (&req->dbt1, key); |
… | |
… | |
1575 | req->uint1 = flags; |
1866 | req->uint1 = flags; |
1576 | REQ_SEND; |
1867 | REQ_SEND; |
1577 | } |
1868 | } |
1578 | |
1869 | |
1579 | void |
1870 | void |
1580 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1871 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1872 | PREINIT: |
|
|
1873 | CALLBACK |
1581 | CODE: |
1874 | CODE: |
1582 | { |
1875 | { |
1583 | dREQ (REQ_C_GET); |
1876 | dREQ (REQ_C_GET); |
1584 | req->dbc = dbc; |
1877 | req->dbc = dbc; |
1585 | req->uint1 = flags; |
1878 | req->uint1 = flags; |
… | |
… | |
1600 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1893 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1601 | REQ_SEND; |
1894 | REQ_SEND; |
1602 | } |
1895 | } |
1603 | |
1896 | |
1604 | void |
1897 | void |
1605 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1898 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1899 | PREINIT: |
|
|
1900 | CALLBACK |
1606 | CODE: |
1901 | CODE: |
1607 | { |
1902 | { |
1608 | dREQ (REQ_C_PGET); |
1903 | dREQ (REQ_C_PGET); |
1609 | req->dbc = dbc; |
1904 | req->dbc = dbc; |
1610 | req->uint1 = flags; |
1905 | req->uint1 = flags; |
… | |
… | |
1628 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1923 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1629 | REQ_SEND; |
1924 | REQ_SEND; |
1630 | } |
1925 | } |
1631 | |
1926 | |
1632 | void |
1927 | void |
1633 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = &PL_sv_undef) |
1928 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0) |
|
|
1929 | PREINIT: |
|
|
1930 | CALLBACK |
1634 | CODE: |
1931 | CODE: |
1635 | { |
1932 | { |
1636 | dREQ (REQ_C_DEL); |
1933 | dREQ (REQ_C_DEL); |
1637 | req->dbc = dbc; |
1934 | req->dbc = dbc; |
1638 | req->uint1 = flags; |
1935 | req->uint1 = flags; |
1639 | REQ_SEND; |
1936 | REQ_SEND; |
1640 | } |
1937 | } |
1641 | |
1938 | |
1642 | |
1939 | |
|
|
1940 | #if DB_VERSION_MINOR >= 3 |
|
|
1941 | |
1643 | void |
1942 | void |
1644 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1943 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1944 | PREINIT: |
|
|
1945 | CALLBACK |
1645 | CODE: |
1946 | CODE: |
1646 | { |
1947 | { |
1647 | dREQ (REQ_SEQ_OPEN); |
1948 | dREQ (REQ_SEQ_OPEN); |
1648 | req->seq = seq; |
1949 | req->seq = seq; |
1649 | req->txn = txnid; |
1950 | req->txn = txnid; |
… | |
… | |
1651 | sv_to_dbt (&req->dbt1, key); |
1952 | sv_to_dbt (&req->dbt1, key); |
1652 | REQ_SEND; |
1953 | REQ_SEND; |
1653 | } |
1954 | } |
1654 | |
1955 | |
1655 | void |
1956 | void |
1656 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = &PL_sv_undef) |
1957 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) |
|
|
1958 | PREINIT: |
|
|
1959 | CALLBACK |
1657 | CODE: |
1960 | CODE: |
1658 | { |
1961 | { |
1659 | dREQ (REQ_SEQ_CLOSE); |
1962 | dREQ (REQ_SEQ_CLOSE); |
1660 | req->seq = seq; |
1963 | req->seq = seq; |
1661 | req->uint1 = flags; |
1964 | req->uint1 = flags; |
1662 | REQ_SEND; |
1965 | REQ_SEND; |
1663 | ptr_nuke (ST (0)); |
1966 | ptr_nuke (ST (0)); |
1664 | } |
1967 | } |
1665 | |
1968 | |
1666 | void |
1969 | void |
1667 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = &PL_sv_undef) |
1970 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) |
|
|
1971 | PREINIT: |
|
|
1972 | CALLBACK |
1668 | CODE: |
1973 | CODE: |
1669 | { |
1974 | { |
1670 | dREQ (REQ_SEQ_GET); |
1975 | dREQ (REQ_SEQ_GET); |
1671 | req->seq = seq; |
1976 | req->seq = seq; |
1672 | req->txn = txnid; |
1977 | req->txn = txnid; |
… | |
… | |
1675 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1980 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1676 | REQ_SEND; |
1981 | REQ_SEND; |
1677 | } |
1982 | } |
1678 | |
1983 | |
1679 | void |
1984 | void |
1680 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1985 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) |
|
|
1986 | PREINIT: |
|
|
1987 | CALLBACK |
1681 | CODE: |
1988 | CODE: |
1682 | { |
1989 | { |
1683 | dREQ (REQ_SEQ_REMOVE); |
1990 | dREQ (REQ_SEQ_REMOVE); |
1684 | req->seq = seq; |
1991 | req->seq = seq; |
1685 | req->txn = txnid; |
1992 | req->txn = txnid; |
1686 | req->uint1 = flags; |
1993 | req->uint1 = flags; |
1687 | REQ_SEND; |
1994 | REQ_SEND; |
1688 | } |
1995 | } |
1689 | |
1996 | |
|
|
1997 | #endif |
|
|
1998 | |
1690 | |
1999 | |
1691 | MODULE = BDB PACKAGE = BDB::Env |
2000 | MODULE = BDB PACKAGE = BDB::Env |
1692 | |
2001 | |
1693 | void |
2002 | void |
1694 | DESTROY (DB_ENV_ornull *env) |
2003 | DESTROY (DB_ENV_ornuked *env) |
1695 | CODE: |
2004 | CODE: |
1696 | if (env) |
2005 | if (env) |
1697 | env->close (env, 0); |
2006 | env->close (env, 0); |
1698 | |
2007 | |
1699 | int set_data_dir (DB_ENV *env, const char *dir) |
2008 | int set_data_dir (DB_ENV *env, const char *dir) |
… | |
… | |
1724 | CODE: |
2033 | CODE: |
1725 | RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
2034 | RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
1726 | OUTPUT: |
2035 | OUTPUT: |
1727 | RETVAL |
2036 | RETVAL |
1728 | |
2037 | |
1729 | int set_flags (DB_ENV *env, U32 flags, int onoff) |
2038 | int set_flags (DB_ENV *env, U32 flags, int onoff = 1) |
1730 | CODE: |
2039 | CODE: |
1731 | RETVAL = env->set_flags (env, flags, onoff); |
2040 | RETVAL = env->set_flags (env, flags, onoff); |
1732 | OUTPUT: |
2041 | OUTPUT: |
1733 | RETVAL |
2042 | RETVAL |
1734 | |
2043 | |
|
|
2044 | #if DB_VERSION_MINOR >= 7 |
|
|
2045 | |
|
|
2046 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
|
|
2047 | CODE: |
|
|
2048 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
|
|
2049 | OUTPUT: |
|
|
2050 | RETVAL |
|
|
2051 | |
|
|
2052 | int log_set_config (DB_ENV *env, U32 flags, int onoff = 1) |
|
|
2053 | CODE: |
|
|
2054 | RETVAL = env->log_set_config (env, flags, onoff); |
|
|
2055 | OUTPUT: |
|
|
2056 | RETVAL |
|
|
2057 | |
|
|
2058 | #endif |
|
|
2059 | |
|
|
2060 | |
1735 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
2061 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
1736 | CODE: |
2062 | CODE: |
1737 | env->set_errfile (env, errfile); |
2063 | env->set_errfile (env, errfile); |
1738 | |
2064 | |
1739 | void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
2065 | void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
1740 | CODE: |
2066 | CODE: |
1741 | env->set_msgfile (env, msgfile); |
2067 | env->set_msgfile (env, msgfile); |
1742 | |
2068 | |
1743 | int set_verbose (DB_ENV *env, U32 which, int onoff = 1) |
2069 | int set_verbose (DB_ENV *env, U32 which = -1, int onoff = 1) |
1744 | CODE: |
2070 | CODE: |
1745 | RETVAL = env->set_verbose (env, which, onoff); |
2071 | RETVAL = env->set_verbose (env, which, onoff); |
1746 | OUTPUT: |
2072 | OUTPUT: |
1747 | RETVAL |
2073 | RETVAL |
1748 | |
2074 | |
… | |
… | |
1809 | int set_lg_max (DB_ENV *env, U32 max) |
2135 | int set_lg_max (DB_ENV *env, U32 max) |
1810 | CODE: |
2136 | CODE: |
1811 | RETVAL = env->set_lg_max (env, max); |
2137 | RETVAL = env->set_lg_max (env, max); |
1812 | OUTPUT: |
2138 | OUTPUT: |
1813 | RETVAL |
2139 | RETVAL |
|
|
2140 | |
|
|
2141 | #if DB_VERSION_MINOR >= 4 |
|
|
2142 | |
|
|
2143 | int mutex_set_max (DB_ENV *env, U32 max) |
|
|
2144 | CODE: |
|
|
2145 | RETVAL = env->mutex_set_max (env, max); |
|
|
2146 | OUTPUT: |
|
|
2147 | RETVAL |
|
|
2148 | |
|
|
2149 | int mutex_set_increment (DB_ENV *env, U32 increment) |
|
|
2150 | CODE: |
|
|
2151 | RETVAL = env->mutex_set_increment (env, increment); |
|
|
2152 | OUTPUT: |
|
|
2153 | RETVAL |
|
|
2154 | |
|
|
2155 | int mutex_set_tas_spins (DB_ENV *env, U32 tas_spins) |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = env->mutex_set_tas_spins (env, tas_spins); |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
|
|
2160 | |
|
|
2161 | int mutex_set_align (DB_ENV *env, U32 align) |
|
|
2162 | CODE: |
|
|
2163 | RETVAL = env->mutex_set_align (env, align); |
|
|
2164 | OUTPUT: |
|
|
2165 | RETVAL |
|
|
2166 | |
|
|
2167 | #endif |
1814 | |
2168 | |
1815 | DB_TXN * |
2169 | DB_TXN * |
1816 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
2170 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
1817 | CODE: |
2171 | CODE: |
1818 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
2172 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
1819 | if (errno) |
2173 | if (errno) |
1820 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2174 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
1821 | OUTPUT: |
2175 | OUTPUT: |
1822 | RETVAL |
2176 | RETVAL |
1823 | |
2177 | |
|
|
2178 | #if DB_VERSION_MINOR >= 5 |
|
|
2179 | |
|
|
2180 | DB_TXN * |
|
|
2181 | cdsgroup_begin (DB_ENV *env) |
|
|
2182 | CODE: |
|
|
2183 | errno = env->cdsgroup_begin (env, &RETVAL); |
|
|
2184 | if (errno) |
|
|
2185 | croak ("DB_ENV->cdsgroup_begin: %s", db_strerror (errno)); |
|
|
2186 | OUTPUT: |
|
|
2187 | RETVAL |
|
|
2188 | |
|
|
2189 | #endif |
|
|
2190 | |
1824 | MODULE = BDB PACKAGE = BDB::Db |
2191 | MODULE = BDB PACKAGE = BDB::Db |
1825 | |
2192 | |
1826 | void |
2193 | void |
1827 | DESTROY (DB_ornull *db) |
2194 | DESTROY (DB_ornuked *db) |
1828 | CODE: |
2195 | CODE: |
1829 | if (db) |
2196 | if (db) |
1830 | { |
2197 | { |
1831 | SV *env = (SV *)db->app_private; |
2198 | SV *env = (SV *)db->app_private; |
1832 | db->close (db, 0); |
2199 | db->close (db, 0); |
… | |
… | |
1912 | if (errno) |
2279 | if (errno) |
1913 | croak ("DB->cursor: %s", db_strerror (errno)); |
2280 | croak ("DB->cursor: %s", db_strerror (errno)); |
1914 | OUTPUT: |
2281 | OUTPUT: |
1915 | RETVAL |
2282 | RETVAL |
1916 | |
2283 | |
|
|
2284 | #if DB_VERSION_MINOR >= 3 |
|
|
2285 | |
1917 | DB_SEQUENCE * |
2286 | DB_SEQUENCE * |
1918 | sequence (DB *db, U32 flags = 0) |
2287 | sequence (DB *db, U32 flags = 0) |
1919 | CODE: |
2288 | CODE: |
1920 | { |
2289 | { |
1921 | errno = db_sequence_create (&RETVAL, db, flags); |
2290 | errno = db_sequence_create (&RETVAL, db, flags); |
… | |
… | |
1923 | croak ("db_sequence_create: %s", db_strerror (errno)); |
2292 | croak ("db_sequence_create: %s", db_strerror (errno)); |
1924 | } |
2293 | } |
1925 | OUTPUT: |
2294 | OUTPUT: |
1926 | RETVAL |
2295 | RETVAL |
1927 | |
2296 | |
|
|
2297 | #endif |
|
|
2298 | |
1928 | |
2299 | |
1929 | MODULE = BDB PACKAGE = BDB::Txn |
2300 | MODULE = BDB PACKAGE = BDB::Txn |
1930 | |
2301 | |
1931 | void |
2302 | void |
1932 | DESTROY (DB_TXN_ornull *txn) |
2303 | DESTROY (DB_TXN_ornuked *txn) |
1933 | CODE: |
2304 | CODE: |
1934 | if (txn) |
2305 | if (txn) |
1935 | txn->abort (txn); |
2306 | txn->abort (txn); |
1936 | |
2307 | |
1937 | int set_timeout (DB_TXN *txn, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
2308 | int set_timeout (DB_TXN *txn, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
… | |
… | |
1948 | |
2319 | |
1949 | |
2320 | |
1950 | MODULE = BDB PACKAGE = BDB::Cursor |
2321 | MODULE = BDB PACKAGE = BDB::Cursor |
1951 | |
2322 | |
1952 | void |
2323 | void |
1953 | DESTROY (DBC_ornull *dbc) |
2324 | DESTROY (DBC_ornuked *dbc) |
1954 | CODE: |
2325 | CODE: |
1955 | if (dbc) |
2326 | if (dbc) |
1956 | dbc->c_close (dbc); |
2327 | dbc->c_close (dbc); |
1957 | |
2328 | |
|
|
2329 | #if DB_VERSION_MINOR >= 6 |
|
|
2330 | |
|
|
2331 | int set_priority (DBC *dbc, int priority) |
|
|
2332 | CODE: |
|
|
2333 | dbc->set_priority (dbc, priority); |
|
|
2334 | |
|
|
2335 | #endif |
|
|
2336 | |
|
|
2337 | #if DB_VERSION_MINOR >= 3 |
|
|
2338 | |
1958 | MODULE = BDB PACKAGE = BDB::Sequence |
2339 | MODULE = BDB PACKAGE = BDB::Sequence |
1959 | |
2340 | |
1960 | void |
2341 | void |
1961 | DESTROY (DB_SEQUENCE_ornull *seq) |
2342 | DESTROY (DB_SEQUENCE_ornuked *seq) |
1962 | CODE: |
2343 | CODE: |
1963 | if (seq) |
2344 | if (seq) |
1964 | seq->close (seq, 0); |
2345 | seq->close (seq, 0); |
1965 | |
2346 | |
1966 | int initial_value (DB_SEQUENCE *seq, db_seq_t value) |
2347 | int initial_value (DB_SEQUENCE *seq, db_seq_t value) |
… | |
… | |
1985 | CODE: |
2366 | CODE: |
1986 | RETVAL = seq->set_range (seq, min, max); |
2367 | RETVAL = seq->set_range (seq, min, max); |
1987 | OUTPUT: |
2368 | OUTPUT: |
1988 | RETVAL |
2369 | RETVAL |
1989 | |
2370 | |
|
|
2371 | #endif |
|
|
2372 | |
|
|
2373 | |