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

Comparing BDB/BDB.xs (file contents):
Revision 1.57 by root, Mon Sep 29 03:01:54 2008 UTC vs.
Revision 1.78 by root, Thu Oct 11 05:02:53 2012 UTC

6 6
7#include "EXTERN.h" 7#include "EXTERN.h"
8#include "perl.h" 8#include "perl.h"
9#include "XSUB.h" 9#include "XSUB.h"
10 10
11#include "schmorp.h"
12
11// perl stupidly defines these as macros, breaking 13// perl stupidly defines these as argument-less macros, breaking
12// lots and lots of code. 14// lots and lots of code.
13#undef open 15#undef open
14#undef close 16#undef close
15#undef abort 17#undef abort
16#undef malloc 18#undef malloc
29# include <unistd.h> 31# include <unistd.h>
30#endif 32#endif
31 33
32#include <db.h> 34#include <db.h>
33 35
34#if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) 36#define DBVER DB_VERSION_MAJOR * 100 + DB_VERSION_MINOR
37
38#if DBVER < 403
35# error you need Berkeley DB 4.3 or a newer 4.x version installed 39# error you need Berkeley DB 4.3 or a newer version installed
36#endif 40#endif
37 41
38/* number of seconds after which idle threads exit */ 42/* number of seconds after which idle threads exit */
39#define IDLE_TIMEOUT 10 43#define IDLE_TIMEOUT 10
40 44
48typedef DB_ENV DB_ENV_ornuked; 52typedef DB_ENV DB_ENV_ornuked;
49typedef DB_TXN DB_TXN_ornuked; 53typedef DB_TXN DB_TXN_ornuked;
50typedef DBC DBC_ornuked; 54typedef DBC DBC_ornuked;
51typedef DB DB_ornuked; 55typedef DB DB_ornuked;
52 56
53#if DB_VERSION_MINOR >= 3 57#if DBVER >= 403
54typedef DB_SEQUENCE DB_SEQUENCE_ornull; 58typedef DB_SEQUENCE DB_SEQUENCE_ornull;
55typedef DB_SEQUENCE DB_SEQUENCE_ornuked; 59typedef DB_SEQUENCE DB_SEQUENCE_ornuked;
56#endif 60#endif
57 61
58typedef SV SV8; /* byte-sv, used for argument-checking */
59typedef char *bdb_filename; 62typedef char *bdb_filename;
60 63
61static SV *prepare_cb; 64static SV *prepare_cb;
62 65
63#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
64# define c_close close 75# define c_close close
65# define c_count count 76# define c_count count
66# define c_del del 77# define c_del del
67# define c_dup dup 78# define c_dup dup
68# define c_get get 79# define c_get get
150 161
151enum { 162enum {
152 REQ_QUIT, 163 REQ_QUIT,
153 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,
154 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,
155 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,
156 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,
157 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, 169 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH,
158 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,
159 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,
160}; 172};
176 char *buf1, *buf2, *buf3; 188 char *buf1, *buf2, *buf3;
177 SV *sv1, *sv2, *sv3; 189 SV *sv1, *sv2, *sv3;
178 190
179 DBT dbt1, dbt2, dbt3; 191 DBT dbt1, dbt2, dbt3;
180 DB_KEY_RANGE key_range; 192 DB_KEY_RANGE key_range;
181#if DB_VERSION_MINOR >= 3 193#if DBVER >= 403
182 DB_SEQUENCE *seq; 194 DB_SEQUENCE *seq;
183 db_seq_t seq_t; 195 db_seq_t seq_t;
184#endif 196#endif
185 197
186 SV *rsv1, *rsv2; // keep some request objects alive 198 SV *rsv1, *rsv2; // keep some request objects alive
214static int next_pri = DEFAULT_PRI + PRI_BIAS; 226static int next_pri = DEFAULT_PRI + PRI_BIAS;
215 227
216static unsigned int started, idle, wanted; 228static unsigned int started, idle, wanted;
217 229
218/* worker threads management */ 230/* worker threads management */
219static mutex_t wrklock = X_MUTEX_INIT; 231static xmutex_t wrklock = X_MUTEX_INIT;
220 232
221typedef struct worker { 233typedef struct worker {
222 /* locked by wrklock */ 234 /* locked by wrklock */
223 struct worker *prev, *next; 235 struct worker *prev, *next;
224 236
225 thread_t tid; 237 xthread_t tid;
226 238
227 /* locked by reslock, reqlock or wrklock */ 239 /* locked by reslock, reqlock or wrklock */
228 bdb_req req; /* currently processed request */ 240 bdb_req req; /* currently processed request */
229 void *dbuf; 241 void *dbuf;
230 DIR *dirp; 242 DIR *dirp;
245} 257}
246 258
247static volatile unsigned int nreqs, nready, npending; 259static volatile unsigned int nreqs, nready, npending;
248static volatile unsigned int max_idle = 4; 260static volatile unsigned int max_idle = 4;
249static volatile unsigned int max_outstanding = 0xffffffff; 261static volatile unsigned int max_outstanding = 0xffffffff;
250static int respipe_osf [2], respipe [2] = { -1, -1 }; 262static s_epipe respipe;
251 263
252static mutex_t reslock = X_MUTEX_INIT; 264static xmutex_t reslock = X_MUTEX_INIT;
253static mutex_t reqlock = X_MUTEX_INIT; 265static xmutex_t reqlock = X_MUTEX_INIT;
254static cond_t reqwait = X_COND_INIT; 266static xcond_t reqwait = X_COND_INIT;
255 267
256#if WORDACCESS_UNSAFE 268#if WORDACCESS_UNSAFE
257 269
258static unsigned int get_nready (void) 270static unsigned int get_nready (void)
259{ 271{
350 abort (); 362 abort ();
351} 363}
352 364
353static int poll_cb (void); 365static int poll_cb (void);
354static void req_free (bdb_req req); 366static void req_free (bdb_req req);
355static void req_cancel (bdb_req req);
356 367
357static int req_invoke (bdb_req req) 368static int req_invoke (bdb_req req)
358{ 369{
359 switch (req->type) 370 switch (req->type)
360 { 371 {
379 390
380 av_push (av, newSVnv (req->key_range.less)); 391 av_push (av, newSVnv (req->key_range.less));
381 av_push (av, newSVnv (req->key_range.equal)); 392 av_push (av, newSVnv (req->key_range.equal));
382 av_push (av, newSVnv (req->key_range.greater)); 393 av_push (av, newSVnv (req->key_range.greater));
383 394
395 av = (AV *)newRV_noinc ((SV *)av);
396
384 SvREADONLY_off (req->sv1); 397 SvREADONLY_off (req->sv1);
385 sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); 398 sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av));
399 SvREFCNT_dec (av);
386 SvREFCNT_dec (req->sv1); 400 SvREFCNT_dec (req->sv1);
387 } 401 }
388 break; 402 break;
389 403
390#if DB_VERSION_MINOR >= 3 404#if DBVER >= 403
391 case REQ_SEQ_GET: 405 case REQ_SEQ_GET:
392 SvREADONLY_off (req->sv1); 406 SvREADONLY_off (req->sv1);
393 407
394 if (sizeof (IV) > 4) 408 if (sizeof (IV) > 4)
395 sv_setiv_mg (req->sv1, (IV)req->seq_t); 409 sv_setiv_mg (req->sv1, (IV)req->seq_t);
397 sv_setnv_mg (req->sv1, (NV)req->seq_t); 411 sv_setnv_mg (req->sv1, (NV)req->seq_t);
398 412
399 SvREFCNT_dec (req->sv1); 413 SvREFCNT_dec (req->sv1);
400 break; 414 break;
401#endif 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;
402 } 434 }
403 435
404 errno = req->result; 436 errno = req->result;
405 437
406 if (req->callback) 438 if (req->callback)
436 free (req->buf3); 468 free (req->buf3);
437 469
438 Safefree (req); 470 Safefree (req);
439} 471}
440 472
441#ifdef USE_SOCKETS_AS_HANDLES
442# define TO_SOCKET(x) (win32_get_osfhandle (x))
443#else
444# define TO_SOCKET(x) (x)
445#endif
446
447static void 473static void
448create_respipe (void) 474create_respipe (void)
449{ 475{
450#ifdef _WIN32
451 int arg; /* argg */
452#endif
453 int old_readfd = respipe [0];
454
455 if (respipe [1] >= 0)
456 respipe_close (TO_SOCKET (respipe [1]));
457
458#ifdef _WIN32
459 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe))
460#else
461 if (pipe (respipe)) 476 if (s_epipe_renew (&respipe))
462#endif 477 croak ("BDB: unable to create event pipe");
463 croak ("unable to initialize result pipe");
464
465 if (old_readfd >= 0)
466 {
467 if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0)
468 croak ("unable to initialize result pipe(2)");
469
470 respipe_close (respipe [0]);
471 respipe [0] = old_readfd;
472 }
473
474#ifdef _WIN32
475 arg = 1;
476 if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg)
477 || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg))
478#else
479 if (fcntl (respipe [0], F_SETFL, O_NONBLOCK)
480 || fcntl (respipe [1], F_SETFL, O_NONBLOCK))
481#endif
482 croak ("unable to initialize result pipe(3)");
483
484 respipe_osf [0] = TO_SOCKET (respipe [0]);
485 respipe_osf [1] = TO_SOCKET (respipe [1]);
486} 478}
487 479
488static void bdb_request (bdb_req req); 480static void bdb_request (bdb_req req);
489X_THREAD_PROC (bdb_proc); 481X_THREAD_PROC (bdb_proc);
490 482
494 486
495 if (!wrk) 487 if (!wrk)
496 croak ("unable to allocate worker thread data"); 488 croak ("unable to allocate worker thread data");
497 489
498 X_LOCK (wrklock); 490 X_LOCK (wrklock);
499 if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) 491 if (xthread_create (&wrk->tid, bdb_proc, (void *)wrk))
500 { 492 {
501 wrk->prev = &wrk_first; 493 wrk->prev = &wrk_first;
502 wrk->next = wrk_first.next; 494 wrk->next = wrk_first.next;
503 wrk_first.next->prev = wrk; 495 wrk_first.next->prev = wrk;
504 wrk_first.next = wrk; 496 wrk_first.next = wrk;
626 end_thread (); 618 end_thread ();
627} 619}
628 620
629static void poll_wait (void) 621static void poll_wait (void)
630{ 622{
631 fd_set rfd;
632
633 while (nreqs) 623 while (nreqs)
634 { 624 {
635 int size; 625 int size;
636 if (WORDACCESS_UNSAFE) X_LOCK (reslock); 626 if (WORDACCESS_UNSAFE) X_LOCK (reslock);
637 size = res_queue.size; 627 size = res_queue.size;
640 if (size) 630 if (size)
641 return; 631 return;
642 632
643 maybe_start_thread (); 633 maybe_start_thread ();
644 634
645 FD_ZERO (&rfd); 635 s_epipe_wait (&respipe);
646 FD_SET (respipe [0], &rfd);
647
648 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0);
649 } 636 }
650} 637}
651 638
652static int poll_cb (void) 639static int poll_cb (void)
653{ 640{
673 if (req) 660 if (req)
674 { 661 {
675 --npending; 662 --npending;
676 663
677 if (!res_queue.size) 664 if (!res_queue.size)
678 {
679 /* read any signals sent by the worker threads */ 665 /* read any signals sent by the worker threads */
680 char buf [4]; 666 s_epipe_drain (&respipe);
681 while (respipe_read (respipe [0], buf, 4) == 4)
682 ;
683 }
684 } 667 }
685 668
686 X_UNLOCK (reslock); 669 X_UNLOCK (reslock);
687 670
688 if (!req) 671 if (!req)
768 751
769 case REQ_DB_CLOSE: 752 case REQ_DB_CLOSE:
770 req->result = req->db->close (req->db, req->uint1); 753 req->result = req->db->close (req->db, req->uint1);
771 break; 754 break;
772 755
773#if DB_VERSION_MINOR >= 4 756#if DBVER >= 404
774 case REQ_DB_COMPACT: 757 case REQ_DB_COMPACT:
775 req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); 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);
776 break; 759 break;
777#endif 760#endif
778 761
779 case REQ_DB_SYNC: 762 case REQ_DB_SYNC:
780 req->result = req->db->sync (req->db, req->uint1); 763 req->result = req->db->sync (req->db, req->uint1);
781 break; 764 break;
782 765
766 case REQ_DB_VERIFY:
767 req->result = req->db->verify (req->db, req->buf1, req->buf2, 0, req->uint1);
768 break;
769
783 case REQ_DB_UPGRADE: 770 case REQ_DB_UPGRADE:
784 req->result = req->db->upgrade (req->db, req->buf1, req->uint1); 771 req->result = req->db->upgrade (req->db, req->buf1, req->uint1);
785 break; 772 break;
786 773
787 case REQ_DB_PUT: 774 case REQ_DB_PUT:
788 req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); 775 req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1);
789 break; 776 break;
790 777
791#if DB_VERSION_MINOR >= 6 778#if DBVER >= 406
792 case REQ_DB_EXISTS: 779 case REQ_DB_EXISTS:
793 req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); 780 req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1);
794 break; 781 break;
795#endif 782#endif
796 case REQ_DB_GET: 783 case REQ_DB_GET:
854 841
855 case REQ_C_DEL: 842 case REQ_C_DEL:
856 req->result = req->dbc->c_del (req->dbc, req->uint1); 843 req->result = req->dbc->c_del (req->dbc, req->uint1);
857 break; 844 break;
858 845
859#if DB_VERSION_MINOR >= 3 846#if DBVER >= 403
860 case REQ_SEQ_OPEN: 847 case REQ_SEQ_OPEN:
861 req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); 848 req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1);
862 break; 849 break;
863 850
864 case REQ_SEQ_CLOSE: 851 case REQ_SEQ_CLOSE:
871 858
872 case REQ_SEQ_REMOVE: 859 case REQ_SEQ_REMOVE:
873 req->result = req->seq->remove (req->seq, req->txn, req->uint1); 860 req->result = req->seq->remove (req->seq, req->txn, req->uint1);
874 break; 861 break;
875#endif 862#endif
863
864 case REQ_ENV_LOG_ARCHIVE:
865 {
866 char **listp = 0; /* DB_ARCH_REMOVE does not touch listp, contrary to docs */
867 req->result = req->env->log_archive (req->env, &listp, req->uint1);
868 req->buf1 = (char *)listp;
869 }
870 break;
876 871
877 default: 872 default:
878 req->result = ENOSYS; 873 req->result = ENOSYS;
879 break; 874 break;
880 } 875 }
892 /* try to distribute timeouts somewhat evenly */ 887 /* try to distribute timeouts somewhat evenly */
893 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); 888 ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL);
894 889
895 for (;;) 890 for (;;)
896 { 891 {
897 ts.tv_sec = time (0) + IDLE_TIMEOUT; 892 ts.tv_sec = time (0) + IDLE_TIMEOUT;
898 893
899 X_LOCK (reqlock); 894 X_LOCK (reqlock);
900 895
901 for (;;) 896 for (;;)
902 { 897 {
947 X_LOCK (reslock); 942 X_LOCK (reslock);
948 943
949 ++npending; 944 ++npending;
950 945
951 if (!reqq_push (&res_queue, req)) 946 if (!reqq_push (&res_queue, req))
952 /* write a dummy byte to the pipe so fh becomes ready */ 947 s_epipe_signal (&respipe);
953 respipe_write (respipe_osf [1], (const void *)&respipe_osf, 1);
954 948
955 self->req = 0; 949 self->req = 0;
956 worker_clear (self); 950 worker_clear (self);
957 951
958 X_UNLOCK (reslock); 952 X_UNLOCK (reslock);
1034 (void)0; 1028 (void)0;
1035 1029
1036#define REQ_SEND \ 1030#define REQ_SEND \
1037 req_send (req) 1031 req_send (req)
1038 1032
1039#define SvPTR(var, arg, type, class, nullok) \ 1033#define SvPTR(var, arg, type, stash, class, nullok) \
1040 if (!SvOK (arg)) \ 1034 if (!SvOK (arg)) \
1041 { \ 1035 { \
1042 if (nullok != 1) \ 1036 if (nullok != 1) \
1043 croak (# var " must be a " # class " object, not undef"); \ 1037 croak (# var " must be a " # class " object, not undef"); \
1044 \ 1038 \
1045 (var) = 0; \ 1039 (var) = 0; \
1046 } \ 1040 } \
1047 else if (sv_derived_from ((arg), # class)) \ 1041 else if (SvSTASH (SvRV (arg)) == stash || sv_derived_from ((arg), # class)) \
1048 { \ 1042 { \
1049 IV tmp = SvIV ((SV*) SvRV (arg)); \ 1043 IV tmp = SvIV ((SV*) SvRV (arg)); \
1050 (var) = INT2PTR (type, tmp); \ 1044 (var) = INT2PTR (type, tmp); \
1051 if (!var && nullok != 2) \ 1045 if (!var && nullok != 2) \
1052 croak (# var " is not a valid " # class " object anymore"); \ 1046 croak (# var " is not a valid " # class " object anymore"); \
1055 croak (# var " is not of type " # class); 1049 croak (# var " is not of type " # class);
1056 1050
1057#define ARG_MUTABLE(name) \ 1051#define ARG_MUTABLE(name) \
1058 if (SvREADONLY (name)) \ 1052 if (SvREADONLY (name)) \
1059 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable"); 1053 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable");
1054
1055static SV *
1056newSVptr (void *ptr, HV *stash)
1057{
1058 SV *rv = NEWSV (0, 0);
1059 sv_upgrade (rv, SVt_PVMG);
1060 sv_setiv (rv, PTR2IV (ptr));
1061
1062 return sv_bless (newRV_noinc (rv), stash);
1063}
1060 1064
1061static void 1065static void
1062ptr_nuke (SV *sv) 1066ptr_nuke (SV *sv)
1063{ 1067{
1064 assert (SvROK (sv)); 1068 assert (SvROK (sv));
1135 } 1139 }
1136 1140
1137 return 0; 1141 return 0;
1138} 1142}
1139 1143
1144/*****************************************************************************/
1145
1146#if 0
1147static int
1148bt_pfxc_compare (DB *db, const DBT *dbt1, const DBT *dbt2)
1149{
1150 ssize_t size1 = dbt1->size;
1151 ssize_t size2 = dbt2->size;
1152 int res = memcmp ((void *)dbt1->data, (void *)dbt2->data,
1153 size1 <= size2 ? size1 : size2);
1154
1155 if (res)
1156 return res;
1157 else if (size1 - size2)
1158 return size1 - size2;
1159 else
1160 return 0;
1161}
1162
1163static size_t
1164bt_pfxc_prefix_x (DB *db, const DBT *dbt1, const DBT *dbt2)
1165{
1166 ssize_t size1 = dbt1->size;
1167 ssize_t size2 = dbt2->size;
1168 u_int8_t *p1 = (u_int8_t *)dbt1->data;
1169 u_int8_t *p2 = (u_int8_t *)dbt2->data;
1170 u_int8_t *pe = p1 + (size1 <= size2 ? size1 : size2);
1171
1172 while (p1 < pe)
1173 if (*p1++ != *p2++)
1174 return p1 - (u_int8_t *)dbt1->data - 1;
1175
1176 if (size1 < size2) return size1 + 1;
1177 if (size1 > size2) return size2 + 1;
1178
1179 return size1;
1180}
1181#endif
1182
1183/*****************************************************************************/
1184
1140/* stupid windoes defined CALLBACK as well */ 1185/* stupid windows defines CALLBACK as well */
1141#undef CALLBACK 1186#undef CALLBACK
1142#define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); 1187#define CALLBACK SV *cb = pop_callback (&items, ST (items - 1));
1143 1188
1144MODULE = BDB PACKAGE = BDB 1189MODULE = BDB PACKAGE = BDB
1145 1190
1146PROTOTYPES: ENABLE 1191PROTOTYPES: ENABLE
1147 1192
1148BOOT: 1193BOOT:
1149{ 1194{
1150 HV *stash = gv_stashpv ("BDB", 1);
1151
1152 static const struct { 1195 static const struct {
1153 const char *name; 1196 const char *name;
1154 IV iv; 1197 IV iv;
1155 } *civ, const_iv[] = { 1198 } *civ, const_iv[] = {
1156#define const_iv(name) { # name, (IV)DB_ ## name }, 1199#define const_iv(name) { # name, (IV)DB_ ## name },
1200#if DBVER <= 408
1157 const_iv (RPCCLIENT) 1201 const_iv (RPCCLIENT)
1202#endif
1158 const_iv (INIT_CDB) 1203 const_iv (INIT_CDB)
1159 const_iv (INIT_LOCK) 1204 const_iv (INIT_LOCK)
1160 const_iv (INIT_LOG) 1205 const_iv (INIT_LOG)
1161 const_iv (INIT_MPOOL) 1206 const_iv (INIT_MPOOL)
1162 const_iv (INIT_REP) 1207 const_iv (INIT_REP)
1185 const_iv (TXN_NOT_DURABLE) 1230 const_iv (TXN_NOT_DURABLE)
1186 const_iv (TXN_WRITE_NOSYNC) 1231 const_iv (TXN_WRITE_NOSYNC)
1187 const_iv (WRITECURSOR) 1232 const_iv (WRITECURSOR)
1188 const_iv (YIELDCPU) 1233 const_iv (YIELDCPU)
1189 const_iv (ENCRYPT_AES) 1234 const_iv (ENCRYPT_AES)
1235#if DBVER < 408
1190 const_iv (XA_CREATE) 1236 const_iv (XA_CREATE)
1237#endif
1191 const_iv (BTREE) 1238 const_iv (BTREE)
1192 const_iv (HASH) 1239 const_iv (HASH)
1193 const_iv (QUEUE) 1240 const_iv (QUEUE)
1194 const_iv (RECNO) 1241 const_iv (RECNO)
1195 const_iv (UNKNOWN) 1242 const_iv (UNKNOWN)
1198 const_iv (NOSYNC) 1245 const_iv (NOSYNC)
1199 const_iv (CHKSUM) 1246 const_iv (CHKSUM)
1200 const_iv (ENCRYPT) 1247 const_iv (ENCRYPT)
1201 const_iv (DUP) 1248 const_iv (DUP)
1202 const_iv (DUPSORT) 1249 const_iv (DUPSORT)
1203 const_iv (RECNUM) 1250 //const_iv (RECNUM)
1204 const_iv (RENUMBER) 1251 const_iv (RENUMBER)
1205 const_iv (REVSPLITOFF) 1252 const_iv (REVSPLITOFF)
1206 const_iv (CONSUME) 1253 const_iv (CONSUME)
1207 const_iv (CONSUME_WAIT) 1254 const_iv (CONSUME_WAIT)
1208 const_iv (GET_BOTH) 1255 const_iv (GET_BOTH)
1259 const_iv (LOCK_OLDEST) 1306 const_iv (LOCK_OLDEST)
1260 const_iv (LOCK_RANDOM) 1307 const_iv (LOCK_RANDOM)
1261 const_iv (LOCK_YOUNGEST) 1308 const_iv (LOCK_YOUNGEST)
1262 1309
1263 const_iv (DONOTINDEX) 1310 const_iv (DONOTINDEX)
1264 const_iv (KEYEMPTY ) 1311 const_iv (KEYEMPTY)
1265 const_iv (KEYEXIST ) 1312 const_iv (KEYEXIST)
1266 const_iv (LOCK_DEADLOCK) 1313 const_iv (LOCK_DEADLOCK)
1267 const_iv (LOCK_NOTGRANTED) 1314 const_iv (LOCK_NOTGRANTED)
1268 const_iv (NOSERVER) 1315 const_iv (NOSERVER)
1316#if DBVER < 502
1269 const_iv (NOSERVER_HOME) 1317 const_iv (NOSERVER_HOME)
1270 const_iv (NOSERVER_ID) 1318 const_iv (NOSERVER_ID)
1319#endif
1271 const_iv (NOTFOUND) 1320 const_iv (NOTFOUND)
1272 const_iv (PAGE_NOTFOUND) 1321 const_iv (PAGE_NOTFOUND)
1273 const_iv (REP_DUPMASTER) 1322 const_iv (REP_DUPMASTER)
1274 const_iv (REP_HANDLE_DEAD) 1323 const_iv (REP_HANDLE_DEAD)
1275 const_iv (REP_HOLDELECTION) 1324 const_iv (REP_HOLDELECTION)
1280 const_iv (REP_UNAVAIL) 1329 const_iv (REP_UNAVAIL)
1281 const_iv (RUNRECOVERY) 1330 const_iv (RUNRECOVERY)
1282 const_iv (SECONDARY_BAD) 1331 const_iv (SECONDARY_BAD)
1283 const_iv (VERIFY_BAD) 1332 const_iv (VERIFY_BAD)
1284 1333
1334 const_iv (SALVAGE)
1335 const_iv (AGGRESSIVE)
1336 const_iv (PRINTABLE)
1337 const_iv (NOORDERCHK)
1338 const_iv (ORDERCHKONLY)
1339
1340 const_iv (ARCH_ABS)
1341 const_iv (ARCH_DATA)
1342 const_iv (ARCH_LOG)
1343 const_iv (ARCH_REMOVE)
1344
1285 const_iv (VERB_DEADLOCK) 1345 const_iv (VERB_DEADLOCK)
1286 const_iv (VERB_RECOVERY) 1346 const_iv (VERB_RECOVERY)
1287 const_iv (VERB_REPLICATION) 1347 const_iv (VERB_REPLICATION)
1288 const_iv (VERB_WAITSFOR) 1348 const_iv (VERB_WAITSFOR)
1289 1349
1290 const_iv (VERSION_MAJOR) 1350 const_iv (VERSION_MAJOR)
1291 const_iv (VERSION_MINOR) 1351 const_iv (VERSION_MINOR)
1292 const_iv (VERSION_PATCH) 1352 const_iv (VERSION_PATCH)
1293#if DB_VERSION_MINOR >= 3 1353 const_iv (LOGVERSION)
1354 const_iv (LOGOLDVER)
1355#if DBVER >= 403
1294 const_iv (INORDER) 1356 const_iv (INORDER)
1295 const_iv (LOCK_MAXWRITE) 1357 const_iv (LOCK_MAXWRITE)
1296 const_iv (SEQ_DEC) 1358 const_iv (SEQ_DEC)
1297 const_iv (SEQ_INC) 1359 const_iv (SEQ_INC)
1298 const_iv (SEQ_WRAP) 1360 const_iv (SEQ_WRAP)
1299 const_iv (BUFFER_SMALL) 1361 const_iv (BUFFER_SMALL)
1300 const_iv (LOG_BUFFER_FULL) 1362 const_iv (LOG_BUFFER_FULL)
1301 const_iv (VERSION_MISMATCH) 1363 const_iv (VERSION_MISMATCH)
1302#endif 1364#endif
1303#if DB_VERSION_MINOR >= 4 1365#if DBVER >= 404
1304 const_iv (REGISTER) 1366 const_iv (REGISTER)
1305 const_iv (DSYNC_DB) 1367 const_iv (DSYNC_DB)
1306 const_iv (READ_COMMITTED) 1368 const_iv (READ_COMMITTED)
1307 const_iv (READ_UNCOMMITTED) 1369 const_iv (READ_UNCOMMITTED)
1308 const_iv (REP_IGNORE) 1370 const_iv (REP_IGNORE)
1310 const_iv (REP_JOIN_FAILURE) 1372 const_iv (REP_JOIN_FAILURE)
1311 const_iv (FREE_SPACE) 1373 const_iv (FREE_SPACE)
1312 const_iv (FREELIST_ONLY) 1374 const_iv (FREELIST_ONLY)
1313 const_iv (VERB_REGISTER) 1375 const_iv (VERB_REGISTER)
1314#endif 1376#endif
1315#if DB_VERSION_MINOR >= 5 1377#if DBVER >= 405
1316 const_iv (MULTIVERSION) 1378 const_iv (MULTIVERSION)
1317 const_iv (TXN_SNAPSHOT) 1379 const_iv (TXN_SNAPSHOT)
1318#endif 1380#endif
1319#if DB_VERSION_MINOR >= 6 1381#if DBVER >= 406
1320 const_iv (PREV_DUP) 1382 const_iv (PREV_DUP)
1321 const_iv (PRIORITY_UNCHANGED) 1383 const_iv (PRIORITY_UNCHANGED)
1322 const_iv (PRIORITY_VERY_LOW) 1384 const_iv (PRIORITY_VERY_LOW)
1323 const_iv (PRIORITY_LOW) 1385 const_iv (PRIORITY_LOW)
1324 const_iv (PRIORITY_DEFAULT) 1386 const_iv (PRIORITY_DEFAULT)
1325 const_iv (PRIORITY_HIGH) 1387 const_iv (PRIORITY_HIGH)
1326 const_iv (PRIORITY_VERY_HIGH) 1388 const_iv (PRIORITY_VERY_HIGH)
1389 const_iv (IGNORE_LEASE)
1327#endif 1390#endif
1328#if DB_VERSION_MINOR >= 7 1391#if DBVER >= 407
1392 //const_iv (MULTIPLE_KEY)
1329 const_iv (LOG_DIRECT) 1393 const_iv (LOG_DIRECT)
1330 const_iv (LOG_DSYNC) 1394 const_iv (LOG_DSYNC)
1331 const_iv (LOG_AUTO_REMOVE) 1395 const_iv (LOG_AUTO_REMOVE)
1332 const_iv (LOG_IN_MEMORY) 1396 const_iv (LOG_IN_MEMORY)
1333 const_iv (LOG_ZERO) 1397 const_iv (LOG_ZERO)
1334#else 1398#else
1335 const_iv (DIRECT_LOG) 1399 const_iv (DIRECT_LOG)
1336 const_iv (LOG_AUTOREMOVE) 1400 const_iv (LOG_AUTOREMOVE)
1337# if DB_VERSION_MINOR >= 3 1401# if DBVER >= 403
1338 const_iv (DSYNC_LOG) 1402 const_iv (DSYNC_LOG)
1339 const_iv (LOG_INMEMORY) 1403 const_iv (LOG_INMEMORY)
1340# endif 1404# endif
1405#if DBVER >= 408
1406 const_iv (LOGVERSION_LATCHING)
1407#endif
1341#endif 1408#endif
1342 }; 1409 };
1343 1410
1411 bdb_stash = gv_stashpv ("BDB" , 1);
1412 bdb_env_stash = gv_stashpv ("BDB::Env" , 1);
1413 bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1);
1414 bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1);
1415 bdb_db_stash = gv_stashpv ("BDB::Db" , 1);
1416 bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1);
1417
1344 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1418 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
1345 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1419 newCONSTSUB (bdb_stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
1346 1420
1347 prepare_cb = &PL_sv_undef; 1421 prepare_cb = &PL_sv_undef;
1348 1422
1349 { 1423 {
1350 /* we currently only allow version, minor-version and patchlevel to go up to 255 */ 1424 /* we currently only allow version, minor-version and patchlevel to go up to 255 */
1351 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; 1425 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH };
1352 1426
1353 newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); 1427 newCONSTSUB (bdb_stash, "VERSION_v", newSVpvn (vstring, 3));
1354 } 1428 }
1355 1429
1356 newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); 1430 newCONSTSUB (bdb_stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1357 1431
1358 create_respipe (); 1432 create_respipe ();
1359 1433
1360 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1434 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1361 patch_errno (); 1435 patch_errno ();
1439 1513
1440int 1514int
1441poll_fileno () 1515poll_fileno ()
1442 PROTOTYPE: 1516 PROTOTYPE:
1443 CODE: 1517 CODE:
1444 RETVAL = respipe [0]; 1518 RETVAL = s_epipe_fd (&respipe);
1445 OUTPUT: 1519 OUTPUT:
1446 RETVAL 1520 RETVAL
1447 1521
1448int 1522int
1449poll_cb (...) 1523poll_cb (...)
1633 dREQ (REQ_ENV_DBRENAME, 2); 1707 dREQ (REQ_ENV_DBRENAME, 2);
1634 req->env = env; 1708 req->env = env;
1635 req->buf1 = strdup_ornull (file); 1709 req->buf1 = strdup_ornull (file);
1636 req->buf2 = strdup_ornull (database); 1710 req->buf2 = strdup_ornull (database);
1637 req->buf3 = strdup_ornull (newname); 1711 req->buf3 = strdup_ornull (newname);
1712 req->uint1 = flags;
1713 REQ_SEND;
1714}
1715
1716void
1717db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0)
1718 PREINIT:
1719 CALLBACK
1720 CODE:
1721{
1722 dREQ (REQ_ENV_LOG_ARCHIVE, 1);
1723 req->sv1 = SvREFCNT_inc (listp);
1724 req->env = env;
1638 req->uint1 = flags; 1725 req->uint1 = flags;
1639 REQ_SEND; 1726 REQ_SEND;
1640} 1727}
1641 1728
1642DB * 1729DB *
1682 req->uint1 = flags; 1769 req->uint1 = flags;
1683 req->sv1 = (SV *)db->app_private; 1770 req->sv1 = (SV *)db->app_private;
1684 REQ_SEND; 1771 REQ_SEND;
1685} 1772}
1686 1773
1687#if DB_VERSION_MINOR >= 4 1774#if DBVER >= 404
1688 1775
1689void 1776void
1690db_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) 1777db_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)
1691 PREINIT: 1778 PREINIT:
1692 CALLBACK 1779 CALLBACK
1693 CODE: 1780 CODE:
1694{ 1781{
1695 dREQ (REQ_DB_COMPACT, 2); 1782 dREQ (REQ_DB_COMPACT, 2);
1696 req->db = db; 1783 req->db = db;
1697 req->txn = txn; 1784 req->txn = txn;
1698 sv_to_dbt (&req->dbt1, start); 1785 if (start) sv_to_dbt (&req->dbt1, start);
1699 sv_to_dbt (&req->dbt2, stop); 1786 if (stop ) sv_to_dbt (&req->dbt2, stop );
1700 req->uint1 = flags; 1787 req->uint1 = flags;
1701 REQ_SEND; 1788 REQ_SEND;
1702} 1789}
1703 1790
1704#endif 1791#endif
1714 req->uint1 = flags; 1801 req->uint1 = flags;
1715 REQ_SEND; 1802 REQ_SEND;
1716} 1803}
1717 1804
1718void 1805void
1806db_verify (DB *db, bdb_filename file, bdb_filename database = 0, SV *dummy = 0, U32 flags = 0, SV *callback = 0)
1807 PREINIT:
1808 CALLBACK
1809 CODE:
1810{
1811 dREQ (REQ_DB_VERIFY, 1);
1812 ptr_nuke (ST (0)); /* verify destroys the database handle, hopefully it is freed as well */
1813 req->db = db;
1814 req->buf1 = strdup (file);
1815 req->buf2 = strdup_ornull (database);
1816 req->uint1 = flags;
1817 REQ_SEND;
1818}
1819
1820void
1719db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) 1821db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0)
1720 PREINIT: 1822 PREINIT:
1721 CALLBACK 1823 CALLBACK
1722 CODE: 1824 CODE:
1723{ 1825{
1724 dREQ (REQ_DB_SYNC, 1); 1826 dREQ (REQ_DB_UPGRADE, 1);
1725 req->db = db; 1827 req->db = db;
1726 req->buf1 = strdup (file); 1828 req->buf1 = strdup (file);
1727 req->uint1 = flags; 1829 req->uint1 = flags;
1728 REQ_SEND; 1830 REQ_SEND;
1729} 1831}
1756 sv_to_dbt (&req->dbt2, data); 1858 sv_to_dbt (&req->dbt2, data);
1757 req->uint1 = flags; 1859 req->uint1 = flags;
1758 REQ_SEND; 1860 REQ_SEND;
1759} 1861}
1760 1862
1761#if DB_VERSION_MINOR >= 6 1863#if DBVER >= 406
1762 1864
1763void 1865void
1764db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) 1866db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0)
1765 PREINIT: 1867 PREINIT:
1766 CALLBACK 1868 CALLBACK
1909db_c_get (DBC *dbc, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0) 2011db_c_get (DBC *dbc, SV *key, SV_mutable *data, U32 flags = 0, SV *callback = 0)
1910 PREINIT: 2012 PREINIT:
1911 CALLBACK 2013 CALLBACK
1912 CODE: 2014 CODE:
1913{ 2015{
1914 if (flags & DB_OPFLAGS_MASK != DB_SET && SvREADONLY (key)) 2016 if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key))
1915 croak ("db_c_get was passed a read-only/constant 'key' argument but operation is not DB_SET"); 2017 croak ("db_c_get was passed a read-only/constant 'key' argument but operation is not DB_SET");
2018 if (SvPOKp (key) && !sv_utf8_downgrade (key, 1))
2019 croak ("argument \"%s\" must be byte/octet-encoded in %s",
2020 "key",
2021 "BDB::db_c_get");
1916 2022
1917 { 2023 {
1918 dREQ (REQ_C_GET, 1); 2024 dREQ (REQ_C_GET, 1);
1919 req->dbc = dbc; 2025 req->dbc = dbc;
1920 req->uint1 = flags; 2026 req->uint1 = flags;
1921 if (flags & DB_OPFLAGS_MASK == DB_SET) 2027 if ((flags & DB_OPFLAGS_MASK) == DB_SET)
1922 sv_to_dbt (&req->dbt1, key); 2028 sv_to_dbt (&req->dbt1, key);
1923 else 2029 else
1924 { 2030 {
1925 if (flags & DB_OPFLAGS_MASK == DB_SET_RANGE) 2031 if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE)
1926 sv_to_dbt (&req->dbt1, key); 2032 sv_to_dbt (&req->dbt1, key);
1927 else 2033 else
1928 req->dbt1.flags = DB_DBT_MALLOC; 2034 req->dbt1.flags = DB_DBT_MALLOC;
1929 2035
1930 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key); 2036 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key);
1931 } 2037 }
1932 2038
1933 if (flags & DB_OPFLAGS_MASK == DB_GET_BOTH 2039 if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH
1934 || flags & DB_OPFLAGS_MASK == DB_GET_BOTH_RANGE) 2040 || (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE)
1935 sv_to_dbt (&req->dbt3, data); 2041 sv_to_dbt (&req->dbt3, data);
1936 else 2042 else
1937 req->dbt3.flags = DB_DBT_MALLOC; 2043 req->dbt3.flags = DB_DBT_MALLOC;
1938 2044
1939 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); 2045 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1945db_c_pget (DBC *dbc, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0) 2051db_c_pget (DBC *dbc, SV *key, SV_mutable *pkey, SV_mutable *data, U32 flags = 0, SV *callback = 0)
1946 PREINIT: 2052 PREINIT:
1947 CALLBACK 2053 CALLBACK
1948 CODE: 2054 CODE:
1949{ 2055{
1950 if (flags & DB_OPFLAGS_MASK != DB_SET && SvREADONLY (key)) 2056 if ((flags & DB_OPFLAGS_MASK) != DB_SET && SvREADONLY (key))
1951 croak ("db_c_pget was passed a read-only/constant 'key' argument but operation is not DB_SET"); 2057 croak ("db_c_pget was passed a read-only/constant 'key' argument but operation is not DB_SET");
2058 if (SvPOKp (key) && !sv_utf8_downgrade (key, 1))
2059 croak ("argument \"%s\" must be byte/octet-encoded in %s",
2060 "key",
2061 "BDB::db_c_pget");
1952 2062
1953 { 2063 {
1954 dREQ (REQ_C_PGET, 1); 2064 dREQ (REQ_C_PGET, 1);
1955 req->dbc = dbc; 2065 req->dbc = dbc;
1956 req->uint1 = flags; 2066 req->uint1 = flags;
1957 if (flags & DB_OPFLAGS_MASK == DB_SET) 2067 if ((flags & DB_OPFLAGS_MASK) == DB_SET)
1958 sv_to_dbt (&req->dbt1, key); 2068 sv_to_dbt (&req->dbt1, key);
1959 else 2069 else
1960 { 2070 {
1961 if (flags & DB_OPFLAGS_MASK == DB_SET_RANGE) 2071 if ((flags & DB_OPFLAGS_MASK) == DB_SET_RANGE)
1962 sv_to_dbt (&req->dbt1, key); 2072 sv_to_dbt (&req->dbt1, key);
1963 else 2073 else
1964 req->dbt1.flags = DB_DBT_MALLOC; 2074 req->dbt1.flags = DB_DBT_MALLOC;
1965 2075
1966 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key); 2076 req->sv1 = SvREFCNT_inc (key); SvREADONLY_on (key);
1967 } 2077 }
1968 2078
1969 req->dbt2.flags = DB_DBT_MALLOC; 2079 req->dbt2.flags = DB_DBT_MALLOC;
1970 req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey); 2080 req->sv2 = SvREFCNT_inc (pkey); SvREADONLY_on (pkey);
1971 2081
1972 if (flags & DB_OPFLAGS_MASK == DB_GET_BOTH 2082 if ((flags & DB_OPFLAGS_MASK) == DB_GET_BOTH
1973 || flags & DB_OPFLAGS_MASK == DB_GET_BOTH_RANGE) 2083 || (flags & DB_OPFLAGS_MASK) == DB_GET_BOTH_RANGE)
1974 sv_to_dbt (&req->dbt3, data); 2084 sv_to_dbt (&req->dbt3, data);
1975 else 2085 else
1976 req->dbt3.flags = DB_DBT_MALLOC; 2086 req->dbt3.flags = DB_DBT_MALLOC;
1977 2087
1978 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); 2088 req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data);
1991 req->uint1 = flags; 2101 req->uint1 = flags;
1992 REQ_SEND; 2102 REQ_SEND;
1993} 2103}
1994 2104
1995 2105
1996#if DB_VERSION_MINOR >= 3 2106#if DBVER >= 403
1997 2107
1998void 2108void
1999db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) 2109db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0)
2000 PREINIT: 2110 PREINIT:
2001 CALLBACK 2111 CALLBACK
2095 CODE: 2205 CODE:
2096 RETVAL = env->set_flags (env, flags, onoff); 2206 RETVAL = env->set_flags (env, flags, onoff);
2097 OUTPUT: 2207 OUTPUT:
2098 RETVAL 2208 RETVAL
2099 2209
2100#if DB_VERSION_MINOR >= 7 2210#if DBVER >= 407
2101 2211
2102int set_intermediate_dir_mode (DB_ENV *env, const char *mode) 2212int set_intermediate_dir_mode (DB_ENV *env, const char *mode)
2103 CODE: 2213 CODE:
2104 RETVAL = env->set_intermediate_dir_mode (env, mode); 2214 RETVAL = env->set_intermediate_dir_mode (env, mode);
2105 OUTPUT: 2215 OUTPUT:
2192 CODE: 2302 CODE:
2193 RETVAL = env->set_lg_max (env, max); 2303 RETVAL = env->set_lg_max (env, max);
2194 OUTPUT: 2304 OUTPUT:
2195 RETVAL 2305 RETVAL
2196 2306
2197#if DB_VERSION_MINOR >= 4 2307#if DBVER >= 404
2198 2308
2199int mutex_set_max (DB_ENV *env, U32 max) 2309int mutex_set_max (DB_ENV *env, U32 max)
2200 CODE: 2310 CODE:
2201 RETVAL = env->mutex_set_max (env, max); 2311 RETVAL = env->mutex_set_max (env, max);
2202 OUTPUT: 2312 OUTPUT:
2229 if (errno) 2339 if (errno)
2230 croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); 2340 croak ("DB_ENV->txn_begin: %s", db_strerror (errno));
2231 OUTPUT: 2341 OUTPUT:
2232 RETVAL 2342 RETVAL
2233 2343
2234#if DB_VERSION_MINOR >= 5 2344#if DBVER >= 405
2235 2345
2236DB_TXN * 2346DB_TXN *
2237cdsgroup_begin (DB_ENV *env) 2347cdsgroup_begin (DB_ENV *env)
2238 CODE: 2348 CODE:
2239 errno = env->cdsgroup_begin (env, &RETVAL); 2349 errno = env->cdsgroup_begin (env, &RETVAL);
2260 CODE: 2370 CODE:
2261 RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); 2371 RETVAL = db->set_cachesize (db, gbytes, bytes, ncache);
2262 OUTPUT: 2372 OUTPUT:
2263 RETVAL 2373 RETVAL
2264 2374
2375int set_pagesize (DB *db, U32 pagesize)
2376 CODE:
2377 RETVAL = db->set_pagesize (db, pagesize);
2378 OUTPUT:
2379 RETVAL
2380
2265int set_flags (DB *db, U32 flags) 2381int set_flags (DB *db, U32 flags)
2266 CODE: 2382 CODE:
2267 RETVAL = db->set_flags (db, flags); 2383 RETVAL = db->set_flags (db, flags);
2268 OUTPUT: 2384 OUTPUT:
2269 RETVAL 2385 RETVAL
2335 if (errno) 2451 if (errno)
2336 croak ("DB->cursor: %s", db_strerror (errno)); 2452 croak ("DB->cursor: %s", db_strerror (errno));
2337 OUTPUT: 2453 OUTPUT:
2338 RETVAL 2454 RETVAL
2339 2455
2340#if DB_VERSION_MINOR >= 3 2456#if DBVER >= 403
2341 2457
2342DB_SEQUENCE * 2458DB_SEQUENCE *
2343sequence (DB *db, U32 flags = 0) 2459sequence (DB *db, U32 flags = 0)
2344 CODE: 2460 CODE:
2345{ 2461{
2380DESTROY (DBC_ornuked *dbc) 2496DESTROY (DBC_ornuked *dbc)
2381 CODE: 2497 CODE:
2382 if (dbc) 2498 if (dbc)
2383 dbc->c_close (dbc); 2499 dbc->c_close (dbc);
2384 2500
2385#if DB_VERSION_MINOR >= 6 2501#if DBVER >= 406
2386 2502
2387int set_priority (DBC *dbc, int priority) 2503int set_priority (DBC *dbc, int priority)
2388 CODE: 2504 CODE:
2389 dbc->set_priority (dbc, priority); 2505 dbc->set_priority (dbc, priority);
2390 2506
2391#endif 2507#endif
2392 2508
2393#if DB_VERSION_MINOR >= 3 2509#if DBVER >= 403
2394 2510
2395MODULE = BDB PACKAGE = BDB::Sequence 2511MODULE = BDB PACKAGE = BDB::Sequence
2396 2512
2397void 2513void
2398DESTROY (DB_SEQUENCE_ornuked *seq) 2514DESTROY (DB_SEQUENCE_ornuked *seq)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines