ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/BDB/BDB.xs
(Generate patch)

Comparing BDB/BDB.xs (file contents):
Revision 1.46 by root, Wed Jul 9 21:16:14 2008 UTC vs.
Revision 1.81 by root, Tue Feb 2 04:28:06 2016 UTC

1#define X_STACKSIZE 1024 * 128 + sizeof (long) * 64 * 1024 / 4
2
1#include "xthread.h" 3#include "xthread.h"
2 4
3#include <errno.h> 5#include <errno.h>
4 6
5#include "EXTERN.h" 7#include "EXTERN.h"
6#include "perl.h" 8#include "perl.h"
7#include "XSUB.h" 9#include "XSUB.h"
8 10
11#include "schmorp.h"
12
9// perl stupidly defines these as macros, breaking 13// perl stupidly defines these as argument-less macros, breaking
10// lots and lots of code. 14// lots and lots of code.
11#undef open 15#undef open
12#undef close 16#undef close
13#undef abort 17#undef abort
14#undef malloc 18#undef malloc
27# include <unistd.h> 31# include <unistd.h>
28#endif 32#endif
29 33
30#include <db.h> 34#include <db.h>
31 35
32#if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 4) 36#define DBVER DB_VERSION_MAJOR * 100 + DB_VERSION_MINOR
37
38#if DBVER < 403
33# error you need Berkeley DB 4.4 or newer installed 39# error you need Berkeley DB 4.3 or a newer version installed
34#endif 40#endif
35 41
36/* number of seconds after which idle threads exit */ 42/* number of seconds after which idle threads exit */
37#define IDLE_TIMEOUT 10 43#define IDLE_TIMEOUT 10
44
45typedef SV SV_mutable;
38 46
39typedef DB_ENV DB_ENV_ornull; 47typedef DB_ENV DB_ENV_ornull;
40typedef DB_TXN DB_TXN_ornull; 48typedef DB_TXN DB_TXN_ornull;
41typedef DBC DBC_ornull; 49typedef DBC DBC_ornull;
42typedef DB DB_ornull; 50typedef DB DB_ornull;
43typedef DB_SEQUENCE DB_SEQUENCE_ornull;
44 51
45typedef DB_ENV DB_ENV_ornuked; 52typedef DB_ENV DB_ENV_ornuked;
46typedef DB_TXN DB_TXN_ornuked; 53typedef DB_TXN DB_TXN_ornuked;
47typedef DBC DBC_ornuked; 54typedef DBC DBC_ornuked;
48typedef DB DB_ornuked; 55typedef DB DB_ornuked;
56
57#if DBVER >= 403
58typedef DB_SEQUENCE DB_SEQUENCE_ornull;
49typedef DB_SEQUENCE DB_SEQUENCE_ornuked; 59typedef DB_SEQUENCE DB_SEQUENCE_ornuked;
60#endif
50 61
51typedef SV SV8; /* byte-sv, used for argument-checking */
52typedef char *bdb_filename; 62typedef char *bdb_filename;
53 63
54static SV *prepare_cb; 64static SV *prepare_cb;
55 65
56#if DB_VERSION_MINOR >= 6 66static HV
67 *bdb_stash,
68 *bdb_env_stash,
69 *bdb_txn_stash,
70 *bdb_cursor_stash,
71 *bdb_db_stash,
72 *bdb_sequence_stash;
73
74#if DBVER >= 406
57# define c_close close 75# define c_close close
58# define c_count count 76# define c_count count
59# define c_del del 77# define c_del del
60# define c_dup dup 78# define c_dup dup
61# define c_get get 79# define c_get get
127dbt_to_sv (SV *sv, DBT *dbt) 145dbt_to_sv (SV *sv, DBT *dbt)
128{ 146{
129 if (sv) 147 if (sv)
130 { 148 {
131 SvREADONLY_off (sv); 149 SvREADONLY_off (sv);
150
151 if (dbt->data)
132 sv_setpvn_mg (sv, dbt->data, dbt->size); 152 sv_setpvn_mg (sv, dbt->data, dbt->size);
153 else
154 sv_setsv_mg (sv, &PL_sv_undef);
155
133 SvREFCNT_dec (sv); 156 SvREFCNT_dec (sv);
134 } 157 }
135 158
136 free (dbt->data); 159 free (dbt->data);
137} 160}
138 161
139enum { 162enum {
140 REQ_QUIT, 163 REQ_QUIT,
141 REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, 164 REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT,
142 REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, 165 REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME,
166 REQ_ENV_LOG_ARCHIVE, REQ_ENV_LSN_RESET, REQ_ENV_FILEID_RESET,
143 REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, 167 REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_VERIFY, REQ_DB_UPGRADE,
144 REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, 168 REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE,
145 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, 169 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH,
146 REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, 170 REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL,
147 REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, 171 REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE,
148}; 172};
164 char *buf1, *buf2, *buf3; 188 char *buf1, *buf2, *buf3;
165 SV *sv1, *sv2, *sv3; 189 SV *sv1, *sv2, *sv3;
166 190
167 DBT dbt1, dbt2, dbt3; 191 DBT dbt1, dbt2, dbt3;
168 DB_KEY_RANGE key_range; 192 DB_KEY_RANGE key_range;
193#if DBVER >= 403
169 DB_SEQUENCE *seq; 194 DB_SEQUENCE *seq;
170 db_seq_t seq_t; 195 db_seq_t seq_t;
196#endif
197
198 SV *rsv1, *rsv2; // keep some request objects alive
171} bdb_cb; 199} bdb_cb;
172 200
173typedef bdb_cb *bdb_req; 201typedef bdb_cb *bdb_req;
174 202
175enum { 203enum {
198static int next_pri = DEFAULT_PRI + PRI_BIAS; 226static int next_pri = DEFAULT_PRI + PRI_BIAS;
199 227
200static unsigned int started, idle, wanted; 228static unsigned int started, idle, wanted;
201 229
202/* worker threads management */ 230/* worker threads management */
203static mutex_t wrklock = X_MUTEX_INIT; 231static xmutex_t wrklock = X_MUTEX_INIT;
204 232
205typedef struct worker { 233typedef struct worker {
206 /* locked by wrklock */ 234 /* locked by wrklock */
207 struct worker *prev, *next; 235 struct worker *prev, *next;
208 236
209 thread_t tid; 237 xthread_t tid;
210 238
211 /* locked by reslock, reqlock or wrklock */ 239 /* locked by reslock, reqlock or wrklock */
212 bdb_req req; /* currently processed request */ 240 bdb_req req; /* currently processed request */
213 void *dbuf; 241 void *dbuf;
214 DIR *dirp; 242 DIR *dirp;
229} 257}
230 258
231static volatile unsigned int nreqs, nready, npending; 259static volatile unsigned int nreqs, nready, npending;
232static volatile unsigned int max_idle = 4; 260static volatile unsigned int max_idle = 4;
233static volatile unsigned int max_outstanding = 0xffffffff; 261static volatile unsigned int max_outstanding = 0xffffffff;
234static int respipe_osf [2], respipe [2] = { -1, -1 }; 262static s_epipe respipe;
235 263
236static mutex_t reslock = X_MUTEX_INIT; 264static xmutex_t reslock = X_MUTEX_INIT;
237static mutex_t reqlock = X_MUTEX_INIT; 265static xmutex_t reqlock = X_MUTEX_INIT;
238static cond_t reqwait = X_COND_INIT; 266static xcond_t reqwait = X_COND_INIT;
239 267
240#if WORDACCESS_UNSAFE 268#if WORDACCESS_UNSAFE
241 269
242static unsigned int get_nready (void) 270static unsigned int get_nready (void)
243{ 271{
334 abort (); 362 abort ();
335} 363}
336 364
337static int poll_cb (void); 365static int poll_cb (void);
338static void req_free (bdb_req req); 366static void req_free (bdb_req req);
339static void req_cancel (bdb_req req);
340 367
341static int req_invoke (bdb_req req) 368static int req_invoke (bdb_req req)
342{ 369{
343 dSP; 370 switch (req->type)
371 {
372 case REQ_DB_CLOSE:
373 SvREFCNT_dec (req->sv1);
374 break;
375
376 case REQ_DB_GET:
377 case REQ_DB_PGET:
378 case REQ_C_GET:
379 case REQ_C_PGET:
380 case REQ_DB_PUT:
381 case REQ_C_PUT:
382 dbt_to_sv (req->sv1, &req->dbt1);
383 dbt_to_sv (req->sv2, &req->dbt2);
384 dbt_to_sv (req->sv3, &req->dbt3);
385 break;
386
387 case REQ_DB_KEY_RANGE:
388 {
389 AV *av = newAV ();
390
391 av_push (av, newSVnv (req->key_range.less));
392 av_push (av, newSVnv (req->key_range.equal));
393 av_push (av, newSVnv (req->key_range.greater));
394
395 av = (AV *)newRV_noinc ((SV *)av);
396
397 SvREADONLY_off (req->sv1);
398 sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av));
399 SvREFCNT_dec (av);
400 SvREFCNT_dec (req->sv1);
401 }
402 break;
403
404#if DBVER >= 403
405 case REQ_SEQ_GET:
406 SvREADONLY_off (req->sv1);
407
408 if (sizeof (IV) > 4)
409 sv_setiv_mg (req->sv1, (IV)req->seq_t);
410 else
411 sv_setnv_mg (req->sv1, (NV)req->seq_t);
412
413 SvREFCNT_dec (req->sv1);
414 break;
415#endif
416
417 case REQ_ENV_LOG_ARCHIVE:
418 {
419 AV *av = newAV ();
420 char **listp = (char **)req->buf1;
421
422 if (listp)
423 while (*listp)
424 av_push (av, newSVpv (*listp, 0)), ++listp;
425
426 av = (AV *)newRV_noinc ((SV *)av);
427
428 SvREADONLY_off (req->sv1);
429 sv_setsv_mg (req->sv1, (SV *)av);
430 SvREFCNT_dec (av);
431 SvREFCNT_dec (req->sv1);
432 }
433 break;
434 }
435
436 errno = req->result;
344 437
345 if (req->callback) 438 if (req->callback)
346 { 439 {
440 dSP;
441
347 ENTER; 442 ENTER;
348 SAVETMPS; 443 SAVETMPS;
349 PUSHMARK (SP); 444 PUSHMARK (SP);
350 445
351 switch (req->type)
352 {
353 case REQ_DB_CLOSE:
354 SvREFCNT_dec (req->sv1);
355 break;
356
357 case REQ_DB_GET:
358 case REQ_DB_PGET:
359 dbt_to_sv (req->sv3, &req->dbt3);
360 break;
361
362 case REQ_C_GET:
363 case REQ_C_PGET:
364 dbt_to_sv (req->sv1, &req->dbt1);
365 dbt_to_sv (req->sv2, &req->dbt2);
366 dbt_to_sv (req->sv3, &req->dbt3);
367 break;
368
369 case REQ_DB_PUT:
370 case REQ_C_PUT:
371 dbt_to_sv (0, &req->dbt1);
372 dbt_to_sv (0, &req->dbt2);
373 break;
374
375 case REQ_DB_KEY_RANGE:
376 {
377 AV *av = newAV ();
378
379 av_push (av, newSVnv (req->key_range.less));
380 av_push (av, newSVnv (req->key_range.equal));
381 av_push (av, newSVnv (req->key_range.greater));
382
383 SvREADONLY_off (req->sv1);
384 sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av));
385 SvREFCNT_dec (req->sv1);
386 }
387 break;
388
389 case REQ_SEQ_GET:
390 SvREADONLY_off (req->sv1);
391
392 if (sizeof (IV) > 4)
393 sv_setiv_mg (req->sv1, (IV)req->seq_t);
394 else
395 sv_setnv_mg (req->sv1, (NV)req->seq_t);
396
397 SvREFCNT_dec (req->sv1);
398 break;
399 }
400
401 errno = req->result;
402
403 PUTBACK; 446 PUTBACK;
404 call_sv (req->callback, G_VOID | G_EVAL); 447 call_sv (req->callback, G_VOID | G_EVAL);
405 SPAGAIN; 448 SPAGAIN;
406 449
407 FREETMPS; 450 FREETMPS;
408 LEAVE; 451 LEAVE;
452
453 return !SvTRUE (ERRSV);
409 } 454 }
410 455
411 return !SvTRUE (ERRSV); 456 return 1;
412} 457}
413 458
414static void req_free (bdb_req req) 459static void req_free (bdb_req req)
415{ 460{
416 SvREFCNT_dec (req->callback); 461 SvREFCNT_dec (req->callback);
462
463 SvREFCNT_dec (req->rsv1);
464 SvREFCNT_dec (req->rsv2);
417 465
418 free (req->buf1); 466 free (req->buf1);
419 free (req->buf2); 467 free (req->buf2);
420 free (req->buf3); 468 free (req->buf3);
421 469
422 Safefree (req); 470 Safefree (req);
423} 471}
424 472
425#ifdef USE_SOCKETS_AS_HANDLES
426# define TO_SOCKET(x) (win32_get_osfhandle (x))
427#else
428# define TO_SOCKET(x) (x)
429#endif
430
431static void 473static void
432create_respipe (void) 474create_respipe (void)
433{ 475{
434#ifdef _WIN32
435 int arg; /* argg */
436#endif
437 int old_readfd = respipe [0];
438
439 if (respipe [1] >= 0)
440 respipe_close (TO_SOCKET (respipe [1]));
441
442#ifdef _WIN32
443 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe))
444#else
445 if (pipe (respipe)) 476 if (s_epipe_renew (&respipe))
446#endif 477 croak ("BDB: unable to create event pipe");
447 croak ("unable to initialize result pipe");
448
449 if (old_readfd >= 0)
450 {
451 if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0)
452 croak ("unable to initialize result pipe(2)");
453
454 respipe_close (respipe [0]);
455 respipe [0] = old_readfd;
456 }
457
458#ifdef _WIN32
459 arg = 1;
460 if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg)
461 || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg))
462#else
463 if (fcntl (respipe [0], F_SETFL, O_NONBLOCK)
464 || fcntl (respipe [1], F_SETFL, O_NONBLOCK))
465#endif
466 croak ("unable to initialize result pipe(3)");
467
468 respipe_osf [0] = TO_SOCKET (respipe [0]);
469 respipe_osf [1] = TO_SOCKET (respipe [1]);
470} 478}
471 479
480static void bdb_request (bdb_req req);
472X_THREAD_PROC (bdb_proc); 481X_THREAD_PROC (bdb_proc);
473 482
474static void start_thread (void) 483static void start_thread (void)
475{ 484{
476 worker *wrk = calloc (1, sizeof (worker)); 485 worker *wrk = calloc (1, sizeof (worker));
477 486
478 if (!wrk) 487 if (!wrk)
479 croak ("unable to allocate worker thread data"); 488 croak ("unable to allocate worker thread data");
480 489
481 X_LOCK (wrklock); 490 X_LOCK (wrklock);
482 if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) 491 if (xthread_create (&wrk->tid, bdb_proc, (void *)wrk))
483 { 492 {
484 wrk->prev = &wrk_first; 493 wrk->prev = &wrk_first;
485 wrk->next = wrk_first.next; 494 wrk->next = wrk_first.next;
486 wrk_first.next->prev = wrk; 495 wrk_first.next->prev = wrk;
487 wrk_first.next = wrk; 496 wrk_first.next = wrk;
517 on_next_submit = 0; 526 on_next_submit = 0;
518 527
519 PUSHMARK (SP); 528 PUSHMARK (SP);
520 PUTBACK; 529 PUTBACK;
521 call_sv (cb, G_DISCARD | G_EVAL); 530 call_sv (cb, G_DISCARD | G_EVAL);
531 SPAGAIN;
522 } 532 }
523 533
524 // synthesize callback if none given 534 // synthesize callback if none given
525 if (!req->callback) 535 if (!req->callback)
526 { 536 {
537 if (SvOK (prepare_cb))
538 {
527 int count; 539 int count;
528 540
529 dSP; 541 dSP;
530 PUSHMARK (SP); 542 PUSHMARK (SP);
531 PUTBACK; 543 PUTBACK;
532 count = call_sv (prepare_cb, G_ARRAY); 544 count = call_sv (prepare_cb, G_ARRAY);
533 SPAGAIN; 545 SPAGAIN;
534 546
535 if (count != 2) 547 if (count != 2)
536 croak ("prepare callback must return exactly two values\n"); 548 croak ("sync prepare callback must return exactly two values\n");
537 549
538 wait_callback = POPs; 550 wait_callback = POPs;
539 SvREFCNT_dec (req->callback);
540 req->callback = SvREFCNT_inc (POPs); 551 req->callback = SvREFCNT_inc (POPs);
552 }
553 else
554 {
555 // execute request synchronously
556 bdb_request (req);
557 req_invoke (req);
558 req_free (req);
559 return;
560 }
541 } 561 }
542 562
543 ++nreqs; 563 ++nreqs;
544 564
545 X_LOCK (reqlock); 565 X_LOCK (reqlock);
559 } 579 }
560} 580}
561 581
562static void end_thread (void) 582static void end_thread (void)
563{ 583{
564 bdb_req req; 584 bdb_req req = calloc (1, sizeof (bdb_cb));
565
566 Newz (0, req, 1, bdb_cb);
567 585
568 req->type = REQ_QUIT; 586 req->type = REQ_QUIT;
569 req->pri = PRI_MAX + PRI_BIAS; 587 req->pri = PRI_MAX + PRI_BIAS;
570 588
571 X_LOCK (reqlock); 589 X_LOCK (reqlock);
600 end_thread (); 618 end_thread ();
601} 619}
602 620
603static void poll_wait (void) 621static void poll_wait (void)
604{ 622{
605 fd_set rfd;
606
607 while (nreqs) 623 while (nreqs)
608 { 624 {
609 int size; 625 int size;
610 if (WORDACCESS_UNSAFE) X_LOCK (reslock); 626 if (WORDACCESS_UNSAFE) X_LOCK (reslock);
611 size = res_queue.size; 627 size = res_queue.size;
614 if (size) 630 if (size)
615 return; 631 return;
616 632
617 maybe_start_thread (); 633 maybe_start_thread ();
618 634
619 FD_ZERO (&rfd); 635 s_epipe_wait (&respipe);
620 FD_SET (respipe [0], &rfd);
621
622 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0);
623 } 636 }
624} 637}
625 638
626static int poll_cb (void) 639static int poll_cb (void)
627{ 640{
647 if (req) 660 if (req)
648 { 661 {
649 --npending; 662 --npending;
650 663
651 if (!res_queue.size) 664 if (!res_queue.size)
652 {
653 /* read any signals sent by the worker threads */ 665 /* read any signals sent by the worker threads */
654 char buf [4]; 666 s_epipe_drain (&respipe);
655 while (respipe_read (respipe [0], buf, 4) == 4)
656 ;
657 }
658 } 667 }
659 668
660 X_UNLOCK (reslock); 669 X_UNLOCK (reslock);
661 670
662 if (!req) 671 if (!req)
697 return count; 706 return count;
698} 707}
699 708
700/*****************************************************************************/ 709/*****************************************************************************/
701 710
711static void
712bdb_request (bdb_req req)
713{
714 switch (req->type)
715 {
716 case REQ_ENV_OPEN:
717 req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1);
718 break;
719
720 case REQ_ENV_CLOSE:
721 req->result = req->env->close (req->env, req->uint1);
722 break;
723
724 case REQ_ENV_TXN_CHECKPOINT:
725 req->result = req->env->txn_checkpoint (req->env, req->uint1, req->int1, req->uint2);
726 break;
727
728 case REQ_ENV_LOCK_DETECT:
729 req->result = req->env->lock_detect (req->env, req->uint1, req->uint2, &req->int1);
730 break;
731
732 case REQ_ENV_MEMP_SYNC:
733 req->result = req->env->memp_sync (req->env, 0);
734 break;
735
736 case REQ_ENV_MEMP_TRICKLE:
737 req->result = req->env->memp_trickle (req->env, req->int1, &req->int2);
738 break;
739
740 case REQ_ENV_DBREMOVE:
741 req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1);
742 break;
743
744 case REQ_ENV_DBRENAME:
745 req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1);
746 break;
747
748 case REQ_DB_OPEN:
749 req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2);
750 break;
751
752 case REQ_DB_CLOSE:
753 req->result = req->db->close (req->db, req->uint1);
754 break;
755
756#if DBVER >= 404
757 case REQ_DB_COMPACT:
758 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);
759 break;
760#endif
761
762 case REQ_DB_SYNC:
763 req->result = req->db->sync (req->db, req->uint1);
764 break;
765
766 case REQ_DB_VERIFY:
767 req->result = req->db->verify (req->db, req->buf1, req->buf2, 0, req->uint1);
768 break;
769
770 case REQ_DB_UPGRADE:
771 req->result = req->db->upgrade (req->db, req->buf1, req->uint1);
772 break;
773
774 case REQ_DB_PUT:
775 req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1);
776 break;
777
778#if DBVER >= 406
779 case REQ_DB_EXISTS:
780 req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1);
781 break;
782#endif
783 case REQ_DB_GET:
784 req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1);
785 break;
786
787 case REQ_DB_PGET:
788 req->result = req->db->pget (req->db, req->txn, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1);
789 break;
790
791 case REQ_DB_DEL:
792 req->result = req->db->del (req->db, req->txn, &req->dbt1, req->uint1);
793 break;
794
795 case REQ_DB_KEY_RANGE:
796 req->result = req->db->key_range (req->db, req->txn, &req->dbt1, &req->key_range, req->uint1);
797 break;
798
799 case REQ_TXN_COMMIT:
800 req->result = req->txn->commit (req->txn, req->uint1);
801 break;
802
803 case REQ_TXN_ABORT:
804 req->result = req->txn->abort (req->txn);
805 break;
806
807 case REQ_TXN_FINISH:
808 if (req->txn->flags & TXN_DEADLOCK)
809 {
810 req->result = req->txn->abort (req->txn);
811 if (!req->result)
812 req->result = DB_LOCK_DEADLOCK;
813 }
814 else
815 req->result = req->txn->commit (req->txn, req->uint1);
816 break;
817
818 case REQ_C_CLOSE:
819 req->result = req->dbc->c_close (req->dbc);
820 break;
821
822 case REQ_C_COUNT:
823 {
824 db_recno_t recno;
825 req->result = req->dbc->c_count (req->dbc, &recno, req->uint1);
826 req->uv1 = recno;
827 }
828 break;
829
830 case REQ_C_PUT:
831 req->result = req->dbc->c_put (req->dbc, &req->dbt1, &req->dbt2, req->uint1);
832 break;
833
834 case REQ_C_GET:
835 req->result = req->dbc->c_get (req->dbc, &req->dbt1, &req->dbt3, req->uint1);
836 break;
837
838 case REQ_C_PGET:
839 req->result = req->dbc->c_pget (req->dbc, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1);
840 break;
841
842 case REQ_C_DEL:
843 req->result = req->dbc->c_del (req->dbc, req->uint1);
844 break;
845
846#if DBVER >= 403
847 case REQ_SEQ_OPEN:
848 req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1);
849 break;
850
851 case REQ_SEQ_CLOSE:
852 req->result = req->seq->close (req->seq, req->uint1);
853 break;
854
855 case REQ_SEQ_GET:
856 req->result = req->seq->get (req->seq, req->txn, req->int1, &req->seq_t, req->uint1);
857 break;
858
859 case REQ_SEQ_REMOVE:
860 req->result = req->seq->remove (req->seq, req->txn, req->uint1);
861 break;
862#endif
863
864#if DBVER >= 407
865 case REQ_ENV_LSN_RESET:
866 req->result = req->env->lsn_reset (req->env, req->buf1, req->uint1);
867 break;
868
869 case REQ_ENV_FILEID_RESET:
870 req->result = req->env->fileid_reset (req->env, req->buf1, req->uint1);
871 break;
872#endif
873
874 case REQ_ENV_LOG_ARCHIVE:
875 {
876 char **listp = 0; /* DB_ARCH_REMOVE does not touch listp, contrary to docs */
877 req->result = req->env->log_archive (req->env, &listp, req->uint1);
878 req->buf1 = (char *)listp;
879 }
880 break;
881
882 default:
883 req->result = ENOSYS;
884 break;
885 }
886
887 if (req->txn && (req->result > 0 || req->result == DB_LOCK_NOTGRANTED))
888 req->txn->flags |= TXN_DEADLOCK;
889}
890
702X_THREAD_PROC (bdb_proc) 891X_THREAD_PROC (bdb_proc)
703{ 892{
704 bdb_req req; 893 bdb_req req;
705 struct timespec ts; 894 struct timespec ts;
706 worker *self = (worker *)thr_arg; 895 worker *self = (worker *)thr_arg;
708 /* try to distribute timeouts somewhat evenly */ 897 /* try to distribute timeouts somewhat evenly */
709 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); 898 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL);
710 899
711 for (;;) 900 for (;;)
712 { 901 {
713 ts.tv_sec = time (0) + IDLE_TIMEOUT; 902 ts.tv_sec = time (0) + IDLE_TIMEOUT;
714 903
715 X_LOCK (reqlock); 904 X_LOCK (reqlock);
716 905
717 for (;;) 906 for (;;)
718 { 907 {
745 } 934 }
746 935
747 --nready; 936 --nready;
748 937
749 X_UNLOCK (reqlock); 938 X_UNLOCK (reqlock);
750 939
751 switch (req->type) 940 if (req->type == REQ_QUIT)
752 { 941 {
753 case REQ_QUIT: 942 X_LOCK (reslock);
754 req->result = ENOSYS; 943 free (req);
944 self->req = 0;
945 X_UNLOCK (reslock);
946
755 goto quit; 947 goto quit;
756
757 case REQ_ENV_OPEN:
758 req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1);
759 break;
760
761 case REQ_ENV_CLOSE:
762 req->result = req->env->close (req->env, req->uint1);
763 break;
764
765 case REQ_ENV_TXN_CHECKPOINT:
766 req->result = req->env->txn_checkpoint (req->env, req->uint1, req->int1, req->uint2);
767 break;
768
769 case REQ_ENV_LOCK_DETECT:
770 req->result = req->env->lock_detect (req->env, req->uint1, req->uint2, &req->int1);
771 break;
772
773 case REQ_ENV_MEMP_SYNC:
774 req->result = req->env->memp_sync (req->env, 0);
775 break;
776
777 case REQ_ENV_MEMP_TRICKLE:
778 req->result = req->env->memp_trickle (req->env, req->int1, &req->int2);
779 break;
780
781 case REQ_ENV_DBREMOVE:
782 req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1);
783 break;
784
785 case REQ_ENV_DBRENAME:
786 req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1);
787 break;
788
789 case REQ_DB_OPEN:
790 req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2);
791 break;
792
793 case REQ_DB_CLOSE:
794 req->result = req->db->close (req->db, req->uint1);
795 break;
796
797 case REQ_DB_COMPACT:
798 req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0);
799 break;
800
801 case REQ_DB_SYNC:
802 req->result = req->db->sync (req->db, req->uint1);
803 break;
804
805 case REQ_DB_UPGRADE:
806 req->result = req->db->upgrade (req->db, req->buf1, req->uint1);
807 break;
808
809 case REQ_DB_PUT:
810 req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1);
811 break;
812
813#if DB_VERSION_MINOR >= 6
814 case REQ_DB_EXISTS:
815 req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1);
816 break;
817#endif
818 case REQ_DB_GET:
819 req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1);
820 break;
821
822 case REQ_DB_PGET:
823 req->result = req->db->pget (req->db, req->txn, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1);
824 break;
825
826 case REQ_DB_DEL:
827 req->result = req->db->del (req->db, req->txn, &req->dbt1, req->uint1);
828 break;
829
830 case REQ_DB_KEY_RANGE:
831 req->result = req->db->key_range (req->db, req->txn, &req->dbt1, &req->key_range, req->uint1);
832 break;
833
834 case REQ_TXN_COMMIT:
835 req->result = req->txn->commit (req->txn, req->uint1);
836 break;
837
838 case REQ_TXN_ABORT:
839 req->result = req->txn->abort (req->txn);
840 break;
841
842 case REQ_TXN_FINISH:
843 if (req->txn->flags & TXN_DEADLOCK)
844 {
845 req->result = req->txn->abort (req->txn);
846 if (!req->result)
847 req->result = DB_LOCK_DEADLOCK;
848 }
849 else
850 req->result = req->txn->commit (req->txn, req->uint1);
851 break;
852
853 case REQ_C_CLOSE:
854 req->result = req->dbc->c_close (req->dbc);
855 break;
856
857 case REQ_C_COUNT:
858 {
859 db_recno_t recno;
860 req->result = req->dbc->c_count (req->dbc, &recno, req->uint1);
861 req->uv1 = recno;
862 }
863 break;
864
865 case REQ_C_PUT:
866 req->result = req->dbc->c_put (req->dbc, &req->dbt1, &req->dbt2, req->uint1);
867 break;
868
869 case REQ_C_GET:
870 req->result = req->dbc->c_get (req->dbc, &req->dbt1, &req->dbt3, req->uint1);
871 break;
872
873 case REQ_C_PGET:
874 req->result = req->dbc->c_pget (req->dbc, &req->dbt1, &req->dbt2, &req->dbt3, req->uint1);
875 break;
876
877 case REQ_C_DEL:
878 req->result = req->dbc->c_del (req->dbc, req->uint1);
879 break;
880
881 case REQ_SEQ_OPEN:
882 req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1);
883 break;
884
885 case REQ_SEQ_CLOSE:
886 req->result = req->seq->close (req->seq, req->uint1);
887 break;
888
889 case REQ_SEQ_GET:
890 req->result = req->seq->get (req->seq, req->txn, req->int1, &req->seq_t, req->uint1);
891 break;
892
893 case REQ_SEQ_REMOVE:
894 req->result = req->seq->remove (req->seq, req->txn, req->uint1);
895 break;
896
897 default:
898 req->result = ENOSYS;
899 break;
900 } 948 }
901 949
902 if (req->txn && (req->result > 0 || req->result == DB_LOCK_NOTGRANTED)) 950 bdb_request (req);
903 req->txn->flags |= TXN_DEADLOCK;
904 951
905 X_LOCK (reslock); 952 X_LOCK (reslock);
906 953
907 ++npending; 954 ++npending;
908 955
909 if (!reqq_push (&res_queue, req)) 956 if (!reqq_push (&res_queue, req))
910 /* write a dummy byte to the pipe so fh becomes ready */ 957 s_epipe_signal (&respipe);
911 respipe_write (respipe_osf [1], (const void *)&respipe_osf, 1);
912 958
913 self->req = 0; 959 self->req = 0;
914 worker_clear (self); 960 worker_clear (self);
915 961
916 X_UNLOCK (reslock); 962 X_UNLOCK (reslock);
970 create_respipe (); 1016 create_respipe ();
971 1017
972 atfork_parent (); 1018 atfork_parent ();
973} 1019}
974 1020
975#define dREQ(reqtype) \ 1021#define dREQ(reqtype,rsvcnt) \
976 bdb_req req; \ 1022 bdb_req req; \
977 int req_pri = next_pri; \ 1023 int req_pri = next_pri; \
978 next_pri = DEFAULT_PRI + PRI_BIAS; \ 1024 next_pri = DEFAULT_PRI + PRI_BIAS; \
979 \ 1025 \
980 if (callback && SvOK (callback)) \ 1026 if (callback && SvOK (callback)) \
981 croak ("callback has illegal type or extra arguments"); \ 1027 croak ("callback has illegal type or extra arguments"); \
982 \ 1028 \
983 Newz (0, req, 1, bdb_cb); \ 1029 Newz (0, req, 1, bdb_cb); \
984 if (!req) \ 1030 if (!req) \
985 croak ("out of memory during bdb_req allocation"); \ 1031 croak ("out of memory during bdb_req allocation"); \
986 \ 1032 \
987 req->callback = cb ? SvREFCNT_inc (cb) : 0; \ 1033 req->callback = SvREFCNT_inc (cb); \
988 req->type = (reqtype); \ 1034 req->type = (reqtype); \
989 req->pri = req_pri 1035 req->pri = req_pri; \
1036 if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \
1037 if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \
1038 (void)0;
990 1039
991#define REQ_SEND \ 1040#define REQ_SEND \
992 req_send (req) 1041 req_send (req)
993 1042
994#define SvPTR(var, arg, type, class, nullok) \ 1043#define SvPTR(var, arg, type, stash, class, nullok) \
995 if (!SvOK (arg)) \ 1044 if (!SvOK (arg)) \
996 { \ 1045 { \
997 if (nullok != 1) \ 1046 if (nullok != 1) \
998 croak (# var " must be a " # class " object, not undef"); \ 1047 croak (# var " must be a " # class " object, not undef"); \
999 \ 1048 \
1000 (var) = 0; \ 1049 (var) = 0; \
1001 } \ 1050 } \
1002 else if (sv_derived_from ((arg), # class)) \ 1051 else if (SvSTASH (SvRV (arg)) == stash || sv_derived_from ((arg), # class)) \
1003 { \ 1052 { \
1004 IV tmp = SvIV ((SV*) SvRV (arg)); \ 1053 IV tmp = SvIV ((SV*) SvRV (arg)); \
1005 (var) = INT2PTR (type, tmp); \ 1054 (var) = INT2PTR (type, tmp); \
1006 if (!var && nullok != 2) \ 1055 if (!var && nullok != 2) \
1007 croak (# var " is not a valid " # class " object anymore"); \ 1056 croak (# var " is not a valid " # class " object anymore"); \
1008 } \ 1057 } \
1009 else \ 1058 else \
1010 croak (# var " is not of type " # class); 1059 croak (# var " is not of type " # class);
1060
1061#define ARG_MUTABLE(name) \
1062 if (SvREADONLY (name)) \
1063 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable");
1064
1065static SV *
1066newSVptr (void *ptr, HV *stash)
1067{
1068 SV *rv = NEWSV (0, 0);
1069 sv_upgrade (rv, SVt_PVMG);
1070 sv_setiv (rv, PTR2IV (ptr));
1071
1072 return sv_bless (newRV_noinc (rv), stash);
1073}
1011 1074
1012static void 1075static void
1013ptr_nuke (SV *sv) 1076ptr_nuke (SV *sv)
1014{ 1077{
1015 assert (SvROK (sv)); 1078 assert (SvROK (sv));
1086 } 1149 }
1087 1150
1088 return 0; 1151 return 0;
1089} 1152}
1090 1153
1154/*****************************************************************************/
1155
1156#if 0
1157static int
1158bt_pfxc_compare (DB *db, const DBT *dbt1, const DBT *dbt2)
1159{
1160 ssize_t size1 = dbt1->size;
1161 ssize_t size2 = dbt2->size;
1162 int res = memcmp ((void *)dbt1->data, (void *)dbt2->data,
1163 size1 <= size2 ? size1 : size2);
1164
1165 if (res)
1166 return res;
1167 else if (size1 - size2)
1168 return size1 - size2;
1169 else
1170 return 0;
1171}
1172
1173static size_t
1174bt_pfxc_prefix_x (DB *db, const DBT *dbt1, const DBT *dbt2)
1175{
1176 ssize_t size1 = dbt1->size;
1177 ssize_t size2 = dbt2->size;
1178 u_int8_t *p1 = (u_int8_t *)dbt1->data;
1179 u_int8_t *p2 = (u_int8_t *)dbt2->data;
1180 u_int8_t *pe = p1 + (size1 <= size2 ? size1 : size2);
1181
1182 while (p1 < pe)
1183 if (*p1++ != *p2++)
1184 return p1 - (u_int8_t *)dbt1->data - 1;
1185
1186 if (size1 < size2) return size1 + 1;
1187 if (size1 > size2) return size2 + 1;
1188
1189 return size1;
1190}
1191#endif
1192
1193/*****************************************************************************/
1194
1195/* stupid windows defines CALLBACK as well */
1196#undef CALLBACK
1091#define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); 1197#define CALLBACK SV *cb = pop_callback (&items, ST (items - 1));
1092 1198
1093MODULE = BDB PACKAGE = BDB 1199MODULE = BDB PACKAGE = BDB
1094 1200
1095PROTOTYPES: ENABLE 1201PROTOTYPES: ENABLE
1096 1202
1097BOOT: 1203BOOT:
1098{ 1204{
1099 HV *stash = gv_stashpv ("BDB", 1);
1100
1101 static const struct { 1205 static const struct {
1102 const char *name; 1206 const char *name;
1103 IV iv; 1207 IV iv;
1104 } *civ, const_iv[] = { 1208 } *civ, const_iv[] = {
1105#define const_iv(name) { # name, (IV)DB_ ## name }, 1209#define const_iv(name) { # name, (IV)DB_ ## name },
1210#if DBVER <= 408
1106 const_iv (RPCCLIENT) 1211 const_iv (RPCCLIENT)
1212#endif
1107 const_iv (INIT_CDB) 1213 const_iv (INIT_CDB)
1108 const_iv (INIT_LOCK) 1214 const_iv (INIT_LOCK)
1109 const_iv (INIT_LOG) 1215 const_iv (INIT_LOG)
1110 const_iv (INIT_MPOOL) 1216 const_iv (INIT_MPOOL)
1111 const_iv (INIT_REP) 1217 const_iv (INIT_REP)
1117 const_iv (RDONLY) 1223 const_iv (RDONLY)
1118 const_iv (USE_ENVIRON) 1224 const_iv (USE_ENVIRON)
1119 const_iv (USE_ENVIRON_ROOT) 1225 const_iv (USE_ENVIRON_ROOT)
1120 const_iv (LOCKDOWN) 1226 const_iv (LOCKDOWN)
1121 const_iv (PRIVATE) 1227 const_iv (PRIVATE)
1122 const_iv (REGISTER)
1123 const_iv (SYSTEM_MEM) 1228 const_iv (SYSTEM_MEM)
1124 const_iv (AUTO_COMMIT) 1229 const_iv (AUTO_COMMIT)
1125 const_iv (CDB_ALLDB) 1230 const_iv (CDB_ALLDB)
1126 const_iv (DIRECT_DB) 1231 const_iv (DIRECT_DB)
1127 const_iv (DSYNC_DB)
1128 const_iv (NOLOCKING) 1232 const_iv (NOLOCKING)
1129 const_iv (NOMMAP) 1233 const_iv (NOMMAP)
1130 const_iv (NOPANIC) 1234 const_iv (NOPANIC)
1131 const_iv (OVERWRITE) 1235 const_iv (OVERWRITE)
1132 const_iv (PANIC_ENVIRONMENT) 1236 const_iv (PANIC_ENVIRONMENT)
1136 const_iv (TXN_NOT_DURABLE) 1240 const_iv (TXN_NOT_DURABLE)
1137 const_iv (TXN_WRITE_NOSYNC) 1241 const_iv (TXN_WRITE_NOSYNC)
1138 const_iv (WRITECURSOR) 1242 const_iv (WRITECURSOR)
1139 const_iv (YIELDCPU) 1243 const_iv (YIELDCPU)
1140 const_iv (ENCRYPT_AES) 1244 const_iv (ENCRYPT_AES)
1245#if DBVER < 408
1141 const_iv (XA_CREATE) 1246 const_iv (XA_CREATE)
1247#endif
1142 const_iv (BTREE) 1248 const_iv (BTREE)
1143 const_iv (HASH) 1249 const_iv (HASH)
1144 const_iv (QUEUE) 1250 const_iv (QUEUE)
1145 const_iv (RECNO) 1251 const_iv (RECNO)
1146 const_iv (UNKNOWN) 1252 const_iv (UNKNOWN)
1147 const_iv (EXCL) 1253 const_iv (EXCL)
1148 const_iv (READ_COMMITTED)
1149 const_iv (READ_UNCOMMITTED)
1150 const_iv (TRUNCATE) 1254 const_iv (TRUNCATE)
1151 const_iv (NOSYNC) 1255 const_iv (NOSYNC)
1152 const_iv (CHKSUM) 1256 const_iv (CHKSUM)
1153 const_iv (ENCRYPT) 1257 const_iv (ENCRYPT)
1154 const_iv (DUP) 1258 const_iv (DUP)
1155 const_iv (DUPSORT) 1259 const_iv (DUPSORT)
1156 const_iv (RECNUM) 1260 //const_iv (RECNUM)
1157 const_iv (RENUMBER) 1261 const_iv (RENUMBER)
1158 const_iv (REVSPLITOFF) 1262 const_iv (REVSPLITOFF)
1159 const_iv (INORDER)
1160 const_iv (CONSUME) 1263 const_iv (CONSUME)
1161 const_iv (CONSUME_WAIT) 1264 const_iv (CONSUME_WAIT)
1162 const_iv (GET_BOTH) 1265 const_iv (GET_BOTH)
1163 const_iv (GET_BOTH_RANGE) 1266 const_iv (GET_BOTH_RANGE)
1164 //const_iv (SET_RECNO) 1267 //const_iv (SET_RECNO)
1173 const_iv (LOCK_DEADLOCK) 1276 const_iv (LOCK_DEADLOCK)
1174 const_iv (LOCK_NOTGRANTED) 1277 const_iv (LOCK_NOTGRANTED)
1175 const_iv (RUNRECOVERY) 1278 const_iv (RUNRECOVERY)
1176 const_iv (OLD_VERSION) 1279 const_iv (OLD_VERSION)
1177 const_iv (REP_HANDLE_DEAD) 1280 const_iv (REP_HANDLE_DEAD)
1178 const_iv (REP_LOCKOUT)
1179 const_iv (SECONDARY_BAD) 1281 const_iv (SECONDARY_BAD)
1180
1181 const_iv (FREE_SPACE)
1182 const_iv (FREELIST_ONLY)
1183 1282
1184 const_iv (APPEND) 1283 const_iv (APPEND)
1185 const_iv (NODUPDATA) 1284 const_iv (NODUPDATA)
1186 const_iv (NOOVERWRITE) 1285 const_iv (NOOVERWRITE)
1187 1286
1210 const_iv (FORCE) 1309 const_iv (FORCE)
1211 1310
1212 const_iv (LOCK_DEFAULT) 1311 const_iv (LOCK_DEFAULT)
1213 const_iv (LOCK_EXPIRE) 1312 const_iv (LOCK_EXPIRE)
1214 const_iv (LOCK_MAXLOCKS) 1313 const_iv (LOCK_MAXLOCKS)
1215 const_iv (LOCK_MAXWRITE)
1216 const_iv (LOCK_MINLOCKS) 1314 const_iv (LOCK_MINLOCKS)
1217 const_iv (LOCK_MINWRITE) 1315 const_iv (LOCK_MINWRITE)
1218 const_iv (LOCK_OLDEST) 1316 const_iv (LOCK_OLDEST)
1219 const_iv (LOCK_RANDOM) 1317 const_iv (LOCK_RANDOM)
1220 const_iv (LOCK_YOUNGEST) 1318 const_iv (LOCK_YOUNGEST)
1221 1319
1222 const_iv (SEQ_DEC)
1223 const_iv (SEQ_INC)
1224 const_iv (SEQ_WRAP)
1225
1226 const_iv (BUFFER_SMALL)
1227 const_iv (DONOTINDEX) 1320 const_iv (DONOTINDEX)
1228 const_iv (KEYEMPTY ) 1321 const_iv (KEYEMPTY)
1229 const_iv (KEYEXIST ) 1322 const_iv (KEYEXIST)
1230 const_iv (LOCK_DEADLOCK) 1323 const_iv (LOCK_DEADLOCK)
1231 const_iv (LOCK_NOTGRANTED) 1324 const_iv (LOCK_NOTGRANTED)
1232 const_iv (LOG_BUFFER_FULL)
1233 const_iv (NOSERVER) 1325 const_iv (NOSERVER)
1326#if DBVER < 502
1234 const_iv (NOSERVER_HOME) 1327 const_iv (NOSERVER_HOME)
1235 const_iv (NOSERVER_ID) 1328 const_iv (NOSERVER_ID)
1329#endif
1236 const_iv (NOTFOUND) 1330 const_iv (NOTFOUND)
1237 const_iv (PAGE_NOTFOUND) 1331 const_iv (PAGE_NOTFOUND)
1238 const_iv (REP_DUPMASTER) 1332 const_iv (REP_DUPMASTER)
1239 const_iv (REP_HANDLE_DEAD) 1333 const_iv (REP_HANDLE_DEAD)
1240 const_iv (REP_HOLDELECTION) 1334 const_iv (REP_HOLDELECTION)
1241 const_iv (REP_IGNORE)
1242 const_iv (REP_ISPERM) 1335 const_iv (REP_ISPERM)
1243 const_iv (REP_JOIN_FAILURE)
1244 const_iv (REP_LOCKOUT)
1245 const_iv (REP_NEWMASTER) 1336 const_iv (REP_NEWMASTER)
1246 const_iv (REP_NEWSITE) 1337 const_iv (REP_NEWSITE)
1247 const_iv (REP_NOTPERM) 1338 const_iv (REP_NOTPERM)
1248 const_iv (REP_UNAVAIL) 1339 const_iv (REP_UNAVAIL)
1249 const_iv (RUNRECOVERY) 1340 const_iv (RUNRECOVERY)
1250 const_iv (SECONDARY_BAD) 1341 const_iv (SECONDARY_BAD)
1251 const_iv (VERIFY_BAD) 1342 const_iv (VERIFY_BAD)
1252 const_iv (VERSION_MISMATCH) 1343
1344 const_iv (SALVAGE)
1345 const_iv (AGGRESSIVE)
1346 const_iv (PRINTABLE)
1347 const_iv (NOORDERCHK)
1348 const_iv (ORDERCHKONLY)
1349
1350 const_iv (ARCH_ABS)
1351 const_iv (ARCH_DATA)
1352 const_iv (ARCH_LOG)
1353 const_iv (ARCH_REMOVE)
1253 1354
1254 const_iv (VERB_DEADLOCK) 1355 const_iv (VERB_DEADLOCK)
1255 const_iv (VERB_RECOVERY) 1356 const_iv (VERB_RECOVERY)
1256 const_iv (VERB_REGISTER)
1257 const_iv (VERB_REPLICATION) 1357 const_iv (VERB_REPLICATION)
1258 const_iv (VERB_WAITSFOR) 1358 const_iv (VERB_WAITSFOR)
1259 1359
1260 const_iv (VERSION_MAJOR) 1360 const_iv (VERSION_MAJOR)
1261 const_iv (VERSION_MINOR) 1361 const_iv (VERSION_MINOR)
1262 const_iv (VERSION_PATCH) 1362 const_iv (VERSION_PATCH)
1263#if DB_VERSION_MINOR >= 5 1363 const_iv (LOGVERSION)
1364 const_iv (LOGOLDVER)
1365#if DBVER >= 403
1366 const_iv (INORDER)
1367 const_iv (LOCK_MAXWRITE)
1368 const_iv (SEQ_DEC)
1369 const_iv (SEQ_INC)
1370 const_iv (SEQ_WRAP)
1371 const_iv (BUFFER_SMALL)
1372 const_iv (LOG_BUFFER_FULL)
1373 const_iv (VERSION_MISMATCH)
1374#endif
1375#if DBVER >= 404
1376 const_iv (REGISTER)
1377 const_iv (DSYNC_DB)
1378 const_iv (READ_COMMITTED)
1379 const_iv (READ_UNCOMMITTED)
1380 const_iv (REP_IGNORE)
1381 const_iv (REP_LOCKOUT)
1382 const_iv (REP_JOIN_FAILURE)
1383 const_iv (FREE_SPACE)
1384 const_iv (FREELIST_ONLY)
1385 const_iv (VERB_REGISTER)
1386#endif
1387#if DBVER >= 405
1264 const_iv (MULTIVERSION) 1388 const_iv (MULTIVERSION)
1265 const_iv (TXN_SNAPSHOT) 1389 const_iv (TXN_SNAPSHOT)
1266#endif 1390#endif
1267#if DB_VERSION_MINOR >= 6 1391#if DBVER >= 406
1268 const_iv (PREV_DUP) 1392 const_iv (PREV_DUP)
1269 const_iv (PRIORITY_UNCHANGED) 1393 const_iv (PRIORITY_UNCHANGED)
1270 const_iv (PRIORITY_VERY_LOW) 1394 const_iv (PRIORITY_VERY_LOW)
1271 const_iv (PRIORITY_LOW) 1395 const_iv (PRIORITY_LOW)
1272 const_iv (PRIORITY_DEFAULT) 1396 const_iv (PRIORITY_DEFAULT)
1273 const_iv (PRIORITY_HIGH) 1397 const_iv (PRIORITY_HIGH)
1274 const_iv (PRIORITY_VERY_HIGH) 1398 const_iv (PRIORITY_VERY_HIGH)
1399 const_iv (IGNORE_LEASE)
1275#endif 1400#endif
1276#if DB_VERSION_MINOR >= 7 1401#if DBVER >= 407
1402 //const_iv (MULTIPLE_KEY)
1277 const_iv (LOG_DIRECT) 1403 const_iv (LOG_DIRECT)
1278 const_iv (LOG_DSYNC) 1404 const_iv (LOG_DSYNC)
1279 const_iv (LOG_AUTO_REMOVE) 1405 const_iv (LOG_AUTO_REMOVE)
1280 const_iv (LOG_IN_MEMORY) 1406 const_iv (LOG_IN_MEMORY)
1281 const_iv (LOG_ZERO) 1407 const_iv (LOG_ZERO)
1282#else 1408#else
1283 const_iv (DIRECT_LOG) 1409 const_iv (DIRECT_LOG)
1410 const_iv (LOG_AUTOREMOVE)
1411# if DBVER >= 403
1284 const_iv (DSYNC_LOG) 1412 const_iv (DSYNC_LOG)
1285 const_iv (LOG_AUTOREMOVE)
1286 const_iv (LOG_INMEMORY) 1413 const_iv (LOG_INMEMORY)
1414# endif
1415#if DBVER >= 408
1416 const_iv (LOGVERSION_LATCHING)
1417#endif
1287#endif 1418#endif
1288 }; 1419 };
1289 1420
1421 bdb_stash = gv_stashpv ("BDB" , 1);
1422 bdb_env_stash = gv_stashpv ("BDB::Env" , 1);
1423 bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1);
1424 bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1);
1425 bdb_db_stash = gv_stashpv ("BDB::Db" , 1);
1426 bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1);
1427
1290 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1428 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
1291 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1429 newCONSTSUB (bdb_stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
1430
1431 prepare_cb = &PL_sv_undef;
1292 1432
1293 { 1433 {
1294 /* we currently only allow version, minor-version and patchlevel to go up to 255 */ 1434 /* we currently only allow version, minor-version and patchlevel to go up to 255 */
1295 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; 1435 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH };
1296 1436
1297 newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); 1437 newCONSTSUB (bdb_stash, "VERSION_v", newSVpvn (vstring, 3));
1298 } 1438 }
1299 1439
1300 newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); 1440 newCONSTSUB (bdb_stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1301 1441
1302 create_respipe (); 1442 create_respipe ();
1303 1443
1304 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1444 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1305 patch_errno (); 1445 patch_errno ();
1383 1523
1384int 1524int
1385poll_fileno () 1525poll_fileno ()
1386 PROTOTYPE: 1526 PROTOTYPE:
1387 CODE: 1527 CODE:
1388 RETVAL = respipe [0]; 1528 RETVAL = s_epipe_fd (&respipe);
1389 OUTPUT: 1529 OUTPUT:
1390 RETVAL 1530 RETVAL
1391 1531
1392int 1532int
1393poll_cb (...) 1533poll_cb (...)
1435 RETVAL = started; 1575 RETVAL = started;
1436 if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); 1576 if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock);
1437 OUTPUT: 1577 OUTPUT:
1438 RETVAL 1578 RETVAL
1439 1579
1440void 1580SV *
1441set_sync_prepare (SV *cb) 1581set_sync_prepare (SV *cb)
1442 PROTOTYPE: & 1582 PROTOTYPE: &
1443 CODE: 1583 CODE:
1444 SvREFCNT_dec (prepare_cb); 1584 RETVAL = prepare_cb;
1445 prepare_cb = newSVsv (cb); 1585 prepare_cb = newSVsv (cb);
1586 OUTPUT:
1587 RETVAL
1446 1588
1447char * 1589char *
1448strerror (int errorno = errno) 1590strerror (int errorno = errno)
1449 PROTOTYPE: ;$ 1591 PROTOTYPE: ;$
1450 CODE: 1592 CODE:
1478db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) 1620db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0)
1479 PREINIT: 1621 PREINIT:
1480 CALLBACK 1622 CALLBACK
1481 CODE: 1623 CODE:
1482{ 1624{
1483 dREQ (REQ_ENV_OPEN); 1625 dREQ (REQ_ENV_OPEN, 1);
1484 req->env = env; 1626 req->env = env;
1485 req->uint1 = open_flags | DB_THREAD; 1627 req->uint1 = open_flags | DB_THREAD;
1486 req->int1 = mode; 1628 req->int1 = mode;
1487 req->buf1 = strdup_ornull (db_home); 1629 req->buf1 = strdup_ornull (db_home);
1488 REQ_SEND; 1630 REQ_SEND;
1492db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) 1634db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0)
1493 PREINIT: 1635 PREINIT:
1494 CALLBACK 1636 CALLBACK
1495 CODE: 1637 CODE:
1496{ 1638{
1497 dREQ (REQ_ENV_CLOSE); 1639 dREQ (REQ_ENV_CLOSE, 0);
1640 ptr_nuke (ST (0));
1498 req->env = env; 1641 req->env = env;
1499 req->uint1 = flags; 1642 req->uint1 = flags;
1500 REQ_SEND; 1643 REQ_SEND;
1501 ptr_nuke (ST (0));
1502} 1644}
1503 1645
1504void 1646void
1505db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) 1647db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0)
1506 PREINIT: 1648 PREINIT:
1507 CALLBACK 1649 CALLBACK
1508 CODE: 1650 CODE:
1509{ 1651{
1510 dREQ (REQ_ENV_TXN_CHECKPOINT); 1652 dREQ (REQ_ENV_TXN_CHECKPOINT, 1);
1511 req->env = env; 1653 req->env = env;
1512 req->uint1 = kbyte; 1654 req->uint1 = kbyte;
1513 req->int1 = min; 1655 req->int1 = min;
1514 req->uint2 = flags; 1656 req->uint2 = flags;
1515 REQ_SEND; 1657 REQ_SEND;
1519db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) 1661db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0)
1520 PREINIT: 1662 PREINIT:
1521 CALLBACK 1663 CALLBACK
1522 CODE: 1664 CODE:
1523{ 1665{
1524 dREQ (REQ_ENV_LOCK_DETECT); 1666 dREQ (REQ_ENV_LOCK_DETECT, 1);
1525 req->env = env; 1667 req->env = env;
1526 req->uint1 = flags; 1668 req->uint1 = flags;
1527 req->uint2 = atype; 1669 req->uint2 = atype;
1528 /* req->int2 = 0; dummy */ 1670 /* req->int2 = 0; dummy */
1529 REQ_SEND; 1671 REQ_SEND;
1533db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) 1675db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0)
1534 PREINIT: 1676 PREINIT:
1535 CALLBACK 1677 CALLBACK
1536 CODE: 1678 CODE:
1537{ 1679{
1538 dREQ (REQ_ENV_MEMP_SYNC); 1680 dREQ (REQ_ENV_MEMP_SYNC, 1);
1539 req->env = env; 1681 req->env = env;
1540 REQ_SEND; 1682 REQ_SEND;
1541} 1683}
1542 1684
1543void 1685void
1544db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) 1686db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0)
1545 PREINIT: 1687 PREINIT:
1546 CALLBACK 1688 CALLBACK
1547 CODE: 1689 CODE:
1548{ 1690{
1549 dREQ (REQ_ENV_MEMP_TRICKLE); 1691 dREQ (REQ_ENV_MEMP_TRICKLE, 1);
1550 req->env = env; 1692 req->env = env;
1551 req->int1 = percent; 1693 req->int1 = percent;
1552 REQ_SEND; 1694 REQ_SEND;
1553} 1695}
1554 1696
1556db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) 1698db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0)
1557 PREINIT: 1699 PREINIT:
1558 CALLBACK 1700 CALLBACK
1559 CODE: 1701 CODE:
1560{ 1702{
1561 dREQ (REQ_ENV_DBREMOVE); 1703 dREQ (REQ_ENV_DBREMOVE, 2);
1562 req->env = env; 1704 req->env = env;
1563 req->buf1 = strdup_ornull (file); 1705 req->buf1 = strdup_ornull (file);
1564 req->buf2 = strdup_ornull (database); 1706 req->buf2 = strdup_ornull (database);
1565 req->uint1 = flags; 1707 req->uint1 = flags;
1566 REQ_SEND; 1708 REQ_SEND;
1570db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) 1712db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0)
1571 PREINIT: 1713 PREINIT:
1572 CALLBACK 1714 CALLBACK
1573 CODE: 1715 CODE:
1574{ 1716{
1575 dREQ (REQ_ENV_DBRENAME); 1717 dREQ (REQ_ENV_DBRENAME, 2);
1576 req->env = env; 1718 req->env = env;
1577 req->buf1 = strdup_ornull (file); 1719 req->buf1 = strdup_ornull (file);
1578 req->buf2 = strdup_ornull (database); 1720 req->buf2 = strdup_ornull (database);
1579 req->buf3 = strdup_ornull (newname); 1721 req->buf3 = strdup_ornull (newname);
1580 req->uint1 = flags; 1722 req->uint1 = flags;
1581 REQ_SEND; 1723 REQ_SEND;
1582} 1724}
1583 1725
1726void
1727db_env_lsn_reset (DB_ENV *env, bdb_filename db, U32 flags = 0, SV *callback = 0)
1728 ALIAS:
1729 db_env_fileid_reset = 1
1730 PREINIT:
1731 CALLBACK
1732 CODE:
1733{
1734 dREQ (ix ? REQ_ENV_FILEID_RESET : REQ_ENV_LSN_RESET, 1);
1735 req->env = env;
1736 req->uint1 = flags;
1737 req->buf1 = strdup_ornull (db);
1738 REQ_SEND;
1739}
1740
1741void
1742db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0)
1743 PREINIT:
1744 CALLBACK
1745 CODE:
1746{
1747 dREQ (REQ_ENV_LOG_ARCHIVE, 1);
1748 req->sv1 = SvREFCNT_inc (listp);
1749 req->env = env;
1750 req->uint1 = flags;
1751 REQ_SEND;
1752}
1753
1584DB * 1754DB *
1585db_create (DB_ENV *env = 0, U32 flags = 0) 1755db_create (DB_ENV *env = 0, U32 flags = 0)
1586 CODE: 1756 CODE:
1587{ 1757{
1588 errno = db_create (&RETVAL, env, flags); 1758 errno = db_create (&RETVAL, env, flags);
1599db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) 1769db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0)
1600 PREINIT: 1770 PREINIT:
1601 CALLBACK 1771 CALLBACK
1602 CODE: 1772 CODE:
1603{ 1773{
1604 dREQ (REQ_DB_OPEN); 1774 dREQ (REQ_DB_OPEN, 2);
1605 req->db = db; 1775 req->db = db;
1606 req->txn = txnid; 1776 req->txn = txnid;
1607 req->buf1 = strdup_ornull (file); 1777 req->buf1 = strdup_ornull (file);
1608 req->buf2 = strdup_ornull (database); 1778 req->buf2 = strdup_ornull (database);
1609 req->int1 = type; 1779 req->int1 = type;
1616db_close (DB *db, U32 flags = 0, SV *callback = 0) 1786db_close (DB *db, U32 flags = 0, SV *callback = 0)
1617 PREINIT: 1787 PREINIT:
1618 CALLBACK 1788 CALLBACK
1619 CODE: 1789 CODE:
1620{ 1790{
1621 dREQ (REQ_DB_CLOSE); 1791 dREQ (REQ_DB_CLOSE, 0);
1792 ptr_nuke (ST (0));
1622 req->db = db; 1793 req->db = db;
1623 req->uint1 = flags; 1794 req->uint1 = flags;
1624 req->sv1 = (SV *)db->app_private; 1795 req->sv1 = (SV *)db->app_private;
1625 REQ_SEND; 1796 REQ_SEND;
1626 ptr_nuke (ST (0));
1627} 1797}
1798
1799#if DBVER >= 404
1628 1800
1629void 1801void
1630db_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) 1802db_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)
1631 PREINIT: 1803 PREINIT:
1632 CALLBACK 1804 CALLBACK
1633 CODE: 1805 CODE:
1634{ 1806{
1635 dREQ (REQ_DB_COMPACT); 1807 dREQ (REQ_DB_COMPACT, 2);
1636 req->db = db; 1808 req->db = db;
1637 req->txn = txn; 1809 req->txn = txn;
1638 sv_to_dbt (&req->dbt1, start); 1810 if (start) sv_to_dbt (&req->dbt1, start);
1639 sv_to_dbt (&req->dbt2, stop); 1811 if (stop ) sv_to_dbt (&req->dbt2, stop );
1640 req->uint1 = flags; 1812 req->uint1 = flags;
1641 REQ_SEND; 1813 REQ_SEND;
1642} 1814}
1643 1815
1816#endif
1817
1644void 1818void
1645db_sync (DB *db, U32 flags = 0, SV *callback = 0) 1819db_sync (DB *db, U32 flags = 0, SV *callback = 0)
1646 PREINIT: 1820 PREINIT:
1647 CALLBACK 1821 CALLBACK
1648 CODE: 1822 CODE:
1649{ 1823{
1650 dREQ (REQ_DB_SYNC); 1824 dREQ (REQ_DB_SYNC, 1);
1651 req->db = db; 1825 req->db = db;
1652 req->uint1 = flags; 1826 req->uint1 = flags;
1653 REQ_SEND; 1827 REQ_SEND;
1654} 1828}
1655 1829
1656void 1830void
1831db_verify (DB *db, bdb_filename file, bdb_filename database = 0, SV *dummy = 0, U32 flags = 0, SV *callback = 0)
1832 PREINIT:
1833 CALLBACK
1834 CODE:
1835{
1836 dREQ (REQ_DB_VERIFY, 1);
1837 ptr_nuke (ST (0)); /* verify destroys the database handle, hopefully it is freed as well */
1838 req->db = db;
1839 req->buf1 = strdup (file);
1840 req->buf2 = strdup_ornull (database);
1841 req->uint1 = flags;
1842 REQ_SEND;
1843}
1844
1845void
1657db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) 1846db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0)
1658 PREINIT: 1847 PREINIT:
1659 CALLBACK 1848 CALLBACK
1660 CODE: 1849 CODE:
1661{ 1850{
1662 dREQ (REQ_DB_SYNC); 1851 dREQ (REQ_DB_UPGRADE, 1);
1663 req->db = db; 1852 req->db = db;
1664 req->buf1 = strdup (file); 1853 req->buf1 = strdup (file);
1665 req->uint1 = flags; 1854 req->uint1 = flags;
1666 REQ_SEND; 1855 REQ_SEND;
1667} 1856}
1668 1857
1669void 1858void
1670db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = 0) 1859db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *key_range, U32 flags = 0, SV *callback = 0)
1671 PREINIT: 1860 PREINIT:
1672 CALLBACK 1861 CALLBACK
1673 CODE: 1862 CODE:
1674{ 1863{
1675 dREQ (REQ_DB_KEY_RANGE); 1864 dREQ (REQ_DB_KEY_RANGE, 2);
1676 req->db = db; 1865 req->db = db;
1677 req->txn = txn; 1866 req->txn = txn;
1678 sv_to_dbt (&req->dbt1, key); 1867 sv_to_dbt (&req->dbt1, key);
1679 req->uint1 = flags; 1868 req->uint1 = flags;
1680 req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); 1869 req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range);
1685db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) 1874db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0)
1686 PREINIT: 1875 PREINIT:
1687 CALLBACK 1876 CALLBACK
1688 CODE: 1877 CODE:
1689{ 1878{
1690 dREQ (REQ_DB_PUT); 1879 dREQ (REQ_DB_PUT, 2);
1691 req->db = db; 1880 req->db = db;
1692 req->txn = txn; 1881 req->txn = txn;
1693 sv_to_dbt (&req->dbt1, key); 1882 sv_to_dbt (&req->dbt1, key);
1694 sv_to_dbt (&req->dbt2, data); 1883 sv_to_dbt (&req->dbt2, data);
1695 req->uint1 = flags; 1884 req->uint1 = flags;
1696 REQ_SEND; 1885 REQ_SEND;
1697} 1886}
1698 1887
1699#if DB_VERSION_MINOR >= 6 1888#if DBVER >= 406
1700 1889
1701void 1890void
1702db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) 1891db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0)
1703 PREINIT: 1892 PREINIT:
1704 CALLBACK 1893 CALLBACK
1705 CODE: 1894 CODE:
1706{ 1895{
1707 dREQ (REQ_DB_EXISTS); 1896 dREQ (REQ_DB_EXISTS, 2);
1708 req->db = db; 1897 req->db = db;
1709 req->txn = txn; 1898 req->txn = txn;
1710 req->uint1 = flags; 1899 req->uint1 = flags;
1711 sv_to_dbt (&req->dbt1, key); 1900 sv_to_dbt (&req->dbt1, key);
1712 REQ_SEND; 1901 REQ_SEND;
1713} 1902}
1714 1903
1715#endif 1904#endif
1716 1905
1717void 1906void
1718db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) 1907db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0)
1719 PREINIT: 1908 PREINIT:
1720 CALLBACK 1909 CALLBACK
1721 CODE: 1910 CODE:
1722 if (SvREADONLY (data))
1723 croak ("can't modify read-only data scalar in db_get");
1724{ 1911{
1912 //TODO: key is somtimesmutable
1725 dREQ (REQ_DB_GET); 1913 dREQ (REQ_DB_GET, 2);
1726 req->db = db; 1914 req->db = db;
1727 req->txn = txn; 1915 req->txn = txn;
1728 req->uint1 = flags; 1916 req->uint1 = flags;
1729 sv_to_dbt (&req->dbt1, key); 1917 sv_to_dbt (&req->dbt1, key);
1730 req->dbt3.flags = DB_DBT_MALLOC; 1918 req->dbt3.flags = DB_DBT_MALLOC;
1731 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); 1919 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1732 REQ_SEND; 1920 REQ_SEND;
1733} 1921}
1734 1922
1735void 1923void
1736db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) 1924db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0)
1737 PREINIT: 1925 PREINIT:
1738 CALLBACK 1926 CALLBACK
1739 CODE: 1927 CODE:
1740 if (SvREADONLY (data))
1741 croak ("can't modify read-only data scalar in db_pget");
1742{ 1928{
1929 //TODO: key is somtimesmutable
1743 dREQ (REQ_DB_PGET); 1930 dREQ (REQ_DB_PGET, 2);
1931 req->db = db;
1932 req->txn = txn;
1933 req->uint1 = flags;
1934
1935 sv_to_dbt (&req->dbt1, key);
1936
1937 req->dbt2.flags = DB_DBT_MALLOC;
1938 req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey);
1939
1940 req->dbt3.flags = DB_DBT_MALLOC;
1941 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1942 REQ_SEND;
1943}
1944
1945void
1946db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0)
1947 PREINIT:
1948 CALLBACK
1949 CODE:
1950{
1951 dREQ (REQ_DB_DEL, 2);
1744 req->db = db; 1952 req->db = db;
1745 req->txn = txn; 1953 req->txn = txn;
1746 req->uint1 = flags; 1954 req->uint1 = flags;
1747 sv_to_dbt (&req->dbt1, key); 1955 sv_to_dbt (&req->dbt1, key);
1748 sv_to_dbt (&req->dbt2, pkey);
1749 req->dbt3.flags = DB_DBT_MALLOC;
1750 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1751 REQ_SEND; 1956 REQ_SEND;
1752} 1957}
1753 1958
1754void 1959void
1755db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) 1960db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0)
1756 PREINIT: 1961 PREINIT:
1757 CALLBACK 1962 CALLBACK
1758 CODE: 1963 CODE:
1759{ 1964{
1760 dREQ (REQ_DB_DEL); 1965 dREQ (REQ_TXN_COMMIT, 0);
1761 req->db = db; 1966 ptr_nuke (ST (0));
1762 req->txn = txn; 1967 req->txn = txn;
1763 req->uint1 = flags; 1968 req->uint1 = flags;
1764 sv_to_dbt (&req->dbt1, key);
1765 REQ_SEND; 1969 REQ_SEND;
1766} 1970}
1767 1971
1768void 1972void
1973db_txn_abort (DB_TXN *txn, SV *callback = 0)
1974 PREINIT:
1975 CALLBACK
1976 CODE:
1977{
1978 dREQ (REQ_TXN_ABORT, 0);
1979 ptr_nuke (ST (0));
1980 req->txn = txn;
1981 REQ_SEND;
1982}
1983
1984void
1769db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) 1985db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0)
1770 PREINIT: 1986 PREINIT:
1771 CALLBACK 1987 CALLBACK
1772 CODE: 1988 CODE:
1773{ 1989{
1774 dREQ (REQ_TXN_COMMIT); 1990 dREQ (REQ_TXN_FINISH, 0);
1991 ptr_nuke (ST (0));
1775 req->txn = txn; 1992 req->txn = txn;
1776 req->uint1 = flags; 1993 req->uint1 = flags;
1777 REQ_SEND; 1994 REQ_SEND;
1995}
1996
1997void
1998db_c_close (DBC *dbc, SV *callback = 0)
1999 PREINIT:
2000 CALLBACK
2001 CODE:
2002{
2003 dREQ (REQ_C_CLOSE, 0);
1778 ptr_nuke (ST (0)); 2004 ptr_nuke (ST (0));
1779}
1780
1781void
1782db_txn_abort (DB_TXN *txn, SV *callback = 0)
1783 PREINIT:
1784 CALLBACK
1785 CODE:
1786{
1787 dREQ (REQ_TXN_ABORT);
1788 req->txn = txn;
1789 REQ_SEND;
1790 ptr_nuke (ST (0));
1791}
1792
1793void
1794db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0)
1795 PREINIT:
1796 CALLBACK
1797 CODE:
1798{
1799 dREQ (REQ_TXN_FINISH);
1800 req->txn = txn;
1801 req->uint1 = flags;
1802 REQ_SEND;
1803 ptr_nuke (ST (0));
1804}
1805
1806void
1807db_c_close (DBC *dbc, SV *callback = 0)
1808 PREINIT:
1809 CALLBACK
1810 CODE:
1811{
1812 dREQ (REQ_C_CLOSE);
1813 req->dbc = dbc; 2005 req->dbc = dbc;
1814 REQ_SEND; 2006 REQ_SEND;
1815 ptr_nuke (ST (0));
1816} 2007}
1817 2008
1818void 2009void
1819db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) 2010db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0)
1820 PREINIT: 2011 PREINIT:
1821 CALLBACK 2012 CALLBACK
1822 CODE: 2013 CODE:
1823{ 2014{
1824 dREQ (REQ_C_COUNT); 2015 dREQ (REQ_C_COUNT, 1);
1825 req->dbc = dbc; 2016 req->dbc = dbc;
1826 req->sv1 = SvREFCNT_inc (count); 2017 req->sv1 = SvREFCNT_inc (count);
1827 REQ_SEND; 2018 REQ_SEND;
1828} 2019}
1829 2020
1831db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) 2022db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0)
1832 PREINIT: 2023 PREINIT:
1833 CALLBACK 2024 CALLBACK
1834 CODE: 2025 CODE:
1835{ 2026{
1836 dREQ (REQ_C_PUT); 2027 dREQ (REQ_C_PUT, 1);
1837 req->dbc = dbc; 2028 req->dbc = dbc;
1838 sv_to_dbt (&req->dbt1, key); 2029 sv_to_dbt (&req->dbt1, key);
1839 sv_to_dbt (&req->dbt2, data); 2030 sv_to_dbt (&req->dbt2, data);
1840 req->uint1 = flags; 2031 req->uint1 = flags;
1841 REQ_SEND; 2032 REQ_SEND;
1842} 2033}
1843 2034
1844void 2035void
1845db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) 2036db_c_get (DBC *dbc, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0)
1846 PREINIT: 2037 PREINIT:
1847 CALLBACK 2038 CALLBACK
1848 CODE: 2039 CODE:
1849{ 2040{
2041 if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key))
2042 croak ("db_c_get was passed a read-only/constant 'key' argument but operation is not DB_SET");
2043 if (SvPOKp (key) && !sv_utf8_downgrade (key, 1))
2044 croak ("argument \"%s\" must be byte/octet-encoded in %s",
2045 "key",
2046 "BDB::db_c_get");
2047
2048 {
1850 dREQ (REQ_C_GET); 2049 dREQ (REQ_C_GET, 1);
2050 req->dbc = dbc;
2051 req->uint1 = flags;
2052 if ((flags & DB_OPFLAGS_MASK) == DB_SET)
2053 sv_to_dbt (&req->dbt1, key);
2054 else
2055 {
2056 if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE)
2057 sv_to_dbt (&req->dbt1, key);
2058 else
2059 req->dbt1.flags = DB_DBT_MALLOC;
2060
2061 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key);
2062 }
2063
2064 if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH
2065 || (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE)
2066 sv_to_dbt (&req->dbt3, data);
2067 else
2068 req->dbt3.flags = DB_DBT_MALLOC;
2069
2070 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
2071 REQ_SEND;
2072 }
2073}
2074
2075void
2076db_c_pget (DBC *dbc, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0)
2077 PREINIT:
2078 CALLBACK
2079 CODE:
2080{
2081 if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key))
2082 croak ("db_c_pget was passed a read-only/constant 'key' argument but operation is not DB_SET");
2083 if (SvPOKp (key) && !sv_utf8_downgrade (key, 1))
2084 croak ("argument \"%s\" must be byte/octet-encoded in %s",
2085 "key",
2086 "BDB::db_c_pget");
2087
2088 {
2089 dREQ (REQ_C_PGET, 1);
2090 req->dbc = dbc;
2091 req->uint1 = flags;
2092 if ((flags & DB_OPFLAGS_MASK) == DB_SET)
2093 sv_to_dbt (&req->dbt1, key);
2094 else
2095 {
2096 if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE)
2097 sv_to_dbt (&req->dbt1, key);
2098 else
2099 req->dbt1.flags = DB_DBT_MALLOC;
2100
2101 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key);
2102 }
2103
2104 req->dbt2.flags = DB_DBT_MALLOC;
2105 req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey);
2106
2107 if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH
2108 || (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE)
2109 sv_to_dbt (&req->dbt3, data);
2110 else
2111 req->dbt3.flags = DB_DBT_MALLOC;
2112
2113 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
2114 REQ_SEND;
2115 }
2116}
2117
2118void
2119db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0)
2120 PREINIT:
2121 CALLBACK
2122 CODE:
2123{
2124 dREQ (REQ_C_DEL, 1);
1851 req->dbc = dbc; 2125 req->dbc = dbc;
1852 req->uint1 = flags; 2126 req->uint1 = flags;
1853 if ((flags & DB_SET) == DB_SET
1854 || (flags & DB_SET_RANGE) == DB_SET_RANGE)
1855 sv_to_dbt (&req->dbt1, key);
1856 else
1857 req->dbt1.flags = DB_DBT_MALLOC;
1858
1859 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key);
1860
1861 if ((flags & DB_GET_BOTH) == DB_GET_BOTH
1862 || (flags & DB_GET_BOTH_RANGE) == DB_GET_BOTH_RANGE)
1863 sv_to_dbt (&req->dbt3, data);
1864 else
1865 req->dbt3.flags = DB_DBT_MALLOC;
1866
1867 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1868 REQ_SEND; 2127 REQ_SEND;
1869} 2128}
1870 2129
1871void
1872db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0)
1873 PREINIT:
1874 CALLBACK
1875 CODE:
1876{
1877 dREQ (REQ_C_PGET);
1878 req->dbc = dbc;
1879 req->uint1 = flags;
1880 if ((flags & DB_SET) == DB_SET
1881 || (flags & DB_SET_RANGE) == DB_SET_RANGE)
1882 sv_to_dbt (&req->dbt1, key);
1883 else
1884 req->dbt1.flags = DB_DBT_MALLOC;
1885 2130
1886 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key); 2131#if DBVER >= 403
1887
1888 req->dbt2.flags = DB_DBT_MALLOC;
1889 req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey);
1890
1891 if ((flags & DB_GET_BOTH) == DB_GET_BOTH
1892 || (flags & DB_GET_BOTH_RANGE) == DB_GET_BOTH_RANGE)
1893 sv_to_dbt (&req->dbt3, data);
1894 else
1895 req->dbt3.flags = DB_DBT_MALLOC;
1896
1897 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1898 REQ_SEND;
1899}
1900
1901void
1902db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0)
1903 PREINIT:
1904 CALLBACK
1905 CODE:
1906{
1907 dREQ (REQ_C_DEL);
1908 req->dbc = dbc;
1909 req->uint1 = flags;
1910 REQ_SEND;
1911}
1912
1913 2132
1914void 2133void
1915db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) 2134db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0)
1916 PREINIT: 2135 PREINIT:
1917 CALLBACK 2136 CALLBACK
1918 CODE: 2137 CODE:
1919{ 2138{
1920 dREQ (REQ_SEQ_OPEN); 2139 dREQ (REQ_SEQ_OPEN, 2);
1921 req->seq = seq; 2140 req->seq = seq;
1922 req->txn = txnid; 2141 req->txn = txnid;
1923 req->uint1 = flags | DB_THREAD; 2142 req->uint1 = flags | DB_THREAD;
1924 sv_to_dbt (&req->dbt1, key); 2143 sv_to_dbt (&req->dbt1, key);
1925 REQ_SEND; 2144 REQ_SEND;
1929db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) 2148db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0)
1930 PREINIT: 2149 PREINIT:
1931 CALLBACK 2150 CALLBACK
1932 CODE: 2151 CODE:
1933{ 2152{
1934 dREQ (REQ_SEQ_CLOSE); 2153 dREQ (REQ_SEQ_CLOSE, 0);
2154 ptr_nuke (ST (0));
1935 req->seq = seq; 2155 req->seq = seq;
1936 req->uint1 = flags; 2156 req->uint1 = flags;
1937 REQ_SEND; 2157 REQ_SEND;
1938 ptr_nuke (ST (0));
1939} 2158}
1940 2159
1941void 2160void
1942db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) 2161db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV_mutable *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0)
1943 PREINIT: 2162 PREINIT:
1944 CALLBACK 2163 CALLBACK
1945 CODE: 2164 CODE:
1946{ 2165{
1947 dREQ (REQ_SEQ_GET); 2166 dREQ (REQ_SEQ_GET, 2);
1948 req->seq = seq; 2167 req->seq = seq;
1949 req->txn = txnid; 2168 req->txn = txnid;
1950 req->int1 = delta; 2169 req->int1 = delta;
1951 req->uint1 = flags; 2170 req->uint1 = flags;
1952 req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); 2171 req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value);
1957db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) 2176db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0)
1958 PREINIT: 2177 PREINIT:
1959 CALLBACK 2178 CALLBACK
1960 CODE: 2179 CODE:
1961{ 2180{
1962 dREQ (REQ_SEQ_REMOVE); 2181 dREQ (REQ_SEQ_REMOVE, 2);
1963 req->seq = seq; 2182 req->seq = seq;
1964 req->txn = txnid; 2183 req->txn = txnid;
1965 req->uint1 = flags; 2184 req->uint1 = flags;
1966 REQ_SEND; 2185 REQ_SEND;
1967} 2186}
1968 2187
2188#endif
2189
1969 2190
1970MODULE = BDB PACKAGE = BDB::Env 2191MODULE = BDB PACKAGE = BDB::Env
1971 2192
1972void 2193void
1973DESTROY (DB_ENV_ornuked *env) 2194DESTROY (DB_ENV_ornuked *env)
2009 CODE: 2230 CODE:
2010 RETVAL = env->set_flags (env, flags, onoff); 2231 RETVAL = env->set_flags (env, flags, onoff);
2011 OUTPUT: 2232 OUTPUT:
2012 RETVAL 2233 RETVAL
2013 2234
2014#if DB_VERSION_MINOR >= 7 2235#if DBVER >= 407
2015 2236
2016int set_intermediate_dir_mode (DB_ENV *env, const char *mode) 2237int set_intermediate_dir_mode (DB_ENV *env, const char *mode)
2017 CODE: 2238 CODE:
2018 RETVAL = env->set_intermediate_dir_mode (env, mode); 2239 RETVAL = env->set_intermediate_dir_mode (env, mode);
2019 OUTPUT: 2240 OUTPUT:
2105int set_lg_max (DB_ENV *env, U32 max) 2326int set_lg_max (DB_ENV *env, U32 max)
2106 CODE: 2327 CODE:
2107 RETVAL = env->set_lg_max (env, max); 2328 RETVAL = env->set_lg_max (env, max);
2108 OUTPUT: 2329 OUTPUT:
2109 RETVAL 2330 RETVAL
2331
2332#if DBVER >= 404
2110 2333
2111int mutex_set_max (DB_ENV *env, U32 max) 2334int mutex_set_max (DB_ENV *env, U32 max)
2112 CODE: 2335 CODE:
2113 RETVAL = env->mutex_set_max (env, max); 2336 RETVAL = env->mutex_set_max (env, max);
2114 OUTPUT: 2337 OUTPUT:
2130 CODE: 2353 CODE:
2131 RETVAL = env->mutex_set_align (env, align); 2354 RETVAL = env->mutex_set_align (env, align);
2132 OUTPUT: 2355 OUTPUT:
2133 RETVAL 2356 RETVAL
2134 2357
2358#endif
2359
2135DB_TXN * 2360DB_TXN *
2136txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) 2361txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0)
2137 CODE: 2362 CODE:
2138 errno = env->txn_begin (env, parent, &RETVAL, flags); 2363 errno = env->txn_begin (env, parent, &RETVAL, flags);
2139 if (errno) 2364 if (errno)
2140 croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); 2365 croak ("DB_ENV->txn_begin: %s", db_strerror (errno));
2141 OUTPUT: 2366 OUTPUT:
2142 RETVAL 2367 RETVAL
2143 2368
2144#if DB_VERSION_MINOR >= 5 2369#if DBVER >= 405
2145 2370
2146DB_TXN * 2371DB_TXN *
2147cdsgroup_begin (DB_ENV *env) 2372cdsgroup_begin (DB_ENV *env)
2148 CODE: 2373 CODE:
2149 errno = env->cdsgroup_begin (env, &RETVAL); 2374 errno = env->cdsgroup_begin (env, &RETVAL);
2170 CODE: 2395 CODE:
2171 RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); 2396 RETVAL = db->set_cachesize (db, gbytes, bytes, ncache);
2172 OUTPUT: 2397 OUTPUT:
2173 RETVAL 2398 RETVAL
2174 2399
2400int set_pagesize (DB *db, U32 pagesize)
2401 CODE:
2402 RETVAL = db->set_pagesize (db, pagesize);
2403 OUTPUT:
2404 RETVAL
2405
2175int set_flags (DB *db, U32 flags) 2406int set_flags (DB *db, U32 flags)
2176 CODE: 2407 CODE:
2177 RETVAL = db->set_flags (db, flags); 2408 RETVAL = db->set_flags (db, flags);
2178 OUTPUT: 2409 OUTPUT:
2179 RETVAL 2410 RETVAL
2245 if (errno) 2476 if (errno)
2246 croak ("DB->cursor: %s", db_strerror (errno)); 2477 croak ("DB->cursor: %s", db_strerror (errno));
2247 OUTPUT: 2478 OUTPUT:
2248 RETVAL 2479 RETVAL
2249 2480
2481#if DBVER >= 403
2482
2250DB_SEQUENCE * 2483DB_SEQUENCE *
2251sequence (DB *db, U32 flags = 0) 2484sequence (DB *db, U32 flags = 0)
2252 CODE: 2485 CODE:
2253{ 2486{
2254 errno = db_sequence_create (&RETVAL, db, flags); 2487 errno = db_sequence_create (&RETVAL, db, flags);
2256 croak ("db_sequence_create: %s", db_strerror (errno)); 2489 croak ("db_sequence_create: %s", db_strerror (errno));
2257} 2490}
2258 OUTPUT: 2491 OUTPUT:
2259 RETVAL 2492 RETVAL
2260 2493
2494#endif
2495
2261 2496
2262MODULE = BDB PACKAGE = BDB::Txn 2497MODULE = BDB PACKAGE = BDB::Txn
2263 2498
2264void 2499void
2265DESTROY (DB_TXN_ornuked *txn) 2500DESTROY (DB_TXN_ornuked *txn)
2286DESTROY (DBC_ornuked *dbc) 2521DESTROY (DBC_ornuked *dbc)
2287 CODE: 2522 CODE:
2288 if (dbc) 2523 if (dbc)
2289 dbc->c_close (dbc); 2524 dbc->c_close (dbc);
2290 2525
2291#if DB_VERSION_MINOR >= 6 2526#if DBVER >= 406
2292 2527
2293int set_priority (DBC *dbc, int priority) 2528int set_priority (DBC *dbc, int priority)
2294 CODE: 2529 CODE:
2295 dbc->set_priority (dbc, priority); 2530 dbc->set_priority (dbc, priority);
2296 2531
2297#endif 2532#endif
2298 2533
2534#if DBVER >= 403
2535
2299MODULE = BDB PACKAGE = BDB::Sequence 2536MODULE = BDB PACKAGE = BDB::Sequence
2300 2537
2301void 2538void
2302DESTROY (DB_SEQUENCE_ornuked *seq) 2539DESTROY (DB_SEQUENCE_ornuked *seq)
2303 CODE: 2540 CODE:
2326 CODE: 2563 CODE:
2327 RETVAL = seq->set_range (seq, min, max); 2564 RETVAL = seq->set_range (seq, min, max);
2328 OUTPUT: 2565 OUTPUT:
2329 RETVAL 2566 RETVAL
2330 2567
2568#endif
2331 2569
2570

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines