1 |
#define X_STACKSIZE 1024 * 128 + sizeof (long) * 64 * 1024 / 4 |
2 |
|
3 |
#include "xthread.h" |
4 |
|
5 |
#include <errno.h> |
6 |
|
7 |
#include "EXTERN.h" |
8 |
#include "perl.h" |
9 |
#include "XSUB.h" |
10 |
|
11 |
#include "schmorp.h" |
12 |
|
13 |
// perl stupidly defines these as argument-less macros, breaking |
14 |
// lots and lots of code. |
15 |
#undef open |
16 |
#undef close |
17 |
#undef abort |
18 |
#undef malloc |
19 |
#undef free |
20 |
#undef send |
21 |
|
22 |
#include <stddef.h> |
23 |
#include <stdlib.h> |
24 |
#include <errno.h> |
25 |
#include <sys/types.h> |
26 |
#include <limits.h> |
27 |
#include <fcntl.h> |
28 |
|
29 |
#ifndef _WIN32 |
30 |
# include <sys/time.h> |
31 |
# include <unistd.h> |
32 |
#endif |
33 |
|
34 |
#include <db.h> |
35 |
|
36 |
#if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) |
37 |
# error you need Berkeley DB 4.3 or a newer 4.x version installed |
38 |
#endif |
39 |
|
40 |
/* number of seconds after which idle threads exit */ |
41 |
#define IDLE_TIMEOUT 10 |
42 |
|
43 |
typedef SV SV_mutable; |
44 |
|
45 |
typedef DB_ENV DB_ENV_ornull; |
46 |
typedef DB_TXN DB_TXN_ornull; |
47 |
typedef DBC DBC_ornull; |
48 |
typedef DB DB_ornull; |
49 |
|
50 |
typedef DB_ENV DB_ENV_ornuked; |
51 |
typedef DB_TXN DB_TXN_ornuked; |
52 |
typedef DBC DBC_ornuked; |
53 |
typedef DB DB_ornuked; |
54 |
|
55 |
#if DB_VERSION_MINOR >= 3 |
56 |
typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
57 |
typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
58 |
#endif |
59 |
|
60 |
typedef char *bdb_filename; |
61 |
|
62 |
static SV *prepare_cb; |
63 |
|
64 |
#if DB_VERSION_MINOR >= 6 |
65 |
# define c_close close |
66 |
# define c_count count |
67 |
# define c_del del |
68 |
# define c_dup dup |
69 |
# define c_get get |
70 |
# define c_pget pget |
71 |
# define c_put put |
72 |
#endif |
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 |
|
104 |
static void |
105 |
debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
106 |
{ |
107 |
printf ("err[%s]\n", msg); |
108 |
} |
109 |
|
110 |
static void |
111 |
debug_msgcall (const DB_ENV *dbenv, const char *msg) |
112 |
{ |
113 |
printf ("msg[%s]\n", msg); |
114 |
} |
115 |
|
116 |
static char * |
117 |
strdup_ornull (const char *s) |
118 |
{ |
119 |
return s ? strdup (s) : 0; |
120 |
} |
121 |
|
122 |
static void |
123 |
sv_to_dbt (DBT *dbt, SV *sv) |
124 |
{ |
125 |
STRLEN len; |
126 |
char *data = SvPVbyte (sv, len); |
127 |
|
128 |
dbt->data = malloc (len); |
129 |
memcpy (dbt->data, data, len); |
130 |
dbt->size = len; |
131 |
dbt->flags = DB_DBT_REALLOC; |
132 |
} |
133 |
|
134 |
static void |
135 |
dbt_to_sv (SV *sv, DBT *dbt) |
136 |
{ |
137 |
if (sv) |
138 |
{ |
139 |
SvREADONLY_off (sv); |
140 |
|
141 |
if (dbt->data) |
142 |
sv_setpvn_mg (sv, dbt->data, dbt->size); |
143 |
else |
144 |
sv_setsv_mg (sv, &PL_sv_undef); |
145 |
|
146 |
SvREFCNT_dec (sv); |
147 |
} |
148 |
|
149 |
free (dbt->data); |
150 |
} |
151 |
|
152 |
enum { |
153 |
REQ_QUIT, |
154 |
REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
155 |
REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
156 |
REQ_ENV_LOG_ARCHIVE, |
157 |
REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_VERIFY, REQ_DB_UPGRADE, |
158 |
REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
159 |
REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
160 |
REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
161 |
REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
162 |
}; |
163 |
|
164 |
typedef struct bdb_cb |
165 |
{ |
166 |
struct bdb_cb *volatile next; |
167 |
SV *callback; |
168 |
int type, pri, result; |
169 |
|
170 |
DB_ENV *env; |
171 |
DB *db; |
172 |
DB_TXN *txn; |
173 |
DBC *dbc; |
174 |
|
175 |
UV uv1; |
176 |
int int1, int2; |
177 |
U32 uint1, uint2; |
178 |
char *buf1, *buf2, *buf3; |
179 |
SV *sv1, *sv2, *sv3; |
180 |
|
181 |
DBT dbt1, dbt2, dbt3; |
182 |
DB_KEY_RANGE key_range; |
183 |
#if DB_VERSION_MINOR >= 3 |
184 |
DB_SEQUENCE *seq; |
185 |
db_seq_t seq_t; |
186 |
#endif |
187 |
|
188 |
SV *rsv1, *rsv2; // keep some request objects alive |
189 |
} bdb_cb; |
190 |
|
191 |
typedef bdb_cb *bdb_req; |
192 |
|
193 |
enum { |
194 |
PRI_MIN = -4, |
195 |
PRI_MAX = 4, |
196 |
|
197 |
DEFAULT_PRI = 0, |
198 |
PRI_BIAS = -PRI_MIN, |
199 |
NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
200 |
}; |
201 |
|
202 |
#define AIO_TICKS ((1000000 + 1023) >> 10) |
203 |
|
204 |
static SV *on_next_submit; |
205 |
|
206 |
static unsigned int max_poll_time = 0; |
207 |
static unsigned int max_poll_reqs = 0; |
208 |
|
209 |
/* calculcate time difference in ~1/AIO_TICKS of a second */ |
210 |
static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
211 |
{ |
212 |
return (tv2->tv_sec - tv1->tv_sec ) * AIO_TICKS |
213 |
+ ((tv2->tv_usec - tv1->tv_usec) >> 10); |
214 |
} |
215 |
|
216 |
static int next_pri = DEFAULT_PRI + PRI_BIAS; |
217 |
|
218 |
static unsigned int started, idle, wanted; |
219 |
|
220 |
/* worker threads management */ |
221 |
static mutex_t wrklock = X_MUTEX_INIT; |
222 |
|
223 |
typedef struct worker { |
224 |
/* locked by wrklock */ |
225 |
struct worker *prev, *next; |
226 |
|
227 |
thread_t tid; |
228 |
|
229 |
/* locked by reslock, reqlock or wrklock */ |
230 |
bdb_req req; /* currently processed request */ |
231 |
void *dbuf; |
232 |
DIR *dirp; |
233 |
} worker; |
234 |
|
235 |
static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
236 |
|
237 |
static void worker_clear (worker *wrk) |
238 |
{ |
239 |
} |
240 |
|
241 |
static void worker_free (worker *wrk) |
242 |
{ |
243 |
wrk->next->prev = wrk->prev; |
244 |
wrk->prev->next = wrk->next; |
245 |
|
246 |
free (wrk); |
247 |
} |
248 |
|
249 |
static volatile unsigned int nreqs, nready, npending; |
250 |
static volatile unsigned int max_idle = 4; |
251 |
static volatile unsigned int max_outstanding = 0xffffffff; |
252 |
static s_epipe respipe; |
253 |
|
254 |
static mutex_t reslock = X_MUTEX_INIT; |
255 |
static mutex_t reqlock = X_MUTEX_INIT; |
256 |
static cond_t reqwait = X_COND_INIT; |
257 |
|
258 |
#if WORDACCESS_UNSAFE |
259 |
|
260 |
static unsigned int get_nready (void) |
261 |
{ |
262 |
unsigned int retval; |
263 |
|
264 |
X_LOCK (reqlock); |
265 |
retval = nready; |
266 |
X_UNLOCK (reqlock); |
267 |
|
268 |
return retval; |
269 |
} |
270 |
|
271 |
static unsigned int get_npending (void) |
272 |
{ |
273 |
unsigned int retval; |
274 |
|
275 |
X_LOCK (reslock); |
276 |
retval = npending; |
277 |
X_UNLOCK (reslock); |
278 |
|
279 |
return retval; |
280 |
} |
281 |
|
282 |
static unsigned int get_nthreads (void) |
283 |
{ |
284 |
unsigned int retval; |
285 |
|
286 |
X_LOCK (wrklock); |
287 |
retval = started; |
288 |
X_UNLOCK (wrklock); |
289 |
|
290 |
return retval; |
291 |
} |
292 |
|
293 |
#else |
294 |
|
295 |
# define get_nready() nready |
296 |
# define get_npending() npending |
297 |
# define get_nthreads() started |
298 |
|
299 |
#endif |
300 |
|
301 |
/* |
302 |
* a somewhat faster data structure might be nice, but |
303 |
* with 8 priorities this actually needs <20 insns |
304 |
* per shift, the most expensive operation. |
305 |
*/ |
306 |
typedef struct { |
307 |
bdb_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
308 |
int size; |
309 |
} reqq; |
310 |
|
311 |
static reqq req_queue; |
312 |
static reqq res_queue; |
313 |
|
314 |
int reqq_push (reqq *q, bdb_req req) |
315 |
{ |
316 |
int pri = req->pri; |
317 |
req->next = 0; |
318 |
|
319 |
if (q->qe[pri]) |
320 |
{ |
321 |
q->qe[pri]->next = req; |
322 |
q->qe[pri] = req; |
323 |
} |
324 |
else |
325 |
q->qe[pri] = q->qs[pri] = req; |
326 |
|
327 |
return q->size++; |
328 |
} |
329 |
|
330 |
bdb_req reqq_shift (reqq *q) |
331 |
{ |
332 |
int pri; |
333 |
|
334 |
if (!q->size) |
335 |
return 0; |
336 |
|
337 |
--q->size; |
338 |
|
339 |
for (pri = NUM_PRI; pri--; ) |
340 |
{ |
341 |
bdb_req req = q->qs[pri]; |
342 |
|
343 |
if (req) |
344 |
{ |
345 |
if (!(q->qs[pri] = req->next)) |
346 |
q->qe[pri] = 0; |
347 |
|
348 |
return req; |
349 |
} |
350 |
} |
351 |
|
352 |
abort (); |
353 |
} |
354 |
|
355 |
static int poll_cb (void); |
356 |
static void req_free (bdb_req req); |
357 |
|
358 |
static int req_invoke (bdb_req req) |
359 |
{ |
360 |
switch (req->type) |
361 |
{ |
362 |
case REQ_DB_CLOSE: |
363 |
SvREFCNT_dec (req->sv1); |
364 |
break; |
365 |
|
366 |
case REQ_DB_GET: |
367 |
case REQ_DB_PGET: |
368 |
case REQ_C_GET: |
369 |
case REQ_C_PGET: |
370 |
case REQ_DB_PUT: |
371 |
case REQ_C_PUT: |
372 |
dbt_to_sv (req->sv1, &req->dbt1); |
373 |
dbt_to_sv (req->sv2, &req->dbt2); |
374 |
dbt_to_sv (req->sv3, &req->dbt3); |
375 |
break; |
376 |
|
377 |
case REQ_DB_KEY_RANGE: |
378 |
{ |
379 |
AV *av = newAV (); |
380 |
|
381 |
av_push (av, newSVnv (req->key_range.less)); |
382 |
av_push (av, newSVnv (req->key_range.equal)); |
383 |
av_push (av, newSVnv (req->key_range.greater)); |
384 |
|
385 |
av = (AV *)newRV_noinc ((SV *)av); |
386 |
|
387 |
SvREADONLY_off (req->sv1); |
388 |
sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
389 |
SvREFCNT_dec (av); |
390 |
SvREFCNT_dec (req->sv1); |
391 |
} |
392 |
break; |
393 |
|
394 |
#if DB_VERSION_MINOR >= 3 |
395 |
case REQ_SEQ_GET: |
396 |
SvREADONLY_off (req->sv1); |
397 |
|
398 |
if (sizeof (IV) > 4) |
399 |
sv_setiv_mg (req->sv1, (IV)req->seq_t); |
400 |
else |
401 |
sv_setnv_mg (req->sv1, (NV)req->seq_t); |
402 |
|
403 |
SvREFCNT_dec (req->sv1); |
404 |
break; |
405 |
#endif |
406 |
|
407 |
case REQ_ENV_LOG_ARCHIVE: |
408 |
{ |
409 |
AV *av = newAV (); |
410 |
char **listp = (char **)req->buf1; |
411 |
|
412 |
if (listp) |
413 |
while (*listp) |
414 |
av_push (av, newSVpv (*listp, 0)), ++listp; |
415 |
|
416 |
av = (AV *)newRV_noinc ((SV *)av); |
417 |
|
418 |
SvREADONLY_off (req->sv1); |
419 |
sv_setsv_mg (req->sv1, (SV *)av); |
420 |
SvREFCNT_dec (av); |
421 |
SvREFCNT_dec (req->sv1); |
422 |
} |
423 |
break; |
424 |
} |
425 |
|
426 |
errno = req->result; |
427 |
|
428 |
if (req->callback) |
429 |
{ |
430 |
dSP; |
431 |
|
432 |
ENTER; |
433 |
SAVETMPS; |
434 |
PUSHMARK (SP); |
435 |
|
436 |
PUTBACK; |
437 |
call_sv (req->callback, G_VOID | G_EVAL); |
438 |
SPAGAIN; |
439 |
|
440 |
FREETMPS; |
441 |
LEAVE; |
442 |
|
443 |
return !SvTRUE (ERRSV); |
444 |
} |
445 |
|
446 |
return 1; |
447 |
} |
448 |
|
449 |
static void req_free (bdb_req req) |
450 |
{ |
451 |
SvREFCNT_dec (req->callback); |
452 |
|
453 |
SvREFCNT_dec (req->rsv1); |
454 |
SvREFCNT_dec (req->rsv2); |
455 |
|
456 |
free (req->buf1); |
457 |
free (req->buf2); |
458 |
free (req->buf3); |
459 |
|
460 |
Safefree (req); |
461 |
} |
462 |
|
463 |
static void |
464 |
create_respipe (void) |
465 |
{ |
466 |
if (s_epipe_renew (&respipe)) |
467 |
croak ("BDB: unable to create event pipe"); |
468 |
} |
469 |
|
470 |
static void bdb_request (bdb_req req); |
471 |
X_THREAD_PROC (bdb_proc); |
472 |
|
473 |
static void start_thread (void) |
474 |
{ |
475 |
worker *wrk = calloc (1, sizeof (worker)); |
476 |
|
477 |
if (!wrk) |
478 |
croak ("unable to allocate worker thread data"); |
479 |
|
480 |
X_LOCK (wrklock); |
481 |
if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) |
482 |
{ |
483 |
wrk->prev = &wrk_first; |
484 |
wrk->next = wrk_first.next; |
485 |
wrk_first.next->prev = wrk; |
486 |
wrk_first.next = wrk; |
487 |
++started; |
488 |
} |
489 |
else |
490 |
free (wrk); |
491 |
|
492 |
X_UNLOCK (wrklock); |
493 |
} |
494 |
|
495 |
static void maybe_start_thread (void) |
496 |
{ |
497 |
if (get_nthreads () >= wanted) |
498 |
return; |
499 |
|
500 |
/* todo: maybe use idle here, but might be less exact */ |
501 |
if (0 <= (int)get_nthreads () + (int)get_npending () - (int)nreqs) |
502 |
return; |
503 |
|
504 |
start_thread (); |
505 |
} |
506 |
|
507 |
static void req_send (bdb_req req) |
508 |
{ |
509 |
SV *wait_callback = 0; |
510 |
|
511 |
if (on_next_submit) |
512 |
{ |
513 |
dSP; |
514 |
SV *cb = sv_2mortal (on_next_submit); |
515 |
|
516 |
on_next_submit = 0; |
517 |
|
518 |
PUSHMARK (SP); |
519 |
PUTBACK; |
520 |
call_sv (cb, G_DISCARD | G_EVAL); |
521 |
SPAGAIN; |
522 |
} |
523 |
|
524 |
// synthesize callback if none given |
525 |
if (!req->callback) |
526 |
{ |
527 |
if (SvOK (prepare_cb)) |
528 |
{ |
529 |
int count; |
530 |
|
531 |
dSP; |
532 |
PUSHMARK (SP); |
533 |
PUTBACK; |
534 |
count = call_sv (prepare_cb, G_ARRAY); |
535 |
SPAGAIN; |
536 |
|
537 |
if (count != 2) |
538 |
croak ("sync prepare callback must return exactly two values\n"); |
539 |
|
540 |
wait_callback = POPs; |
541 |
req->callback = SvREFCNT_inc (POPs); |
542 |
} |
543 |
else |
544 |
{ |
545 |
// execute request synchronously |
546 |
bdb_request (req); |
547 |
req_invoke (req); |
548 |
req_free (req); |
549 |
return; |
550 |
} |
551 |
} |
552 |
|
553 |
++nreqs; |
554 |
|
555 |
X_LOCK (reqlock); |
556 |
++nready; |
557 |
reqq_push (&req_queue, req); |
558 |
X_COND_SIGNAL (reqwait); |
559 |
X_UNLOCK (reqlock); |
560 |
|
561 |
maybe_start_thread (); |
562 |
|
563 |
if (wait_callback) |
564 |
{ |
565 |
dSP; |
566 |
PUSHMARK (SP); |
567 |
PUTBACK; |
568 |
call_sv (wait_callback, G_DISCARD); |
569 |
} |
570 |
} |
571 |
|
572 |
static void end_thread (void) |
573 |
{ |
574 |
bdb_req req = calloc (1, sizeof (bdb_cb)); |
575 |
|
576 |
req->type = REQ_QUIT; |
577 |
req->pri = PRI_MAX + PRI_BIAS; |
578 |
|
579 |
X_LOCK (reqlock); |
580 |
reqq_push (&req_queue, req); |
581 |
X_COND_SIGNAL (reqwait); |
582 |
X_UNLOCK (reqlock); |
583 |
|
584 |
X_LOCK (wrklock); |
585 |
--started; |
586 |
X_UNLOCK (wrklock); |
587 |
} |
588 |
|
589 |
static void set_max_idle (int nthreads) |
590 |
{ |
591 |
if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
592 |
max_idle = nthreads <= 0 ? 1 : nthreads; |
593 |
if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
594 |
} |
595 |
|
596 |
static void min_parallel (int nthreads) |
597 |
{ |
598 |
if (wanted < nthreads) |
599 |
wanted = nthreads; |
600 |
} |
601 |
|
602 |
static void max_parallel (int nthreads) |
603 |
{ |
604 |
if (wanted > nthreads) |
605 |
wanted = nthreads; |
606 |
|
607 |
while (started > wanted) |
608 |
end_thread (); |
609 |
} |
610 |
|
611 |
static void poll_wait (void) |
612 |
{ |
613 |
fd_set rfd; |
614 |
|
615 |
while (nreqs) |
616 |
{ |
617 |
int size; |
618 |
if (WORDACCESS_UNSAFE) X_LOCK (reslock); |
619 |
size = res_queue.size; |
620 |
if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); |
621 |
|
622 |
if (size) |
623 |
return; |
624 |
|
625 |
maybe_start_thread (); |
626 |
|
627 |
s_epipe_wait (&respipe); |
628 |
} |
629 |
} |
630 |
|
631 |
static int poll_cb (void) |
632 |
{ |
633 |
dSP; |
634 |
int count = 0; |
635 |
int maxreqs = max_poll_reqs; |
636 |
int do_croak = 0; |
637 |
struct timeval tv_start, tv_now; |
638 |
bdb_req req; |
639 |
|
640 |
if (max_poll_time) |
641 |
gettimeofday (&tv_start, 0); |
642 |
|
643 |
for (;;) |
644 |
{ |
645 |
for (;;) |
646 |
{ |
647 |
maybe_start_thread (); |
648 |
|
649 |
X_LOCK (reslock); |
650 |
req = reqq_shift (&res_queue); |
651 |
|
652 |
if (req) |
653 |
{ |
654 |
--npending; |
655 |
|
656 |
if (!res_queue.size) |
657 |
/* read any signals sent by the worker threads */ |
658 |
s_epipe_drain (&respipe); |
659 |
} |
660 |
|
661 |
X_UNLOCK (reslock); |
662 |
|
663 |
if (!req) |
664 |
break; |
665 |
|
666 |
--nreqs; |
667 |
|
668 |
if (!req_invoke (req)) |
669 |
{ |
670 |
req_free (req); |
671 |
croak (0); |
672 |
} |
673 |
|
674 |
count++; |
675 |
|
676 |
req_free (req); |
677 |
|
678 |
if (maxreqs && !--maxreqs) |
679 |
break; |
680 |
|
681 |
if (max_poll_time) |
682 |
{ |
683 |
gettimeofday (&tv_now, 0); |
684 |
|
685 |
if (tvdiff (&tv_start, &tv_now) >= max_poll_time) |
686 |
break; |
687 |
} |
688 |
} |
689 |
|
690 |
if (nreqs <= max_outstanding) |
691 |
break; |
692 |
|
693 |
poll_wait (); |
694 |
|
695 |
++maxreqs; |
696 |
} |
697 |
|
698 |
return count; |
699 |
} |
700 |
|
701 |
/*****************************************************************************/ |
702 |
|
703 |
static void |
704 |
bdb_request (bdb_req req) |
705 |
{ |
706 |
switch (req->type) |
707 |
{ |
708 |
case REQ_ENV_OPEN: |
709 |
req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1); |
710 |
break; |
711 |
|
712 |
case REQ_ENV_CLOSE: |
713 |
req->result = req->env->close (req->env, req->uint1); |
714 |
break; |
715 |
|
716 |
case REQ_ENV_TXN_CHECKPOINT: |
717 |
req->result = req->env->txn_checkpoint (req->env, req->uint1, req->int1, req->uint2); |
718 |
break; |
719 |
|
720 |
case REQ_ENV_LOCK_DETECT: |
721 |
req->result = req->env->lock_detect (req->env, req->uint1, req->uint2, &req->int1); |
722 |
break; |
723 |
|
724 |
case REQ_ENV_MEMP_SYNC: |
725 |
req->result = req->env->memp_sync (req->env, 0); |
726 |
break; |
727 |
|
728 |
case REQ_ENV_MEMP_TRICKLE: |
729 |
req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
730 |
break; |
731 |
|
732 |
case REQ_ENV_DBREMOVE: |
733 |
req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1); |
734 |
break; |
735 |
|
736 |
case REQ_ENV_DBRENAME: |
737 |
req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1); |
738 |
break; |
739 |
|
740 |
case REQ_DB_OPEN: |
741 |
req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
742 |
break; |
743 |
|
744 |
case REQ_DB_CLOSE: |
745 |
req->result = req->db->close (req->db, req->uint1); |
746 |
break; |
747 |
|
748 |
#if DB_VERSION_MINOR >= 4 |
749 |
case REQ_DB_COMPACT: |
750 |
req->result = req->db->compact (req->db, req->txn, req->dbt1.data ? &req->dbt1 : 0, req->dbt2.data ? &req->dbt2 : 0, 0, req->uint1, 0); |
751 |
break; |
752 |
#endif |
753 |
|
754 |
case REQ_DB_SYNC: |
755 |
req->result = req->db->sync (req->db, req->uint1); |
756 |
break; |
757 |
|
758 |
case REQ_DB_VERIFY: |
759 |
req->result = req->db->verify (req->db, req->buf1, req->buf2, 0, req->uint1); |
760 |
break; |
761 |
|
762 |
case REQ_DB_UPGRADE: |
763 |
req->result = req->db->upgrade (req->db, req->buf1, req->uint1); |
764 |
break; |
765 |
|
766 |
case REQ_DB_PUT: |
767 |
req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
768 |
break; |
769 |
|
770 |
#if DB_VERSION_MINOR >= 6 |
771 |
case REQ_DB_EXISTS: |
772 |
req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
773 |
break; |
774 |
#endif |
775 |
case REQ_DB_GET: |
776 |
req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
777 |
break; |
778 |
|
779 |
case REQ_DB_PGET: |
780 |
req->result = req->db->pget (req->db, req->txn, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1); |
781 |
break; |
782 |
|
783 |
case REQ_DB_DEL: |
784 |
req->result = req->db->del (req->db, req->txn, &req->dbt1, req->uint1); |
785 |
break; |
786 |
|
787 |
case REQ_DB_KEY_RANGE: |
788 |
req->result = req->db->key_range (req->db, req->txn, &req->dbt1, &req->key_range, req->uint1); |
789 |
break; |
790 |
|
791 |
case REQ_TXN_COMMIT: |
792 |
req->result = req->txn->commit (req->txn, req->uint1); |
793 |
break; |
794 |
|
795 |
case REQ_TXN_ABORT: |
796 |
req->result = req->txn->abort (req->txn); |
797 |
break; |
798 |
|
799 |
case REQ_TXN_FINISH: |
800 |
if (req->txn->flags & TXN_DEADLOCK) |
801 |
{ |
802 |
req->result = req->txn->abort (req->txn); |
803 |
if (!req->result) |
804 |
req->result = DB_LOCK_DEADLOCK; |
805 |
} |
806 |
else |
807 |
req->result = req->txn->commit (req->txn, req->uint1); |
808 |
break; |
809 |
|
810 |
case REQ_C_CLOSE: |
811 |
req->result = req->dbc->c_close (req->dbc); |
812 |
break; |
813 |
|
814 |
case REQ_C_COUNT: |
815 |
{ |
816 |
db_recno_t recno; |
817 |
req->result = req->dbc->c_count (req->dbc, &recno, req->uint1); |
818 |
req->uv1 = recno; |
819 |
} |
820 |
break; |
821 |
|
822 |
case REQ_C_PUT: |
823 |
req->result = req->dbc->c_put (req->dbc, &req->dbt1, &req->dbt2, req->uint1); |
824 |
break; |
825 |
|
826 |
case REQ_C_GET: |
827 |
req->result = req->dbc->c_get (req->dbc, &req->dbt1, &req->dbt3, req->uint1); |
828 |
break; |
829 |
|
830 |
case REQ_C_PGET: |
831 |
req->result = req->dbc->c_pget (req->dbc, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1); |
832 |
break; |
833 |
|
834 |
case REQ_C_DEL: |
835 |
req->result = req->dbc->c_del (req->dbc, req->uint1); |
836 |
break; |
837 |
|
838 |
#if DB_VERSION_MINOR >= 3 |
839 |
case REQ_SEQ_OPEN: |
840 |
req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
841 |
break; |
842 |
|
843 |
case REQ_SEQ_CLOSE: |
844 |
req->result = req->seq->close (req->seq, req->uint1); |
845 |
break; |
846 |
|
847 |
case REQ_SEQ_GET: |
848 |
req->result = req->seq->get (req->seq, req->txn, req->int1, &req->seq_t, req->uint1); |
849 |
break; |
850 |
|
851 |
case REQ_SEQ_REMOVE: |
852 |
req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
853 |
break; |
854 |
#endif |
855 |
|
856 |
case REQ_ENV_LOG_ARCHIVE: |
857 |
{ |
858 |
char **listp = 0; /* DB_ARCH_REMOVE does not touch listp, contrary to docs */ |
859 |
req->result = req->env->log_archive (req->env, &listp, req->uint1); |
860 |
req->buf1 = (char *)listp; |
861 |
} |
862 |
break; |
863 |
|
864 |
default: |
865 |
req->result = ENOSYS; |
866 |
break; |
867 |
} |
868 |
|
869 |
if (req->txn && (req->result > 0 || req->result == DB_LOCK_NOTGRANTED)) |
870 |
req->txn->flags |= TXN_DEADLOCK; |
871 |
} |
872 |
|
873 |
X_THREAD_PROC (bdb_proc) |
874 |
{ |
875 |
bdb_req req; |
876 |
struct timespec ts; |
877 |
worker *self = (worker *)thr_arg; |
878 |
|
879 |
/* try to distribute timeouts somewhat evenly */ |
880 |
ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
881 |
|
882 |
for (;;) |
883 |
{ |
884 |
ts.tv_sec = time (0) + IDLE_TIMEOUT; |
885 |
|
886 |
X_LOCK (reqlock); |
887 |
|
888 |
for (;;) |
889 |
{ |
890 |
self->req = req = reqq_shift (&req_queue); |
891 |
|
892 |
if (req) |
893 |
break; |
894 |
|
895 |
++idle; |
896 |
|
897 |
if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) |
898 |
== ETIMEDOUT) |
899 |
{ |
900 |
if (idle > max_idle) |
901 |
{ |
902 |
--idle; |
903 |
X_UNLOCK (reqlock); |
904 |
X_LOCK (wrklock); |
905 |
--started; |
906 |
X_UNLOCK (wrklock); |
907 |
goto quit; |
908 |
} |
909 |
|
910 |
/* we are allowed to idle, so do so without any timeout */ |
911 |
X_COND_WAIT (reqwait, reqlock); |
912 |
ts.tv_sec = time (0) + IDLE_TIMEOUT; |
913 |
} |
914 |
|
915 |
--idle; |
916 |
} |
917 |
|
918 |
--nready; |
919 |
|
920 |
X_UNLOCK (reqlock); |
921 |
|
922 |
if (req->type == REQ_QUIT) |
923 |
{ |
924 |
X_LOCK (reslock); |
925 |
free (req); |
926 |
self->req = 0; |
927 |
X_UNLOCK (reslock); |
928 |
|
929 |
goto quit; |
930 |
} |
931 |
|
932 |
bdb_request (req); |
933 |
|
934 |
X_LOCK (reslock); |
935 |
|
936 |
++npending; |
937 |
|
938 |
if (!reqq_push (&res_queue, req)) |
939 |
s_epipe_signal (&respipe); |
940 |
|
941 |
self->req = 0; |
942 |
worker_clear (self); |
943 |
|
944 |
X_UNLOCK (reslock); |
945 |
} |
946 |
|
947 |
quit: |
948 |
X_LOCK (wrklock); |
949 |
worker_free (self); |
950 |
X_UNLOCK (wrklock); |
951 |
|
952 |
return 0; |
953 |
} |
954 |
|
955 |
/*****************************************************************************/ |
956 |
|
957 |
static void atfork_prepare (void) |
958 |
{ |
959 |
X_LOCK (wrklock); |
960 |
X_LOCK (reqlock); |
961 |
X_LOCK (reslock); |
962 |
} |
963 |
|
964 |
static void atfork_parent (void) |
965 |
{ |
966 |
X_UNLOCK (reslock); |
967 |
X_UNLOCK (reqlock); |
968 |
X_UNLOCK (wrklock); |
969 |
} |
970 |
|
971 |
static void atfork_child (void) |
972 |
{ |
973 |
bdb_req prv; |
974 |
|
975 |
while (prv = reqq_shift (&req_queue)) |
976 |
req_free (prv); |
977 |
|
978 |
while (prv = reqq_shift (&res_queue)) |
979 |
req_free (prv); |
980 |
|
981 |
while (wrk_first.next != &wrk_first) |
982 |
{ |
983 |
worker *wrk = wrk_first.next; |
984 |
|
985 |
if (wrk->req) |
986 |
req_free (wrk->req); |
987 |
|
988 |
worker_clear (wrk); |
989 |
worker_free (wrk); |
990 |
} |
991 |
|
992 |
started = 0; |
993 |
idle = 0; |
994 |
nreqs = 0; |
995 |
nready = 0; |
996 |
npending = 0; |
997 |
|
998 |
create_respipe (); |
999 |
|
1000 |
atfork_parent (); |
1001 |
} |
1002 |
|
1003 |
#define dREQ(reqtype,rsvcnt) \ |
1004 |
bdb_req req; \ |
1005 |
int req_pri = next_pri; \ |
1006 |
next_pri = DEFAULT_PRI + PRI_BIAS; \ |
1007 |
\ |
1008 |
if (callback && SvOK (callback)) \ |
1009 |
croak ("callback has illegal type or extra arguments"); \ |
1010 |
\ |
1011 |
Newz (0, req, 1, bdb_cb); \ |
1012 |
if (!req) \ |
1013 |
croak ("out of memory during bdb_req allocation"); \ |
1014 |
\ |
1015 |
req->callback = SvREFCNT_inc (cb); \ |
1016 |
req->type = (reqtype); \ |
1017 |
req->pri = req_pri; \ |
1018 |
if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \ |
1019 |
if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \ |
1020 |
(void)0; |
1021 |
|
1022 |
#define REQ_SEND \ |
1023 |
req_send (req) |
1024 |
|
1025 |
#define SvPTR(var, arg, type, class, nullok) \ |
1026 |
if (!SvOK (arg)) \ |
1027 |
{ \ |
1028 |
if (nullok != 1) \ |
1029 |
croak (# var " must be a " # class " object, not undef"); \ |
1030 |
\ |
1031 |
(var) = 0; \ |
1032 |
} \ |
1033 |
else if (sv_derived_from ((arg), # class)) \ |
1034 |
{ \ |
1035 |
IV tmp = SvIV ((SV*) SvRV (arg)); \ |
1036 |
(var) = INT2PTR (type, tmp); \ |
1037 |
if (!var && nullok != 2) \ |
1038 |
croak (# var " is not a valid " # class " object anymore"); \ |
1039 |
} \ |
1040 |
else \ |
1041 |
croak (# var " is not of type " # class); |
1042 |
|
1043 |
#define ARG_MUTABLE(name) \ |
1044 |
if (SvREADONLY (name)) \ |
1045 |
croak ("argument " #name " is read-only/constant, but the request requires it to be mutable"); |
1046 |
|
1047 |
static void |
1048 |
ptr_nuke (SV *sv) |
1049 |
{ |
1050 |
assert (SvROK (sv)); |
1051 |
sv_setiv (SvRV (sv), 0); |
1052 |
} |
1053 |
|
1054 |
static int |
1055 |
errno_get (pTHX_ SV *sv, MAGIC *mg) |
1056 |
{ |
1057 |
if (*mg->mg_ptr == '!') // should always be the case |
1058 |
if (-30999 <= errno && errno <= -30800) |
1059 |
{ |
1060 |
sv_setnv (sv, (NV)errno); |
1061 |
sv_setpv (sv, db_strerror (errno)); |
1062 |
SvNOK_on (sv); /* what a wonderful hack! */ |
1063 |
// ^^^ copied from perl sources |
1064 |
return 0; |
1065 |
} |
1066 |
|
1067 |
return PL_vtbl_sv.svt_get (aTHX_ sv, mg); |
1068 |
} |
1069 |
|
1070 |
static MGVTBL vtbl_errno; |
1071 |
|
1072 |
// this wonderful hack :( patches perl's $! variable to support our errno values |
1073 |
static void |
1074 |
patch_errno (void) |
1075 |
{ |
1076 |
SV *sv; |
1077 |
MAGIC *mg; |
1078 |
|
1079 |
if (!(sv = get_sv ("!", 1))) |
1080 |
return; |
1081 |
|
1082 |
if (!(mg = mg_find (sv, PERL_MAGIC_sv))) |
1083 |
return; |
1084 |
|
1085 |
if (mg->mg_virtual != &PL_vtbl_sv) |
1086 |
return; |
1087 |
|
1088 |
vtbl_errno = PL_vtbl_sv; |
1089 |
vtbl_errno.svt_get = errno_get; |
1090 |
mg->mg_virtual = &vtbl_errno; |
1091 |
} |
1092 |
|
1093 |
#if __GNUC__ >= 4 |
1094 |
# define noinline __attribute__ ((noinline)) |
1095 |
#else |
1096 |
# define noinline |
1097 |
#endif |
1098 |
|
1099 |
static noinline SV * |
1100 |
pop_callback (I32 *ritems, SV *sv) |
1101 |
{ |
1102 |
if (SvROK (sv)) |
1103 |
{ |
1104 |
HV *st; |
1105 |
GV *gvp; |
1106 |
CV *cv; |
1107 |
const char *name; |
1108 |
|
1109 |
/* forgive me */ |
1110 |
if (SvTYPE (SvRV (sv)) == SVt_PVMG |
1111 |
&& (st = SvSTASH (SvRV (sv))) |
1112 |
&& (name = HvNAME_get (st)) |
1113 |
&& (name [0] == 'B' && name [1] == 'D' && name [2] == 'B' && name [3] == ':')) |
1114 |
return 0; |
1115 |
|
1116 |
if ((cv = sv_2cv (sv, &st, &gvp, 0))) |
1117 |
{ |
1118 |
--*ritems; |
1119 |
return (SV *)cv; |
1120 |
} |
1121 |
} |
1122 |
|
1123 |
return 0; |
1124 |
} |
1125 |
|
1126 |
/*****************************************************************************/ |
1127 |
|
1128 |
#if 0 |
1129 |
static int |
1130 |
bt_pfxc_compare (DB *db, const DBT *dbt1, const DBT *dbt2) |
1131 |
{ |
1132 |
ssize_t size1 = dbt1->size; |
1133 |
ssize_t size2 = dbt2->size; |
1134 |
int res = memcmp ((void *)dbt1->data, (void *)dbt2->data, |
1135 |
size1 <= size2 ? size1 : size2); |
1136 |
|
1137 |
if (res) |
1138 |
return res; |
1139 |
else if (size1 - size2) |
1140 |
return size1 - size2; |
1141 |
else |
1142 |
return 0; |
1143 |
} |
1144 |
|
1145 |
static size_t |
1146 |
bt_pfxc_prefix_x (DB *db, const DBT *dbt1, const DBT *dbt2) |
1147 |
{ |
1148 |
ssize_t size1 = dbt1->size; |
1149 |
ssize_t size2 = dbt2->size; |
1150 |
u_int8_t *p1 = (u_int8_t *)dbt1->data; |
1151 |
u_int8_t *p2 = (u_int8_t *)dbt2->data; |
1152 |
u_int8_t *pe = p1 + (size1 <= size2 ? size1 : size2); |
1153 |
|
1154 |
while (p1 < pe) |
1155 |
if (*p1++ != *p2++) |
1156 |
return p1 - (u_int8_t *)dbt1->data - 1; |
1157 |
|
1158 |
if (size1 < size2) return size1 + 1; |
1159 |
if (size1 > size2) return size2 + 1; |
1160 |
|
1161 |
return size1; |
1162 |
} |
1163 |
#endif |
1164 |
|
1165 |
/*****************************************************************************/ |
1166 |
|
1167 |
/* stupid windows defines CALLBACK as well */ |
1168 |
#undef CALLBACK |
1169 |
#define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); |
1170 |
|
1171 |
MODULE = BDB PACKAGE = BDB |
1172 |
|
1173 |
PROTOTYPES: ENABLE |
1174 |
|
1175 |
BOOT: |
1176 |
{ |
1177 |
HV *stash = gv_stashpv ("BDB", 1); |
1178 |
|
1179 |
static const struct { |
1180 |
const char *name; |
1181 |
IV iv; |
1182 |
} *civ, const_iv[] = { |
1183 |
#define const_iv(name) { # name, (IV)DB_ ## name }, |
1184 |
const_iv (RPCCLIENT) |
1185 |
const_iv (INIT_CDB) |
1186 |
const_iv (INIT_LOCK) |
1187 |
const_iv (INIT_LOG) |
1188 |
const_iv (INIT_MPOOL) |
1189 |
const_iv (INIT_REP) |
1190 |
const_iv (INIT_TXN) |
1191 |
const_iv (RECOVER) |
1192 |
const_iv (INIT_TXN) |
1193 |
const_iv (RECOVER_FATAL) |
1194 |
const_iv (CREATE) |
1195 |
const_iv (RDONLY) |
1196 |
const_iv (USE_ENVIRON) |
1197 |
const_iv (USE_ENVIRON_ROOT) |
1198 |
const_iv (LOCKDOWN) |
1199 |
const_iv (PRIVATE) |
1200 |
const_iv (SYSTEM_MEM) |
1201 |
const_iv (AUTO_COMMIT) |
1202 |
const_iv (CDB_ALLDB) |
1203 |
const_iv (DIRECT_DB) |
1204 |
const_iv (NOLOCKING) |
1205 |
const_iv (NOMMAP) |
1206 |
const_iv (NOPANIC) |
1207 |
const_iv (OVERWRITE) |
1208 |
const_iv (PANIC_ENVIRONMENT) |
1209 |
const_iv (REGION_INIT) |
1210 |
const_iv (TIME_NOTGRANTED) |
1211 |
const_iv (TXN_NOSYNC) |
1212 |
const_iv (TXN_NOT_DURABLE) |
1213 |
const_iv (TXN_WRITE_NOSYNC) |
1214 |
const_iv (WRITECURSOR) |
1215 |
const_iv (YIELDCPU) |
1216 |
const_iv (ENCRYPT_AES) |
1217 |
const_iv (XA_CREATE) |
1218 |
const_iv (BTREE) |
1219 |
const_iv (HASH) |
1220 |
const_iv (QUEUE) |
1221 |
const_iv (RECNO) |
1222 |
const_iv (UNKNOWN) |
1223 |
const_iv (EXCL) |
1224 |
const_iv (TRUNCATE) |
1225 |
const_iv (NOSYNC) |
1226 |
const_iv (CHKSUM) |
1227 |
const_iv (ENCRYPT) |
1228 |
const_iv (DUP) |
1229 |
const_iv (DUPSORT) |
1230 |
//const_iv (RECNUM) |
1231 |
const_iv (RENUMBER) |
1232 |
const_iv (REVSPLITOFF) |
1233 |
const_iv (CONSUME) |
1234 |
const_iv (CONSUME_WAIT) |
1235 |
const_iv (GET_BOTH) |
1236 |
const_iv (GET_BOTH_RANGE) |
1237 |
//const_iv (SET_RECNO) |
1238 |
//const_iv (MULTIPLE) |
1239 |
const_iv (SNAPSHOT) |
1240 |
const_iv (JOIN_ITEM) |
1241 |
const_iv (JOIN_NOSORT) |
1242 |
const_iv (RMW) |
1243 |
|
1244 |
const_iv (NOTFOUND) |
1245 |
const_iv (KEYEMPTY) |
1246 |
const_iv (LOCK_DEADLOCK) |
1247 |
const_iv (LOCK_NOTGRANTED) |
1248 |
const_iv (RUNRECOVERY) |
1249 |
const_iv (OLD_VERSION) |
1250 |
const_iv (REP_HANDLE_DEAD) |
1251 |
const_iv (SECONDARY_BAD) |
1252 |
|
1253 |
const_iv (APPEND) |
1254 |
const_iv (NODUPDATA) |
1255 |
const_iv (NOOVERWRITE) |
1256 |
|
1257 |
const_iv (TXN_NOWAIT) |
1258 |
const_iv (TXN_SYNC) |
1259 |
|
1260 |
const_iv (SET_LOCK_TIMEOUT) |
1261 |
const_iv (SET_TXN_TIMEOUT) |
1262 |
|
1263 |
const_iv (FIRST) |
1264 |
const_iv (NEXT) |
1265 |
const_iv (NEXT_DUP) |
1266 |
const_iv (NEXT_NODUP) |
1267 |
const_iv (PREV) |
1268 |
const_iv (PREV_NODUP) |
1269 |
const_iv (SET) |
1270 |
const_iv (SET_RANGE) |
1271 |
const_iv (LAST) |
1272 |
const_iv (BEFORE) |
1273 |
const_iv (AFTER) |
1274 |
const_iv (CURRENT) |
1275 |
const_iv (KEYFIRST) |
1276 |
const_iv (KEYLAST) |
1277 |
const_iv (NODUPDATA) |
1278 |
|
1279 |
const_iv (FORCE) |
1280 |
|
1281 |
const_iv (LOCK_DEFAULT) |
1282 |
const_iv (LOCK_EXPIRE) |
1283 |
const_iv (LOCK_MAXLOCKS) |
1284 |
const_iv (LOCK_MINLOCKS) |
1285 |
const_iv (LOCK_MINWRITE) |
1286 |
const_iv (LOCK_OLDEST) |
1287 |
const_iv (LOCK_RANDOM) |
1288 |
const_iv (LOCK_YOUNGEST) |
1289 |
|
1290 |
const_iv (DONOTINDEX) |
1291 |
const_iv (KEYEMPTY ) |
1292 |
const_iv (KEYEXIST ) |
1293 |
const_iv (LOCK_DEADLOCK) |
1294 |
const_iv (LOCK_NOTGRANTED) |
1295 |
const_iv (NOSERVER) |
1296 |
const_iv (NOSERVER_HOME) |
1297 |
const_iv (NOSERVER_ID) |
1298 |
const_iv (NOTFOUND) |
1299 |
const_iv (PAGE_NOTFOUND) |
1300 |
const_iv (REP_DUPMASTER) |
1301 |
const_iv (REP_HANDLE_DEAD) |
1302 |
const_iv (REP_HOLDELECTION) |
1303 |
const_iv (REP_ISPERM) |
1304 |
const_iv (REP_NEWMASTER) |
1305 |
const_iv (REP_NEWSITE) |
1306 |
const_iv (REP_NOTPERM) |
1307 |
const_iv (REP_UNAVAIL) |
1308 |
const_iv (RUNRECOVERY) |
1309 |
const_iv (SECONDARY_BAD) |
1310 |
const_iv (VERIFY_BAD) |
1311 |
|
1312 |
const_iv (SALVAGE) |
1313 |
const_iv (AGGRESSIVE) |
1314 |
const_iv (PRINTABLE) |
1315 |
const_iv (NOORDERCHK) |
1316 |
const_iv (ORDERCHKONLY) |
1317 |
|
1318 |
const_iv (ARCH_ABS) |
1319 |
const_iv (ARCH_DATA) |
1320 |
const_iv (ARCH_LOG) |
1321 |
const_iv (ARCH_REMOVE) |
1322 |
|
1323 |
const_iv (VERB_DEADLOCK) |
1324 |
const_iv (VERB_RECOVERY) |
1325 |
const_iv (VERB_REPLICATION) |
1326 |
const_iv (VERB_WAITSFOR) |
1327 |
|
1328 |
const_iv (VERSION_MAJOR) |
1329 |
const_iv (VERSION_MINOR) |
1330 |
const_iv (VERSION_PATCH) |
1331 |
#if DB_VERSION_MINOR >= 3 |
1332 |
const_iv (INORDER) |
1333 |
const_iv (LOCK_MAXWRITE) |
1334 |
const_iv (SEQ_DEC) |
1335 |
const_iv (SEQ_INC) |
1336 |
const_iv (SEQ_WRAP) |
1337 |
const_iv (BUFFER_SMALL) |
1338 |
const_iv (LOG_BUFFER_FULL) |
1339 |
const_iv (VERSION_MISMATCH) |
1340 |
#endif |
1341 |
#if DB_VERSION_MINOR >= 4 |
1342 |
const_iv (REGISTER) |
1343 |
const_iv (DSYNC_DB) |
1344 |
const_iv (READ_COMMITTED) |
1345 |
const_iv (READ_UNCOMMITTED) |
1346 |
const_iv (REP_IGNORE) |
1347 |
const_iv (REP_LOCKOUT) |
1348 |
const_iv (REP_JOIN_FAILURE) |
1349 |
const_iv (FREE_SPACE) |
1350 |
const_iv (FREELIST_ONLY) |
1351 |
const_iv (VERB_REGISTER) |
1352 |
#endif |
1353 |
#if DB_VERSION_MINOR >= 5 |
1354 |
const_iv (MULTIVERSION) |
1355 |
const_iv (TXN_SNAPSHOT) |
1356 |
#endif |
1357 |
#if DB_VERSION_MINOR >= 6 |
1358 |
const_iv (PREV_DUP) |
1359 |
const_iv (PRIORITY_UNCHANGED) |
1360 |
const_iv (PRIORITY_VERY_LOW) |
1361 |
const_iv (PRIORITY_LOW) |
1362 |
const_iv (PRIORITY_DEFAULT) |
1363 |
const_iv (PRIORITY_HIGH) |
1364 |
const_iv (PRIORITY_VERY_HIGH) |
1365 |
const_iv (IGNORE_LEASE) |
1366 |
#endif |
1367 |
#if DB_VERSION_MINOR >= 7 |
1368 |
//const_iv (MULTIPLE_KEY) |
1369 |
const_iv (LOG_DIRECT) |
1370 |
const_iv (LOG_DSYNC) |
1371 |
const_iv (LOG_AUTO_REMOVE) |
1372 |
const_iv (LOG_IN_MEMORY) |
1373 |
const_iv (LOG_ZERO) |
1374 |
#else |
1375 |
const_iv (DIRECT_LOG) |
1376 |
const_iv (LOG_AUTOREMOVE) |
1377 |
# if DB_VERSION_MINOR >= 3 |
1378 |
const_iv (DSYNC_LOG) |
1379 |
const_iv (LOG_INMEMORY) |
1380 |
# endif |
1381 |
#endif |
1382 |
}; |
1383 |
|
1384 |
for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1385 |
newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1386 |
|
1387 |
prepare_cb = &PL_sv_undef; |
1388 |
|
1389 |
{ |
1390 |
/* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
1391 |
char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; |
1392 |
|
1393 |
newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); |
1394 |
} |
1395 |
|
1396 |
newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1397 |
|
1398 |
create_respipe (); |
1399 |
|
1400 |
X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1401 |
patch_errno (); |
1402 |
} |
1403 |
|
1404 |
void |
1405 |
max_poll_reqs (int nreqs) |
1406 |
PROTOTYPE: $ |
1407 |
CODE: |
1408 |
max_poll_reqs = nreqs; |
1409 |
|
1410 |
void |
1411 |
max_poll_time (double nseconds) |
1412 |
PROTOTYPE: $ |
1413 |
CODE: |
1414 |
max_poll_time = nseconds * AIO_TICKS; |
1415 |
|
1416 |
void |
1417 |
min_parallel (int nthreads) |
1418 |
PROTOTYPE: $ |
1419 |
|
1420 |
void |
1421 |
max_parallel (int nthreads) |
1422 |
PROTOTYPE: $ |
1423 |
|
1424 |
void |
1425 |
max_idle (int nthreads) |
1426 |
PROTOTYPE: $ |
1427 |
CODE: |
1428 |
set_max_idle (nthreads); |
1429 |
|
1430 |
int |
1431 |
max_outstanding (int maxreqs) |
1432 |
PROTOTYPE: $ |
1433 |
CODE: |
1434 |
RETVAL = max_outstanding; |
1435 |
max_outstanding = maxreqs; |
1436 |
OUTPUT: |
1437 |
RETVAL |
1438 |
|
1439 |
int |
1440 |
dbreq_pri (int pri = 0) |
1441 |
PROTOTYPE: ;$ |
1442 |
CODE: |
1443 |
RETVAL = next_pri - PRI_BIAS; |
1444 |
if (items > 0) |
1445 |
{ |
1446 |
if (pri < PRI_MIN) pri = PRI_MIN; |
1447 |
if (pri > PRI_MAX) pri = PRI_MAX; |
1448 |
next_pri = pri + PRI_BIAS; |
1449 |
} |
1450 |
OUTPUT: |
1451 |
RETVAL |
1452 |
|
1453 |
void |
1454 |
dbreq_nice (int nice = 0) |
1455 |
CODE: |
1456 |
nice = next_pri - nice; |
1457 |
if (nice < PRI_MIN) nice = PRI_MIN; |
1458 |
if (nice > PRI_MAX) nice = PRI_MAX; |
1459 |
next_pri = nice + PRI_BIAS; |
1460 |
|
1461 |
void |
1462 |
flush () |
1463 |
PROTOTYPE: |
1464 |
CODE: |
1465 |
while (nreqs) |
1466 |
{ |
1467 |
poll_wait (); |
1468 |
poll_cb (); |
1469 |
} |
1470 |
|
1471 |
int |
1472 |
poll () |
1473 |
PROTOTYPE: |
1474 |
CODE: |
1475 |
poll_wait (); |
1476 |
RETVAL = poll_cb (); |
1477 |
OUTPUT: |
1478 |
RETVAL |
1479 |
|
1480 |
int |
1481 |
poll_fileno () |
1482 |
PROTOTYPE: |
1483 |
CODE: |
1484 |
RETVAL = s_epipe_fd (&respipe); |
1485 |
OUTPUT: |
1486 |
RETVAL |
1487 |
|
1488 |
int |
1489 |
poll_cb (...) |
1490 |
PROTOTYPE: |
1491 |
CODE: |
1492 |
RETVAL = poll_cb (); |
1493 |
OUTPUT: |
1494 |
RETVAL |
1495 |
|
1496 |
void |
1497 |
poll_wait () |
1498 |
PROTOTYPE: |
1499 |
CODE: |
1500 |
poll_wait (); |
1501 |
|
1502 |
int |
1503 |
nreqs () |
1504 |
PROTOTYPE: |
1505 |
CODE: |
1506 |
RETVAL = nreqs; |
1507 |
OUTPUT: |
1508 |
RETVAL |
1509 |
|
1510 |
int |
1511 |
nready () |
1512 |
PROTOTYPE: |
1513 |
CODE: |
1514 |
RETVAL = get_nready (); |
1515 |
OUTPUT: |
1516 |
RETVAL |
1517 |
|
1518 |
int |
1519 |
npending () |
1520 |
PROTOTYPE: |
1521 |
CODE: |
1522 |
RETVAL = get_npending (); |
1523 |
OUTPUT: |
1524 |
RETVAL |
1525 |
|
1526 |
int |
1527 |
nthreads () |
1528 |
PROTOTYPE: |
1529 |
CODE: |
1530 |
if (WORDACCESS_UNSAFE) X_LOCK (wrklock); |
1531 |
RETVAL = started; |
1532 |
if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); |
1533 |
OUTPUT: |
1534 |
RETVAL |
1535 |
|
1536 |
SV * |
1537 |
set_sync_prepare (SV *cb) |
1538 |
PROTOTYPE: & |
1539 |
CODE: |
1540 |
RETVAL = prepare_cb; |
1541 |
prepare_cb = newSVsv (cb); |
1542 |
OUTPUT: |
1543 |
RETVAL |
1544 |
|
1545 |
char * |
1546 |
strerror (int errorno = errno) |
1547 |
PROTOTYPE: ;$ |
1548 |
CODE: |
1549 |
RETVAL = db_strerror (errorno); |
1550 |
OUTPUT: |
1551 |
RETVAL |
1552 |
|
1553 |
void _on_next_submit (SV *cb) |
1554 |
CODE: |
1555 |
SvREFCNT_dec (on_next_submit); |
1556 |
on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1557 |
|
1558 |
DB_ENV * |
1559 |
db_env_create (U32 env_flags = 0) |
1560 |
CODE: |
1561 |
{ |
1562 |
errno = db_env_create (&RETVAL, env_flags); |
1563 |
if (errno) |
1564 |
croak ("db_env_create: %s", db_strerror (errno)); |
1565 |
|
1566 |
if (0) |
1567 |
{ |
1568 |
RETVAL->set_errcall (RETVAL, debug_errcall); |
1569 |
RETVAL->set_msgcall (RETVAL, debug_msgcall); |
1570 |
} |
1571 |
} |
1572 |
OUTPUT: |
1573 |
RETVAL |
1574 |
|
1575 |
void |
1576 |
db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) |
1577 |
PREINIT: |
1578 |
CALLBACK |
1579 |
CODE: |
1580 |
{ |
1581 |
dREQ (REQ_ENV_OPEN, 1); |
1582 |
req->env = env; |
1583 |
req->uint1 = open_flags | DB_THREAD; |
1584 |
req->int1 = mode; |
1585 |
req->buf1 = strdup_ornull (db_home); |
1586 |
REQ_SEND; |
1587 |
} |
1588 |
|
1589 |
void |
1590 |
db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) |
1591 |
PREINIT: |
1592 |
CALLBACK |
1593 |
CODE: |
1594 |
{ |
1595 |
dREQ (REQ_ENV_CLOSE, 0); |
1596 |
ptr_nuke (ST (0)); |
1597 |
req->env = env; |
1598 |
req->uint1 = flags; |
1599 |
REQ_SEND; |
1600 |
} |
1601 |
|
1602 |
void |
1603 |
db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) |
1604 |
PREINIT: |
1605 |
CALLBACK |
1606 |
CODE: |
1607 |
{ |
1608 |
dREQ (REQ_ENV_TXN_CHECKPOINT, 1); |
1609 |
req->env = env; |
1610 |
req->uint1 = kbyte; |
1611 |
req->int1 = min; |
1612 |
req->uint2 = flags; |
1613 |
REQ_SEND; |
1614 |
} |
1615 |
|
1616 |
void |
1617 |
db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) |
1618 |
PREINIT: |
1619 |
CALLBACK |
1620 |
CODE: |
1621 |
{ |
1622 |
dREQ (REQ_ENV_LOCK_DETECT, 1); |
1623 |
req->env = env; |
1624 |
req->uint1 = flags; |
1625 |
req->uint2 = atype; |
1626 |
/* req->int2 = 0; dummy */ |
1627 |
REQ_SEND; |
1628 |
} |
1629 |
|
1630 |
void |
1631 |
db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
1632 |
PREINIT: |
1633 |
CALLBACK |
1634 |
CODE: |
1635 |
{ |
1636 |
dREQ (REQ_ENV_MEMP_SYNC, 1); |
1637 |
req->env = env; |
1638 |
REQ_SEND; |
1639 |
} |
1640 |
|
1641 |
void |
1642 |
db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
1643 |
PREINIT: |
1644 |
CALLBACK |
1645 |
CODE: |
1646 |
{ |
1647 |
dREQ (REQ_ENV_MEMP_TRICKLE, 1); |
1648 |
req->env = env; |
1649 |
req->int1 = percent; |
1650 |
REQ_SEND; |
1651 |
} |
1652 |
|
1653 |
void |
1654 |
db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
1655 |
PREINIT: |
1656 |
CALLBACK |
1657 |
CODE: |
1658 |
{ |
1659 |
dREQ (REQ_ENV_DBREMOVE, 2); |
1660 |
req->env = env; |
1661 |
req->buf1 = strdup_ornull (file); |
1662 |
req->buf2 = strdup_ornull (database); |
1663 |
req->uint1 = flags; |
1664 |
REQ_SEND; |
1665 |
} |
1666 |
|
1667 |
void |
1668 |
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) |
1669 |
PREINIT: |
1670 |
CALLBACK |
1671 |
CODE: |
1672 |
{ |
1673 |
dREQ (REQ_ENV_DBRENAME, 2); |
1674 |
req->env = env; |
1675 |
req->buf1 = strdup_ornull (file); |
1676 |
req->buf2 = strdup_ornull (database); |
1677 |
req->buf3 = strdup_ornull (newname); |
1678 |
req->uint1 = flags; |
1679 |
REQ_SEND; |
1680 |
} |
1681 |
|
1682 |
void |
1683 |
db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0) |
1684 |
PREINIT: |
1685 |
CALLBACK |
1686 |
CODE: |
1687 |
{ |
1688 |
dREQ (REQ_ENV_LOG_ARCHIVE, 1); |
1689 |
req->sv1 = SvREFCNT_inc (listp); |
1690 |
req->env = env; |
1691 |
req->uint1 = flags; |
1692 |
REQ_SEND; |
1693 |
} |
1694 |
|
1695 |
DB * |
1696 |
db_create (DB_ENV *env = 0, U32 flags = 0) |
1697 |
CODE: |
1698 |
{ |
1699 |
errno = db_create (&RETVAL, env, flags); |
1700 |
if (errno) |
1701 |
croak ("db_create: %s", db_strerror (errno)); |
1702 |
|
1703 |
if (RETVAL) |
1704 |
RETVAL->app_private = (void *)newSVsv (ST (0)); |
1705 |
} |
1706 |
OUTPUT: |
1707 |
RETVAL |
1708 |
|
1709 |
void |
1710 |
db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
1711 |
PREINIT: |
1712 |
CALLBACK |
1713 |
CODE: |
1714 |
{ |
1715 |
dREQ (REQ_DB_OPEN, 2); |
1716 |
req->db = db; |
1717 |
req->txn = txnid; |
1718 |
req->buf1 = strdup_ornull (file); |
1719 |
req->buf2 = strdup_ornull (database); |
1720 |
req->int1 = type; |
1721 |
req->uint1 = flags | DB_THREAD; |
1722 |
req->int2 = mode; |
1723 |
REQ_SEND; |
1724 |
} |
1725 |
|
1726 |
void |
1727 |
db_close (DB *db, U32 flags = 0, SV *callback = 0) |
1728 |
PREINIT: |
1729 |
CALLBACK |
1730 |
CODE: |
1731 |
{ |
1732 |
dREQ (REQ_DB_CLOSE, 0); |
1733 |
ptr_nuke (ST (0)); |
1734 |
req->db = db; |
1735 |
req->uint1 = flags; |
1736 |
req->sv1 = (SV *)db->app_private; |
1737 |
REQ_SEND; |
1738 |
} |
1739 |
|
1740 |
#if DB_VERSION_MINOR >= 4 |
1741 |
|
1742 |
void |
1743 |
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) |
1744 |
PREINIT: |
1745 |
CALLBACK |
1746 |
CODE: |
1747 |
{ |
1748 |
dREQ (REQ_DB_COMPACT, 2); |
1749 |
req->db = db; |
1750 |
req->txn = txn; |
1751 |
if (start) sv_to_dbt (&req->dbt1, start); |
1752 |
if (stop ) sv_to_dbt (&req->dbt2, stop ); |
1753 |
req->uint1 = flags; |
1754 |
REQ_SEND; |
1755 |
} |
1756 |
|
1757 |
#endif |
1758 |
|
1759 |
void |
1760 |
db_sync (DB *db, U32 flags = 0, SV *callback = 0) |
1761 |
PREINIT: |
1762 |
CALLBACK |
1763 |
CODE: |
1764 |
{ |
1765 |
dREQ (REQ_DB_SYNC, 1); |
1766 |
req->db = db; |
1767 |
req->uint1 = flags; |
1768 |
REQ_SEND; |
1769 |
} |
1770 |
|
1771 |
void |
1772 |
db_verify (DB *db, bdb_filename file, bdb_filename database = 0, SV *dummy = 0, U32 flags = 0, SV *callback = 0) |
1773 |
PREINIT: |
1774 |
CALLBACK |
1775 |
CODE: |
1776 |
{ |
1777 |
dREQ (REQ_DB_VERIFY, 1); |
1778 |
ptr_nuke (ST (0)); /* verify destroys the database handle, hopefully it is freed as well */ |
1779 |
req->db = db; |
1780 |
req->buf1 = strdup (file); |
1781 |
req->buf2 = strdup_ornull (database); |
1782 |
req->uint1 = flags; |
1783 |
REQ_SEND; |
1784 |
} |
1785 |
|
1786 |
void |
1787 |
db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
1788 |
PREINIT: |
1789 |
CALLBACK |
1790 |
CODE: |
1791 |
{ |
1792 |
dREQ (REQ_DB_UPGRADE, 1); |
1793 |
req->db = db; |
1794 |
req->buf1 = strdup (file); |
1795 |
req->uint1 = flags; |
1796 |
REQ_SEND; |
1797 |
} |
1798 |
|
1799 |
void |
1800 |
db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *key_range, U32 flags = 0, SV *callback = 0) |
1801 |
PREINIT: |
1802 |
CALLBACK |
1803 |
CODE: |
1804 |
{ |
1805 |
dREQ (REQ_DB_KEY_RANGE, 2); |
1806 |
req->db = db; |
1807 |
req->txn = txn; |
1808 |
sv_to_dbt (&req->dbt1, key); |
1809 |
req->uint1 = flags; |
1810 |
req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1811 |
REQ_SEND; |
1812 |
} |
1813 |
|
1814 |
void |
1815 |
db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
1816 |
PREINIT: |
1817 |
CALLBACK |
1818 |
CODE: |
1819 |
{ |
1820 |
dREQ (REQ_DB_PUT, 2); |
1821 |
req->db = db; |
1822 |
req->txn = txn; |
1823 |
sv_to_dbt (&req->dbt1, key); |
1824 |
sv_to_dbt (&req->dbt2, data); |
1825 |
req->uint1 = flags; |
1826 |
REQ_SEND; |
1827 |
} |
1828 |
|
1829 |
#if DB_VERSION_MINOR >= 6 |
1830 |
|
1831 |
void |
1832 |
db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
1833 |
PREINIT: |
1834 |
CALLBACK |
1835 |
CODE: |
1836 |
{ |
1837 |
dREQ (REQ_DB_EXISTS, 2); |
1838 |
req->db = db; |
1839 |
req->txn = txn; |
1840 |
req->uint1 = flags; |
1841 |
sv_to_dbt (&req->dbt1, key); |
1842 |
REQ_SEND; |
1843 |
} |
1844 |
|
1845 |
#endif |
1846 |
|
1847 |
void |
1848 |
db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0) |
1849 |
PREINIT: |
1850 |
CALLBACK |
1851 |
CODE: |
1852 |
{ |
1853 |
//TODO: key is somtimesmutable |
1854 |
dREQ (REQ_DB_GET, 2); |
1855 |
req->db = db; |
1856 |
req->txn = txn; |
1857 |
req->uint1 = flags; |
1858 |
sv_to_dbt (&req->dbt1, key); |
1859 |
req->dbt3.flags = DB_DBT_MALLOC; |
1860 |
req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1861 |
REQ_SEND; |
1862 |
} |
1863 |
|
1864 |
void |
1865 |
db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0) |
1866 |
PREINIT: |
1867 |
CALLBACK |
1868 |
CODE: |
1869 |
{ |
1870 |
//TODO: key is somtimesmutable |
1871 |
dREQ (REQ_DB_PGET, 2); |
1872 |
req->db = db; |
1873 |
req->txn = txn; |
1874 |
req->uint1 = flags; |
1875 |
|
1876 |
sv_to_dbt (&req->dbt1, key); |
1877 |
|
1878 |
req->dbt2.flags = DB_DBT_MALLOC; |
1879 |
req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey); |
1880 |
|
1881 |
req->dbt3.flags = DB_DBT_MALLOC; |
1882 |
req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1883 |
REQ_SEND; |
1884 |
} |
1885 |
|
1886 |
void |
1887 |
db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
1888 |
PREINIT: |
1889 |
CALLBACK |
1890 |
CODE: |
1891 |
{ |
1892 |
dREQ (REQ_DB_DEL, 2); |
1893 |
req->db = db; |
1894 |
req->txn = txn; |
1895 |
req->uint1 = flags; |
1896 |
sv_to_dbt (&req->dbt1, key); |
1897 |
REQ_SEND; |
1898 |
} |
1899 |
|
1900 |
void |
1901 |
db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
1902 |
PREINIT: |
1903 |
CALLBACK |
1904 |
CODE: |
1905 |
{ |
1906 |
dREQ (REQ_TXN_COMMIT, 0); |
1907 |
ptr_nuke (ST (0)); |
1908 |
req->txn = txn; |
1909 |
req->uint1 = flags; |
1910 |
REQ_SEND; |
1911 |
} |
1912 |
|
1913 |
void |
1914 |
db_txn_abort (DB_TXN *txn, SV *callback = 0) |
1915 |
PREINIT: |
1916 |
CALLBACK |
1917 |
CODE: |
1918 |
{ |
1919 |
dREQ (REQ_TXN_ABORT, 0); |
1920 |
ptr_nuke (ST (0)); |
1921 |
req->txn = txn; |
1922 |
REQ_SEND; |
1923 |
} |
1924 |
|
1925 |
void |
1926 |
db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
1927 |
PREINIT: |
1928 |
CALLBACK |
1929 |
CODE: |
1930 |
{ |
1931 |
dREQ (REQ_TXN_FINISH, 0); |
1932 |
ptr_nuke (ST (0)); |
1933 |
req->txn = txn; |
1934 |
req->uint1 = flags; |
1935 |
REQ_SEND; |
1936 |
} |
1937 |
|
1938 |
void |
1939 |
db_c_close (DBC *dbc, SV *callback = 0) |
1940 |
PREINIT: |
1941 |
CALLBACK |
1942 |
CODE: |
1943 |
{ |
1944 |
dREQ (REQ_C_CLOSE, 0); |
1945 |
ptr_nuke (ST (0)); |
1946 |
req->dbc = dbc; |
1947 |
REQ_SEND; |
1948 |
} |
1949 |
|
1950 |
void |
1951 |
db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) |
1952 |
PREINIT: |
1953 |
CALLBACK |
1954 |
CODE: |
1955 |
{ |
1956 |
dREQ (REQ_C_COUNT, 1); |
1957 |
req->dbc = dbc; |
1958 |
req->sv1 = SvREFCNT_inc (count); |
1959 |
REQ_SEND; |
1960 |
} |
1961 |
|
1962 |
void |
1963 |
db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
1964 |
PREINIT: |
1965 |
CALLBACK |
1966 |
CODE: |
1967 |
{ |
1968 |
dREQ (REQ_C_PUT, 1); |
1969 |
req->dbc = dbc; |
1970 |
sv_to_dbt (&req->dbt1, key); |
1971 |
sv_to_dbt (&req->dbt2, data); |
1972 |
req->uint1 = flags; |
1973 |
REQ_SEND; |
1974 |
} |
1975 |
|
1976 |
void |
1977 |
db_c_get (DBC *dbc, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0) |
1978 |
PREINIT: |
1979 |
CALLBACK |
1980 |
CODE: |
1981 |
{ |
1982 |
if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key)) |
1983 |
croak ("db_c_get was passed a read-only/constant 'key' argument but operation is not DB_SET"); |
1984 |
if (SvPOKp (key) && !sv_utf8_downgrade (key, 1)) |
1985 |
croak ("argument \"%s\" must be byte/octet-encoded in %s", |
1986 |
"key", |
1987 |
"BDB::db_c_get"); |
1988 |
|
1989 |
{ |
1990 |
dREQ (REQ_C_GET, 1); |
1991 |
req->dbc = dbc; |
1992 |
req->uint1 = flags; |
1993 |
if ((flags & DB_OPFLAGS_MASK) == DB_SET) |
1994 |
sv_to_dbt (&req->dbt1, key); |
1995 |
else |
1996 |
{ |
1997 |
if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE) |
1998 |
sv_to_dbt (&req->dbt1, key); |
1999 |
else |
2000 |
req->dbt1.flags = DB_DBT_MALLOC; |
2001 |
|
2002 |
req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key); |
2003 |
} |
2004 |
|
2005 |
if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH |
2006 |
|| (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE) |
2007 |
sv_to_dbt (&req->dbt3, data); |
2008 |
else |
2009 |
req->dbt3.flags = DB_DBT_MALLOC; |
2010 |
|
2011 |
req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
2012 |
REQ_SEND; |
2013 |
} |
2014 |
} |
2015 |
|
2016 |
void |
2017 |
db_c_pget (DBC *dbc, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0) |
2018 |
PREINIT: |
2019 |
CALLBACK |
2020 |
CODE: |
2021 |
{ |
2022 |
if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key)) |
2023 |
croak ("db_c_pget was passed a read-only/constant 'key' argument but operation is not DB_SET"); |
2024 |
if (SvPOKp (key) && !sv_utf8_downgrade (key, 1)) |
2025 |
croak ("argument \"%s\" must be byte/octet-encoded in %s", |
2026 |
"key", |
2027 |
"BDB::db_c_pget"); |
2028 |
|
2029 |
{ |
2030 |
dREQ (REQ_C_PGET, 1); |
2031 |
req->dbc = dbc; |
2032 |
req->uint1 = flags; |
2033 |
if ((flags & DB_OPFLAGS_MASK) == DB_SET) |
2034 |
sv_to_dbt (&req->dbt1, key); |
2035 |
else |
2036 |
{ |
2037 |
if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE) |
2038 |
sv_to_dbt (&req->dbt1, key); |
2039 |
else |
2040 |
req->dbt1.flags = DB_DBT_MALLOC; |
2041 |
|
2042 |
req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key); |
2043 |
} |
2044 |
|
2045 |
req->dbt2.flags = DB_DBT_MALLOC; |
2046 |
req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey); |
2047 |
|
2048 |
if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH |
2049 |
|| (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE) |
2050 |
sv_to_dbt (&req->dbt3, data); |
2051 |
else |
2052 |
req->dbt3.flags = DB_DBT_MALLOC; |
2053 |
|
2054 |
req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
2055 |
REQ_SEND; |
2056 |
} |
2057 |
} |
2058 |
|
2059 |
void |
2060 |
db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0) |
2061 |
PREINIT: |
2062 |
CALLBACK |
2063 |
CODE: |
2064 |
{ |
2065 |
dREQ (REQ_C_DEL, 1); |
2066 |
req->dbc = dbc; |
2067 |
req->uint1 = flags; |
2068 |
REQ_SEND; |
2069 |
} |
2070 |
|
2071 |
|
2072 |
#if DB_VERSION_MINOR >= 3 |
2073 |
|
2074 |
void |
2075 |
db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
2076 |
PREINIT: |
2077 |
CALLBACK |
2078 |
CODE: |
2079 |
{ |
2080 |
dREQ (REQ_SEQ_OPEN, 2); |
2081 |
req->seq = seq; |
2082 |
req->txn = txnid; |
2083 |
req->uint1 = flags | DB_THREAD; |
2084 |
sv_to_dbt (&req->dbt1, key); |
2085 |
REQ_SEND; |
2086 |
} |
2087 |
|
2088 |
void |
2089 |
db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) |
2090 |
PREINIT: |
2091 |
CALLBACK |
2092 |
CODE: |
2093 |
{ |
2094 |
dREQ (REQ_SEQ_CLOSE, 0); |
2095 |
ptr_nuke (ST (0)); |
2096 |
req->seq = seq; |
2097 |
req->uint1 = flags; |
2098 |
REQ_SEND; |
2099 |
} |
2100 |
|
2101 |
void |
2102 |
db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV_mutable *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) |
2103 |
PREINIT: |
2104 |
CALLBACK |
2105 |
CODE: |
2106 |
{ |
2107 |
dREQ (REQ_SEQ_GET, 2); |
2108 |
req->seq = seq; |
2109 |
req->txn = txnid; |
2110 |
req->int1 = delta; |
2111 |
req->uint1 = flags; |
2112 |
req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
2113 |
REQ_SEND; |
2114 |
} |
2115 |
|
2116 |
void |
2117 |
db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) |
2118 |
PREINIT: |
2119 |
CALLBACK |
2120 |
CODE: |
2121 |
{ |
2122 |
dREQ (REQ_SEQ_REMOVE, 2); |
2123 |
req->seq = seq; |
2124 |
req->txn = txnid; |
2125 |
req->uint1 = flags; |
2126 |
REQ_SEND; |
2127 |
} |
2128 |
|
2129 |
#endif |
2130 |
|
2131 |
|
2132 |
MODULE = BDB PACKAGE = BDB::Env |
2133 |
|
2134 |
void |
2135 |
DESTROY (DB_ENV_ornuked *env) |
2136 |
CODE: |
2137 |
if (env) |
2138 |
env->close (env, 0); |
2139 |
|
2140 |
int set_data_dir (DB_ENV *env, const char *dir) |
2141 |
CODE: |
2142 |
RETVAL = env->set_data_dir (env, dir); |
2143 |
OUTPUT: |
2144 |
RETVAL |
2145 |
|
2146 |
int set_tmp_dir (DB_ENV *env, const char *dir) |
2147 |
CODE: |
2148 |
RETVAL = env->set_tmp_dir (env, dir); |
2149 |
OUTPUT: |
2150 |
RETVAL |
2151 |
|
2152 |
int set_lg_dir (DB_ENV *env, const char *dir) |
2153 |
CODE: |
2154 |
RETVAL = env->set_lg_dir (env, dir); |
2155 |
OUTPUT: |
2156 |
RETVAL |
2157 |
|
2158 |
int set_shm_key (DB_ENV *env, long shm_key) |
2159 |
CODE: |
2160 |
RETVAL = env->set_shm_key (env, shm_key); |
2161 |
OUTPUT: |
2162 |
RETVAL |
2163 |
|
2164 |
int set_cachesize (DB_ENV *env, U32 gbytes, U32 bytes, int ncache = 0) |
2165 |
CODE: |
2166 |
RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
2167 |
OUTPUT: |
2168 |
RETVAL |
2169 |
|
2170 |
int set_flags (DB_ENV *env, U32 flags, int onoff = 1) |
2171 |
CODE: |
2172 |
RETVAL = env->set_flags (env, flags, onoff); |
2173 |
OUTPUT: |
2174 |
RETVAL |
2175 |
|
2176 |
#if DB_VERSION_MINOR >= 7 |
2177 |
|
2178 |
int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
2179 |
CODE: |
2180 |
RETVAL = env->set_intermediate_dir_mode (env, mode); |
2181 |
OUTPUT: |
2182 |
RETVAL |
2183 |
|
2184 |
int log_set_config (DB_ENV *env, U32 flags, int onoff = 1) |
2185 |
CODE: |
2186 |
RETVAL = env->log_set_config (env, flags, onoff); |
2187 |
OUTPUT: |
2188 |
RETVAL |
2189 |
|
2190 |
#endif |
2191 |
|
2192 |
|
2193 |
void set_errfile (DB_ENV *env, FILE *errfile = 0) |
2194 |
CODE: |
2195 |
env->set_errfile (env, errfile); |
2196 |
|
2197 |
void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
2198 |
CODE: |
2199 |
env->set_msgfile (env, msgfile); |
2200 |
|
2201 |
int set_verbose (DB_ENV *env, U32 which = -1, int onoff = 1) |
2202 |
CODE: |
2203 |
RETVAL = env->set_verbose (env, which, onoff); |
2204 |
OUTPUT: |
2205 |
RETVAL |
2206 |
|
2207 |
int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0) |
2208 |
CODE: |
2209 |
RETVAL = env->set_encrypt (env, password, flags); |
2210 |
OUTPUT: |
2211 |
RETVAL |
2212 |
|
2213 |
int set_timeout (DB_ENV *env, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
2214 |
CODE: |
2215 |
RETVAL = env->set_timeout (env, timeout * 1000000, flags); |
2216 |
OUTPUT: |
2217 |
RETVAL |
2218 |
|
2219 |
int set_mp_max_openfd (DB_ENV *env, int maxopenfd); |
2220 |
CODE: |
2221 |
RETVAL = env->set_mp_max_openfd (env, maxopenfd); |
2222 |
OUTPUT: |
2223 |
RETVAL |
2224 |
|
2225 |
int set_mp_max_write (DB_ENV *env, int maxwrite, int maxwrite_sleep); |
2226 |
CODE: |
2227 |
RETVAL = env->set_mp_max_write (env, maxwrite, maxwrite_sleep); |
2228 |
OUTPUT: |
2229 |
RETVAL |
2230 |
|
2231 |
int set_mp_mmapsize (DB_ENV *env, int mmapsize_mb) |
2232 |
CODE: |
2233 |
RETVAL = env->set_mp_mmapsize (env, ((size_t)mmapsize_mb) << 20); |
2234 |
OUTPUT: |
2235 |
RETVAL |
2236 |
|
2237 |
int set_lk_detect (DB_ENV *env, U32 detect = DB_LOCK_DEFAULT) |
2238 |
CODE: |
2239 |
RETVAL = env->set_lk_detect (env, detect); |
2240 |
OUTPUT: |
2241 |
RETVAL |
2242 |
|
2243 |
int set_lk_max_lockers (DB_ENV *env, U32 max) |
2244 |
CODE: |
2245 |
RETVAL = env->set_lk_max_lockers (env, max); |
2246 |
OUTPUT: |
2247 |
RETVAL |
2248 |
|
2249 |
int set_lk_max_locks (DB_ENV *env, U32 max) |
2250 |
CODE: |
2251 |
RETVAL = env->set_lk_max_locks (env, max); |
2252 |
OUTPUT: |
2253 |
RETVAL |
2254 |
|
2255 |
int set_lk_max_objects (DB_ENV *env, U32 max) |
2256 |
CODE: |
2257 |
RETVAL = env->set_lk_max_objects (env, max); |
2258 |
OUTPUT: |
2259 |
RETVAL |
2260 |
|
2261 |
int set_lg_bsize (DB_ENV *env, U32 max) |
2262 |
CODE: |
2263 |
RETVAL = env->set_lg_bsize (env, max); |
2264 |
OUTPUT: |
2265 |
RETVAL |
2266 |
|
2267 |
int set_lg_max (DB_ENV *env, U32 max) |
2268 |
CODE: |
2269 |
RETVAL = env->set_lg_max (env, max); |
2270 |
OUTPUT: |
2271 |
RETVAL |
2272 |
|
2273 |
#if DB_VERSION_MINOR >= 4 |
2274 |
|
2275 |
int mutex_set_max (DB_ENV *env, U32 max) |
2276 |
CODE: |
2277 |
RETVAL = env->mutex_set_max (env, max); |
2278 |
OUTPUT: |
2279 |
RETVAL |
2280 |
|
2281 |
int mutex_set_increment (DB_ENV *env, U32 increment) |
2282 |
CODE: |
2283 |
RETVAL = env->mutex_set_increment (env, increment); |
2284 |
OUTPUT: |
2285 |
RETVAL |
2286 |
|
2287 |
int mutex_set_tas_spins (DB_ENV *env, U32 tas_spins) |
2288 |
CODE: |
2289 |
RETVAL = env->mutex_set_tas_spins (env, tas_spins); |
2290 |
OUTPUT: |
2291 |
RETVAL |
2292 |
|
2293 |
int mutex_set_align (DB_ENV *env, U32 align) |
2294 |
CODE: |
2295 |
RETVAL = env->mutex_set_align (env, align); |
2296 |
OUTPUT: |
2297 |
RETVAL |
2298 |
|
2299 |
#endif |
2300 |
|
2301 |
DB_TXN * |
2302 |
txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
2303 |
CODE: |
2304 |
errno = env->txn_begin (env, parent, &RETVAL, flags); |
2305 |
if (errno) |
2306 |
croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2307 |
OUTPUT: |
2308 |
RETVAL |
2309 |
|
2310 |
#if DB_VERSION_MINOR >= 5 |
2311 |
|
2312 |
DB_TXN * |
2313 |
cdsgroup_begin (DB_ENV *env) |
2314 |
CODE: |
2315 |
errno = env->cdsgroup_begin (env, &RETVAL); |
2316 |
if (errno) |
2317 |
croak ("DB_ENV->cdsgroup_begin: %s", db_strerror (errno)); |
2318 |
OUTPUT: |
2319 |
RETVAL |
2320 |
|
2321 |
#endif |
2322 |
|
2323 |
MODULE = BDB PACKAGE = BDB::Db |
2324 |
|
2325 |
void |
2326 |
DESTROY (DB_ornuked *db) |
2327 |
CODE: |
2328 |
if (db) |
2329 |
{ |
2330 |
SV *env = (SV *)db->app_private; |
2331 |
db->close (db, 0); |
2332 |
SvREFCNT_dec (env); |
2333 |
} |
2334 |
|
2335 |
int set_cachesize (DB *db, U32 gbytes, U32 bytes, int ncache = 0) |
2336 |
CODE: |
2337 |
RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); |
2338 |
OUTPUT: |
2339 |
RETVAL |
2340 |
|
2341 |
int set_pagesize (DB *db, U32 pagesize) |
2342 |
CODE: |
2343 |
RETVAL = db->set_pagesize (db, pagesize); |
2344 |
OUTPUT: |
2345 |
RETVAL |
2346 |
|
2347 |
int set_flags (DB *db, U32 flags) |
2348 |
CODE: |
2349 |
RETVAL = db->set_flags (db, flags); |
2350 |
OUTPUT: |
2351 |
RETVAL |
2352 |
|
2353 |
int set_encrypt (DB *db, const char *password, U32 flags) |
2354 |
CODE: |
2355 |
RETVAL = db->set_encrypt (db, password, flags); |
2356 |
OUTPUT: |
2357 |
RETVAL |
2358 |
|
2359 |
int set_lorder (DB *db, int lorder) |
2360 |
CODE: |
2361 |
RETVAL = db->set_lorder (db, lorder); |
2362 |
OUTPUT: |
2363 |
RETVAL |
2364 |
|
2365 |
int set_bt_minkey (DB *db, U32 minkey) |
2366 |
CODE: |
2367 |
RETVAL = db->set_bt_minkey (db, minkey); |
2368 |
OUTPUT: |
2369 |
RETVAL |
2370 |
|
2371 |
int set_re_delim (DB *db, int delim) |
2372 |
CODE: |
2373 |
RETVAL = db->set_re_delim (db, delim); |
2374 |
OUTPUT: |
2375 |
RETVAL |
2376 |
|
2377 |
int set_re_pad (DB *db, int re_pad) |
2378 |
CODE: |
2379 |
RETVAL = db->set_re_pad (db, re_pad); |
2380 |
OUTPUT: |
2381 |
RETVAL |
2382 |
|
2383 |
int set_re_source (DB *db, char *source) |
2384 |
CODE: |
2385 |
RETVAL = db->set_re_source (db, source); |
2386 |
OUTPUT: |
2387 |
RETVAL |
2388 |
|
2389 |
int set_re_len (DB *db, U32 re_len) |
2390 |
CODE: |
2391 |
RETVAL = db->set_re_len (db, re_len); |
2392 |
OUTPUT: |
2393 |
RETVAL |
2394 |
|
2395 |
int set_h_ffactor (DB *db, U32 h_ffactor) |
2396 |
CODE: |
2397 |
RETVAL = db->set_h_ffactor (db, h_ffactor); |
2398 |
OUTPUT: |
2399 |
RETVAL |
2400 |
|
2401 |
int set_h_nelem (DB *db, U32 h_nelem) |
2402 |
CODE: |
2403 |
RETVAL = db->set_h_nelem (db, h_nelem); |
2404 |
OUTPUT: |
2405 |
RETVAL |
2406 |
|
2407 |
int set_q_extentsize (DB *db, U32 extentsize) |
2408 |
CODE: |
2409 |
RETVAL = db->set_q_extentsize (db, extentsize); |
2410 |
OUTPUT: |
2411 |
RETVAL |
2412 |
|
2413 |
DBC * |
2414 |
cursor (DB *db, DB_TXN_ornull *txn = 0, U32 flags = 0) |
2415 |
CODE: |
2416 |
errno = db->cursor (db, txn, &RETVAL, flags); |
2417 |
if (errno) |
2418 |
croak ("DB->cursor: %s", db_strerror (errno)); |
2419 |
OUTPUT: |
2420 |
RETVAL |
2421 |
|
2422 |
#if DB_VERSION_MINOR >= 3 |
2423 |
|
2424 |
DB_SEQUENCE * |
2425 |
sequence (DB *db, U32 flags = 0) |
2426 |
CODE: |
2427 |
{ |
2428 |
errno = db_sequence_create (&RETVAL, db, flags); |
2429 |
if (errno) |
2430 |
croak ("db_sequence_create: %s", db_strerror (errno)); |
2431 |
} |
2432 |
OUTPUT: |
2433 |
RETVAL |
2434 |
|
2435 |
#endif |
2436 |
|
2437 |
|
2438 |
MODULE = BDB PACKAGE = BDB::Txn |
2439 |
|
2440 |
void |
2441 |
DESTROY (DB_TXN_ornuked *txn) |
2442 |
CODE: |
2443 |
if (txn) |
2444 |
txn->abort (txn); |
2445 |
|
2446 |
int set_timeout (DB_TXN *txn, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
2447 |
CODE: |
2448 |
RETVAL = txn->set_timeout (txn, timeout * 1000000, flags); |
2449 |
OUTPUT: |
2450 |
RETVAL |
2451 |
|
2452 |
int failed (DB_TXN *txn) |
2453 |
CODE: |
2454 |
RETVAL = !!(txn->flags & TXN_DEADLOCK); |
2455 |
OUTPUT: |
2456 |
RETVAL |
2457 |
|
2458 |
|
2459 |
MODULE = BDB PACKAGE = BDB::Cursor |
2460 |
|
2461 |
void |
2462 |
DESTROY (DBC_ornuked *dbc) |
2463 |
CODE: |
2464 |
if (dbc) |
2465 |
dbc->c_close (dbc); |
2466 |
|
2467 |
#if DB_VERSION_MINOR >= 6 |
2468 |
|
2469 |
int set_priority (DBC *dbc, int priority) |
2470 |
CODE: |
2471 |
dbc->set_priority (dbc, priority); |
2472 |
|
2473 |
#endif |
2474 |
|
2475 |
#if DB_VERSION_MINOR >= 3 |
2476 |
|
2477 |
MODULE = BDB PACKAGE = BDB::Sequence |
2478 |
|
2479 |
void |
2480 |
DESTROY (DB_SEQUENCE_ornuked *seq) |
2481 |
CODE: |
2482 |
if (seq) |
2483 |
seq->close (seq, 0); |
2484 |
|
2485 |
int initial_value (DB_SEQUENCE *seq, db_seq_t value) |
2486 |
CODE: |
2487 |
RETVAL = seq->initial_value (seq, value); |
2488 |
OUTPUT: |
2489 |
RETVAL |
2490 |
|
2491 |
int set_cachesize (DB_SEQUENCE *seq, U32 size) |
2492 |
CODE: |
2493 |
RETVAL = seq->set_cachesize (seq, size); |
2494 |
OUTPUT: |
2495 |
RETVAL |
2496 |
|
2497 |
int set_flags (DB_SEQUENCE *seq, U32 flags) |
2498 |
CODE: |
2499 |
RETVAL = seq->set_flags (seq, flags); |
2500 |
OUTPUT: |
2501 |
RETVAL |
2502 |
|
2503 |
int set_range (DB_SEQUENCE *seq, db_seq_t min, db_seq_t max) |
2504 |
CODE: |
2505 |
RETVAL = seq->set_range (seq, min, max); |
2506 |
OUTPUT: |
2507 |
RETVAL |
2508 |
|
2509 |
#endif |
2510 |
|
2511 |
|