|
|
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" |
… | |
… | |
27 | # include <unistd.h> |
29 | # include <unistd.h> |
28 | #endif |
30 | #endif |
29 | |
31 | |
30 | #include <db.h> |
32 | #include <db.h> |
31 | |
33 | |
32 | #if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 4) |
34 | #if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) |
33 | # error you need Berkeley DB 4.4 or newer installed |
35 | # error you need Berkeley DB 4.3 or a newer 4.x version installed |
34 | #endif |
36 | #endif |
35 | |
37 | |
36 | /* number of seconds after which idle threads exit */ |
38 | /* number of seconds after which idle threads exit */ |
37 | #define IDLE_TIMEOUT 10 |
39 | #define IDLE_TIMEOUT 10 |
38 | |
40 | |
39 | typedef DB_ENV DB_ENV_ornull; |
41 | typedef DB_ENV DB_ENV_ornull; |
40 | typedef DB_TXN DB_TXN_ornull; |
42 | typedef DB_TXN DB_TXN_ornull; |
41 | typedef DBC DBC_ornull; |
43 | typedef DBC DBC_ornull; |
42 | typedef DB DB_ornull; |
44 | typedef DB DB_ornull; |
43 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
|
|
44 | |
45 | |
45 | typedef DB_ENV DB_ENV_ornuked; |
46 | typedef DB_ENV DB_ENV_ornuked; |
46 | typedef DB_TXN DB_TXN_ornuked; |
47 | typedef DB_TXN DB_TXN_ornuked; |
47 | typedef DBC DBC_ornuked; |
48 | typedef DBC DBC_ornuked; |
48 | typedef DB DB_ornuked; |
49 | typedef DB DB_ornuked; |
|
|
50 | |
|
|
51 | #if DB_VERSION_MINOR >= 3 |
|
|
52 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
49 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
53 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
|
|
54 | #endif |
50 | |
55 | |
51 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
56 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
52 | typedef char *bdb_filename; |
57 | typedef char *bdb_filename; |
53 | |
58 | |
54 | static SV *prepare_cb; |
59 | static SV *prepare_cb; |
… | |
… | |
61 | # define c_get get |
66 | # define c_get get |
62 | # define c_pget pget |
67 | # define c_pget pget |
63 | # define c_put put |
68 | # define c_put put |
64 | #endif |
69 | #endif |
65 | |
70 | |
|
|
71 | static char * |
|
|
72 | get_bdb_filename (SV *sv) |
|
|
73 | { |
|
|
74 | if (!SvOK (sv)) |
|
|
75 | return 0; |
|
|
76 | |
|
|
77 | #if _WIN32 |
|
|
78 | /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */ |
|
|
79 | { |
|
|
80 | STRLEN len; |
|
|
81 | char *src = SvPVbyte (sv, len); |
|
|
82 | SV *t1 = sv_newmortal (); |
|
|
83 | SV *t2 = sv_newmortal (); |
|
|
84 | |
|
|
85 | sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1); |
|
|
86 | sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1); |
|
|
87 | |
|
|
88 | len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR)); |
|
|
89 | len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0); |
|
|
90 | SvPOK_only (t2); |
|
|
91 | SvPVX (t2)[len] = 0; |
|
|
92 | SvCUR_set (t2, len); |
|
|
93 | |
|
|
94 | return SvPVX (t2); |
|
|
95 | } |
|
|
96 | #else |
|
|
97 | return SvPVbyte_nolen (sv); |
|
|
98 | #endif |
|
|
99 | } |
|
|
100 | |
66 | static void |
101 | static void |
67 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
102 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
68 | { |
103 | { |
69 | printf ("err[%s]\n", msg); |
104 | printf ("err[%s]\n", msg); |
70 | } |
105 | } |
… | |
… | |
107 | } |
142 | } |
108 | |
143 | |
109 | enum { |
144 | enum { |
110 | REQ_QUIT, |
145 | REQ_QUIT, |
111 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
146 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
112 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, |
147 | 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, |
148 | 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, |
149 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
115 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
150 | 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, |
151 | 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, |
152 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
118 | }; |
153 | }; |
119 | |
154 | |
… | |
… | |
129 | DBC *dbc; |
164 | DBC *dbc; |
130 | |
165 | |
131 | UV uv1; |
166 | UV uv1; |
132 | int int1, int2; |
167 | int int1, int2; |
133 | U32 uint1, uint2; |
168 | U32 uint1, uint2; |
134 | char *buf1, *buf2; |
169 | char *buf1, *buf2, *buf3; |
135 | SV *sv1, *sv2, *sv3; |
170 | SV *sv1, *sv2, *sv3; |
136 | |
171 | |
137 | DBT dbt1, dbt2, dbt3; |
172 | DBT dbt1, dbt2, dbt3; |
138 | DB_KEY_RANGE key_range; |
173 | DB_KEY_RANGE key_range; |
|
|
174 | #if DB_VERSION_MINOR >= 3 |
139 | DB_SEQUENCE *seq; |
175 | DB_SEQUENCE *seq; |
140 | db_seq_t seq_t; |
176 | db_seq_t seq_t; |
|
|
177 | #endif |
141 | } bdb_cb; |
178 | } bdb_cb; |
142 | |
179 | |
143 | typedef bdb_cb *bdb_req; |
180 | typedef bdb_cb *bdb_req; |
144 | |
181 | |
145 | enum { |
182 | enum { |
… | |
… | |
150 | PRI_BIAS = -PRI_MIN, |
187 | PRI_BIAS = -PRI_MIN, |
151 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
188 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
152 | }; |
189 | }; |
153 | |
190 | |
154 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
191 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
|
|
192 | |
|
|
193 | static SV *on_next_submit; |
155 | |
194 | |
156 | static unsigned int max_poll_time = 0; |
195 | static unsigned int max_poll_time = 0; |
157 | static unsigned int max_poll_reqs = 0; |
196 | static unsigned int max_poll_reqs = 0; |
158 | |
197 | |
159 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
198 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
… | |
… | |
205 | static mutex_t reqlock = X_MUTEX_INIT; |
244 | static mutex_t reqlock = X_MUTEX_INIT; |
206 | static cond_t reqwait = X_COND_INIT; |
245 | static cond_t reqwait = X_COND_INIT; |
207 | |
246 | |
208 | #if WORDACCESS_UNSAFE |
247 | #if WORDACCESS_UNSAFE |
209 | |
248 | |
210 | static unsigned int get_nready () |
249 | static unsigned int get_nready (void) |
211 | { |
250 | { |
212 | unsigned int retval; |
251 | unsigned int retval; |
213 | |
252 | |
214 | X_LOCK (reqlock); |
253 | X_LOCK (reqlock); |
215 | retval = nready; |
254 | retval = nready; |
216 | X_UNLOCK (reqlock); |
255 | X_UNLOCK (reqlock); |
217 | |
256 | |
218 | return retval; |
257 | return retval; |
219 | } |
258 | } |
220 | |
259 | |
221 | static unsigned int get_npending () |
260 | static unsigned int get_npending (void) |
222 | { |
261 | { |
223 | unsigned int retval; |
262 | unsigned int retval; |
224 | |
263 | |
225 | X_LOCK (reslock); |
264 | X_LOCK (reslock); |
226 | retval = npending; |
265 | retval = npending; |
227 | X_UNLOCK (reslock); |
266 | X_UNLOCK (reslock); |
228 | |
267 | |
229 | return retval; |
268 | return retval; |
230 | } |
269 | } |
231 | |
270 | |
232 | static unsigned int get_nthreads () |
271 | static unsigned int get_nthreads (void) |
233 | { |
272 | { |
234 | unsigned int retval; |
273 | unsigned int retval; |
235 | |
274 | |
236 | X_LOCK (wrklock); |
275 | X_LOCK (wrklock); |
237 | retval = started; |
276 | retval = started; |
… | |
… | |
300 | } |
339 | } |
301 | |
340 | |
302 | abort (); |
341 | abort (); |
303 | } |
342 | } |
304 | |
343 | |
305 | static int poll_cb (); |
344 | static int poll_cb (void); |
306 | static void req_free (bdb_req req); |
345 | static void req_free (bdb_req req); |
307 | static void req_cancel (bdb_req req); |
346 | static void req_cancel (bdb_req req); |
308 | |
347 | |
309 | static int req_invoke (bdb_req req) |
348 | static int req_invoke (bdb_req req) |
310 | { |
349 | { |
311 | dSP; |
350 | dSP; |
312 | |
351 | |
313 | if (SvOK (req->callback)) |
352 | if (req->callback) |
314 | { |
353 | { |
315 | ENTER; |
354 | ENTER; |
316 | SAVETMPS; |
355 | SAVETMPS; |
317 | PUSHMARK (SP); |
356 | PUSHMARK (SP); |
318 | |
357 | |
… | |
… | |
352 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
391 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
353 | SvREFCNT_dec (req->sv1); |
392 | SvREFCNT_dec (req->sv1); |
354 | } |
393 | } |
355 | break; |
394 | break; |
356 | |
395 | |
|
|
396 | #if DB_VERSION_MINOR >= 3 |
357 | case REQ_SEQ_GET: |
397 | case REQ_SEQ_GET: |
358 | SvREADONLY_off (req->sv1); |
398 | SvREADONLY_off (req->sv1); |
359 | |
399 | |
360 | if (sizeof (IV) > 4) |
400 | if (sizeof (IV) > 4) |
361 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
401 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
362 | else |
402 | else |
363 | sv_setnv_mg (req->sv1, (NV)req->seq_t); |
403 | sv_setnv_mg (req->sv1, (NV)req->seq_t); |
364 | |
404 | |
365 | SvREFCNT_dec (req->sv1); |
405 | SvREFCNT_dec (req->sv1); |
366 | break; |
406 | break; |
|
|
407 | #endif |
367 | } |
408 | } |
368 | |
409 | |
369 | errno = req->result; |
410 | errno = req->result; |
370 | |
411 | |
371 | PUTBACK; |
412 | PUTBACK; |
… | |
… | |
379 | return !SvTRUE (ERRSV); |
420 | return !SvTRUE (ERRSV); |
380 | } |
421 | } |
381 | |
422 | |
382 | static void req_free (bdb_req req) |
423 | static void req_free (bdb_req req) |
383 | { |
424 | { |
|
|
425 | SvREFCNT_dec (req->callback); |
|
|
426 | |
384 | free (req->buf1); |
427 | free (req->buf1); |
385 | free (req->buf2); |
428 | free (req->buf2); |
|
|
429 | free (req->buf3); |
|
|
430 | |
386 | Safefree (req); |
431 | Safefree (req); |
387 | } |
432 | } |
388 | |
433 | |
389 | #ifdef USE_SOCKETS_AS_HANDLES |
434 | #ifdef USE_SOCKETS_AS_HANDLES |
390 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
435 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
391 | #else |
436 | #else |
392 | # define TO_SOCKET(x) (x) |
437 | # define TO_SOCKET(x) (x) |
393 | #endif |
438 | #endif |
394 | |
439 | |
395 | static void |
440 | static void |
396 | create_respipe () |
441 | create_respipe (void) |
397 | { |
442 | { |
398 | #ifdef _WIN32 |
443 | #ifdef _WIN32 |
399 | int arg; /* argg */ |
444 | int arg; /* argg */ |
400 | #endif |
445 | #endif |
401 | int old_readfd = respipe [0]; |
446 | int old_readfd = respipe [0]; |
… | |
… | |
455 | free (wrk); |
500 | free (wrk); |
456 | |
501 | |
457 | X_UNLOCK (wrklock); |
502 | X_UNLOCK (wrklock); |
458 | } |
503 | } |
459 | |
504 | |
460 | static void maybe_start_thread () |
505 | static void maybe_start_thread (void) |
461 | { |
506 | { |
462 | if (get_nthreads () >= wanted) |
507 | if (get_nthreads () >= wanted) |
463 | return; |
508 | return; |
464 | |
509 | |
465 | /* todo: maybe use idle here, but might be less exact */ |
510 | /* todo: maybe use idle here, but might be less exact */ |
… | |
… | |
471 | |
516 | |
472 | static void req_send (bdb_req req) |
517 | static void req_send (bdb_req req) |
473 | { |
518 | { |
474 | SV *wait_callback = 0; |
519 | SV *wait_callback = 0; |
475 | |
520 | |
|
|
521 | if (on_next_submit) |
|
|
522 | { |
|
|
523 | dSP; |
|
|
524 | SV *cb = sv_2mortal (on_next_submit); |
|
|
525 | |
|
|
526 | on_next_submit = 0; |
|
|
527 | |
|
|
528 | PUSHMARK (SP); |
|
|
529 | PUTBACK; |
|
|
530 | call_sv (cb, G_DISCARD | G_EVAL); |
|
|
531 | } |
|
|
532 | |
476 | // synthesize callback if none given |
533 | // synthesize callback if none given |
477 | if (!SvOK (req->callback)) |
534 | if (!req->callback) |
478 | { |
535 | { |
479 | int count; |
536 | int count; |
480 | |
537 | |
481 | dSP; |
538 | dSP; |
482 | PUSHMARK (SP); |
539 | PUSHMARK (SP); |
… | |
… | |
550 | |
607 | |
551 | while (started > wanted) |
608 | while (started > wanted) |
552 | end_thread (); |
609 | end_thread (); |
553 | } |
610 | } |
554 | |
611 | |
555 | static void poll_wait () |
612 | static void poll_wait (void) |
556 | { |
613 | { |
557 | fd_set rfd; |
614 | fd_set rfd; |
558 | |
615 | |
559 | while (nreqs) |
616 | while (nreqs) |
560 | { |
617 | { |
… | |
… | |
573 | |
630 | |
574 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
631 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
575 | } |
632 | } |
576 | } |
633 | } |
577 | |
634 | |
578 | static int poll_cb () |
635 | static int poll_cb (void) |
579 | { |
636 | { |
580 | dSP; |
637 | dSP; |
581 | int count = 0; |
638 | int count = 0; |
582 | int maxreqs = max_poll_reqs; |
639 | int maxreqs = max_poll_reqs; |
583 | int do_croak = 0; |
640 | int do_croak = 0; |
… | |
… | |
728 | |
785 | |
729 | case REQ_ENV_MEMP_TRICKLE: |
786 | case REQ_ENV_MEMP_TRICKLE: |
730 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
787 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
731 | break; |
788 | break; |
732 | |
789 | |
|
|
790 | case REQ_ENV_DBREMOVE: |
|
|
791 | req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1); |
|
|
792 | break; |
|
|
793 | |
|
|
794 | case REQ_ENV_DBRENAME: |
|
|
795 | req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1); |
|
|
796 | break; |
|
|
797 | |
733 | case REQ_DB_OPEN: |
798 | case REQ_DB_OPEN: |
734 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
799 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
735 | break; |
800 | break; |
736 | |
801 | |
737 | case REQ_DB_CLOSE: |
802 | case REQ_DB_CLOSE: |
738 | req->result = req->db->close (req->db, req->uint1); |
803 | req->result = req->db->close (req->db, req->uint1); |
739 | break; |
804 | break; |
740 | |
805 | |
|
|
806 | #if DB_VERSION_MINOR >= 4 |
741 | case REQ_DB_COMPACT: |
807 | case REQ_DB_COMPACT: |
742 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
808 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
743 | break; |
809 | break; |
|
|
810 | #endif |
744 | |
811 | |
745 | case REQ_DB_SYNC: |
812 | case REQ_DB_SYNC: |
746 | req->result = req->db->sync (req->db, req->uint1); |
813 | req->result = req->db->sync (req->db, req->uint1); |
747 | break; |
814 | break; |
748 | |
815 | |
… | |
… | |
752 | |
819 | |
753 | case REQ_DB_PUT: |
820 | case REQ_DB_PUT: |
754 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
821 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
755 | break; |
822 | break; |
756 | |
823 | |
|
|
824 | #if DB_VERSION_MINOR >= 6 |
|
|
825 | case REQ_DB_EXISTS: |
|
|
826 | req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
|
|
827 | break; |
|
|
828 | #endif |
757 | case REQ_DB_GET: |
829 | case REQ_DB_GET: |
758 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
830 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
759 | break; |
831 | break; |
760 | |
832 | |
761 | case REQ_DB_PGET: |
833 | case REQ_DB_PGET: |
… | |
… | |
815 | |
887 | |
816 | case REQ_C_DEL: |
888 | case REQ_C_DEL: |
817 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
889 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
818 | break; |
890 | break; |
819 | |
891 | |
|
|
892 | #if DB_VERSION_MINOR >= 3 |
820 | case REQ_SEQ_OPEN: |
893 | case REQ_SEQ_OPEN: |
821 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
894 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
822 | break; |
895 | break; |
823 | |
896 | |
824 | case REQ_SEQ_CLOSE: |
897 | case REQ_SEQ_CLOSE: |
… | |
… | |
830 | break; |
903 | break; |
831 | |
904 | |
832 | case REQ_SEQ_REMOVE: |
905 | case REQ_SEQ_REMOVE: |
833 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
906 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
834 | break; |
907 | break; |
|
|
908 | #endif |
835 | |
909 | |
836 | default: |
910 | default: |
837 | req->result = ENOSYS; |
911 | req->result = ENOSYS; |
838 | break; |
912 | break; |
839 | } |
913 | } |
… | |
… | |
914 | #define dREQ(reqtype) \ |
988 | #define dREQ(reqtype) \ |
915 | bdb_req req; \ |
989 | bdb_req req; \ |
916 | int req_pri = next_pri; \ |
990 | int req_pri = next_pri; \ |
917 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
991 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
918 | \ |
992 | \ |
919 | if (SvOK (callback) && !SvROK (callback)) \ |
993 | if (callback && SvOK (callback)) \ |
920 | croak ("callback must be undef or of reference type"); \ |
994 | croak ("callback has illegal type or extra arguments"); \ |
921 | \ |
995 | \ |
922 | Newz (0, req, 1, bdb_cb); \ |
996 | Newz (0, req, 1, bdb_cb); \ |
923 | if (!req) \ |
997 | if (!req) \ |
924 | croak ("out of memory during bdb_req allocation"); \ |
998 | croak ("out of memory during bdb_req allocation"); \ |
925 | \ |
999 | \ |
926 | req->callback = newSVsv (callback); \ |
1000 | req->callback = cb ? SvREFCNT_inc (cb) : 0; \ |
927 | req->type = (reqtype); \ |
1001 | req->type = (reqtype); \ |
928 | req->pri = req_pri |
1002 | req->pri = req_pri |
929 | |
1003 | |
930 | #define REQ_SEND \ |
1004 | #define REQ_SEND \ |
931 | req_send (req) |
1005 | req_send (req) |
… | |
… | |
944 | (var) = INT2PTR (type, tmp); \ |
1018 | (var) = INT2PTR (type, tmp); \ |
945 | if (!var && nullok != 2) \ |
1019 | if (!var && nullok != 2) \ |
946 | croak (# var " is not a valid " # class " object anymore"); \ |
1020 | croak (# var " is not a valid " # class " object anymore"); \ |
947 | } \ |
1021 | } \ |
948 | else \ |
1022 | else \ |
949 | croak (# var " is not of type " # class); \ |
1023 | croak (# var " is not of type " # class); |
950 | \ |
|
|
951 | |
1024 | |
952 | static void |
1025 | static void |
953 | ptr_nuke (SV *sv) |
1026 | ptr_nuke (SV *sv) |
954 | { |
1027 | { |
955 | assert (SvROK (sv)); |
1028 | assert (SvROK (sv)); |
… | |
… | |
992 | |
1065 | |
993 | vtbl_errno = PL_vtbl_sv; |
1066 | vtbl_errno = PL_vtbl_sv; |
994 | vtbl_errno.svt_get = errno_get; |
1067 | vtbl_errno.svt_get = errno_get; |
995 | mg->mg_virtual = &vtbl_errno; |
1068 | mg->mg_virtual = &vtbl_errno; |
996 | } |
1069 | } |
|
|
1070 | |
|
|
1071 | #if __GNUC__ >= 4 |
|
|
1072 | # define noinline __attribute__ ((noinline)) |
|
|
1073 | #else |
|
|
1074 | # define noinline |
|
|
1075 | #endif |
|
|
1076 | |
|
|
1077 | static noinline SV * |
|
|
1078 | pop_callback (I32 *ritems, SV *sv) |
|
|
1079 | { |
|
|
1080 | if (SvROK (sv)) |
|
|
1081 | { |
|
|
1082 | HV *st; |
|
|
1083 | GV *gvp; |
|
|
1084 | CV *cv; |
|
|
1085 | const char *name; |
|
|
1086 | |
|
|
1087 | /* forgive me */ |
|
|
1088 | if (SvTYPE (SvRV (sv)) == SVt_PVMG |
|
|
1089 | && (st = SvSTASH (SvRV (sv))) |
|
|
1090 | && (name = HvNAME_get (st)) |
|
|
1091 | && (name [0] == 'B' && name [1] == 'D' && name [2] == 'B' && name [3] == ':')) |
|
|
1092 | return 0; |
|
|
1093 | |
|
|
1094 | if ((cv = sv_2cv (sv, &st, &gvp, 0))) |
|
|
1095 | { |
|
|
1096 | --*ritems; |
|
|
1097 | return (SV *)cv; |
|
|
1098 | } |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | return 0; |
|
|
1102 | } |
|
|
1103 | |
|
|
1104 | /* stupid windoes defined CALLBACK as well */ |
|
|
1105 | #undef CALLBACK |
|
|
1106 | #define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); |
997 | |
1107 | |
998 | MODULE = BDB PACKAGE = BDB |
1108 | MODULE = BDB PACKAGE = BDB |
999 | |
1109 | |
1000 | PROTOTYPES: ENABLE |
1110 | PROTOTYPES: ENABLE |
1001 | |
1111 | |
… | |
… | |
1022 | const_iv (RDONLY) |
1132 | const_iv (RDONLY) |
1023 | const_iv (USE_ENVIRON) |
1133 | const_iv (USE_ENVIRON) |
1024 | const_iv (USE_ENVIRON_ROOT) |
1134 | const_iv (USE_ENVIRON_ROOT) |
1025 | const_iv (LOCKDOWN) |
1135 | const_iv (LOCKDOWN) |
1026 | const_iv (PRIVATE) |
1136 | const_iv (PRIVATE) |
1027 | const_iv (REGISTER) |
|
|
1028 | const_iv (SYSTEM_MEM) |
1137 | const_iv (SYSTEM_MEM) |
1029 | const_iv (AUTO_COMMIT) |
1138 | const_iv (AUTO_COMMIT) |
1030 | const_iv (CDB_ALLDB) |
1139 | const_iv (CDB_ALLDB) |
1031 | const_iv (DIRECT_DB) |
1140 | const_iv (DIRECT_DB) |
1032 | const_iv (DIRECT_LOG) |
|
|
1033 | const_iv (DSYNC_DB) |
|
|
1034 | const_iv (DSYNC_LOG) |
|
|
1035 | const_iv (LOG_AUTOREMOVE) |
|
|
1036 | const_iv (LOG_INMEMORY) |
|
|
1037 | const_iv (NOLOCKING) |
1141 | const_iv (NOLOCKING) |
1038 | const_iv (NOMMAP) |
1142 | const_iv (NOMMAP) |
1039 | const_iv (NOPANIC) |
1143 | const_iv (NOPANIC) |
1040 | const_iv (OVERWRITE) |
1144 | const_iv (OVERWRITE) |
1041 | const_iv (PANIC_ENVIRONMENT) |
1145 | const_iv (PANIC_ENVIRONMENT) |
… | |
… | |
1052 | const_iv (HASH) |
1156 | const_iv (HASH) |
1053 | const_iv (QUEUE) |
1157 | const_iv (QUEUE) |
1054 | const_iv (RECNO) |
1158 | const_iv (RECNO) |
1055 | const_iv (UNKNOWN) |
1159 | const_iv (UNKNOWN) |
1056 | const_iv (EXCL) |
1160 | const_iv (EXCL) |
1057 | const_iv (READ_COMMITTED) |
|
|
1058 | const_iv (READ_UNCOMMITTED) |
|
|
1059 | const_iv (TRUNCATE) |
1161 | const_iv (TRUNCATE) |
1060 | const_iv (NOSYNC) |
1162 | const_iv (NOSYNC) |
1061 | const_iv (CHKSUM) |
1163 | const_iv (CHKSUM) |
1062 | const_iv (ENCRYPT) |
1164 | const_iv (ENCRYPT) |
1063 | const_iv (DUP) |
1165 | const_iv (DUP) |
1064 | const_iv (DUPSORT) |
1166 | const_iv (DUPSORT) |
1065 | const_iv (RECNUM) |
1167 | const_iv (RECNUM) |
1066 | const_iv (RENUMBER) |
1168 | const_iv (RENUMBER) |
1067 | const_iv (REVSPLITOFF) |
1169 | const_iv (REVSPLITOFF) |
1068 | const_iv (INORDER) |
|
|
1069 | const_iv (CONSUME) |
1170 | const_iv (CONSUME) |
1070 | const_iv (CONSUME_WAIT) |
1171 | const_iv (CONSUME_WAIT) |
1071 | const_iv (GET_BOTH) |
1172 | const_iv (GET_BOTH) |
1072 | const_iv (GET_BOTH_RANGE) |
1173 | const_iv (GET_BOTH_RANGE) |
1073 | //const_iv (SET_RECNO) |
1174 | //const_iv (SET_RECNO) |
… | |
… | |
1082 | const_iv (LOCK_DEADLOCK) |
1183 | const_iv (LOCK_DEADLOCK) |
1083 | const_iv (LOCK_NOTGRANTED) |
1184 | const_iv (LOCK_NOTGRANTED) |
1084 | const_iv (RUNRECOVERY) |
1185 | const_iv (RUNRECOVERY) |
1085 | const_iv (OLD_VERSION) |
1186 | const_iv (OLD_VERSION) |
1086 | const_iv (REP_HANDLE_DEAD) |
1187 | const_iv (REP_HANDLE_DEAD) |
1087 | const_iv (REP_LOCKOUT) |
|
|
1088 | const_iv (SECONDARY_BAD) |
1188 | const_iv (SECONDARY_BAD) |
1089 | |
|
|
1090 | const_iv (FREE_SPACE) |
|
|
1091 | const_iv (FREELIST_ONLY) |
|
|
1092 | |
1189 | |
1093 | const_iv (APPEND) |
1190 | const_iv (APPEND) |
1094 | const_iv (NODUPDATA) |
1191 | const_iv (NODUPDATA) |
1095 | const_iv (NOOVERWRITE) |
1192 | const_iv (NOOVERWRITE) |
1096 | |
1193 | |
… | |
… | |
1119 | const_iv (FORCE) |
1216 | const_iv (FORCE) |
1120 | |
1217 | |
1121 | const_iv (LOCK_DEFAULT) |
1218 | const_iv (LOCK_DEFAULT) |
1122 | const_iv (LOCK_EXPIRE) |
1219 | const_iv (LOCK_EXPIRE) |
1123 | const_iv (LOCK_MAXLOCKS) |
1220 | const_iv (LOCK_MAXLOCKS) |
1124 | const_iv (LOCK_MAXWRITE) |
|
|
1125 | const_iv (LOCK_MINLOCKS) |
1221 | const_iv (LOCK_MINLOCKS) |
1126 | const_iv (LOCK_MINWRITE) |
1222 | const_iv (LOCK_MINWRITE) |
1127 | const_iv (LOCK_OLDEST) |
1223 | const_iv (LOCK_OLDEST) |
1128 | const_iv (LOCK_RANDOM) |
1224 | const_iv (LOCK_RANDOM) |
1129 | const_iv (LOCK_YOUNGEST) |
1225 | const_iv (LOCK_YOUNGEST) |
1130 | |
1226 | |
1131 | const_iv (SEQ_DEC) |
|
|
1132 | const_iv (SEQ_INC) |
|
|
1133 | const_iv (SEQ_WRAP) |
|
|
1134 | |
|
|
1135 | const_iv (BUFFER_SMALL) |
|
|
1136 | const_iv (DONOTINDEX) |
1227 | const_iv (DONOTINDEX) |
1137 | const_iv (KEYEMPTY ) |
1228 | const_iv (KEYEMPTY ) |
1138 | const_iv (KEYEXIST ) |
1229 | const_iv (KEYEXIST ) |
1139 | const_iv (LOCK_DEADLOCK) |
1230 | const_iv (LOCK_DEADLOCK) |
1140 | const_iv (LOCK_NOTGRANTED) |
1231 | const_iv (LOCK_NOTGRANTED) |
1141 | const_iv (LOG_BUFFER_FULL) |
|
|
1142 | const_iv (NOSERVER) |
1232 | const_iv (NOSERVER) |
1143 | const_iv (NOSERVER_HOME) |
1233 | const_iv (NOSERVER_HOME) |
1144 | const_iv (NOSERVER_ID) |
1234 | const_iv (NOSERVER_ID) |
1145 | const_iv (NOTFOUND) |
1235 | const_iv (NOTFOUND) |
1146 | const_iv (PAGE_NOTFOUND) |
1236 | const_iv (PAGE_NOTFOUND) |
1147 | const_iv (REP_DUPMASTER) |
1237 | const_iv (REP_DUPMASTER) |
1148 | const_iv (REP_HANDLE_DEAD) |
1238 | const_iv (REP_HANDLE_DEAD) |
1149 | const_iv (REP_HOLDELECTION) |
1239 | const_iv (REP_HOLDELECTION) |
1150 | const_iv (REP_IGNORE) |
|
|
1151 | const_iv (REP_ISPERM) |
1240 | const_iv (REP_ISPERM) |
1152 | const_iv (REP_JOIN_FAILURE) |
|
|
1153 | const_iv (REP_LOCKOUT) |
|
|
1154 | const_iv (REP_NEWMASTER) |
1241 | const_iv (REP_NEWMASTER) |
1155 | const_iv (REP_NEWSITE) |
1242 | const_iv (REP_NEWSITE) |
1156 | const_iv (REP_NOTPERM) |
1243 | const_iv (REP_NOTPERM) |
1157 | const_iv (REP_UNAVAIL) |
1244 | const_iv (REP_UNAVAIL) |
1158 | const_iv (RUNRECOVERY) |
1245 | const_iv (RUNRECOVERY) |
1159 | const_iv (SECONDARY_BAD) |
1246 | const_iv (SECONDARY_BAD) |
1160 | const_iv (VERIFY_BAD) |
1247 | const_iv (VERIFY_BAD) |
1161 | const_iv (VERSION_MISMATCH) |
|
|
1162 | |
1248 | |
1163 | const_iv (VERB_DEADLOCK) |
1249 | const_iv (VERB_DEADLOCK) |
1164 | const_iv (VERB_RECOVERY) |
1250 | const_iv (VERB_RECOVERY) |
1165 | const_iv (VERB_REGISTER) |
|
|
1166 | const_iv (VERB_REPLICATION) |
1251 | const_iv (VERB_REPLICATION) |
1167 | const_iv (VERB_WAITSFOR) |
1252 | const_iv (VERB_WAITSFOR) |
1168 | |
1253 | |
1169 | const_iv (VERSION_MAJOR) |
1254 | const_iv (VERSION_MAJOR) |
1170 | const_iv (VERSION_MINOR) |
1255 | const_iv (VERSION_MINOR) |
1171 | const_iv (VERSION_PATCH) |
1256 | const_iv (VERSION_PATCH) |
|
|
1257 | #if DB_VERSION_MINOR >= 3 |
|
|
1258 | const_iv (INORDER) |
|
|
1259 | const_iv (LOCK_MAXWRITE) |
|
|
1260 | const_iv (SEQ_DEC) |
|
|
1261 | const_iv (SEQ_INC) |
|
|
1262 | const_iv (SEQ_WRAP) |
|
|
1263 | const_iv (BUFFER_SMALL) |
|
|
1264 | const_iv (LOG_BUFFER_FULL) |
|
|
1265 | const_iv (VERSION_MISMATCH) |
|
|
1266 | #endif |
|
|
1267 | #if DB_VERSION_MINOR >= 4 |
|
|
1268 | const_iv (REGISTER) |
|
|
1269 | const_iv (DSYNC_DB) |
|
|
1270 | const_iv (READ_COMMITTED) |
|
|
1271 | const_iv (READ_UNCOMMITTED) |
|
|
1272 | const_iv (REP_IGNORE) |
|
|
1273 | const_iv (REP_LOCKOUT) |
|
|
1274 | const_iv (REP_JOIN_FAILURE) |
|
|
1275 | const_iv (FREE_SPACE) |
|
|
1276 | const_iv (FREELIST_ONLY) |
|
|
1277 | const_iv (VERB_REGISTER) |
|
|
1278 | #endif |
1172 | #if DB_VERSION_MINOR >= 5 |
1279 | #if DB_VERSION_MINOR >= 5 |
1173 | const_iv (MULTIVERSION) |
1280 | const_iv (MULTIVERSION) |
1174 | const_iv (TXN_SNAPSHOT) |
1281 | const_iv (TXN_SNAPSHOT) |
1175 | #endif |
1282 | #endif |
1176 | #if DB_VERSION_MINOR >= 6 |
1283 | #if DB_VERSION_MINOR >= 6 |
… | |
… | |
1180 | const_iv (PRIORITY_LOW) |
1287 | const_iv (PRIORITY_LOW) |
1181 | const_iv (PRIORITY_DEFAULT) |
1288 | const_iv (PRIORITY_DEFAULT) |
1182 | const_iv (PRIORITY_HIGH) |
1289 | const_iv (PRIORITY_HIGH) |
1183 | const_iv (PRIORITY_VERY_HIGH) |
1290 | const_iv (PRIORITY_VERY_HIGH) |
1184 | #endif |
1291 | #endif |
|
|
1292 | #if DB_VERSION_MINOR >= 7 |
|
|
1293 | const_iv (LOG_DIRECT) |
|
|
1294 | const_iv (LOG_DSYNC) |
|
|
1295 | const_iv (LOG_AUTO_REMOVE) |
|
|
1296 | const_iv (LOG_IN_MEMORY) |
|
|
1297 | const_iv (LOG_ZERO) |
|
|
1298 | #else |
|
|
1299 | const_iv (DIRECT_LOG) |
|
|
1300 | const_iv (LOG_AUTOREMOVE) |
|
|
1301 | # if DB_VERSION_MINOR >= 3 |
|
|
1302 | const_iv (DSYNC_LOG) |
|
|
1303 | const_iv (LOG_INMEMORY) |
|
|
1304 | # endif |
|
|
1305 | #endif |
1185 | }; |
1306 | }; |
1186 | |
1307 | |
1187 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1308 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1188 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1309 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1189 | |
1310 | |
1190 | newCONSTSUB (stash, "VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1)); |
1311 | { |
|
|
1312 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
|
|
1313 | char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; |
|
|
1314 | |
|
|
1315 | newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); |
|
|
1316 | } |
|
|
1317 | |
1191 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1318 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1192 | |
1319 | |
1193 | create_respipe (); |
1320 | create_respipe (); |
1194 | |
1321 | |
1195 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1322 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1196 | #ifdef _WIN32 |
|
|
1197 | X_MUTEX_CHECK (wrklock); |
|
|
1198 | X_MUTEX_CHECK (reslock); |
|
|
1199 | X_MUTEX_CHECK (reqlock); |
|
|
1200 | |
|
|
1201 | X_COND_CHECK (reqwait); |
|
|
1202 | #endif |
|
|
1203 | patch_errno (); |
1323 | patch_errno (); |
1204 | } |
1324 | } |
1205 | |
1325 | |
1206 | void |
1326 | void |
1207 | max_poll_reqs (int nreqs) |
1327 | max_poll_reqs (int nreqs) |
… | |
… | |
1348 | CODE: |
1468 | CODE: |
1349 | RETVAL = db_strerror (errorno); |
1469 | RETVAL = db_strerror (errorno); |
1350 | OUTPUT: |
1470 | OUTPUT: |
1351 | RETVAL |
1471 | RETVAL |
1352 | |
1472 | |
|
|
1473 | void _on_next_submit (SV *cb) |
|
|
1474 | CODE: |
|
|
1475 | SvREFCNT_dec (on_next_submit); |
|
|
1476 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
|
|
1477 | |
1353 | DB_ENV * |
1478 | DB_ENV * |
1354 | db_env_create (U32 env_flags = 0) |
1479 | db_env_create (U32 env_flags = 0) |
1355 | CODE: |
1480 | CODE: |
1356 | { |
1481 | { |
1357 | errno = db_env_create (&RETVAL, env_flags); |
1482 | errno = db_env_create (&RETVAL, env_flags); |
… | |
… | |
1366 | } |
1491 | } |
1367 | OUTPUT: |
1492 | OUTPUT: |
1368 | RETVAL |
1493 | RETVAL |
1369 | |
1494 | |
1370 | void |
1495 | void |
1371 | db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) |
1496 | db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) |
|
|
1497 | PREINIT: |
|
|
1498 | CALLBACK |
1372 | CODE: |
1499 | CODE: |
1373 | { |
1500 | { |
1374 | dREQ (REQ_ENV_OPEN); |
1501 | dREQ (REQ_ENV_OPEN); |
1375 | |
|
|
1376 | req->env = env; |
1502 | req->env = env; |
1377 | req->uint1 = open_flags | DB_THREAD; |
1503 | req->uint1 = open_flags | DB_THREAD; |
1378 | req->int1 = mode; |
1504 | req->int1 = mode; |
1379 | req->buf1 = strdup_ornull (db_home); |
1505 | req->buf1 = strdup_ornull (db_home); |
1380 | REQ_SEND; |
1506 | REQ_SEND; |
1381 | } |
1507 | } |
1382 | |
1508 | |
1383 | void |
1509 | void |
1384 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = &PL_sv_undef) |
1510 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) |
|
|
1511 | PREINIT: |
|
|
1512 | CALLBACK |
1385 | CODE: |
1513 | CODE: |
1386 | { |
1514 | { |
1387 | dREQ (REQ_ENV_CLOSE); |
1515 | dREQ (REQ_ENV_CLOSE); |
1388 | req->env = env; |
1516 | req->env = env; |
1389 | req->uint1 = flags; |
1517 | req->uint1 = flags; |
1390 | REQ_SEND; |
1518 | REQ_SEND; |
1391 | ptr_nuke (ST (0)); |
1519 | ptr_nuke (ST (0)); |
1392 | } |
1520 | } |
1393 | |
1521 | |
1394 | void |
1522 | void |
1395 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1523 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) |
|
|
1524 | PREINIT: |
|
|
1525 | CALLBACK |
1396 | CODE: |
1526 | CODE: |
1397 | { |
1527 | { |
1398 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1528 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1399 | req->env = env; |
1529 | req->env = env; |
1400 | req->uint1 = kbyte; |
1530 | req->uint1 = kbyte; |
… | |
… | |
1402 | req->uint2 = flags; |
1532 | req->uint2 = flags; |
1403 | REQ_SEND; |
1533 | REQ_SEND; |
1404 | } |
1534 | } |
1405 | |
1535 | |
1406 | void |
1536 | void |
1407 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1537 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) |
|
|
1538 | PREINIT: |
|
|
1539 | CALLBACK |
1408 | CODE: |
1540 | CODE: |
1409 | { |
1541 | { |
1410 | dREQ (REQ_ENV_LOCK_DETECT); |
1542 | dREQ (REQ_ENV_LOCK_DETECT); |
1411 | req->env = env; |
1543 | req->env = env; |
1412 | req->uint1 = flags; |
1544 | req->uint1 = flags; |
1413 | req->uint2 = atype; |
1545 | req->uint2 = atype; |
|
|
1546 | /* req->int2 = 0; dummy */ |
1414 | REQ_SEND; |
1547 | REQ_SEND; |
1415 | } |
1548 | } |
1416 | |
1549 | |
1417 | void |
1550 | void |
1418 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1551 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
|
|
1552 | PREINIT: |
|
|
1553 | CALLBACK |
1419 | CODE: |
1554 | CODE: |
1420 | { |
1555 | { |
1421 | dREQ (REQ_ENV_MEMP_SYNC); |
1556 | dREQ (REQ_ENV_MEMP_SYNC); |
1422 | req->env = env; |
1557 | req->env = env; |
1423 | REQ_SEND; |
1558 | REQ_SEND; |
1424 | } |
1559 | } |
1425 | |
1560 | |
1426 | void |
1561 | void |
1427 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1562 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
|
|
1563 | PREINIT: |
|
|
1564 | CALLBACK |
1428 | CODE: |
1565 | CODE: |
1429 | { |
1566 | { |
1430 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1567 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1431 | req->env = env; |
1568 | req->env = env; |
1432 | req->int1 = percent; |
1569 | req->int1 = percent; |
1433 | REQ_SEND; |
1570 | REQ_SEND; |
1434 | } |
1571 | } |
1435 | |
1572 | |
|
|
1573 | void |
|
|
1574 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
|
|
1575 | PREINIT: |
|
|
1576 | CALLBACK |
|
|
1577 | CODE: |
|
|
1578 | { |
|
|
1579 | dREQ (REQ_ENV_DBREMOVE); |
|
|
1580 | req->env = env; |
|
|
1581 | req->buf1 = strdup_ornull (file); |
|
|
1582 | req->buf2 = strdup_ornull (database); |
|
|
1583 | req->uint1 = flags; |
|
|
1584 | REQ_SEND; |
|
|
1585 | } |
|
|
1586 | |
|
|
1587 | void |
|
|
1588 | 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) |
|
|
1589 | PREINIT: |
|
|
1590 | CALLBACK |
|
|
1591 | CODE: |
|
|
1592 | { |
|
|
1593 | dREQ (REQ_ENV_DBRENAME); |
|
|
1594 | req->env = env; |
|
|
1595 | req->buf1 = strdup_ornull (file); |
|
|
1596 | req->buf2 = strdup_ornull (database); |
|
|
1597 | req->buf3 = strdup_ornull (newname); |
|
|
1598 | req->uint1 = flags; |
|
|
1599 | REQ_SEND; |
|
|
1600 | } |
1436 | |
1601 | |
1437 | DB * |
1602 | DB * |
1438 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1603 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1439 | CODE: |
1604 | CODE: |
1440 | { |
1605 | { |
… | |
… | |
1447 | } |
1612 | } |
1448 | OUTPUT: |
1613 | OUTPUT: |
1449 | RETVAL |
1614 | RETVAL |
1450 | |
1615 | |
1451 | void |
1616 | void |
1452 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = &PL_sv_undef) |
1617 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
|
|
1618 | PREINIT: |
|
|
1619 | CALLBACK |
1453 | CODE: |
1620 | CODE: |
1454 | { |
1621 | { |
1455 | dREQ (REQ_DB_OPEN); |
1622 | dREQ (REQ_DB_OPEN); |
1456 | req->db = db; |
1623 | req->db = db; |
1457 | req->txn = txnid; |
1624 | req->txn = txnid; |
… | |
… | |
1462 | req->int2 = mode; |
1629 | req->int2 = mode; |
1463 | REQ_SEND; |
1630 | REQ_SEND; |
1464 | } |
1631 | } |
1465 | |
1632 | |
1466 | void |
1633 | void |
1467 | db_close (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1634 | db_close (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1635 | PREINIT: |
|
|
1636 | CALLBACK |
1468 | CODE: |
1637 | CODE: |
1469 | { |
1638 | { |
1470 | dREQ (REQ_DB_CLOSE); |
1639 | dREQ (REQ_DB_CLOSE); |
1471 | req->db = db; |
1640 | req->db = db; |
1472 | req->uint1 = flags; |
1641 | req->uint1 = flags; |
1473 | req->sv1 = (SV *)db->app_private; |
1642 | req->sv1 = (SV *)db->app_private; |
1474 | REQ_SEND; |
1643 | REQ_SEND; |
1475 | ptr_nuke (ST (0)); |
1644 | ptr_nuke (ST (0)); |
1476 | } |
1645 | } |
1477 | |
1646 | |
|
|
1647 | #if DB_VERSION_MINOR >= 4 |
|
|
1648 | |
1478 | void |
1649 | void |
1479 | 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) |
1650 | 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) |
|
|
1651 | PREINIT: |
|
|
1652 | CALLBACK |
1480 | CODE: |
1653 | CODE: |
1481 | { |
1654 | { |
1482 | dREQ (REQ_DB_COMPACT); |
1655 | dREQ (REQ_DB_COMPACT); |
1483 | req->db = db; |
1656 | req->db = db; |
1484 | req->txn = txn; |
1657 | req->txn = txn; |
… | |
… | |
1486 | sv_to_dbt (&req->dbt2, stop); |
1659 | sv_to_dbt (&req->dbt2, stop); |
1487 | req->uint1 = flags; |
1660 | req->uint1 = flags; |
1488 | REQ_SEND; |
1661 | REQ_SEND; |
1489 | } |
1662 | } |
1490 | |
1663 | |
|
|
1664 | #endif |
|
|
1665 | |
1491 | void |
1666 | void |
1492 | db_sync (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1667 | db_sync (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1668 | PREINIT: |
|
|
1669 | CALLBACK |
1493 | CODE: |
1670 | CODE: |
1494 | { |
1671 | { |
1495 | dREQ (REQ_DB_SYNC); |
1672 | dREQ (REQ_DB_SYNC); |
1496 | req->db = db; |
1673 | req->db = db; |
1497 | req->uint1 = flags; |
1674 | req->uint1 = flags; |
1498 | REQ_SEND; |
1675 | REQ_SEND; |
1499 | } |
1676 | } |
1500 | |
1677 | |
1501 | void |
1678 | void |
1502 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = &PL_sv_undef) |
1679 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
|
|
1680 | PREINIT: |
|
|
1681 | CALLBACK |
1503 | CODE: |
1682 | CODE: |
1504 | { |
1683 | { |
1505 | dREQ (REQ_DB_SYNC); |
1684 | dREQ (REQ_DB_SYNC); |
1506 | req->db = db; |
1685 | req->db = db; |
1507 | req->buf1 = strdup (file); |
1686 | req->buf1 = strdup (file); |
1508 | req->uint1 = flags; |
1687 | req->uint1 = flags; |
1509 | REQ_SEND; |
1688 | REQ_SEND; |
1510 | } |
1689 | } |
1511 | |
1690 | |
1512 | void |
1691 | void |
1513 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = &PL_sv_undef) |
1692 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = 0) |
|
|
1693 | PREINIT: |
|
|
1694 | CALLBACK |
1514 | CODE: |
1695 | CODE: |
1515 | { |
1696 | { |
1516 | dREQ (REQ_DB_KEY_RANGE); |
1697 | dREQ (REQ_DB_KEY_RANGE); |
1517 | req->db = db; |
1698 | req->db = db; |
1518 | req->txn = txn; |
1699 | req->txn = txn; |
… | |
… | |
1521 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1702 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1522 | REQ_SEND; |
1703 | REQ_SEND; |
1523 | } |
1704 | } |
1524 | |
1705 | |
1525 | void |
1706 | void |
1526 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1707 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1708 | PREINIT: |
|
|
1709 | CALLBACK |
1527 | CODE: |
1710 | CODE: |
1528 | { |
1711 | { |
1529 | dREQ (REQ_DB_PUT); |
1712 | dREQ (REQ_DB_PUT); |
1530 | req->db = db; |
1713 | req->db = db; |
1531 | req->txn = txn; |
1714 | req->txn = txn; |
… | |
… | |
1533 | sv_to_dbt (&req->dbt2, data); |
1716 | sv_to_dbt (&req->dbt2, data); |
1534 | req->uint1 = flags; |
1717 | req->uint1 = flags; |
1535 | REQ_SEND; |
1718 | REQ_SEND; |
1536 | } |
1719 | } |
1537 | |
1720 | |
|
|
1721 | #if DB_VERSION_MINOR >= 6 |
|
|
1722 | |
1538 | void |
1723 | void |
|
|
1724 | db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1725 | PREINIT: |
|
|
1726 | CALLBACK |
|
|
1727 | CODE: |
|
|
1728 | { |
|
|
1729 | dREQ (REQ_DB_EXISTS); |
|
|
1730 | req->db = db; |
|
|
1731 | req->txn = txn; |
|
|
1732 | req->uint1 = flags; |
|
|
1733 | sv_to_dbt (&req->dbt1, key); |
|
|
1734 | REQ_SEND; |
|
|
1735 | } |
|
|
1736 | |
|
|
1737 | #endif |
|
|
1738 | |
|
|
1739 | void |
1539 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1740 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1741 | PREINIT: |
|
|
1742 | CALLBACK |
1540 | CODE: |
1743 | CODE: |
1541 | if (SvREADONLY (data)) |
1744 | if (SvREADONLY (data)) |
1542 | croak ("can't modify read-only data scalar in db_get"); |
1745 | croak ("can't modify read-only data scalar in db_get"); |
1543 | { |
1746 | { |
1544 | dREQ (REQ_DB_GET); |
1747 | dREQ (REQ_DB_GET); |
… | |
… | |
1550 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1753 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1551 | REQ_SEND; |
1754 | REQ_SEND; |
1552 | } |
1755 | } |
1553 | |
1756 | |
1554 | void |
1757 | void |
1555 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1758 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1759 | PREINIT: |
|
|
1760 | CALLBACK |
1556 | CODE: |
1761 | CODE: |
1557 | if (SvREADONLY (data)) |
1762 | if (SvREADONLY (data)) |
1558 | croak ("can't modify read-only data scalar in db_pget"); |
1763 | croak ("can't modify read-only data scalar in db_pget"); |
1559 | { |
1764 | { |
1560 | dREQ (REQ_DB_PGET); |
1765 | dREQ (REQ_DB_PGET); |
… | |
… | |
1567 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1772 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1568 | REQ_SEND; |
1773 | REQ_SEND; |
1569 | } |
1774 | } |
1570 | |
1775 | |
1571 | void |
1776 | void |
1572 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1777 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1778 | PREINIT: |
|
|
1779 | CALLBACK |
1573 | CODE: |
1780 | CODE: |
1574 | { |
1781 | { |
1575 | dREQ (REQ_DB_DEL); |
1782 | dREQ (REQ_DB_DEL); |
1576 | req->db = db; |
1783 | req->db = db; |
1577 | req->txn = txn; |
1784 | req->txn = txn; |
… | |
… | |
1579 | sv_to_dbt (&req->dbt1, key); |
1786 | sv_to_dbt (&req->dbt1, key); |
1580 | REQ_SEND; |
1787 | REQ_SEND; |
1581 | } |
1788 | } |
1582 | |
1789 | |
1583 | void |
1790 | void |
1584 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1791 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1792 | PREINIT: |
|
|
1793 | CALLBACK |
1585 | CODE: |
1794 | CODE: |
1586 | { |
1795 | { |
1587 | dREQ (REQ_TXN_COMMIT); |
1796 | dREQ (REQ_TXN_COMMIT); |
1588 | req->txn = txn; |
1797 | req->txn = txn; |
1589 | req->uint1 = flags; |
1798 | req->uint1 = flags; |
1590 | REQ_SEND; |
1799 | REQ_SEND; |
1591 | ptr_nuke (ST (0)); |
1800 | ptr_nuke (ST (0)); |
1592 | } |
1801 | } |
1593 | |
1802 | |
1594 | void |
1803 | void |
1595 | db_txn_abort (DB_TXN *txn, SV *callback = &PL_sv_undef) |
1804 | db_txn_abort (DB_TXN *txn, SV *callback = 0) |
|
|
1805 | PREINIT: |
|
|
1806 | CALLBACK |
1596 | CODE: |
1807 | CODE: |
1597 | { |
1808 | { |
1598 | dREQ (REQ_TXN_ABORT); |
1809 | dREQ (REQ_TXN_ABORT); |
1599 | req->txn = txn; |
1810 | req->txn = txn; |
1600 | REQ_SEND; |
1811 | REQ_SEND; |
1601 | ptr_nuke (ST (0)); |
1812 | ptr_nuke (ST (0)); |
1602 | } |
1813 | } |
1603 | |
1814 | |
1604 | void |
1815 | void |
1605 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1816 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1817 | PREINIT: |
|
|
1818 | CALLBACK |
1606 | CODE: |
1819 | CODE: |
1607 | { |
1820 | { |
1608 | dREQ (REQ_TXN_FINISH); |
1821 | dREQ (REQ_TXN_FINISH); |
1609 | req->txn = txn; |
1822 | req->txn = txn; |
1610 | req->uint1 = flags; |
1823 | req->uint1 = flags; |
1611 | REQ_SEND; |
1824 | REQ_SEND; |
1612 | ptr_nuke (ST (0)); |
1825 | ptr_nuke (ST (0)); |
1613 | } |
1826 | } |
1614 | |
1827 | |
1615 | void |
1828 | void |
1616 | db_c_close (DBC *dbc, SV *callback = &PL_sv_undef) |
1829 | db_c_close (DBC *dbc, SV *callback = 0) |
|
|
1830 | PREINIT: |
|
|
1831 | CALLBACK |
1617 | CODE: |
1832 | CODE: |
1618 | { |
1833 | { |
1619 | dREQ (REQ_C_CLOSE); |
1834 | dREQ (REQ_C_CLOSE); |
1620 | req->dbc = dbc; |
1835 | req->dbc = dbc; |
1621 | REQ_SEND; |
1836 | REQ_SEND; |
1622 | ptr_nuke (ST (0)); |
1837 | ptr_nuke (ST (0)); |
1623 | } |
1838 | } |
1624 | |
1839 | |
1625 | void |
1840 | void |
1626 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = &PL_sv_undef) |
1841 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) |
|
|
1842 | PREINIT: |
|
|
1843 | CALLBACK |
1627 | CODE: |
1844 | CODE: |
1628 | { |
1845 | { |
1629 | dREQ (REQ_C_COUNT); |
1846 | dREQ (REQ_C_COUNT); |
1630 | req->dbc = dbc; |
1847 | req->dbc = dbc; |
1631 | req->sv1 = SvREFCNT_inc (count); |
1848 | req->sv1 = SvREFCNT_inc (count); |
1632 | REQ_SEND; |
1849 | REQ_SEND; |
1633 | } |
1850 | } |
1634 | |
1851 | |
1635 | void |
1852 | void |
1636 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1853 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1854 | PREINIT: |
|
|
1855 | CALLBACK |
1637 | CODE: |
1856 | CODE: |
1638 | { |
1857 | { |
1639 | dREQ (REQ_C_PUT); |
1858 | dREQ (REQ_C_PUT); |
1640 | req->dbc = dbc; |
1859 | req->dbc = dbc; |
1641 | sv_to_dbt (&req->dbt1, key); |
1860 | sv_to_dbt (&req->dbt1, key); |
… | |
… | |
1643 | req->uint1 = flags; |
1862 | req->uint1 = flags; |
1644 | REQ_SEND; |
1863 | REQ_SEND; |
1645 | } |
1864 | } |
1646 | |
1865 | |
1647 | void |
1866 | void |
1648 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1867 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1868 | PREINIT: |
|
|
1869 | CALLBACK |
1649 | CODE: |
1870 | CODE: |
1650 | { |
1871 | { |
1651 | dREQ (REQ_C_GET); |
1872 | dREQ (REQ_C_GET); |
1652 | req->dbc = dbc; |
1873 | req->dbc = dbc; |
1653 | req->uint1 = flags; |
1874 | req->uint1 = flags; |
… | |
… | |
1668 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1889 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1669 | REQ_SEND; |
1890 | REQ_SEND; |
1670 | } |
1891 | } |
1671 | |
1892 | |
1672 | void |
1893 | void |
1673 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1894 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1895 | PREINIT: |
|
|
1896 | CALLBACK |
1674 | CODE: |
1897 | CODE: |
1675 | { |
1898 | { |
1676 | dREQ (REQ_C_PGET); |
1899 | dREQ (REQ_C_PGET); |
1677 | req->dbc = dbc; |
1900 | req->dbc = dbc; |
1678 | req->uint1 = flags; |
1901 | req->uint1 = flags; |
… | |
… | |
1696 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1919 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1697 | REQ_SEND; |
1920 | REQ_SEND; |
1698 | } |
1921 | } |
1699 | |
1922 | |
1700 | void |
1923 | void |
1701 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = &PL_sv_undef) |
1924 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0) |
|
|
1925 | PREINIT: |
|
|
1926 | CALLBACK |
1702 | CODE: |
1927 | CODE: |
1703 | { |
1928 | { |
1704 | dREQ (REQ_C_DEL); |
1929 | dREQ (REQ_C_DEL); |
1705 | req->dbc = dbc; |
1930 | req->dbc = dbc; |
1706 | req->uint1 = flags; |
1931 | req->uint1 = flags; |
1707 | REQ_SEND; |
1932 | REQ_SEND; |
1708 | } |
1933 | } |
1709 | |
1934 | |
1710 | |
1935 | |
|
|
1936 | #if DB_VERSION_MINOR >= 3 |
|
|
1937 | |
1711 | void |
1938 | void |
1712 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1939 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1940 | PREINIT: |
|
|
1941 | CALLBACK |
1713 | CODE: |
1942 | CODE: |
1714 | { |
1943 | { |
1715 | dREQ (REQ_SEQ_OPEN); |
1944 | dREQ (REQ_SEQ_OPEN); |
1716 | req->seq = seq; |
1945 | req->seq = seq; |
1717 | req->txn = txnid; |
1946 | req->txn = txnid; |
… | |
… | |
1719 | sv_to_dbt (&req->dbt1, key); |
1948 | sv_to_dbt (&req->dbt1, key); |
1720 | REQ_SEND; |
1949 | REQ_SEND; |
1721 | } |
1950 | } |
1722 | |
1951 | |
1723 | void |
1952 | void |
1724 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = &PL_sv_undef) |
1953 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) |
|
|
1954 | PREINIT: |
|
|
1955 | CALLBACK |
1725 | CODE: |
1956 | CODE: |
1726 | { |
1957 | { |
1727 | dREQ (REQ_SEQ_CLOSE); |
1958 | dREQ (REQ_SEQ_CLOSE); |
1728 | req->seq = seq; |
1959 | req->seq = seq; |
1729 | req->uint1 = flags; |
1960 | req->uint1 = flags; |
1730 | REQ_SEND; |
1961 | REQ_SEND; |
1731 | ptr_nuke (ST (0)); |
1962 | ptr_nuke (ST (0)); |
1732 | } |
1963 | } |
1733 | |
1964 | |
1734 | void |
1965 | void |
1735 | 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) |
1966 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) |
|
|
1967 | PREINIT: |
|
|
1968 | CALLBACK |
1736 | CODE: |
1969 | CODE: |
1737 | { |
1970 | { |
1738 | dREQ (REQ_SEQ_GET); |
1971 | dREQ (REQ_SEQ_GET); |
1739 | req->seq = seq; |
1972 | req->seq = seq; |
1740 | req->txn = txnid; |
1973 | req->txn = txnid; |
… | |
… | |
1743 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1976 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1744 | REQ_SEND; |
1977 | REQ_SEND; |
1745 | } |
1978 | } |
1746 | |
1979 | |
1747 | void |
1980 | void |
1748 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1981 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) |
|
|
1982 | PREINIT: |
|
|
1983 | CALLBACK |
1749 | CODE: |
1984 | CODE: |
1750 | { |
1985 | { |
1751 | dREQ (REQ_SEQ_REMOVE); |
1986 | dREQ (REQ_SEQ_REMOVE); |
1752 | req->seq = seq; |
1987 | req->seq = seq; |
1753 | req->txn = txnid; |
1988 | req->txn = txnid; |
1754 | req->uint1 = flags; |
1989 | req->uint1 = flags; |
1755 | REQ_SEND; |
1990 | REQ_SEND; |
1756 | } |
1991 | } |
1757 | |
1992 | |
|
|
1993 | #endif |
|
|
1994 | |
1758 | |
1995 | |
1759 | MODULE = BDB PACKAGE = BDB::Env |
1996 | MODULE = BDB PACKAGE = BDB::Env |
1760 | |
1997 | |
1761 | void |
1998 | void |
1762 | DESTROY (DB_ENV_ornuked *env) |
1999 | DESTROY (DB_ENV_ornuked *env) |
… | |
… | |
1798 | CODE: |
2035 | CODE: |
1799 | RETVAL = env->set_flags (env, flags, onoff); |
2036 | RETVAL = env->set_flags (env, flags, onoff); |
1800 | OUTPUT: |
2037 | OUTPUT: |
1801 | RETVAL |
2038 | RETVAL |
1802 | |
2039 | |
|
|
2040 | #if DB_VERSION_MINOR >= 7 |
|
|
2041 | |
|
|
2042 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
|
|
2043 | CODE: |
|
|
2044 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
|
|
2045 | OUTPUT: |
|
|
2046 | RETVAL |
|
|
2047 | |
|
|
2048 | int log_set_config (DB_ENV *env, U32 flags, int onoff = 1) |
|
|
2049 | CODE: |
|
|
2050 | RETVAL = env->log_set_config (env, flags, onoff); |
|
|
2051 | OUTPUT: |
|
|
2052 | RETVAL |
|
|
2053 | |
|
|
2054 | #endif |
|
|
2055 | |
|
|
2056 | |
1803 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
2057 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
1804 | CODE: |
2058 | CODE: |
1805 | env->set_errfile (env, errfile); |
2059 | env->set_errfile (env, errfile); |
1806 | |
2060 | |
1807 | void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
2061 | void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
… | |
… | |
1877 | int set_lg_max (DB_ENV *env, U32 max) |
2131 | int set_lg_max (DB_ENV *env, U32 max) |
1878 | CODE: |
2132 | CODE: |
1879 | RETVAL = env->set_lg_max (env, max); |
2133 | RETVAL = env->set_lg_max (env, max); |
1880 | OUTPUT: |
2134 | OUTPUT: |
1881 | RETVAL |
2135 | RETVAL |
|
|
2136 | |
|
|
2137 | #if DB_VERSION_MINOR >= 4 |
1882 | |
2138 | |
1883 | int mutex_set_max (DB_ENV *env, U32 max) |
2139 | int mutex_set_max (DB_ENV *env, U32 max) |
1884 | CODE: |
2140 | CODE: |
1885 | RETVAL = env->mutex_set_max (env, max); |
2141 | RETVAL = env->mutex_set_max (env, max); |
1886 | OUTPUT: |
2142 | OUTPUT: |
… | |
… | |
1902 | CODE: |
2158 | CODE: |
1903 | RETVAL = env->mutex_set_align (env, align); |
2159 | RETVAL = env->mutex_set_align (env, align); |
1904 | OUTPUT: |
2160 | OUTPUT: |
1905 | RETVAL |
2161 | RETVAL |
1906 | |
2162 | |
|
|
2163 | #endif |
|
|
2164 | |
1907 | DB_TXN * |
2165 | DB_TXN * |
1908 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
2166 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
1909 | CODE: |
2167 | CODE: |
1910 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
2168 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
1911 | if (errno) |
2169 | if (errno) |
1912 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2170 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
1913 | OUTPUT: |
2171 | OUTPUT: |
1914 | RETVAL |
2172 | RETVAL |
|
|
2173 | |
|
|
2174 | #if DB_VERSION_MINOR >= 5 |
|
|
2175 | |
|
|
2176 | DB_TXN * |
|
|
2177 | cdsgroup_begin (DB_ENV *env) |
|
|
2178 | CODE: |
|
|
2179 | errno = env->cdsgroup_begin (env, &RETVAL); |
|
|
2180 | if (errno) |
|
|
2181 | croak ("DB_ENV->cdsgroup_begin: %s", db_strerror (errno)); |
|
|
2182 | OUTPUT: |
|
|
2183 | RETVAL |
|
|
2184 | |
|
|
2185 | #endif |
1915 | |
2186 | |
1916 | MODULE = BDB PACKAGE = BDB::Db |
2187 | MODULE = BDB PACKAGE = BDB::Db |
1917 | |
2188 | |
1918 | void |
2189 | void |
1919 | DESTROY (DB_ornuked *db) |
2190 | DESTROY (DB_ornuked *db) |
… | |
… | |
2004 | if (errno) |
2275 | if (errno) |
2005 | croak ("DB->cursor: %s", db_strerror (errno)); |
2276 | croak ("DB->cursor: %s", db_strerror (errno)); |
2006 | OUTPUT: |
2277 | OUTPUT: |
2007 | RETVAL |
2278 | RETVAL |
2008 | |
2279 | |
|
|
2280 | #if DB_VERSION_MINOR >= 3 |
|
|
2281 | |
2009 | DB_SEQUENCE * |
2282 | DB_SEQUENCE * |
2010 | sequence (DB *db, U32 flags = 0) |
2283 | sequence (DB *db, U32 flags = 0) |
2011 | CODE: |
2284 | CODE: |
2012 | { |
2285 | { |
2013 | errno = db_sequence_create (&RETVAL, db, flags); |
2286 | errno = db_sequence_create (&RETVAL, db, flags); |
… | |
… | |
2015 | croak ("db_sequence_create: %s", db_strerror (errno)); |
2288 | croak ("db_sequence_create: %s", db_strerror (errno)); |
2016 | } |
2289 | } |
2017 | OUTPUT: |
2290 | OUTPUT: |
2018 | RETVAL |
2291 | RETVAL |
2019 | |
2292 | |
|
|
2293 | #endif |
|
|
2294 | |
2020 | |
2295 | |
2021 | MODULE = BDB PACKAGE = BDB::Txn |
2296 | MODULE = BDB PACKAGE = BDB::Txn |
2022 | |
2297 | |
2023 | void |
2298 | void |
2024 | DESTROY (DB_TXN_ornuked *txn) |
2299 | DESTROY (DB_TXN_ornuked *txn) |
… | |
… | |
2053 | CODE: |
2328 | CODE: |
2054 | dbc->set_priority (dbc, priority); |
2329 | dbc->set_priority (dbc, priority); |
2055 | |
2330 | |
2056 | #endif |
2331 | #endif |
2057 | |
2332 | |
|
|
2333 | #if DB_VERSION_MINOR >= 3 |
|
|
2334 | |
2058 | MODULE = BDB PACKAGE = BDB::Sequence |
2335 | MODULE = BDB PACKAGE = BDB::Sequence |
2059 | |
2336 | |
2060 | void |
2337 | void |
2061 | DESTROY (DB_SEQUENCE_ornuked *seq) |
2338 | DESTROY (DB_SEQUENCE_ornuked *seq) |
2062 | CODE: |
2339 | CODE: |
… | |
… | |
2085 | CODE: |
2362 | CODE: |
2086 | RETVAL = seq->set_range (seq, min, max); |
2363 | RETVAL = seq->set_range (seq, min, max); |
2087 | OUTPUT: |
2364 | OUTPUT: |
2088 | RETVAL |
2365 | RETVAL |
2089 | |
2366 | |
|
|
2367 | #endif |
2090 | |
2368 | |
|
|
2369 | |