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

Comparing BDB/BDB.xs (file contents):
Revision 1.70 by root, Wed Jul 15 14:53:52 2009 UTC vs.
Revision 1.81 by root, Tue Feb 2 04:28:06 2016 UTC

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
50typedef DB_ENV DB_ENV_ornuked; 52typedef DB_ENV DB_ENV_ornuked;
51typedef DB_TXN DB_TXN_ornuked; 53typedef DB_TXN DB_TXN_ornuked;
52typedef DBC DBC_ornuked; 54typedef DBC DBC_ornuked;
53typedef DB DB_ornuked; 55typedef DB DB_ornuked;
54 56
55#if DB_VERSION_MINOR >= 3 57#if DBVER >= 403
56typedef DB_SEQUENCE DB_SEQUENCE_ornull; 58typedef DB_SEQUENCE DB_SEQUENCE_ornull;
57typedef DB_SEQUENCE DB_SEQUENCE_ornuked; 59typedef DB_SEQUENCE DB_SEQUENCE_ornuked;
58#endif 60#endif
59 61
60typedef char *bdb_filename; 62typedef char *bdb_filename;
61 63
62static SV *prepare_cb; 64static SV *prepare_cb;
63 65
64#if DB_VERSION_MINOR >= 6 66static HV
67 *bdb_stash,
68 *bdb_env_stash,
69 *bdb_txn_stash,
70 *bdb_cursor_stash,
71 *bdb_db_stash,
72 *bdb_sequence_stash;
73
74#if DBVER >= 406
65# define c_close close 75# define c_close close
66# define c_count count 76# define c_count count
67# define c_del del 77# define c_del del
68# define c_dup dup 78# define c_dup dup
69# define c_get get 79# define c_get get
151 161
152enum { 162enum {
153 REQ_QUIT, 163 REQ_QUIT,
154 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,
155 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,
156 REQ_ENV_LOG_ARCHIVE, 166 REQ_ENV_LOG_ARCHIVE, REQ_ENV_LSN_RESET, REQ_ENV_FILEID_RESET,
157 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,
158 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,
159 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, 169 REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH,
160 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,
161 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,
178 char *buf1, *buf2, *buf3; 188 char *buf1, *buf2, *buf3;
179 SV *sv1, *sv2, *sv3; 189 SV *sv1, *sv2, *sv3;
180 190
181 DBT dbt1, dbt2, dbt3; 191 DBT dbt1, dbt2, dbt3;
182 DB_KEY_RANGE key_range; 192 DB_KEY_RANGE key_range;
183#if DB_VERSION_MINOR >= 3 193#if DBVER >= 403
184 DB_SEQUENCE *seq; 194 DB_SEQUENCE *seq;
185 db_seq_t seq_t; 195 db_seq_t seq_t;
186#endif 196#endif
187 197
188 SV *rsv1, *rsv2; // keep some request objects alive 198 SV *rsv1, *rsv2; // keep some request objects alive
216static int next_pri = DEFAULT_PRI + PRI_BIAS; 226static int next_pri = DEFAULT_PRI + PRI_BIAS;
217 227
218static unsigned int started, idle, wanted; 228static unsigned int started, idle, wanted;
219 229
220/* worker threads management */ 230/* worker threads management */
221static mutex_t wrklock = X_MUTEX_INIT; 231static xmutex_t wrklock = X_MUTEX_INIT;
222 232
223typedef struct worker { 233typedef struct worker {
224 /* locked by wrklock */ 234 /* locked by wrklock */
225 struct worker *prev, *next; 235 struct worker *prev, *next;
226 236
227 thread_t tid; 237 xthread_t tid;
228 238
229 /* locked by reslock, reqlock or wrklock */ 239 /* locked by reslock, reqlock or wrklock */
230 bdb_req req; /* currently processed request */ 240 bdb_req req; /* currently processed request */
231 void *dbuf; 241 void *dbuf;
232 DIR *dirp; 242 DIR *dirp;
249static volatile unsigned int nreqs, nready, npending; 259static volatile unsigned int nreqs, nready, npending;
250static volatile unsigned int max_idle = 4; 260static volatile unsigned int max_idle = 4;
251static volatile unsigned int max_outstanding = 0xffffffff; 261static volatile unsigned int max_outstanding = 0xffffffff;
252static s_epipe respipe; 262static s_epipe respipe;
253 263
254static mutex_t reslock = X_MUTEX_INIT; 264static xmutex_t reslock = X_MUTEX_INIT;
255static mutex_t reqlock = X_MUTEX_INIT; 265static xmutex_t reqlock = X_MUTEX_INIT;
256static cond_t reqwait = X_COND_INIT; 266static xcond_t reqwait = X_COND_INIT;
257 267
258#if WORDACCESS_UNSAFE 268#if WORDACCESS_UNSAFE
259 269
260static unsigned int get_nready (void) 270static unsigned int get_nready (void)
261{ 271{
389 SvREFCNT_dec (av); 399 SvREFCNT_dec (av);
390 SvREFCNT_dec (req->sv1); 400 SvREFCNT_dec (req->sv1);
391 } 401 }
392 break; 402 break;
393 403
394#if DB_VERSION_MINOR >= 3 404#if DBVER >= 403
395 case REQ_SEQ_GET: 405 case REQ_SEQ_GET:
396 SvREADONLY_off (req->sv1); 406 SvREADONLY_off (req->sv1);
397 407
398 if (sizeof (IV) > 4) 408 if (sizeof (IV) > 4)
399 sv_setiv_mg (req->sv1, (IV)req->seq_t); 409 sv_setiv_mg (req->sv1, (IV)req->seq_t);
476 486
477 if (!wrk) 487 if (!wrk)
478 croak ("unable to allocate worker thread data"); 488 croak ("unable to allocate worker thread data");
479 489
480 X_LOCK (wrklock); 490 X_LOCK (wrklock);
481 if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) 491 if (xthread_create (&wrk->tid, bdb_proc, (void *)wrk))
482 { 492 {
483 wrk->prev = &wrk_first; 493 wrk->prev = &wrk_first;
484 wrk->next = wrk_first.next; 494 wrk->next = wrk_first.next;
485 wrk_first.next->prev = wrk; 495 wrk_first.next->prev = wrk;
486 wrk_first.next = wrk; 496 wrk_first.next = wrk;
741 751
742 case REQ_DB_CLOSE: 752 case REQ_DB_CLOSE:
743 req->result = req->db->close (req->db, req->uint1); 753 req->result = req->db->close (req->db, req->uint1);
744 break; 754 break;
745 755
746#if DB_VERSION_MINOR >= 4 756#if DBVER >= 404
747 case REQ_DB_COMPACT: 757 case REQ_DB_COMPACT:
748 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);
749 break; 759 break;
750#endif 760#endif
751 761
763 773
764 case REQ_DB_PUT: 774 case REQ_DB_PUT:
765 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);
766 break; 776 break;
767 777
768#if DB_VERSION_MINOR >= 6 778#if DBVER >= 406
769 case REQ_DB_EXISTS: 779 case REQ_DB_EXISTS:
770 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);
771 break; 781 break;
772#endif 782#endif
773 case REQ_DB_GET: 783 case REQ_DB_GET:
831 841
832 case REQ_C_DEL: 842 case REQ_C_DEL:
833 req->result = req->dbc->c_del (req->dbc, req->uint1); 843 req->result = req->dbc->c_del (req->dbc, req->uint1);
834 break; 844 break;
835 845
836#if DB_VERSION_MINOR >= 3 846#if DBVER >= 403
837 case REQ_SEQ_OPEN: 847 case REQ_SEQ_OPEN:
838 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);
839 break; 849 break;
840 850
841 case REQ_SEQ_CLOSE: 851 case REQ_SEQ_CLOSE:
846 req->result = req->seq->get (req->seq, req->txn, req->int1, &req->seq_t, req->uint1); 856 req->result = req->seq->get (req->seq, req->txn, req->int1, &req->seq_t, req->uint1);
847 break; 857 break;
848 858
849 case REQ_SEQ_REMOVE: 859 case REQ_SEQ_REMOVE:
850 req->result = req->seq->remove (req->seq, req->txn, req->uint1); 860 req->result = req->seq->remove (req->seq, req->txn, req->uint1);
861 break;
862#endif
863
864#if DBVER >= 407
865 case REQ_ENV_LSN_RESET:
866 req->result = req->env->lsn_reset (req->env, req->buf1, req->uint1);
867 break;
868
869 case REQ_ENV_FILEID_RESET:
870 req->result = req->env->fileid_reset (req->env, req->buf1, req->uint1);
851 break; 871 break;
852#endif 872#endif
853 873
854 case REQ_ENV_LOG_ARCHIVE: 874 case REQ_ENV_LOG_ARCHIVE:
855 { 875 {
1004 next_pri = DEFAULT_PRI + PRI_BIAS; \ 1024 next_pri = DEFAULT_PRI + PRI_BIAS; \
1005 \ 1025 \
1006 if (callback && SvOK (callback)) \ 1026 if (callback && SvOK (callback)) \
1007 croak ("callback has illegal type or extra arguments"); \ 1027 croak ("callback has illegal type or extra arguments"); \
1008 \ 1028 \
1009 Newz (0, req, 1, bdb_cb); \ 1029 Newz (0, req, 1, bdb_cb); \
1010 if (!req) \ 1030 if (!req) \
1011 croak ("out of memory during bdb_req allocation"); \ 1031 croak ("out of memory during bdb_req allocation"); \
1012 \ 1032 \
1013 req->callback = SvREFCNT_inc (cb); \ 1033 req->callback = SvREFCNT_inc (cb); \
1014 req->type = (reqtype); \ 1034 req->type = (reqtype); \
1015 req->pri = req_pri; \ 1035 req->pri = req_pri; \
1016 if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \ 1036 if (rsvcnt >= 1) req->rsv1 = SvREFCNT_inc (ST (0)); \
1017 if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \ 1037 if (rsvcnt >= 2) req->rsv2 = SvREFCNT_inc (ST (1)); \
1018 (void)0; 1038 (void)0;
1019 1039
1020#define REQ_SEND \ 1040#define REQ_SEND \
1021 req_send (req) 1041 req_send (req)
1022 1042
1023#define SvPTR(var, arg, type, class, nullok) \ 1043#define SvPTR(var, arg, type, stash, class, nullok) \
1024 if (!SvOK (arg)) \ 1044 if (!SvOK (arg)) \
1025 { \ 1045 { \
1026 if (nullok != 1) \ 1046 if (nullok != 1) \
1027 croak (# var " must be a " # class " object, not undef"); \ 1047 croak (# var " must be a " # class " object, not undef"); \
1028 \ 1048 \
1029 (var) = 0; \ 1049 (var) = 0; \
1030 } \ 1050 } \
1031 else if (sv_derived_from ((arg), # class)) \ 1051 else if (SvSTASH (SvRV (arg)) == stash || sv_derived_from ((arg), # class)) \
1032 { \ 1052 { \
1033 IV tmp = SvIV ((SV*) SvRV (arg)); \ 1053 IV tmp = SvIV ((SV*) SvRV (arg)); \
1034 (var) = INT2PTR (type, tmp); \ 1054 (var) = INT2PTR (type, tmp); \
1035 if (!var && nullok != 2) \ 1055 if (!var && nullok != 2) \
1036 croak (# var " is not a valid " # class " object anymore"); \ 1056 croak (# var " is not a valid " # class " object anymore"); \
1039 croak (# var " is not of type " # class); 1059 croak (# var " is not of type " # class);
1040 1060
1041#define ARG_MUTABLE(name) \ 1061#define ARG_MUTABLE(name) \
1042 if (SvREADONLY (name)) \ 1062 if (SvREADONLY (name)) \
1043 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable"); 1063 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable");
1064
1065static SV *
1066newSVptr (void *ptr, HV *stash)
1067{
1068 SV *rv = NEWSV (0, 0);
1069 sv_upgrade (rv, SVt_PVMG);
1070 sv_setiv (rv, PTR2IV (ptr));
1071
1072 return sv_bless (newRV_noinc (rv), stash);
1073}
1044 1074
1045static void 1075static void
1046ptr_nuke (SV *sv) 1076ptr_nuke (SV *sv)
1047{ 1077{
1048 assert (SvROK (sv)); 1078 assert (SvROK (sv));
1170 1200
1171PROTOTYPES: ENABLE 1201PROTOTYPES: ENABLE
1172 1202
1173BOOT: 1203BOOT:
1174{ 1204{
1175 HV *stash = gv_stashpv ("BDB", 1);
1176
1177 static const struct { 1205 static const struct {
1178 const char *name; 1206 const char *name;
1179 IV iv; 1207 IV iv;
1180 } *civ, const_iv[] = { 1208 } *civ, const_iv[] = {
1181#define const_iv(name) { # name, (IV)DB_ ## name }, 1209#define const_iv(name) { # name, (IV)DB_ ## name },
1210#if DBVER <= 408
1182 const_iv (RPCCLIENT) 1211 const_iv (RPCCLIENT)
1212#endif
1183 const_iv (INIT_CDB) 1213 const_iv (INIT_CDB)
1184 const_iv (INIT_LOCK) 1214 const_iv (INIT_LOCK)
1185 const_iv (INIT_LOG) 1215 const_iv (INIT_LOG)
1186 const_iv (INIT_MPOOL) 1216 const_iv (INIT_MPOOL)
1187 const_iv (INIT_REP) 1217 const_iv (INIT_REP)
1210 const_iv (TXN_NOT_DURABLE) 1240 const_iv (TXN_NOT_DURABLE)
1211 const_iv (TXN_WRITE_NOSYNC) 1241 const_iv (TXN_WRITE_NOSYNC)
1212 const_iv (WRITECURSOR) 1242 const_iv (WRITECURSOR)
1213 const_iv (YIELDCPU) 1243 const_iv (YIELDCPU)
1214 const_iv (ENCRYPT_AES) 1244 const_iv (ENCRYPT_AES)
1245#if DBVER < 408
1215 const_iv (XA_CREATE) 1246 const_iv (XA_CREATE)
1247#endif
1216 const_iv (BTREE) 1248 const_iv (BTREE)
1217 const_iv (HASH) 1249 const_iv (HASH)
1218 const_iv (QUEUE) 1250 const_iv (QUEUE)
1219 const_iv (RECNO) 1251 const_iv (RECNO)
1220 const_iv (UNKNOWN) 1252 const_iv (UNKNOWN)
1284 const_iv (LOCK_OLDEST) 1316 const_iv (LOCK_OLDEST)
1285 const_iv (LOCK_RANDOM) 1317 const_iv (LOCK_RANDOM)
1286 const_iv (LOCK_YOUNGEST) 1318 const_iv (LOCK_YOUNGEST)
1287 1319
1288 const_iv (DONOTINDEX) 1320 const_iv (DONOTINDEX)
1289 const_iv (KEYEMPTY ) 1321 const_iv (KEYEMPTY)
1290 const_iv (KEYEXIST ) 1322 const_iv (KEYEXIST)
1291 const_iv (LOCK_DEADLOCK) 1323 const_iv (LOCK_DEADLOCK)
1292 const_iv (LOCK_NOTGRANTED) 1324 const_iv (LOCK_NOTGRANTED)
1293 const_iv (NOSERVER) 1325 const_iv (NOSERVER)
1326#if DBVER < 502
1294 const_iv (NOSERVER_HOME) 1327 const_iv (NOSERVER_HOME)
1295 const_iv (NOSERVER_ID) 1328 const_iv (NOSERVER_ID)
1329#endif
1296 const_iv (NOTFOUND) 1330 const_iv (NOTFOUND)
1297 const_iv (PAGE_NOTFOUND) 1331 const_iv (PAGE_NOTFOUND)
1298 const_iv (REP_DUPMASTER) 1332 const_iv (REP_DUPMASTER)
1299 const_iv (REP_HANDLE_DEAD) 1333 const_iv (REP_HANDLE_DEAD)
1300 const_iv (REP_HOLDELECTION) 1334 const_iv (REP_HOLDELECTION)
1324 const_iv (VERB_WAITSFOR) 1358 const_iv (VERB_WAITSFOR)
1325 1359
1326 const_iv (VERSION_MAJOR) 1360 const_iv (VERSION_MAJOR)
1327 const_iv (VERSION_MINOR) 1361 const_iv (VERSION_MINOR)
1328 const_iv (VERSION_PATCH) 1362 const_iv (VERSION_PATCH)
1329#if DB_VERSION_MINOR >= 3 1363 const_iv (LOGVERSION)
1364 const_iv (LOGOLDVER)
1365#if DBVER >= 403
1330 const_iv (INORDER) 1366 const_iv (INORDER)
1331 const_iv (LOCK_MAXWRITE) 1367 const_iv (LOCK_MAXWRITE)
1332 const_iv (SEQ_DEC) 1368 const_iv (SEQ_DEC)
1333 const_iv (SEQ_INC) 1369 const_iv (SEQ_INC)
1334 const_iv (SEQ_WRAP) 1370 const_iv (SEQ_WRAP)
1335 const_iv (BUFFER_SMALL) 1371 const_iv (BUFFER_SMALL)
1336 const_iv (LOG_BUFFER_FULL) 1372 const_iv (LOG_BUFFER_FULL)
1337 const_iv (VERSION_MISMATCH) 1373 const_iv (VERSION_MISMATCH)
1338#endif 1374#endif
1339#if DB_VERSION_MINOR >= 4 1375#if DBVER >= 404
1340 const_iv (REGISTER) 1376 const_iv (REGISTER)
1341 const_iv (DSYNC_DB) 1377 const_iv (DSYNC_DB)
1342 const_iv (READ_COMMITTED) 1378 const_iv (READ_COMMITTED)
1343 const_iv (READ_UNCOMMITTED) 1379 const_iv (READ_UNCOMMITTED)
1344 const_iv (REP_IGNORE) 1380 const_iv (REP_IGNORE)
1346 const_iv (REP_JOIN_FAILURE) 1382 const_iv (REP_JOIN_FAILURE)
1347 const_iv (FREE_SPACE) 1383 const_iv (FREE_SPACE)
1348 const_iv (FREELIST_ONLY) 1384 const_iv (FREELIST_ONLY)
1349 const_iv (VERB_REGISTER) 1385 const_iv (VERB_REGISTER)
1350#endif 1386#endif
1351#if DB_VERSION_MINOR >= 5 1387#if DBVER >= 405
1352 const_iv (MULTIVERSION) 1388 const_iv (MULTIVERSION)
1353 const_iv (TXN_SNAPSHOT) 1389 const_iv (TXN_SNAPSHOT)
1354#endif 1390#endif
1355#if DB_VERSION_MINOR >= 6 1391#if DBVER >= 406
1356 const_iv (PREV_DUP) 1392 const_iv (PREV_DUP)
1357 const_iv (PRIORITY_UNCHANGED) 1393 const_iv (PRIORITY_UNCHANGED)
1358 const_iv (PRIORITY_VERY_LOW) 1394 const_iv (PRIORITY_VERY_LOW)
1359 const_iv (PRIORITY_LOW) 1395 const_iv (PRIORITY_LOW)
1360 const_iv (PRIORITY_DEFAULT) 1396 const_iv (PRIORITY_DEFAULT)
1361 const_iv (PRIORITY_HIGH) 1397 const_iv (PRIORITY_HIGH)
1362 const_iv (PRIORITY_VERY_HIGH) 1398 const_iv (PRIORITY_VERY_HIGH)
1363 const_iv (IGNORE_LEASE) 1399 const_iv (IGNORE_LEASE)
1364#endif 1400#endif
1365#if DB_VERSION_MINOR >= 7 1401#if DBVER >= 407
1366 //const_iv (MULTIPLE_KEY) 1402 //const_iv (MULTIPLE_KEY)
1367 const_iv (LOG_DIRECT) 1403 const_iv (LOG_DIRECT)
1368 const_iv (LOG_DSYNC) 1404 const_iv (LOG_DSYNC)
1369 const_iv (LOG_AUTO_REMOVE) 1405 const_iv (LOG_AUTO_REMOVE)
1370 const_iv (LOG_IN_MEMORY) 1406 const_iv (LOG_IN_MEMORY)
1371 const_iv (LOG_ZERO) 1407 const_iv (LOG_ZERO)
1372#else 1408#else
1373 const_iv (DIRECT_LOG) 1409 const_iv (DIRECT_LOG)
1374 const_iv (LOG_AUTOREMOVE) 1410 const_iv (LOG_AUTOREMOVE)
1375# if DB_VERSION_MINOR >= 3 1411# if DBVER >= 403
1376 const_iv (DSYNC_LOG) 1412 const_iv (DSYNC_LOG)
1377 const_iv (LOG_INMEMORY) 1413 const_iv (LOG_INMEMORY)
1378# endif 1414# endif
1415#if DBVER >= 408
1416 const_iv (LOGVERSION_LATCHING)
1417#endif
1379#endif 1418#endif
1380 }; 1419 };
1381 1420
1421 bdb_stash = gv_stashpv ("BDB" , 1);
1422 bdb_env_stash = gv_stashpv ("BDB::Env" , 1);
1423 bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1);
1424 bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1);
1425 bdb_db_stash = gv_stashpv ("BDB::Db" , 1);
1426 bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1);
1427
1382 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1428 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
1383 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1429 newCONSTSUB (bdb_stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
1384 1430
1385 prepare_cb = &PL_sv_undef; 1431 prepare_cb = &PL_sv_undef;
1386 1432
1387 { 1433 {
1388 /* we currently only allow version, minor-version and patchlevel to go up to 255 */ 1434 /* we currently only allow version, minor-version and patchlevel to go up to 255 */
1389 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; 1435 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH };
1390 1436
1391 newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); 1437 newCONSTSUB (bdb_stash, "VERSION_v", newSVpvn (vstring, 3));
1392 } 1438 }
1393 1439
1394 newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); 1440 newCONSTSUB (bdb_stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1395 1441
1396 create_respipe (); 1442 create_respipe ();
1397 1443
1398 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1444 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1399 patch_errno (); 1445 patch_errno ();
1672 req->env = env; 1718 req->env = env;
1673 req->buf1 = strdup_ornull (file); 1719 req->buf1 = strdup_ornull (file);
1674 req->buf2 = strdup_ornull (database); 1720 req->buf2 = strdup_ornull (database);
1675 req->buf3 = strdup_ornull (newname); 1721 req->buf3 = strdup_ornull (newname);
1676 req->uint1 = flags; 1722 req->uint1 = flags;
1723 REQ_SEND;
1724}
1725
1726void
1727db_env_lsn_reset (DB_ENV *env, bdb_filename db, U32 flags = 0, SV *callback = 0)
1728 ALIAS:
1729 db_env_fileid_reset = 1
1730 PREINIT:
1731 CALLBACK
1732 CODE:
1733{
1734 dREQ (ix ? REQ_ENV_FILEID_RESET : REQ_ENV_LSN_RESET, 1);
1735 req->env = env;
1736 req->uint1 = flags;
1737 req->buf1 = strdup_ornull (db);
1677 REQ_SEND; 1738 REQ_SEND;
1678} 1739}
1679 1740
1680void 1741void
1681db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0) 1742db_env_log_archive (DB_ENV *env, SV_mutable *listp, U32 flags = 0, SV *callback = 0)
1733 req->uint1 = flags; 1794 req->uint1 = flags;
1734 req->sv1 = (SV *)db->app_private; 1795 req->sv1 = (SV *)db->app_private;
1735 REQ_SEND; 1796 REQ_SEND;
1736} 1797}
1737 1798
1738#if DB_VERSION_MINOR >= 4 1799#if DBVER >= 404
1739 1800
1740void 1801void
1741db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = 0) 1802db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = 0)
1742 PREINIT: 1803 PREINIT:
1743 CALLBACK 1804 CALLBACK
1822 sv_to_dbt (&req->dbt2, data); 1883 sv_to_dbt (&req->dbt2, data);
1823 req->uint1 = flags; 1884 req->uint1 = flags;
1824 REQ_SEND; 1885 REQ_SEND;
1825} 1886}
1826 1887
1827#if DB_VERSION_MINOR >= 6 1888#if DBVER >= 406
1828 1889
1829void 1890void
1830db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) 1891db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0)
1831 PREINIT: 1892 PREINIT:
1832 CALLBACK 1893 CALLBACK
2065 req->uint1 = flags; 2126 req->uint1 = flags;
2066 REQ_SEND; 2127 REQ_SEND;
2067} 2128}
2068 2129
2069 2130
2070#if DB_VERSION_MINOR >= 3 2131#if DBVER >= 403
2071 2132
2072void 2133void
2073db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) 2134db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0)
2074 PREINIT: 2135 PREINIT:
2075 CALLBACK 2136 CALLBACK
2169 CODE: 2230 CODE:
2170 RETVAL = env->set_flags (env, flags, onoff); 2231 RETVAL = env->set_flags (env, flags, onoff);
2171 OUTPUT: 2232 OUTPUT:
2172 RETVAL 2233 RETVAL
2173 2234
2174#if DB_VERSION_MINOR >= 7 2235#if DBVER >= 407
2175 2236
2176int set_intermediate_dir_mode (DB_ENV *env, const char *mode) 2237int set_intermediate_dir_mode (DB_ENV *env, const char *mode)
2177 CODE: 2238 CODE:
2178 RETVAL = env->set_intermediate_dir_mode (env, mode); 2239 RETVAL = env->set_intermediate_dir_mode (env, mode);
2179 OUTPUT: 2240 OUTPUT:
2266 CODE: 2327 CODE:
2267 RETVAL = env->set_lg_max (env, max); 2328 RETVAL = env->set_lg_max (env, max);
2268 OUTPUT: 2329 OUTPUT:
2269 RETVAL 2330 RETVAL
2270 2331
2271#if DB_VERSION_MINOR >= 4 2332#if DBVER >= 404
2272 2333
2273int mutex_set_max (DB_ENV *env, U32 max) 2334int mutex_set_max (DB_ENV *env, U32 max)
2274 CODE: 2335 CODE:
2275 RETVAL = env->mutex_set_max (env, max); 2336 RETVAL = env->mutex_set_max (env, max);
2276 OUTPUT: 2337 OUTPUT:
2303 if (errno) 2364 if (errno)
2304 croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); 2365 croak ("DB_ENV->txn_begin: %s", db_strerror (errno));
2305 OUTPUT: 2366 OUTPUT:
2306 RETVAL 2367 RETVAL
2307 2368
2308#if DB_VERSION_MINOR >= 5 2369#if DBVER >= 405
2309 2370
2310DB_TXN * 2371DB_TXN *
2311cdsgroup_begin (DB_ENV *env) 2372cdsgroup_begin (DB_ENV *env)
2312 CODE: 2373 CODE:
2313 errno = env->cdsgroup_begin (env, &RETVAL); 2374 errno = env->cdsgroup_begin (env, &RETVAL);
2415 if (errno) 2476 if (errno)
2416 croak ("DB->cursor: %s", db_strerror (errno)); 2477 croak ("DB->cursor: %s", db_strerror (errno));
2417 OUTPUT: 2478 OUTPUT:
2418 RETVAL 2479 RETVAL
2419 2480
2420#if DB_VERSION_MINOR >= 3 2481#if DBVER >= 403
2421 2482
2422DB_SEQUENCE * 2483DB_SEQUENCE *
2423sequence (DB *db, U32 flags = 0) 2484sequence (DB *db, U32 flags = 0)
2424 CODE: 2485 CODE:
2425{ 2486{
2460DESTROY (DBC_ornuked *dbc) 2521DESTROY (DBC_ornuked *dbc)
2461 CODE: 2522 CODE:
2462 if (dbc) 2523 if (dbc)
2463 dbc->c_close (dbc); 2524 dbc->c_close (dbc);
2464 2525
2465#if DB_VERSION_MINOR >= 6 2526#if DBVER >= 406
2466 2527
2467int set_priority (DBC *dbc, int priority) 2528int set_priority (DBC *dbc, int priority)
2468 CODE: 2529 CODE:
2469 dbc->set_priority (dbc, priority); 2530 dbc->set_priority (dbc, priority);
2470 2531
2471#endif 2532#endif
2472 2533
2473#if DB_VERSION_MINOR >= 3 2534#if DBVER >= 403
2474 2535
2475MODULE = BDB PACKAGE = BDB::Sequence 2536MODULE = BDB PACKAGE = BDB::Sequence
2476 2537
2477void 2538void
2478DESTROY (DB_SEQUENCE_ornuked *seq) 2539DESTROY (DB_SEQUENCE_ornuked *seq)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines