… | |
… | |
47 | typedef DBC DBC_ornuked; |
47 | typedef DBC DBC_ornuked; |
48 | typedef DB DB_ornuked; |
48 | typedef DB DB_ornuked; |
49 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
49 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
50 | |
50 | |
51 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
51 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
52 | typedef char *octetstring; |
52 | typedef char *bdb_filename; |
53 | |
53 | |
54 | static SV *prepare_cb; |
54 | static SV *prepare_cb; |
55 | |
55 | |
56 | #if DB_VERSION_MINOR >= 6 |
56 | #if DB_VERSION_MINOR >= 6 |
57 | # define c_close close |
57 | # define c_close close |
… | |
… | |
61 | # define c_get get |
61 | # define c_get get |
62 | # define c_pget pget |
62 | # define c_pget pget |
63 | # define c_put put |
63 | # define c_put put |
64 | #endif |
64 | #endif |
65 | |
65 | |
|
|
66 | static char * |
|
|
67 | get_bdb_filename (SV *sv) |
|
|
68 | { |
|
|
69 | if (!SvOK (sv)) |
|
|
70 | return 0; |
|
|
71 | |
|
|
72 | #if _WIN32 |
|
|
73 | /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */ |
|
|
74 | { |
|
|
75 | STRLEN len; |
|
|
76 | char *src = SvPVbyte (sv, len); |
|
|
77 | SV *t1 = sv_newmortal (); |
|
|
78 | SV *t2 = sv_newmortal (); |
|
|
79 | |
|
|
80 | sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1); |
|
|
81 | sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1); |
|
|
82 | |
|
|
83 | len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR)); |
|
|
84 | len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0); |
|
|
85 | SvPOK_only (t2); |
|
|
86 | SvPVX (t2)[len] = 0; |
|
|
87 | SvCUR_set (t2, len); |
|
|
88 | |
|
|
89 | return SvPVX (t2); |
|
|
90 | } |
|
|
91 | #else |
|
|
92 | return SvPVbyte_nolen (sv); |
|
|
93 | #endif |
|
|
94 | } |
|
|
95 | |
66 | static void |
96 | static void |
67 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
97 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
68 | { |
98 | { |
69 | printf ("err[%s]\n", msg); |
99 | printf ("err[%s]\n", msg); |
70 | } |
100 | } |
… | |
… | |
107 | } |
137 | } |
108 | |
138 | |
109 | enum { |
139 | enum { |
110 | REQ_QUIT, |
140 | REQ_QUIT, |
111 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
141 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
112 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, |
142 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
113 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, |
143 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, |
114 | REQ_DB_PUT, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
144 | REQ_DB_PUT, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
115 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
145 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
116 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
146 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
117 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
147 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
… | |
… | |
129 | DBC *dbc; |
159 | DBC *dbc; |
130 | |
160 | |
131 | UV uv1; |
161 | UV uv1; |
132 | int int1, int2; |
162 | int int1, int2; |
133 | U32 uint1, uint2; |
163 | U32 uint1, uint2; |
134 | char *buf1, *buf2; |
164 | char *buf1, *buf2, *buf3; |
135 | SV *sv1, *sv2, *sv3; |
165 | SV *sv1, *sv2, *sv3; |
136 | |
166 | |
137 | DBT dbt1, dbt2, dbt3; |
167 | DBT dbt1, dbt2, dbt3; |
138 | DB_KEY_RANGE key_range; |
168 | DB_KEY_RANGE key_range; |
139 | DB_SEQUENCE *seq; |
169 | DB_SEQUENCE *seq; |
… | |
… | |
151 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
181 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
152 | }; |
182 | }; |
153 | |
183 | |
154 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
184 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
155 | |
185 | |
|
|
186 | static SV *on_next_submit; |
|
|
187 | |
156 | static unsigned int max_poll_time = 0; |
188 | static unsigned int max_poll_time = 0; |
157 | static unsigned int max_poll_reqs = 0; |
189 | static unsigned int max_poll_reqs = 0; |
158 | |
190 | |
159 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
191 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
160 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
192 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
… | |
… | |
205 | static mutex_t reqlock = X_MUTEX_INIT; |
237 | static mutex_t reqlock = X_MUTEX_INIT; |
206 | static cond_t reqwait = X_COND_INIT; |
238 | static cond_t reqwait = X_COND_INIT; |
207 | |
239 | |
208 | #if WORDACCESS_UNSAFE |
240 | #if WORDACCESS_UNSAFE |
209 | |
241 | |
210 | static unsigned int get_nready () |
242 | static unsigned int get_nready (void) |
211 | { |
243 | { |
212 | unsigned int retval; |
244 | unsigned int retval; |
213 | |
245 | |
214 | X_LOCK (reqlock); |
246 | X_LOCK (reqlock); |
215 | retval = nready; |
247 | retval = nready; |
216 | X_UNLOCK (reqlock); |
248 | X_UNLOCK (reqlock); |
217 | |
249 | |
218 | return retval; |
250 | return retval; |
219 | } |
251 | } |
220 | |
252 | |
221 | static unsigned int get_npending () |
253 | static unsigned int get_npending (void) |
222 | { |
254 | { |
223 | unsigned int retval; |
255 | unsigned int retval; |
224 | |
256 | |
225 | X_LOCK (reslock); |
257 | X_LOCK (reslock); |
226 | retval = npending; |
258 | retval = npending; |
227 | X_UNLOCK (reslock); |
259 | X_UNLOCK (reslock); |
228 | |
260 | |
229 | return retval; |
261 | return retval; |
230 | } |
262 | } |
231 | |
263 | |
232 | static unsigned int get_nthreads () |
264 | static unsigned int get_nthreads (void) |
233 | { |
265 | { |
234 | unsigned int retval; |
266 | unsigned int retval; |
235 | |
267 | |
236 | X_LOCK (wrklock); |
268 | X_LOCK (wrklock); |
237 | retval = started; |
269 | retval = started; |
… | |
… | |
300 | } |
332 | } |
301 | |
333 | |
302 | abort (); |
334 | abort (); |
303 | } |
335 | } |
304 | |
336 | |
305 | static int poll_cb (); |
337 | static int poll_cb (void); |
306 | static void req_free (bdb_req req); |
338 | static void req_free (bdb_req req); |
307 | static void req_cancel (bdb_req req); |
339 | static void req_cancel (bdb_req req); |
308 | |
340 | |
309 | static int req_invoke (bdb_req req) |
341 | static int req_invoke (bdb_req req) |
310 | { |
342 | { |
311 | dSP; |
343 | dSP; |
312 | |
344 | |
313 | if (SvOK (req->callback)) |
345 | if (req->callback) |
314 | { |
346 | { |
315 | ENTER; |
347 | ENTER; |
316 | SAVETMPS; |
348 | SAVETMPS; |
317 | PUSHMARK (SP); |
349 | PUSHMARK (SP); |
318 | |
350 | |
… | |
… | |
379 | return !SvTRUE (ERRSV); |
411 | return !SvTRUE (ERRSV); |
380 | } |
412 | } |
381 | |
413 | |
382 | static void req_free (bdb_req req) |
414 | static void req_free (bdb_req req) |
383 | { |
415 | { |
|
|
416 | SvREFCNT_dec (req->callback); |
|
|
417 | |
384 | free (req->buf1); |
418 | free (req->buf1); |
385 | free (req->buf2); |
419 | free (req->buf2); |
|
|
420 | free (req->buf3); |
|
|
421 | |
386 | Safefree (req); |
422 | Safefree (req); |
387 | } |
423 | } |
388 | |
424 | |
389 | #ifdef USE_SOCKETS_AS_HANDLES |
425 | #ifdef USE_SOCKETS_AS_HANDLES |
390 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
426 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
391 | #else |
427 | #else |
392 | # define TO_SOCKET(x) (x) |
428 | # define TO_SOCKET(x) (x) |
393 | #endif |
429 | #endif |
394 | |
430 | |
395 | static void |
431 | static void |
396 | create_respipe () |
432 | create_respipe (void) |
397 | { |
433 | { |
398 | #ifdef _WIN32 |
434 | #ifdef _WIN32 |
399 | int arg; /* argg */ |
435 | int arg; /* argg */ |
400 | #endif |
436 | #endif |
401 | int old_readfd = respipe [0]; |
437 | int old_readfd = respipe [0]; |
… | |
… | |
455 | free (wrk); |
491 | free (wrk); |
456 | |
492 | |
457 | X_UNLOCK (wrklock); |
493 | X_UNLOCK (wrklock); |
458 | } |
494 | } |
459 | |
495 | |
460 | static void maybe_start_thread () |
496 | static void maybe_start_thread (void) |
461 | { |
497 | { |
462 | if (get_nthreads () >= wanted) |
498 | if (get_nthreads () >= wanted) |
463 | return; |
499 | return; |
464 | |
500 | |
465 | /* todo: maybe use idle here, but might be less exact */ |
501 | /* todo: maybe use idle here, but might be less exact */ |
… | |
… | |
471 | |
507 | |
472 | static void req_send (bdb_req req) |
508 | static void req_send (bdb_req req) |
473 | { |
509 | { |
474 | SV *wait_callback = 0; |
510 | SV *wait_callback = 0; |
475 | |
511 | |
|
|
512 | if (on_next_submit) |
|
|
513 | { |
|
|
514 | dSP; |
|
|
515 | SV *cb = sv_2mortal (on_next_submit); |
|
|
516 | |
|
|
517 | on_next_submit = 0; |
|
|
518 | |
|
|
519 | PUSHMARK (SP); |
|
|
520 | PUTBACK; |
|
|
521 | call_sv (cb, G_DISCARD | G_EVAL); |
|
|
522 | } |
|
|
523 | |
476 | // synthesize callback if none given |
524 | // synthesize callback if none given |
477 | if (!SvOK (req->callback)) |
525 | if (!req->callback) |
478 | { |
526 | { |
479 | int count; |
527 | int count; |
480 | |
528 | |
481 | dSP; |
529 | dSP; |
482 | PUSHMARK (SP); |
530 | PUSHMARK (SP); |
… | |
… | |
550 | |
598 | |
551 | while (started > wanted) |
599 | while (started > wanted) |
552 | end_thread (); |
600 | end_thread (); |
553 | } |
601 | } |
554 | |
602 | |
555 | static void poll_wait () |
603 | static void poll_wait (void) |
556 | { |
604 | { |
557 | fd_set rfd; |
605 | fd_set rfd; |
558 | |
606 | |
559 | while (nreqs) |
607 | while (nreqs) |
560 | { |
608 | { |
… | |
… | |
573 | |
621 | |
574 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
622 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
575 | } |
623 | } |
576 | } |
624 | } |
577 | |
625 | |
578 | static int poll_cb () |
626 | static int poll_cb (void) |
579 | { |
627 | { |
580 | dSP; |
628 | dSP; |
581 | int count = 0; |
629 | int count = 0; |
582 | int maxreqs = max_poll_reqs; |
630 | int maxreqs = max_poll_reqs; |
583 | int do_croak = 0; |
631 | int do_croak = 0; |
… | |
… | |
728 | |
776 | |
729 | case REQ_ENV_MEMP_TRICKLE: |
777 | case REQ_ENV_MEMP_TRICKLE: |
730 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
778 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
731 | break; |
779 | break; |
732 | |
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 | |
733 | case REQ_DB_OPEN: |
789 | case REQ_DB_OPEN: |
734 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
790 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
735 | break; |
791 | break; |
736 | |
792 | |
737 | case REQ_DB_CLOSE: |
793 | case REQ_DB_CLOSE: |
… | |
… | |
914 | #define dREQ(reqtype) \ |
970 | #define dREQ(reqtype) \ |
915 | bdb_req req; \ |
971 | bdb_req req; \ |
916 | int req_pri = next_pri; \ |
972 | int req_pri = next_pri; \ |
917 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
973 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
918 | \ |
974 | \ |
919 | if (SvOK (callback) && !SvROK (callback)) \ |
975 | if (callback && SvOK (callback)) \ |
920 | croak ("callback must be undef or of reference type"); \ |
976 | croak ("callback has illegal type or extra arguments"); \ |
921 | \ |
977 | \ |
922 | Newz (0, req, 1, bdb_cb); \ |
978 | Newz (0, req, 1, bdb_cb); \ |
923 | if (!req) \ |
979 | if (!req) \ |
924 | croak ("out of memory during bdb_req allocation"); \ |
980 | croak ("out of memory during bdb_req allocation"); \ |
925 | \ |
981 | \ |
926 | req->callback = newSVsv (callback); \ |
982 | req->callback = cb ? SvREFCNT_inc (cb) : 0; \ |
927 | req->type = (reqtype); \ |
983 | req->type = (reqtype); \ |
928 | req->pri = req_pri |
984 | req->pri = req_pri |
929 | |
985 | |
930 | #define REQ_SEND \ |
986 | #define REQ_SEND \ |
931 | req_send (req) |
987 | req_send (req) |
… | |
… | |
944 | (var) = INT2PTR (type, tmp); \ |
1000 | (var) = INT2PTR (type, tmp); \ |
945 | if (!var && nullok != 2) \ |
1001 | if (!var && nullok != 2) \ |
946 | croak (# var " is not a valid " # class " object anymore"); \ |
1002 | croak (# var " is not a valid " # class " object anymore"); \ |
947 | } \ |
1003 | } \ |
948 | else \ |
1004 | else \ |
949 | croak (# var " is not of type " # class); \ |
1005 | croak (# var " is not of type " # class); |
950 | \ |
|
|
951 | |
1006 | |
952 | static void |
1007 | static void |
953 | ptr_nuke (SV *sv) |
1008 | ptr_nuke (SV *sv) |
954 | { |
1009 | { |
955 | assert (SvROK (sv)); |
1010 | assert (SvROK (sv)); |
… | |
… | |
960 | errno_get (pTHX_ SV *sv, MAGIC *mg) |
1015 | errno_get (pTHX_ SV *sv, MAGIC *mg) |
961 | { |
1016 | { |
962 | if (*mg->mg_ptr == '!') // should always be the case |
1017 | if (*mg->mg_ptr == '!') // should always be the case |
963 | if (-30999 <= errno && errno <= -30800) |
1018 | if (-30999 <= errno && errno <= -30800) |
964 | { |
1019 | { |
|
|
1020 | sv_setnv (sv, (NV)errno); |
965 | sv_setpv (sv, db_strerror (errno)); |
1021 | sv_setpv (sv, db_strerror (errno)); |
|
|
1022 | SvNOK_on (sv); /* what a wonderful hack! */ |
|
|
1023 | // ^^^ copied from perl sources |
966 | return 0; |
1024 | return 0; |
967 | } |
1025 | } |
968 | |
1026 | |
969 | return PL_vtbl_sv.svt_get (aTHX_ sv, mg); |
1027 | return PL_vtbl_sv.svt_get (aTHX_ sv, mg); |
970 | } |
1028 | } |
… | |
… | |
989 | |
1047 | |
990 | vtbl_errno = PL_vtbl_sv; |
1048 | vtbl_errno = PL_vtbl_sv; |
991 | vtbl_errno.svt_get = errno_get; |
1049 | vtbl_errno.svt_get = errno_get; |
992 | mg->mg_virtual = &vtbl_errno; |
1050 | mg->mg_virtual = &vtbl_errno; |
993 | } |
1051 | } |
|
|
1052 | |
|
|
1053 | #if __GNUC__ >= 4 |
|
|
1054 | # define noinline __attribute__ ((noinline)) |
|
|
1055 | #else |
|
|
1056 | # define noinline |
|
|
1057 | #endif |
|
|
1058 | |
|
|
1059 | static noinline SV * |
|
|
1060 | pop_callback (I32 *ritems, SV *sv) |
|
|
1061 | { |
|
|
1062 | if (SvROK (sv)) |
|
|
1063 | { |
|
|
1064 | HV *st; |
|
|
1065 | GV *gvp; |
|
|
1066 | CV *cv; |
|
|
1067 | const char *name; |
|
|
1068 | |
|
|
1069 | /* forgive me */ |
|
|
1070 | if (SvTYPE (SvRV (sv)) == SVt_PVMG |
|
|
1071 | && (st = SvSTASH (SvRV (sv))) |
|
|
1072 | && (name = HvNAME_get (st)) |
|
|
1073 | && (name [0] == 'B' && name [1] == 'D' && name [2] == 'B' && name [3] == ':')) |
|
|
1074 | return 0; |
|
|
1075 | |
|
|
1076 | if ((cv = sv_2cv (sv, &st, &gvp, 0))) |
|
|
1077 | { |
|
|
1078 | --*ritems; |
|
|
1079 | return (SV *)cv; |
|
|
1080 | } |
|
|
1081 | } |
|
|
1082 | |
|
|
1083 | return 0; |
|
|
1084 | } |
|
|
1085 | |
|
|
1086 | #define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); |
994 | |
1087 | |
995 | MODULE = BDB PACKAGE = BDB |
1088 | MODULE = BDB PACKAGE = BDB |
996 | |
1089 | |
997 | PROTOTYPES: ENABLE |
1090 | PROTOTYPES: ENABLE |
998 | |
1091 | |
… | |
… | |
1024 | const_iv (REGISTER) |
1117 | const_iv (REGISTER) |
1025 | const_iv (SYSTEM_MEM) |
1118 | const_iv (SYSTEM_MEM) |
1026 | const_iv (AUTO_COMMIT) |
1119 | const_iv (AUTO_COMMIT) |
1027 | const_iv (CDB_ALLDB) |
1120 | const_iv (CDB_ALLDB) |
1028 | const_iv (DIRECT_DB) |
1121 | const_iv (DIRECT_DB) |
1029 | const_iv (DIRECT_LOG) |
|
|
1030 | const_iv (DSYNC_DB) |
1122 | const_iv (DSYNC_DB) |
1031 | const_iv (DSYNC_LOG) |
|
|
1032 | const_iv (LOG_AUTOREMOVE) |
|
|
1033 | const_iv (LOG_INMEMORY) |
|
|
1034 | const_iv (NOLOCKING) |
1123 | const_iv (NOLOCKING) |
1035 | const_iv (NOMMAP) |
1124 | const_iv (NOMMAP) |
1036 | const_iv (NOPANIC) |
1125 | const_iv (NOPANIC) |
1037 | const_iv (OVERWRITE) |
1126 | const_iv (OVERWRITE) |
1038 | const_iv (PANIC_ENVIRONMENT) |
1127 | const_iv (PANIC_ENVIRONMENT) |
… | |
… | |
1177 | const_iv (PRIORITY_LOW) |
1266 | const_iv (PRIORITY_LOW) |
1178 | const_iv (PRIORITY_DEFAULT) |
1267 | const_iv (PRIORITY_DEFAULT) |
1179 | const_iv (PRIORITY_HIGH) |
1268 | const_iv (PRIORITY_HIGH) |
1180 | const_iv (PRIORITY_VERY_HIGH) |
1269 | const_iv (PRIORITY_VERY_HIGH) |
1181 | #endif |
1270 | #endif |
|
|
1271 | #if DB_VERSION_MINOR >= 7 |
|
|
1272 | const_iv (LOG_DIRECT) |
|
|
1273 | const_iv (LOG_DSYNC) |
|
|
1274 | const_iv (LOG_AUTO_REMOVE) |
|
|
1275 | const_iv (LOG_IN_MEMORY) |
|
|
1276 | const_iv (LOG_ZERO) |
|
|
1277 | #else |
|
|
1278 | const_iv (DIRECT_LOG) |
|
|
1279 | const_iv (DSYNC_LOG) |
|
|
1280 | const_iv (LOG_AUTOREMOVE) |
|
|
1281 | const_iv (LOG_INMEMORY) |
|
|
1282 | #endif |
1182 | }; |
1283 | }; |
1183 | |
1284 | |
1184 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1285 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1185 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1286 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1186 | |
1287 | |
1187 | newCONSTSUB (stash, "VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1)); |
1288 | { |
|
|
1289 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
|
|
1290 | char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; |
|
|
1291 | |
|
|
1292 | newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); |
|
|
1293 | } |
|
|
1294 | |
1188 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1295 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1189 | |
1296 | |
1190 | create_respipe (); |
1297 | create_respipe (); |
1191 | |
1298 | |
1192 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1299 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1193 | #ifdef _WIN32 |
|
|
1194 | X_MUTEX_CHECK (wrklock); |
|
|
1195 | X_MUTEX_CHECK (reslock); |
|
|
1196 | X_MUTEX_CHECK (reqlock); |
|
|
1197 | |
|
|
1198 | X_COND_CHECK (reqwait); |
|
|
1199 | #endif |
|
|
1200 | patch_errno (); |
1300 | patch_errno (); |
1201 | } |
1301 | } |
1202 | |
1302 | |
1203 | void |
1303 | void |
1204 | max_poll_reqs (int nreqs) |
1304 | max_poll_reqs (int nreqs) |
… | |
… | |
1345 | CODE: |
1445 | CODE: |
1346 | RETVAL = db_strerror (errorno); |
1446 | RETVAL = db_strerror (errorno); |
1347 | OUTPUT: |
1447 | OUTPUT: |
1348 | RETVAL |
1448 | RETVAL |
1349 | |
1449 | |
|
|
1450 | void _on_next_submit (SV *cb) |
|
|
1451 | CODE: |
|
|
1452 | SvREFCNT_dec (on_next_submit); |
|
|
1453 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
|
|
1454 | |
1350 | DB_ENV * |
1455 | DB_ENV * |
1351 | db_env_create (U32 env_flags = 0) |
1456 | db_env_create (U32 env_flags = 0) |
1352 | CODE: |
1457 | CODE: |
1353 | { |
1458 | { |
1354 | errno = db_env_create (&RETVAL, env_flags); |
1459 | errno = db_env_create (&RETVAL, env_flags); |
… | |
… | |
1363 | } |
1468 | } |
1364 | OUTPUT: |
1469 | OUTPUT: |
1365 | RETVAL |
1470 | RETVAL |
1366 | |
1471 | |
1367 | void |
1472 | void |
1368 | db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) |
1473 | db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) |
|
|
1474 | PREINIT: |
|
|
1475 | CALLBACK |
1369 | CODE: |
1476 | CODE: |
1370 | { |
1477 | { |
1371 | dREQ (REQ_ENV_OPEN); |
1478 | dREQ (REQ_ENV_OPEN); |
1372 | |
|
|
1373 | req->env = env; |
1479 | req->env = env; |
1374 | req->uint1 = open_flags | DB_THREAD; |
1480 | req->uint1 = open_flags | DB_THREAD; |
1375 | req->int1 = mode; |
1481 | req->int1 = mode; |
1376 | req->buf1 = strdup_ornull (db_home); |
1482 | req->buf1 = strdup_ornull (db_home); |
1377 | REQ_SEND; |
1483 | REQ_SEND; |
1378 | } |
1484 | } |
1379 | |
1485 | |
1380 | void |
1486 | void |
1381 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = &PL_sv_undef) |
1487 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) |
|
|
1488 | PREINIT: |
|
|
1489 | CALLBACK |
1382 | CODE: |
1490 | CODE: |
1383 | { |
1491 | { |
1384 | dREQ (REQ_ENV_CLOSE); |
1492 | dREQ (REQ_ENV_CLOSE); |
1385 | req->env = env; |
1493 | req->env = env; |
1386 | req->uint1 = flags; |
1494 | req->uint1 = flags; |
1387 | REQ_SEND; |
1495 | REQ_SEND; |
1388 | ptr_nuke (ST (0)); |
1496 | ptr_nuke (ST (0)); |
1389 | } |
1497 | } |
1390 | |
1498 | |
1391 | void |
1499 | void |
1392 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1500 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) |
|
|
1501 | PREINIT: |
|
|
1502 | CALLBACK |
1393 | CODE: |
1503 | CODE: |
1394 | { |
1504 | { |
1395 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1505 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1396 | req->env = env; |
1506 | req->env = env; |
1397 | req->uint1 = kbyte; |
1507 | req->uint1 = kbyte; |
… | |
… | |
1399 | req->uint2 = flags; |
1509 | req->uint2 = flags; |
1400 | REQ_SEND; |
1510 | REQ_SEND; |
1401 | } |
1511 | } |
1402 | |
1512 | |
1403 | void |
1513 | void |
1404 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1514 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) |
|
|
1515 | PREINIT: |
|
|
1516 | CALLBACK |
1405 | CODE: |
1517 | CODE: |
1406 | { |
1518 | { |
1407 | dREQ (REQ_ENV_LOCK_DETECT); |
1519 | dREQ (REQ_ENV_LOCK_DETECT); |
1408 | req->env = env; |
1520 | req->env = env; |
1409 | req->uint1 = flags; |
1521 | req->uint1 = flags; |
1410 | req->uint2 = atype; |
1522 | req->uint2 = atype; |
|
|
1523 | /* req->int2 = 0; dummy */ |
1411 | REQ_SEND; |
1524 | REQ_SEND; |
1412 | } |
1525 | } |
1413 | |
1526 | |
1414 | void |
1527 | void |
1415 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1528 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
|
|
1529 | PREINIT: |
|
|
1530 | CALLBACK |
1416 | CODE: |
1531 | CODE: |
1417 | { |
1532 | { |
1418 | dREQ (REQ_ENV_MEMP_SYNC); |
1533 | dREQ (REQ_ENV_MEMP_SYNC); |
1419 | req->env = env; |
1534 | req->env = env; |
1420 | REQ_SEND; |
1535 | REQ_SEND; |
1421 | } |
1536 | } |
1422 | |
1537 | |
1423 | void |
1538 | void |
1424 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1539 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
|
|
1540 | PREINIT: |
|
|
1541 | CALLBACK |
1425 | CODE: |
1542 | CODE: |
1426 | { |
1543 | { |
1427 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1544 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1428 | req->env = env; |
1545 | req->env = env; |
1429 | req->int1 = percent; |
1546 | req->int1 = percent; |
1430 | REQ_SEND; |
1547 | REQ_SEND; |
1431 | } |
1548 | } |
1432 | |
1549 | |
|
|
1550 | void |
|
|
1551 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
|
|
1552 | PREINIT: |
|
|
1553 | CALLBACK |
|
|
1554 | CODE: |
|
|
1555 | { |
|
|
1556 | dREQ (REQ_ENV_DBREMOVE); |
|
|
1557 | req->env = env; |
|
|
1558 | req->buf1 = strdup_ornull (file); |
|
|
1559 | req->buf2 = strdup_ornull (database); |
|
|
1560 | req->uint1 = flags; |
|
|
1561 | REQ_SEND; |
|
|
1562 | } |
|
|
1563 | |
|
|
1564 | void |
|
|
1565 | db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) |
|
|
1566 | PREINIT: |
|
|
1567 | CALLBACK |
|
|
1568 | CODE: |
|
|
1569 | { |
|
|
1570 | dREQ (REQ_ENV_DBRENAME); |
|
|
1571 | req->env = env; |
|
|
1572 | req->buf1 = strdup_ornull (file); |
|
|
1573 | req->buf2 = strdup_ornull (database); |
|
|
1574 | req->buf3 = strdup_ornull (newname); |
|
|
1575 | req->uint1 = flags; |
|
|
1576 | REQ_SEND; |
|
|
1577 | } |
1433 | |
1578 | |
1434 | DB * |
1579 | DB * |
1435 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1580 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1436 | CODE: |
1581 | CODE: |
1437 | { |
1582 | { |
… | |
… | |
1444 | } |
1589 | } |
1445 | OUTPUT: |
1590 | OUTPUT: |
1446 | RETVAL |
1591 | RETVAL |
1447 | |
1592 | |
1448 | void |
1593 | void |
1449 | db_open (DB *db, DB_TXN_ornull *txnid, octetstring file, octetstring database, int type, U32 flags, int mode, SV *callback = &PL_sv_undef) |
1594 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
|
|
1595 | PREINIT: |
|
|
1596 | CALLBACK |
1450 | CODE: |
1597 | CODE: |
1451 | { |
1598 | { |
1452 | dREQ (REQ_DB_OPEN); |
1599 | dREQ (REQ_DB_OPEN); |
1453 | req->db = db; |
1600 | req->db = db; |
1454 | req->txn = txnid; |
1601 | req->txn = txnid; |
… | |
… | |
1459 | req->int2 = mode; |
1606 | req->int2 = mode; |
1460 | REQ_SEND; |
1607 | REQ_SEND; |
1461 | } |
1608 | } |
1462 | |
1609 | |
1463 | void |
1610 | void |
1464 | db_close (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1611 | db_close (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1612 | PREINIT: |
|
|
1613 | CALLBACK |
1465 | CODE: |
1614 | CODE: |
1466 | { |
1615 | { |
1467 | dREQ (REQ_DB_CLOSE); |
1616 | dREQ (REQ_DB_CLOSE); |
1468 | req->db = db; |
1617 | req->db = db; |
1469 | req->uint1 = flags; |
1618 | req->uint1 = flags; |
… | |
… | |
1471 | REQ_SEND; |
1620 | REQ_SEND; |
1472 | ptr_nuke (ST (0)); |
1621 | ptr_nuke (ST (0)); |
1473 | } |
1622 | } |
1474 | |
1623 | |
1475 | void |
1624 | void |
1476 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = &PL_sv_undef) |
1625 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = 0) |
|
|
1626 | PREINIT: |
|
|
1627 | CALLBACK |
1477 | CODE: |
1628 | CODE: |
1478 | { |
1629 | { |
1479 | dREQ (REQ_DB_COMPACT); |
1630 | dREQ (REQ_DB_COMPACT); |
1480 | req->db = db; |
1631 | req->db = db; |
1481 | req->txn = txn; |
1632 | req->txn = txn; |
… | |
… | |
1484 | req->uint1 = flags; |
1635 | req->uint1 = flags; |
1485 | REQ_SEND; |
1636 | REQ_SEND; |
1486 | } |
1637 | } |
1487 | |
1638 | |
1488 | void |
1639 | void |
1489 | db_sync (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1640 | db_sync (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1641 | PREINIT: |
|
|
1642 | CALLBACK |
1490 | CODE: |
1643 | CODE: |
1491 | { |
1644 | { |
1492 | dREQ (REQ_DB_SYNC); |
1645 | dREQ (REQ_DB_SYNC); |
1493 | req->db = db; |
1646 | req->db = db; |
1494 | req->uint1 = flags; |
1647 | req->uint1 = flags; |
1495 | REQ_SEND; |
1648 | REQ_SEND; |
1496 | } |
1649 | } |
1497 | |
1650 | |
1498 | void |
1651 | void |
1499 | db_upgrade (DB *db, octetstring file, U32 flags = 0, SV *callback = &PL_sv_undef) |
1652 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
|
|
1653 | PREINIT: |
|
|
1654 | CALLBACK |
1500 | CODE: |
1655 | CODE: |
1501 | { |
1656 | { |
1502 | dREQ (REQ_DB_SYNC); |
1657 | dREQ (REQ_DB_SYNC); |
1503 | req->db = db; |
1658 | req->db = db; |
1504 | req->buf1 = strdup (file); |
1659 | req->buf1 = strdup (file); |
1505 | req->uint1 = flags; |
1660 | req->uint1 = flags; |
1506 | REQ_SEND; |
1661 | REQ_SEND; |
1507 | } |
1662 | } |
1508 | |
1663 | |
1509 | void |
1664 | void |
1510 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = &PL_sv_undef) |
1665 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = 0) |
|
|
1666 | PREINIT: |
|
|
1667 | CALLBACK |
1511 | CODE: |
1668 | CODE: |
1512 | { |
1669 | { |
1513 | dREQ (REQ_DB_KEY_RANGE); |
1670 | dREQ (REQ_DB_KEY_RANGE); |
1514 | req->db = db; |
1671 | req->db = db; |
1515 | req->txn = txn; |
1672 | req->txn = txn; |
… | |
… | |
1518 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1675 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1519 | REQ_SEND; |
1676 | REQ_SEND; |
1520 | } |
1677 | } |
1521 | |
1678 | |
1522 | void |
1679 | void |
1523 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1680 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1681 | PREINIT: |
|
|
1682 | CALLBACK |
1524 | CODE: |
1683 | CODE: |
1525 | { |
1684 | { |
1526 | dREQ (REQ_DB_PUT); |
1685 | dREQ (REQ_DB_PUT); |
1527 | req->db = db; |
1686 | req->db = db; |
1528 | req->txn = txn; |
1687 | req->txn = txn; |
… | |
… | |
1531 | req->uint1 = flags; |
1690 | req->uint1 = flags; |
1532 | REQ_SEND; |
1691 | REQ_SEND; |
1533 | } |
1692 | } |
1534 | |
1693 | |
1535 | void |
1694 | void |
1536 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1695 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1696 | PREINIT: |
|
|
1697 | CALLBACK |
1537 | CODE: |
1698 | CODE: |
1538 | if (SvREADONLY (data)) |
1699 | if (SvREADONLY (data)) |
1539 | croak ("can't modify read-only data scalar in db_get"); |
1700 | croak ("can't modify read-only data scalar in db_get"); |
1540 | { |
1701 | { |
1541 | dREQ (REQ_DB_GET); |
1702 | dREQ (REQ_DB_GET); |
… | |
… | |
1547 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1708 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1548 | REQ_SEND; |
1709 | REQ_SEND; |
1549 | } |
1710 | } |
1550 | |
1711 | |
1551 | void |
1712 | void |
1552 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1713 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1714 | PREINIT: |
|
|
1715 | CALLBACK |
1553 | CODE: |
1716 | CODE: |
1554 | if (SvREADONLY (data)) |
1717 | if (SvREADONLY (data)) |
1555 | croak ("can't modify read-only data scalar in db_pget"); |
1718 | croak ("can't modify read-only data scalar in db_pget"); |
1556 | { |
1719 | { |
1557 | dREQ (REQ_DB_PGET); |
1720 | dREQ (REQ_DB_PGET); |
… | |
… | |
1564 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1727 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1565 | REQ_SEND; |
1728 | REQ_SEND; |
1566 | } |
1729 | } |
1567 | |
1730 | |
1568 | void |
1731 | void |
1569 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1732 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1733 | PREINIT: |
|
|
1734 | CALLBACK |
1570 | CODE: |
1735 | CODE: |
1571 | { |
1736 | { |
1572 | dREQ (REQ_DB_DEL); |
1737 | dREQ (REQ_DB_DEL); |
1573 | req->db = db; |
1738 | req->db = db; |
1574 | req->txn = txn; |
1739 | req->txn = txn; |
… | |
… | |
1576 | sv_to_dbt (&req->dbt1, key); |
1741 | sv_to_dbt (&req->dbt1, key); |
1577 | REQ_SEND; |
1742 | REQ_SEND; |
1578 | } |
1743 | } |
1579 | |
1744 | |
1580 | void |
1745 | void |
1581 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1746 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1747 | PREINIT: |
|
|
1748 | CALLBACK |
1582 | CODE: |
1749 | CODE: |
1583 | { |
1750 | { |
1584 | dREQ (REQ_TXN_COMMIT); |
1751 | dREQ (REQ_TXN_COMMIT); |
1585 | req->txn = txn; |
1752 | req->txn = txn; |
1586 | req->uint1 = flags; |
1753 | req->uint1 = flags; |
1587 | REQ_SEND; |
1754 | REQ_SEND; |
1588 | ptr_nuke (ST (0)); |
1755 | ptr_nuke (ST (0)); |
1589 | } |
1756 | } |
1590 | |
1757 | |
1591 | void |
1758 | void |
1592 | db_txn_abort (DB_TXN *txn, SV *callback = &PL_sv_undef) |
1759 | db_txn_abort (DB_TXN *txn, SV *callback = 0) |
|
|
1760 | PREINIT: |
|
|
1761 | CALLBACK |
1593 | CODE: |
1762 | CODE: |
1594 | { |
1763 | { |
1595 | dREQ (REQ_TXN_ABORT); |
1764 | dREQ (REQ_TXN_ABORT); |
1596 | req->txn = txn; |
1765 | req->txn = txn; |
1597 | REQ_SEND; |
1766 | REQ_SEND; |
1598 | ptr_nuke (ST (0)); |
1767 | ptr_nuke (ST (0)); |
1599 | } |
1768 | } |
1600 | |
1769 | |
1601 | void |
1770 | void |
1602 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1771 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1772 | PREINIT: |
|
|
1773 | CALLBACK |
1603 | CODE: |
1774 | CODE: |
1604 | { |
1775 | { |
1605 | dREQ (REQ_TXN_FINISH); |
1776 | dREQ (REQ_TXN_FINISH); |
1606 | req->txn = txn; |
1777 | req->txn = txn; |
1607 | req->uint1 = flags; |
1778 | req->uint1 = flags; |
1608 | REQ_SEND; |
1779 | REQ_SEND; |
1609 | ptr_nuke (ST (0)); |
1780 | ptr_nuke (ST (0)); |
1610 | } |
1781 | } |
1611 | |
1782 | |
1612 | void |
1783 | void |
1613 | db_c_close (DBC *dbc, SV *callback = &PL_sv_undef) |
1784 | db_c_close (DBC *dbc, SV *callback = 0) |
|
|
1785 | PREINIT: |
|
|
1786 | CALLBACK |
1614 | CODE: |
1787 | CODE: |
1615 | { |
1788 | { |
1616 | dREQ (REQ_C_CLOSE); |
1789 | dREQ (REQ_C_CLOSE); |
1617 | req->dbc = dbc; |
1790 | req->dbc = dbc; |
1618 | REQ_SEND; |
1791 | REQ_SEND; |
1619 | ptr_nuke (ST (0)); |
1792 | ptr_nuke (ST (0)); |
1620 | } |
1793 | } |
1621 | |
1794 | |
1622 | void |
1795 | void |
1623 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = &PL_sv_undef) |
1796 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) |
|
|
1797 | PREINIT: |
|
|
1798 | CALLBACK |
1624 | CODE: |
1799 | CODE: |
1625 | { |
1800 | { |
1626 | dREQ (REQ_C_COUNT); |
1801 | dREQ (REQ_C_COUNT); |
1627 | req->dbc = dbc; |
1802 | req->dbc = dbc; |
1628 | req->sv1 = SvREFCNT_inc (count); |
1803 | req->sv1 = SvREFCNT_inc (count); |
1629 | REQ_SEND; |
1804 | REQ_SEND; |
1630 | } |
1805 | } |
1631 | |
1806 | |
1632 | void |
1807 | void |
1633 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1808 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1809 | PREINIT: |
|
|
1810 | CALLBACK |
1634 | CODE: |
1811 | CODE: |
1635 | { |
1812 | { |
1636 | dREQ (REQ_C_PUT); |
1813 | dREQ (REQ_C_PUT); |
1637 | req->dbc = dbc; |
1814 | req->dbc = dbc; |
1638 | sv_to_dbt (&req->dbt1, key); |
1815 | sv_to_dbt (&req->dbt1, key); |
… | |
… | |
1640 | req->uint1 = flags; |
1817 | req->uint1 = flags; |
1641 | REQ_SEND; |
1818 | REQ_SEND; |
1642 | } |
1819 | } |
1643 | |
1820 | |
1644 | void |
1821 | void |
1645 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1822 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1823 | PREINIT: |
|
|
1824 | CALLBACK |
1646 | CODE: |
1825 | CODE: |
1647 | { |
1826 | { |
1648 | dREQ (REQ_C_GET); |
1827 | dREQ (REQ_C_GET); |
1649 | req->dbc = dbc; |
1828 | req->dbc = dbc; |
1650 | req->uint1 = flags; |
1829 | req->uint1 = flags; |
… | |
… | |
1665 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1844 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1666 | REQ_SEND; |
1845 | REQ_SEND; |
1667 | } |
1846 | } |
1668 | |
1847 | |
1669 | void |
1848 | void |
1670 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1849 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1850 | PREINIT: |
|
|
1851 | CALLBACK |
1671 | CODE: |
1852 | CODE: |
1672 | { |
1853 | { |
1673 | dREQ (REQ_C_PGET); |
1854 | dREQ (REQ_C_PGET); |
1674 | req->dbc = dbc; |
1855 | req->dbc = dbc; |
1675 | req->uint1 = flags; |
1856 | req->uint1 = flags; |
… | |
… | |
1693 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1874 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1694 | REQ_SEND; |
1875 | REQ_SEND; |
1695 | } |
1876 | } |
1696 | |
1877 | |
1697 | void |
1878 | void |
1698 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = &PL_sv_undef) |
1879 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0) |
|
|
1880 | PREINIT: |
|
|
1881 | CALLBACK |
1699 | CODE: |
1882 | CODE: |
1700 | { |
1883 | { |
1701 | dREQ (REQ_C_DEL); |
1884 | dREQ (REQ_C_DEL); |
1702 | req->dbc = dbc; |
1885 | req->dbc = dbc; |
1703 | req->uint1 = flags; |
1886 | req->uint1 = flags; |
1704 | REQ_SEND; |
1887 | REQ_SEND; |
1705 | } |
1888 | } |
1706 | |
1889 | |
1707 | |
1890 | |
1708 | void |
1891 | void |
1709 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1892 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1893 | PREINIT: |
|
|
1894 | CALLBACK |
1710 | CODE: |
1895 | CODE: |
1711 | { |
1896 | { |
1712 | dREQ (REQ_SEQ_OPEN); |
1897 | dREQ (REQ_SEQ_OPEN); |
1713 | req->seq = seq; |
1898 | req->seq = seq; |
1714 | req->txn = txnid; |
1899 | req->txn = txnid; |
… | |
… | |
1716 | sv_to_dbt (&req->dbt1, key); |
1901 | sv_to_dbt (&req->dbt1, key); |
1717 | REQ_SEND; |
1902 | REQ_SEND; |
1718 | } |
1903 | } |
1719 | |
1904 | |
1720 | void |
1905 | void |
1721 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = &PL_sv_undef) |
1906 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) |
|
|
1907 | PREINIT: |
|
|
1908 | CALLBACK |
1722 | CODE: |
1909 | CODE: |
1723 | { |
1910 | { |
1724 | dREQ (REQ_SEQ_CLOSE); |
1911 | dREQ (REQ_SEQ_CLOSE); |
1725 | req->seq = seq; |
1912 | req->seq = seq; |
1726 | req->uint1 = flags; |
1913 | req->uint1 = flags; |
1727 | REQ_SEND; |
1914 | REQ_SEND; |
1728 | ptr_nuke (ST (0)); |
1915 | ptr_nuke (ST (0)); |
1729 | } |
1916 | } |
1730 | |
1917 | |
1731 | void |
1918 | void |
1732 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = &PL_sv_undef) |
1919 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) |
|
|
1920 | PREINIT: |
|
|
1921 | CALLBACK |
1733 | CODE: |
1922 | CODE: |
1734 | { |
1923 | { |
1735 | dREQ (REQ_SEQ_GET); |
1924 | dREQ (REQ_SEQ_GET); |
1736 | req->seq = seq; |
1925 | req->seq = seq; |
1737 | req->txn = txnid; |
1926 | req->txn = txnid; |
… | |
… | |
1740 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1929 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1741 | REQ_SEND; |
1930 | REQ_SEND; |
1742 | } |
1931 | } |
1743 | |
1932 | |
1744 | void |
1933 | void |
1745 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1934 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) |
|
|
1935 | PREINIT: |
|
|
1936 | CALLBACK |
1746 | CODE: |
1937 | CODE: |
1747 | { |
1938 | { |
1748 | dREQ (REQ_SEQ_REMOVE); |
1939 | dREQ (REQ_SEQ_REMOVE); |
1749 | req->seq = seq; |
1940 | req->seq = seq; |
1750 | req->txn = txnid; |
1941 | req->txn = txnid; |
… | |
… | |
1794 | int set_flags (DB_ENV *env, U32 flags, int onoff = 1) |
1985 | int set_flags (DB_ENV *env, U32 flags, int onoff = 1) |
1795 | CODE: |
1986 | CODE: |
1796 | RETVAL = env->set_flags (env, flags, onoff); |
1987 | RETVAL = env->set_flags (env, flags, onoff); |
1797 | OUTPUT: |
1988 | OUTPUT: |
1798 | RETVAL |
1989 | RETVAL |
|
|
1990 | |
|
|
1991 | #if DB_VERSION_MINOR >= 7 |
|
|
1992 | |
|
|
1993 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
|
|
1994 | CODE: |
|
|
1995 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
|
|
1996 | OUTPUT: |
|
|
1997 | RETVAL |
|
|
1998 | |
|
|
1999 | int log_set_config (DB_ENV *env, U32 flags, int onoff = 1) |
|
|
2000 | CODE: |
|
|
2001 | RETVAL = env->log_set_config (env, flags, onoff); |
|
|
2002 | OUTPUT: |
|
|
2003 | RETVAL |
|
|
2004 | |
|
|
2005 | #endif |
|
|
2006 | |
1799 | |
2007 | |
1800 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
2008 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
1801 | CODE: |
2009 | CODE: |
1802 | env->set_errfile (env, errfile); |
2010 | env->set_errfile (env, errfile); |
1803 | |
2011 | |