… | |
… | |
31 | # include <unistd.h> |
31 | # include <unistd.h> |
32 | #endif |
32 | #endif |
33 | |
33 | |
34 | #include <db.h> |
34 | #include <db.h> |
35 | |
35 | |
36 | #if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) |
36 | #define DBVER DB_VERSION_MAJOR * 100 + DB_VERSION_MINOR |
|
|
37 | |
|
|
38 | #if DBVER < 403 |
37 | # error you need Berkeley DB 4.3 or a newer 4.x version installed |
39 | # error you need Berkeley DB 4.3 or a newer version installed |
38 | #endif |
40 | #endif |
39 | |
41 | |
40 | /* number of seconds after which idle threads exit */ |
42 | /* number of seconds after which idle threads exit */ |
41 | #define IDLE_TIMEOUT 10 |
43 | #define IDLE_TIMEOUT 10 |
42 | |
44 | |
… | |
… | |
50 | typedef DB_ENV DB_ENV_ornuked; |
52 | typedef DB_ENV DB_ENV_ornuked; |
51 | typedef DB_TXN DB_TXN_ornuked; |
53 | typedef DB_TXN DB_TXN_ornuked; |
52 | typedef DBC DBC_ornuked; |
54 | typedef DBC DBC_ornuked; |
53 | typedef DB DB_ornuked; |
55 | typedef DB DB_ornuked; |
54 | |
56 | |
55 | #if DB_VERSION_MINOR >= 3 |
57 | #if DBVER >= 403 |
56 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
58 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
57 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
59 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
58 | #endif |
60 | #endif |
59 | |
61 | |
60 | typedef char *bdb_filename; |
62 | typedef char *bdb_filename; |
… | |
… | |
67 | *bdb_txn_stash, |
69 | *bdb_txn_stash, |
68 | *bdb_cursor_stash, |
70 | *bdb_cursor_stash, |
69 | *bdb_db_stash, |
71 | *bdb_db_stash, |
70 | *bdb_sequence_stash; |
72 | *bdb_sequence_stash; |
71 | |
73 | |
72 | #if DB_VERSION_MINOR >= 6 |
74 | #if DBVER >= 406 |
73 | # define c_close close |
75 | # define c_close close |
74 | # define c_count count |
76 | # define c_count count |
75 | # define c_del del |
77 | # define c_del del |
76 | # define c_dup dup |
78 | # define c_dup dup |
77 | # define c_get get |
79 | # define c_get get |
… | |
… | |
159 | |
161 | |
160 | enum { |
162 | enum { |
161 | REQ_QUIT, |
163 | REQ_QUIT, |
162 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
164 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
163 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
165 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
164 | REQ_ENV_LOG_ARCHIVE, |
166 | REQ_ENV_LOG_ARCHIVE, REQ_ENV_LSN_RESET, |
165 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_VERIFY, REQ_DB_UPGRADE, |
167 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_VERIFY, REQ_DB_UPGRADE, |
166 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
168 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
167 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
169 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
168 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
170 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
169 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
171 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
… | |
… | |
186 | char *buf1, *buf2, *buf3; |
188 | char *buf1, *buf2, *buf3; |
187 | SV *sv1, *sv2, *sv3; |
189 | SV *sv1, *sv2, *sv3; |
188 | |
190 | |
189 | DBT dbt1, dbt2, dbt3; |
191 | DBT dbt1, dbt2, dbt3; |
190 | DB_KEY_RANGE key_range; |
192 | DB_KEY_RANGE key_range; |
191 | #if DB_VERSION_MINOR >= 3 |
193 | #if DBVER >= 403 |
192 | DB_SEQUENCE *seq; |
194 | DB_SEQUENCE *seq; |
193 | db_seq_t seq_t; |
195 | db_seq_t seq_t; |
194 | #endif |
196 | #endif |
195 | |
197 | |
196 | SV *rsv1, *rsv2; // keep some request objects alive |
198 | SV *rsv1, *rsv2; // keep some request objects alive |
… | |
… | |
224 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
226 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
225 | |
227 | |
226 | static unsigned int started, idle, wanted; |
228 | static unsigned int started, idle, wanted; |
227 | |
229 | |
228 | /* worker threads management */ |
230 | /* worker threads management */ |
229 | static mutex_t wrklock = X_MUTEX_INIT; |
231 | static xmutex_t wrklock = X_MUTEX_INIT; |
230 | |
232 | |
231 | typedef struct worker { |
233 | typedef struct worker { |
232 | /* locked by wrklock */ |
234 | /* locked by wrklock */ |
233 | struct worker *prev, *next; |
235 | struct worker *prev, *next; |
234 | |
236 | |
235 | thread_t tid; |
237 | xthread_t tid; |
236 | |
238 | |
237 | /* locked by reslock, reqlock or wrklock */ |
239 | /* locked by reslock, reqlock or wrklock */ |
238 | bdb_req req; /* currently processed request */ |
240 | bdb_req req; /* currently processed request */ |
239 | void *dbuf; |
241 | void *dbuf; |
240 | DIR *dirp; |
242 | DIR *dirp; |
… | |
… | |
257 | static volatile unsigned int nreqs, nready, npending; |
259 | static volatile unsigned int nreqs, nready, npending; |
258 | static volatile unsigned int max_idle = 4; |
260 | static volatile unsigned int max_idle = 4; |
259 | static volatile unsigned int max_outstanding = 0xffffffff; |
261 | static volatile unsigned int max_outstanding = 0xffffffff; |
260 | static s_epipe respipe; |
262 | static s_epipe respipe; |
261 | |
263 | |
262 | static mutex_t reslock = X_MUTEX_INIT; |
264 | static xmutex_t reslock = X_MUTEX_INIT; |
263 | static mutex_t reqlock = X_MUTEX_INIT; |
265 | static xmutex_t reqlock = X_MUTEX_INIT; |
264 | static cond_t reqwait = X_COND_INIT; |
266 | static xcond_t reqwait = X_COND_INIT; |
265 | |
267 | |
266 | #if WORDACCESS_UNSAFE |
268 | #if WORDACCESS_UNSAFE |
267 | |
269 | |
268 | static unsigned int get_nready (void) |
270 | static unsigned int get_nready (void) |
269 | { |
271 | { |
… | |
… | |
397 | SvREFCNT_dec (av); |
399 | SvREFCNT_dec (av); |
398 | SvREFCNT_dec (req->sv1); |
400 | SvREFCNT_dec (req->sv1); |
399 | } |
401 | } |
400 | break; |
402 | break; |
401 | |
403 | |
402 | #if DB_VERSION_MINOR >= 3 |
404 | #if DBVER >= 403 |
403 | case REQ_SEQ_GET: |
405 | case REQ_SEQ_GET: |
404 | SvREADONLY_off (req->sv1); |
406 | SvREADONLY_off (req->sv1); |
405 | |
407 | |
406 | if (sizeof (IV) > 4) |
408 | if (sizeof (IV) > 4) |
407 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
409 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
… | |
… | |
484 | |
486 | |
485 | if (!wrk) |
487 | if (!wrk) |
486 | croak ("unable to allocate worker thread data"); |
488 | croak ("unable to allocate worker thread data"); |
487 | |
489 | |
488 | X_LOCK (wrklock); |
490 | X_LOCK (wrklock); |
489 | if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) |
491 | if (xthread_create (&wrk->tid, bdb_proc, (void *)wrk)) |
490 | { |
492 | { |
491 | wrk->prev = &wrk_first; |
493 | wrk->prev = &wrk_first; |
492 | wrk->next = wrk_first.next; |
494 | wrk->next = wrk_first.next; |
493 | wrk_first.next->prev = wrk; |
495 | wrk_first.next->prev = wrk; |
494 | wrk_first.next = wrk; |
496 | wrk_first.next = wrk; |
… | |
… | |
749 | |
751 | |
750 | case REQ_DB_CLOSE: |
752 | case REQ_DB_CLOSE: |
751 | req->result = req->db->close (req->db, req->uint1); |
753 | req->result = req->db->close (req->db, req->uint1); |
752 | break; |
754 | break; |
753 | |
755 | |
754 | #if DB_VERSION_MINOR >= 4 |
756 | #if DBVER >= 404 |
755 | case REQ_DB_COMPACT: |
757 | case REQ_DB_COMPACT: |
756 | req->result = req->db->compact (req->db, req->txn, req->dbt1.data ? &req->dbt1 : 0, req->dbt2.data ? &req->dbt2 : 0, 0, req->uint1, 0); |
758 | req->result = req->db->compact (req->db, req->txn, req->dbt1.data ? &req->dbt1 : 0, req->dbt2.data ? &req->dbt2 : 0, 0, req->uint1, 0); |
757 | break; |
759 | break; |
758 | #endif |
760 | #endif |
759 | |
761 | |
… | |
… | |
771 | |
773 | |
772 | case REQ_DB_PUT: |
774 | case REQ_DB_PUT: |
773 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
775 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
774 | break; |
776 | break; |
775 | |
777 | |
776 | #if DB_VERSION_MINOR >= 6 |
778 | #if DBVER >= 406 |
777 | case REQ_DB_EXISTS: |
779 | case REQ_DB_EXISTS: |
778 | req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
780 | req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
779 | break; |
781 | break; |
780 | #endif |
782 | #endif |
781 | case REQ_DB_GET: |
783 | case REQ_DB_GET: |
… | |
… | |
839 | |
841 | |
840 | case REQ_C_DEL: |
842 | case REQ_C_DEL: |
841 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
843 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
842 | break; |
844 | break; |
843 | |
845 | |
844 | #if DB_VERSION_MINOR >= 3 |
846 | #if DBVER >= 403 |
845 | case REQ_SEQ_OPEN: |
847 | case REQ_SEQ_OPEN: |
846 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
848 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
847 | break; |
849 | break; |
848 | |
850 | |
849 | case REQ_SEQ_CLOSE: |
851 | case REQ_SEQ_CLOSE: |
… | |
… | |
856 | |
858 | |
857 | case REQ_SEQ_REMOVE: |
859 | case REQ_SEQ_REMOVE: |
858 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
860 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
859 | break; |
861 | break; |
860 | #endif |
862 | #endif |
|
|
863 | |
|
|
864 | case REQ_ENV_LSN_RESET: |
|
|
865 | req->result = req->env->lsn_reset (req->env, req->buf1, req->uint1); |
|
|
866 | break; |
861 | |
867 | |
862 | case REQ_ENV_LOG_ARCHIVE: |
868 | case REQ_ENV_LOG_ARCHIVE: |
863 | { |
869 | { |
864 | char **listp = 0; /* DB_ARCH_REMOVE does not touch listp, contrary to docs */ |
870 | char **listp = 0; /* DB_ARCH_REMOVE does not touch listp, contrary to docs */ |
865 | req->result = req->env->log_archive (req->env, &listp, req->uint1); |
871 | req->result = req->env->log_archive (req->env, &listp, req->uint1); |
… | |
… | |
1012 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
1018 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
1013 | \ |
1019 | \ |
1014 | if (callback && SvOK (callback)) \ |
1020 | if (callback && SvOK (callback)) \ |
1015 | croak ("callback has illegal type or extra arguments"); \ |
1021 | croak ("callback has illegal type or extra arguments"); \ |
1016 | \ |
1022 | \ |
1017 | Newz (0, req, 1, bdb_cb); \ |
1023 | Newz (0, req, 1, bdb_cb); \ |
1018 | if (!req) \ |
1024 | if (!req) \ |
1019 | croak ("out of memory during bdb_req allocation"); \ |
1025 | croak ("out of memory during bdb_req allocation"); \ |
1020 | \ |
1026 | \ |
1021 | req->callback = SvREFCNT_inc (cb); \ |
1027 | req->callback = SvREFCNT_inc (cb); \ |
1022 | req->type = (reqtype); \ |
1028 | req->type = (reqtype); \ |
1023 | req->pri = req_pri; \ |
1029 | req->pri = req_pri; \ |
1024 | if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \ |
1030 | if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \ |
1025 | if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \ |
1031 | if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \ |
1026 | (void)0; |
1032 | (void)0; |
1027 | |
1033 | |
1028 | #define REQ_SEND \ |
1034 | #define REQ_SEND \ |
1029 | req_send (req) |
1035 | req_send (req) |
1030 | |
1036 | |
1031 | #define SvPTR(var, arg, type, stash, class, nullok) \ |
1037 | #define SvPTR(var, arg, type, stash, class, nullok) \ |
1032 | if (!SvOK (arg)) \ |
1038 | if (!SvOK (arg)) \ |
1033 | { \ |
1039 | { \ |
1034 | if (nullok != 1) \ |
1040 | if (nullok != 1) \ |
1035 | croak (# var " must be a " # class " object, not undef"); \ |
1041 | croak (# var " must be a " # class " object, not undef"); \ |
1036 | \ |
1042 | \ |
… | |
… | |
1188 | |
1194 | |
1189 | PROTOTYPES: ENABLE |
1195 | PROTOTYPES: ENABLE |
1190 | |
1196 | |
1191 | BOOT: |
1197 | BOOT: |
1192 | { |
1198 | { |
1193 | bdb_stash = gv_stashpv ("BDB" , 1); |
|
|
1194 | bdb_env_stash = gv_stashpv ("BDB::Env" , 1); |
|
|
1195 | bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1); |
|
|
1196 | bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1); |
|
|
1197 | bdb_db_stash = gv_stashpv ("BDB::Db" , 1); |
|
|
1198 | bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1); |
|
|
1199 | |
|
|
1200 | static const struct { |
1199 | static const struct { |
1201 | const char *name; |
1200 | const char *name; |
1202 | IV iv; |
1201 | IV iv; |
1203 | } *civ, const_iv[] = { |
1202 | } *civ, const_iv[] = { |
1204 | #define const_iv(name) { # name, (IV)DB_ ## name }, |
1203 | #define const_iv(name) { # name, (IV)DB_ ## name }, |
|
|
1204 | #if DBVER <= 408 |
1205 | const_iv (RPCCLIENT) |
1205 | const_iv (RPCCLIENT) |
|
|
1206 | #endif |
1206 | const_iv (INIT_CDB) |
1207 | const_iv (INIT_CDB) |
1207 | const_iv (INIT_LOCK) |
1208 | const_iv (INIT_LOCK) |
1208 | const_iv (INIT_LOG) |
1209 | const_iv (INIT_LOG) |
1209 | const_iv (INIT_MPOOL) |
1210 | const_iv (INIT_MPOOL) |
1210 | const_iv (INIT_REP) |
1211 | const_iv (INIT_REP) |
… | |
… | |
1233 | const_iv (TXN_NOT_DURABLE) |
1234 | const_iv (TXN_NOT_DURABLE) |
1234 | const_iv (TXN_WRITE_NOSYNC) |
1235 | const_iv (TXN_WRITE_NOSYNC) |
1235 | const_iv (WRITECURSOR) |
1236 | const_iv (WRITECURSOR) |
1236 | const_iv (YIELDCPU) |
1237 | const_iv (YIELDCPU) |
1237 | const_iv (ENCRYPT_AES) |
1238 | const_iv (ENCRYPT_AES) |
|
|
1239 | #if DBVER < 408 |
1238 | const_iv (XA_CREATE) |
1240 | const_iv (XA_CREATE) |
|
|
1241 | #endif |
1239 | const_iv (BTREE) |
1242 | const_iv (BTREE) |
1240 | const_iv (HASH) |
1243 | const_iv (HASH) |
1241 | const_iv (QUEUE) |
1244 | const_iv (QUEUE) |
1242 | const_iv (RECNO) |
1245 | const_iv (RECNO) |
1243 | const_iv (UNKNOWN) |
1246 | const_iv (UNKNOWN) |
… | |
… | |
1307 | const_iv (LOCK_OLDEST) |
1310 | const_iv (LOCK_OLDEST) |
1308 | const_iv (LOCK_RANDOM) |
1311 | const_iv (LOCK_RANDOM) |
1309 | const_iv (LOCK_YOUNGEST) |
1312 | const_iv (LOCK_YOUNGEST) |
1310 | |
1313 | |
1311 | const_iv (DONOTINDEX) |
1314 | const_iv (DONOTINDEX) |
1312 | const_iv (KEYEMPTY ) |
1315 | const_iv (KEYEMPTY) |
1313 | const_iv (KEYEXIST ) |
1316 | const_iv (KEYEXIST) |
1314 | const_iv (LOCK_DEADLOCK) |
1317 | const_iv (LOCK_DEADLOCK) |
1315 | const_iv (LOCK_NOTGRANTED) |
1318 | const_iv (LOCK_NOTGRANTED) |
1316 | const_iv (NOSERVER) |
1319 | const_iv (NOSERVER) |
|
|
1320 | #if DBVER < 502 |
1317 | const_iv (NOSERVER_HOME) |
1321 | const_iv (NOSERVER_HOME) |
1318 | const_iv (NOSERVER_ID) |
1322 | const_iv (NOSERVER_ID) |
|
|
1323 | #endif |
1319 | const_iv (NOTFOUND) |
1324 | const_iv (NOTFOUND) |
1320 | const_iv (PAGE_NOTFOUND) |
1325 | const_iv (PAGE_NOTFOUND) |
1321 | const_iv (REP_DUPMASTER) |
1326 | const_iv (REP_DUPMASTER) |
1322 | const_iv (REP_HANDLE_DEAD) |
1327 | const_iv (REP_HANDLE_DEAD) |
1323 | const_iv (REP_HOLDELECTION) |
1328 | const_iv (REP_HOLDELECTION) |
… | |
… | |
1347 | const_iv (VERB_WAITSFOR) |
1352 | const_iv (VERB_WAITSFOR) |
1348 | |
1353 | |
1349 | const_iv (VERSION_MAJOR) |
1354 | const_iv (VERSION_MAJOR) |
1350 | const_iv (VERSION_MINOR) |
1355 | const_iv (VERSION_MINOR) |
1351 | const_iv (VERSION_PATCH) |
1356 | const_iv (VERSION_PATCH) |
1352 | #if DB_VERSION_MINOR >= 3 |
1357 | const_iv (LOGVERSION) |
|
|
1358 | const_iv (LOGOLDVER) |
|
|
1359 | #if DBVER >= 403 |
1353 | const_iv (INORDER) |
1360 | const_iv (INORDER) |
1354 | const_iv (LOCK_MAXWRITE) |
1361 | const_iv (LOCK_MAXWRITE) |
1355 | const_iv (SEQ_DEC) |
1362 | const_iv (SEQ_DEC) |
1356 | const_iv (SEQ_INC) |
1363 | const_iv (SEQ_INC) |
1357 | const_iv (SEQ_WRAP) |
1364 | const_iv (SEQ_WRAP) |
1358 | const_iv (BUFFER_SMALL) |
1365 | const_iv (BUFFER_SMALL) |
1359 | const_iv (LOG_BUFFER_FULL) |
1366 | const_iv (LOG_BUFFER_FULL) |
1360 | const_iv (VERSION_MISMATCH) |
1367 | const_iv (VERSION_MISMATCH) |
1361 | #endif |
1368 | #endif |
1362 | #if DB_VERSION_MINOR >= 4 |
1369 | #if DBVER >= 404 |
1363 | const_iv (REGISTER) |
1370 | const_iv (REGISTER) |
1364 | const_iv (DSYNC_DB) |
1371 | const_iv (DSYNC_DB) |
1365 | const_iv (READ_COMMITTED) |
1372 | const_iv (READ_COMMITTED) |
1366 | const_iv (READ_UNCOMMITTED) |
1373 | const_iv (READ_UNCOMMITTED) |
1367 | const_iv (REP_IGNORE) |
1374 | const_iv (REP_IGNORE) |
… | |
… | |
1369 | const_iv (REP_JOIN_FAILURE) |
1376 | const_iv (REP_JOIN_FAILURE) |
1370 | const_iv (FREE_SPACE) |
1377 | const_iv (FREE_SPACE) |
1371 | const_iv (FREELIST_ONLY) |
1378 | const_iv (FREELIST_ONLY) |
1372 | const_iv (VERB_REGISTER) |
1379 | const_iv (VERB_REGISTER) |
1373 | #endif |
1380 | #endif |
1374 | #if DB_VERSION_MINOR >= 5 |
1381 | #if DBVER >= 405 |
1375 | const_iv (MULTIVERSION) |
1382 | const_iv (MULTIVERSION) |
1376 | const_iv (TXN_SNAPSHOT) |
1383 | const_iv (TXN_SNAPSHOT) |
1377 | #endif |
1384 | #endif |
1378 | #if DB_VERSION_MINOR >= 6 |
1385 | #if DBVER >= 406 |
1379 | const_iv (PREV_DUP) |
1386 | const_iv (PREV_DUP) |
1380 | const_iv (PRIORITY_UNCHANGED) |
1387 | const_iv (PRIORITY_UNCHANGED) |
1381 | const_iv (PRIORITY_VERY_LOW) |
1388 | const_iv (PRIORITY_VERY_LOW) |
1382 | const_iv (PRIORITY_LOW) |
1389 | const_iv (PRIORITY_LOW) |
1383 | const_iv (PRIORITY_DEFAULT) |
1390 | const_iv (PRIORITY_DEFAULT) |
1384 | const_iv (PRIORITY_HIGH) |
1391 | const_iv (PRIORITY_HIGH) |
1385 | const_iv (PRIORITY_VERY_HIGH) |
1392 | const_iv (PRIORITY_VERY_HIGH) |
1386 | const_iv (IGNORE_LEASE) |
1393 | const_iv (IGNORE_LEASE) |
1387 | #endif |
1394 | #endif |
1388 | #if DB_VERSION_MINOR >= 7 |
1395 | #if DBVER >= 407 |
1389 | //const_iv (MULTIPLE_KEY) |
1396 | //const_iv (MULTIPLE_KEY) |
1390 | const_iv (LOG_DIRECT) |
1397 | const_iv (LOG_DIRECT) |
1391 | const_iv (LOG_DSYNC) |
1398 | const_iv (LOG_DSYNC) |
1392 | const_iv (LOG_AUTO_REMOVE) |
1399 | const_iv (LOG_AUTO_REMOVE) |
1393 | const_iv (LOG_IN_MEMORY) |
1400 | const_iv (LOG_IN_MEMORY) |
1394 | const_iv (LOG_ZERO) |
1401 | const_iv (LOG_ZERO) |
1395 | #else |
1402 | #else |
1396 | const_iv (DIRECT_LOG) |
1403 | const_iv (DIRECT_LOG) |
1397 | const_iv (LOG_AUTOREMOVE) |
1404 | const_iv (LOG_AUTOREMOVE) |
1398 | # if DB_VERSION_MINOR >= 3 |
1405 | # if DBVER >= 403 |
1399 | const_iv (DSYNC_LOG) |
1406 | const_iv (DSYNC_LOG) |
1400 | const_iv (LOG_INMEMORY) |
1407 | const_iv (LOG_INMEMORY) |
1401 | # endif |
1408 | # endif |
|
|
1409 | #if DBVER >= 408 |
|
|
1410 | const_iv (LOGVERSION_LATCHING) |
|
|
1411 | #endif |
1402 | #endif |
1412 | #endif |
1403 | }; |
1413 | }; |
1404 | |
1414 | |
|
|
1415 | bdb_stash = gv_stashpv ("BDB" , 1); |
|
|
1416 | bdb_env_stash = gv_stashpv ("BDB::Env" , 1); |
|
|
1417 | bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1); |
|
|
1418 | bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1); |
|
|
1419 | bdb_db_stash = gv_stashpv ("BDB::Db" , 1); |
|
|
1420 | bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1); |
|
|
1421 | |
1405 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1422 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
1406 | newCONSTSUB (bdb_stash, (char *)civ->name, newSViv (civ->iv)); |
1423 | newCONSTSUB (bdb_stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
1407 | |
1424 | |
1408 | prepare_cb = &PL_sv_undef; |
1425 | prepare_cb = &PL_sv_undef; |
1409 | |
1426 | |
1410 | { |
1427 | { |
1411 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
1428 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
… | |
… | |
1695 | req->env = env; |
1712 | req->env = env; |
1696 | req->buf1 = strdup_ornull (file); |
1713 | req->buf1 = strdup_ornull (file); |
1697 | req->buf2 = strdup_ornull (database); |
1714 | req->buf2 = strdup_ornull (database); |
1698 | req->buf3 = strdup_ornull (newname); |
1715 | req->buf3 = strdup_ornull (newname); |
1699 | req->uint1 = flags; |
1716 | req->uint1 = flags; |
|
|
1717 | REQ_SEND; |
|
|
1718 | } |
|
|
1719 | |
|
|
1720 | void |
|
|
1721 | db_env_lsn_reset (DB_ENV *env, bdb_filename db, U32 flags = 0, SV *callback = 0) |
|
|
1722 | PREINIT: |
|
|
1723 | CALLBACK |
|
|
1724 | CODE: |
|
|
1725 | { |
|
|
1726 | dREQ (REQ_ENV_LSN_RESET, 1); |
|
|
1727 | req->env = env; |
|
|
1728 | req->uint1 = flags; |
|
|
1729 | req->buf1 = strdup_ornull (db); |
1700 | REQ_SEND; |
1730 | REQ_SEND; |
1701 | } |
1731 | } |
1702 | |
1732 | |
1703 | void |
1733 | void |
1704 | db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0) |
1734 | db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0) |
… | |
… | |
1756 | req->uint1 = flags; |
1786 | req->uint1 = flags; |
1757 | req->sv1 = (SV *)db->app_private; |
1787 | req->sv1 = (SV *)db->app_private; |
1758 | REQ_SEND; |
1788 | REQ_SEND; |
1759 | } |
1789 | } |
1760 | |
1790 | |
1761 | #if DB_VERSION_MINOR >= 4 |
1791 | #if DBVER >= 404 |
1762 | |
1792 | |
1763 | void |
1793 | void |
1764 | 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) |
1794 | 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) |
1765 | PREINIT: |
1795 | PREINIT: |
1766 | CALLBACK |
1796 | CALLBACK |
… | |
… | |
1845 | sv_to_dbt (&req->dbt2, data); |
1875 | sv_to_dbt (&req->dbt2, data); |
1846 | req->uint1 = flags; |
1876 | req->uint1 = flags; |
1847 | REQ_SEND; |
1877 | REQ_SEND; |
1848 | } |
1878 | } |
1849 | |
1879 | |
1850 | #if DB_VERSION_MINOR >= 6 |
1880 | #if DBVER >= 406 |
1851 | |
1881 | |
1852 | void |
1882 | void |
1853 | db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
1883 | db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
1854 | PREINIT: |
1884 | PREINIT: |
1855 | CALLBACK |
1885 | CALLBACK |
… | |
… | |
2088 | req->uint1 = flags; |
2118 | req->uint1 = flags; |
2089 | REQ_SEND; |
2119 | REQ_SEND; |
2090 | } |
2120 | } |
2091 | |
2121 | |
2092 | |
2122 | |
2093 | #if DB_VERSION_MINOR >= 3 |
2123 | #if DBVER >= 403 |
2094 | |
2124 | |
2095 | void |
2125 | void |
2096 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
2126 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
2097 | PREINIT: |
2127 | PREINIT: |
2098 | CALLBACK |
2128 | CALLBACK |
… | |
… | |
2192 | CODE: |
2222 | CODE: |
2193 | RETVAL = env->set_flags (env, flags, onoff); |
2223 | RETVAL = env->set_flags (env, flags, onoff); |
2194 | OUTPUT: |
2224 | OUTPUT: |
2195 | RETVAL |
2225 | RETVAL |
2196 | |
2226 | |
2197 | #if DB_VERSION_MINOR >= 7 |
2227 | #if DBVER >= 407 |
2198 | |
2228 | |
2199 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
2229 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
2200 | CODE: |
2230 | CODE: |
2201 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
2231 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
2202 | OUTPUT: |
2232 | OUTPUT: |
… | |
… | |
2289 | CODE: |
2319 | CODE: |
2290 | RETVAL = env->set_lg_max (env, max); |
2320 | RETVAL = env->set_lg_max (env, max); |
2291 | OUTPUT: |
2321 | OUTPUT: |
2292 | RETVAL |
2322 | RETVAL |
2293 | |
2323 | |
2294 | #if DB_VERSION_MINOR >= 4 |
2324 | #if DBVER >= 404 |
2295 | |
2325 | |
2296 | int mutex_set_max (DB_ENV *env, U32 max) |
2326 | int mutex_set_max (DB_ENV *env, U32 max) |
2297 | CODE: |
2327 | CODE: |
2298 | RETVAL = env->mutex_set_max (env, max); |
2328 | RETVAL = env->mutex_set_max (env, max); |
2299 | OUTPUT: |
2329 | OUTPUT: |
… | |
… | |
2326 | if (errno) |
2356 | if (errno) |
2327 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2357 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2328 | OUTPUT: |
2358 | OUTPUT: |
2329 | RETVAL |
2359 | RETVAL |
2330 | |
2360 | |
2331 | #if DB_VERSION_MINOR >= 5 |
2361 | #if DBVER >= 405 |
2332 | |
2362 | |
2333 | DB_TXN * |
2363 | DB_TXN * |
2334 | cdsgroup_begin (DB_ENV *env) |
2364 | cdsgroup_begin (DB_ENV *env) |
2335 | CODE: |
2365 | CODE: |
2336 | errno = env->cdsgroup_begin (env, &RETVAL); |
2366 | errno = env->cdsgroup_begin (env, &RETVAL); |
… | |
… | |
2438 | if (errno) |
2468 | if (errno) |
2439 | croak ("DB->cursor: %s", db_strerror (errno)); |
2469 | croak ("DB->cursor: %s", db_strerror (errno)); |
2440 | OUTPUT: |
2470 | OUTPUT: |
2441 | RETVAL |
2471 | RETVAL |
2442 | |
2472 | |
2443 | #if DB_VERSION_MINOR >= 3 |
2473 | #if DBVER >= 403 |
2444 | |
2474 | |
2445 | DB_SEQUENCE * |
2475 | DB_SEQUENCE * |
2446 | sequence (DB *db, U32 flags = 0) |
2476 | sequence (DB *db, U32 flags = 0) |
2447 | CODE: |
2477 | CODE: |
2448 | { |
2478 | { |
… | |
… | |
2483 | DESTROY (DBC_ornuked *dbc) |
2513 | DESTROY (DBC_ornuked *dbc) |
2484 | CODE: |
2514 | CODE: |
2485 | if (dbc) |
2515 | if (dbc) |
2486 | dbc->c_close (dbc); |
2516 | dbc->c_close (dbc); |
2487 | |
2517 | |
2488 | #if DB_VERSION_MINOR >= 6 |
2518 | #if DBVER >= 406 |
2489 | |
2519 | |
2490 | int set_priority (DBC *dbc, int priority) |
2520 | int set_priority (DBC *dbc, int priority) |
2491 | CODE: |
2521 | CODE: |
2492 | dbc->set_priority (dbc, priority); |
2522 | dbc->set_priority (dbc, priority); |
2493 | |
2523 | |
2494 | #endif |
2524 | #endif |
2495 | |
2525 | |
2496 | #if DB_VERSION_MINOR >= 3 |
2526 | #if DBVER >= 403 |
2497 | |
2527 | |
2498 | MODULE = BDB PACKAGE = BDB::Sequence |
2528 | MODULE = BDB PACKAGE = BDB::Sequence |
2499 | |
2529 | |
2500 | void |
2530 | void |
2501 | DESTROY (DB_SEQUENCE_ornuked *seq) |
2531 | DESTROY (DB_SEQUENCE_ornuked *seq) |