File indexing completed on 2025-01-17 09:55:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _DB_CXX_H_
0010 #define _DB_CXX_H_
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 #include <stdarg.h>
0052
0053 #define HAVE_CXX_STDHEADERS 1
0054 #ifdef HAVE_CXX_STDHEADERS
0055 #include <iostream>
0056 #include <exception>
0057 #define __DB_STD(x) std::x
0058 #else
0059 #include <iostream.h>
0060 #include <exception.h>
0061 #define __DB_STD(x) x
0062 #endif
0063
0064 #include "db.h"
0065
0066 class Db;
0067 class Dbc;
0068 class DbChannel;
0069 class DbEnv;
0070 class DbHeapRecordId;
0071 class DbInfo;
0072 class DbLock;
0073 class DbLogc;
0074 class DbLsn;
0075 class DbMpoolFile;
0076 class DbPreplist;
0077 class DbSequence;
0078 class DbSite;
0079 class DbStream;
0080 class Dbt;
0081 class DbTxn;
0082
0083 class DbMultipleIterator;
0084 class DbMultipleKeyDataIterator;
0085 class DbMultipleRecnoDataIterator;
0086 class DbMultipleDataIterator;
0087
0088 class DbException;
0089 class DbDeadlockException;
0090 class DbLockNotGrantedException;
0091 class DbMemoryException;
0092 class DbRepHandleDeadException;
0093 class DbRunRecoveryException;
0094
0095
0096
0097
0098
0099
0100
0101 #ifdef _MSC_VER
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 #pragma warning(push)
0115 #pragma warning(disable: 4201 4514)
0116
0117 #endif
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 #if defined(_MSC_VER)
0133
0134 # if defined(DB_CREATE_DLL)
0135 # define _exported __declspec(dllexport)
0136 # elif defined(DB_USE_DLL)
0137 # define _exported __declspec(dllimport)
0138 # else
0139 # define _exported
0140 # endif
0141
0142 #else
0143
0144 # define _exported
0145
0146 #endif
0147
0148
0149
0150
0151
0152
0153
0154
0155 extern "C" {
0156 typedef void * (*db_malloc_fcn_type)
0157 (size_t);
0158 typedef void * (*db_realloc_fcn_type)
0159 (void *, size_t);
0160 typedef void (*db_free_fcn_type)
0161 (void *);
0162 typedef int (*bt_compare_fcn_type)
0163 (DB *, const DBT *, const DBT *, size_t *);
0164 typedef size_t (*bt_prefix_fcn_type)
0165 (DB *, const DBT *, const DBT *);
0166 typedef int (*dup_compare_fcn_type)
0167 (DB *, const DBT *, const DBT *, size_t *);
0168 typedef int (*h_compare_fcn_type)
0169 (DB *, const DBT *, const DBT *, size_t *);
0170 typedef u_int32_t (*h_hash_fcn_type)
0171 (DB *, const void *, u_int32_t);
0172 typedef int (*pgin_fcn_type)
0173 (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie);
0174 typedef int (*pgout_fcn_type)
0175 (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie);
0176 }
0177
0178
0179
0180
0181 class _exported Db
0182 {
0183 friend class DbEnv;
0184
0185 public:
0186 Db(DbEnv*, u_int32_t);
0187 Db(DB*);
0188 virtual ~Db();
0189
0190
0191
0192 virtual int associate(DbTxn *txn, Db *secondary, int (*callback)
0193 (Db *, const Dbt *, const Dbt *, Dbt *), u_int32_t flags);
0194 virtual int associate_foreign(Db *foreign, int (*callback)
0195 (Db *, const Dbt *, Dbt *, const Dbt *, int *), u_int32_t flags);
0196 virtual int close(u_int32_t flags);
0197 virtual int compact(DbTxn *txnid, Dbt *start,
0198 Dbt *stop, DB_COMPACT *c_data, u_int32_t flags, Dbt *end);
0199 virtual int convert(const char *name, u_int32_t lorder);
0200 virtual int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags);
0201 virtual int del(DbTxn *txnid, Dbt *key, u_int32_t flags);
0202 virtual void err(int, const char *, ...);
0203 virtual void errx(const char *, ...);
0204 virtual int exists(DbTxn *txnid, Dbt *key, u_int32_t flags);
0205 virtual int fd(int *fdp);
0206 virtual int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags);
0207 virtual int get_alloc(
0208 db_malloc_fcn_type *, db_realloc_fcn_type *, db_free_fcn_type *);
0209 virtual int get_append_recno(int (**)(Db *, Dbt *, db_recno_t));
0210 virtual int get_blob_dir(const char **);
0211 virtual int get_blob_threshold(u_int32_t *);
0212 virtual int get_bt_compare(
0213 int (**)(Db *, const Dbt *, const Dbt *, size_t *));
0214 virtual int get_bt_compress(
0215 int (**)(
0216 Db *, const Dbt *, const Dbt *, const Dbt *, const Dbt *, Dbt *),
0217 int (**)(Db *, const Dbt *, const Dbt *, Dbt *, Dbt *, Dbt *));
0218 virtual int get_bt_minkey(u_int32_t *);
0219 virtual int get_bt_prefix(size_t (**)(Db *, const Dbt *, const Dbt *));
0220 virtual int get_byteswapped(int *);
0221 virtual int get_cachesize(u_int32_t *, u_int32_t *, int *);
0222 virtual int get_create_dir(const char **);
0223 virtual int get_dbname(const char **, const char **);
0224 virtual int get_dup_compare(
0225 int (**)(Db *, const Dbt *, const Dbt *, size_t *));
0226 virtual int get_encrypt_flags(u_int32_t *);
0227 virtual void get_errcall(
0228 void (**)(const DbEnv *, const char *, const char *));
0229 virtual void get_errfile(FILE **);
0230 virtual void get_errpfx(const char **);
0231 virtual int get_ext_file_dir(const char **);
0232 virtual int get_ext_file_threshold(u_int32_t *);
0233 virtual int get_feedback(void (**)(Db *, int, int));
0234 virtual int get_flags(u_int32_t *);
0235 virtual int get_heapsize(u_int32_t *, u_int32_t *);
0236 virtual int get_heap_regionsize(u_int32_t *);
0237 virtual int get_h_compare(
0238 int (**)(Db *, const Dbt *, const Dbt *, size_t *));
0239 virtual int get_h_ffactor(u_int32_t *);
0240 virtual int get_h_hash(u_int32_t (**)(Db *, const void *, u_int32_t));
0241 virtual int get_h_nelem(u_int32_t *);
0242 virtual int get_lk_exclusive(bool *, bool *);
0243 virtual int get_lorder(int *);
0244 virtual void get_msgcall(
0245 void (**)(const DbEnv *, const char *, const char *));
0246 virtual void get_msgfile(FILE **);
0247 virtual void get_msgpfx(const char **);
0248 virtual int get_multiple();
0249 virtual int get_open_flags(u_int32_t *);
0250 virtual int get_pagesize(u_int32_t *);
0251 virtual int get_partition_callback(
0252 u_int32_t *, u_int32_t (**)(Db *, Dbt *key));
0253 virtual int get_partition_dirs(const char ***);
0254 virtual int get_partition_keys(u_int32_t *, Dbt **);
0255 virtual int get_priority(DB_CACHE_PRIORITY *);
0256 virtual int get_q_extentsize(u_int32_t *);
0257 virtual int get_re_delim(int *);
0258 virtual int get_re_len(u_int32_t *);
0259 virtual int get_re_pad(int *);
0260 virtual int get_re_source(const char **);
0261 virtual int get_slices(Db ***);
0262 virtual int get_transactional();
0263 virtual int get_type(DBTYPE *);
0264 virtual int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags);
0265 virtual int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t);
0266 virtual void msg(const char *, ...);
0267 virtual int open(DbTxn *txnid,
0268 const char *, const char *subname, DBTYPE, u_int32_t, int);
0269 virtual int pget(DbTxn *txnid,
0270 Dbt *key, Dbt *pkey, Dbt *data, u_int32_t flags);
0271 virtual int put(DbTxn *, Dbt *, Dbt *, u_int32_t);
0272 virtual int remove(const char *, const char *, u_int32_t);
0273 virtual int rename(const char *, const char *, const char *, u_int32_t);
0274 virtual int set_alloc(
0275 db_malloc_fcn_type, db_realloc_fcn_type, db_free_fcn_type);
0276 virtual void set_app_private(void *);
0277 virtual int set_append_recno(int (*)(Db *, Dbt *, db_recno_t));
0278 virtual int set_blob_dir(const char *);
0279 virtual int set_blob_threshold(u_int32_t, u_int32_t);
0280 virtual int set_bt_compare(bt_compare_fcn_type);
0281 virtual int set_bt_compare(
0282 int (*)(Db *, const Dbt *, const Dbt *, size_t *));
0283 virtual int set_bt_compress(
0284 int (*)
0285 (Db *, const Dbt *, const Dbt *, const Dbt *, const Dbt *, Dbt *),
0286 int (*)(Db *, const Dbt *, const Dbt *, Dbt *, Dbt *, Dbt *));
0287 virtual int set_bt_minkey(u_int32_t);
0288 virtual int set_bt_prefix(bt_prefix_fcn_type);
0289 virtual int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *));
0290 virtual int set_cachesize(u_int32_t, u_int32_t, int);
0291 virtual int set_create_dir(const char *);
0292 virtual int set_dup_compare(dup_compare_fcn_type);
0293 virtual int set_dup_compare(
0294 int (*)(Db *, const Dbt *, const Dbt *, size_t *));
0295 virtual int set_encrypt(const char *, u_int32_t);
0296 virtual void set_errcall(
0297 void (*)(const DbEnv *, const char *, const char *));
0298 virtual void set_errfile(FILE *);
0299 virtual void set_errpfx(const char *);
0300 virtual int set_ext_file_dir(const char *);
0301 virtual int set_ext_file_threshold(u_int32_t, u_int32_t);
0302 virtual int set_feedback(void (*)(Db *, int, int));
0303 virtual int set_flags(u_int32_t);
0304 virtual int set_heapsize(u_int32_t, u_int32_t);
0305 virtual int set_heap_regionsize(u_int32_t);
0306 virtual int set_h_compare(h_compare_fcn_type);
0307 virtual int set_h_compare(
0308 int (*)(Db *, const Dbt *, const Dbt *, size_t *));
0309 virtual int set_h_ffactor(u_int32_t);
0310 virtual int set_h_hash(h_hash_fcn_type);
0311 virtual int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t));
0312 virtual int set_h_nelem(u_int32_t);
0313 virtual int set_lk_exclusive(bool);
0314 virtual int set_lorder(int);
0315 virtual void set_msgcall(
0316 void (*)(const DbEnv *, const char *, const char *));
0317 virtual void set_msgfile(FILE *);
0318 virtual void set_msgpfx(const char *);
0319 virtual int set_pagesize(u_int32_t);
0320 virtual int set_paniccall(void (*)(DbEnv *, int));
0321 virtual int set_partition(
0322 u_int32_t, Dbt *, u_int32_t (*)(Db *, Dbt *));
0323 virtual int set_partition_dirs(const char **);
0324 virtual int set_priority(DB_CACHE_PRIORITY);
0325 virtual int set_q_extentsize(u_int32_t);
0326 virtual int set_re_delim(int);
0327 virtual int set_re_len(u_int32_t);
0328 virtual int set_re_pad(int);
0329 virtual int set_re_source(const char *);
0330 virtual int set_slice_callback(int (*)(const Db *, const Dbt *, Dbt *));
0331 virtual int slice_lookup(const Dbt *, Db **, u_int32_t);
0332 virtual int sort_multiple(Dbt *, Dbt *, u_int32_t);
0333 virtual int stat(DbTxn *, void *sp, u_int32_t flags);
0334 virtual int stat_print(u_int32_t flags);
0335 virtual int sync(u_int32_t flags);
0336 virtual int truncate(DbTxn *, u_int32_t *, u_int32_t);
0337 virtual int upgrade(const char *name, u_int32_t flags);
0338 virtual int verify(
0339 const char *, const char *, __DB_STD(ostream) *, u_int32_t);
0340
0341
0342
0343
0344 virtual void *get_app_private() const;
0345 virtual __DB_STD(ostream) *get_error_stream();
0346 virtual void set_error_stream(__DB_STD(ostream) *);
0347 virtual __DB_STD(ostream) *get_message_stream();
0348 virtual void set_message_stream(__DB_STD(ostream) *);
0349
0350 virtual DbEnv *get_env();
0351 virtual DbMpoolFile *get_mpf();
0352
0353 virtual ENV *get_ENV()
0354 {
0355 return imp_->env;
0356 }
0357
0358 virtual DB *get_DB()
0359 {
0360 return imp_;
0361 }
0362
0363 virtual const DB *get_const_DB() const
0364 {
0365 return imp_;
0366 }
0367
0368 static Db* get_Db(DB *db)
0369 {
0370 return (Db *)db->api_internal;
0371 }
0372
0373 static const Db* get_const_Db(const DB *db)
0374 {
0375 return (const Db *)db->api_internal;
0376 }
0377
0378 u_int32_t get_create_flags() const
0379 {
0380 return construct_flags_;
0381 }
0382
0383 private:
0384
0385 Db(const Db &);
0386 Db &operator = (const Db &);
0387
0388 void cleanup();
0389 int initialize();
0390 int error_policy();
0391
0392
0393 DB *imp_;
0394 Db **slices_;
0395 DbEnv *dbenv_;
0396 DbMpoolFile *mpf_;
0397 int construct_error_;
0398 int internally_managed_;
0399 u_int32_t flags_;
0400 u_int32_t construct_flags_;
0401
0402 static int alt_close(DB *, u_int32_t);
0403
0404 public:
0405
0406
0407
0408
0409 int (*append_recno_callback_)(Db *, Dbt *, db_recno_t);
0410 int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *);
0411 int (*associate_foreign_callback_)
0412 (Db *, const Dbt *, Dbt *, const Dbt *, int *);
0413 int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *, size_t *);
0414 int (*bt_compress_callback_)(
0415 Db *, const Dbt *, const Dbt *, const Dbt *, const Dbt *, Dbt *);
0416 int (*bt_decompress_callback_)(
0417 Db *, const Dbt *, const Dbt *, Dbt *, Dbt *, Dbt *);
0418 size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *);
0419 u_int32_t (*db_partition_callback_)(Db *, Dbt *);
0420 int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *, size_t *);
0421 void (*feedback_callback_)(Db *, int, int);
0422 int (*h_compare_callback_)(Db *, const Dbt *, const Dbt *, size_t *);
0423 u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t);
0424 int (*slice_callback_)(const Db *, const Dbt *, Dbt *);
0425 };
0426
0427
0428
0429
0430 class _exported Dbc : protected DBC
0431 {
0432 friend class Db;
0433
0434 public:
0435 int close();
0436 int cmp(Dbc *other_csr, int *result, u_int32_t flags);
0437 int count(db_recno_t *countp, u_int32_t flags);
0438 int db_stream(DbStream **dbsp, u_int32_t flags);
0439 int del(u_int32_t flags);
0440 int dup(Dbc** cursorp, u_int32_t flags);
0441 int get(Dbt* key, Dbt *data, u_int32_t flags);
0442 int get_priority(DB_CACHE_PRIORITY *priorityp);
0443 int pget(Dbt* key, Dbt* pkey, Dbt *data, u_int32_t flags);
0444 int put(Dbt* key, Dbt *data, u_int32_t flags);
0445 int set_priority(DB_CACHE_PRIORITY priority);
0446
0447 private:
0448
0449
0450
0451
0452
0453 Dbc();
0454 ~Dbc();
0455
0456
0457 Dbc(const Dbc &);
0458 Dbc &operator = (const Dbc &);
0459 };
0460
0461
0462
0463
0464 class _exported DbChannel
0465 {
0466 friend class DbEnv;
0467
0468 public:
0469 int close();
0470 int send_msg(Dbt *msg, u_int32_t nmsg, u_int32_t flags);
0471 int send_request(Dbt *request, u_int32_t nrequest, Dbt *response,
0472 db_timeout_t timeout, u_int32_t flags);
0473 int set_timeout(db_timeout_t timeout);
0474
0475 virtual DB_CHANNEL *get_DB_CHANNEL()
0476 {
0477 return imp_;
0478 }
0479
0480 virtual const DB_CHANNEL *get_const_DB_CHANNEL() const
0481 {
0482 return imp_;
0483 }
0484
0485 private:
0486 DbChannel();
0487 virtual ~DbChannel();
0488
0489
0490 DbChannel(const DbChannel &);
0491 DbChannel &operator = (const DbChannel &);
0492 DB_CHANNEL *imp_;
0493 DbEnv *dbenv_;
0494 };
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505 class _exported DbEnv
0506 {
0507 friend class Db;
0508 friend class DbLock;
0509 friend class DbMpoolFile;
0510
0511 public:
0512
0513
0514
0515
0516
0517 DbEnv(u_int32_t flags);
0518
0519 DbEnv(DB_ENV *dbenv);
0520
0521 virtual ~DbEnv();
0522
0523
0524
0525 virtual int add_data_dir(const char *);
0526 virtual int backup(const char *target, u_int32_t flags);
0527 virtual int cdsgroup_begin(DbTxn **tid);
0528 virtual int close(u_int32_t);
0529 virtual int dbbackup(
0530 const char *dbfile, const char *target, u_int32_t flags);
0531 virtual int dbremove(DbTxn *txn, const char *name, const char *subdb,
0532 u_int32_t flags);
0533 virtual int dbrename(DbTxn *txn, const char *name, const char *subdb,
0534 const char *newname, u_int32_t flags);
0535 virtual void err(int, const char *, ...);
0536 virtual void errx(const char *, ...);
0537 virtual int failchk(u_int32_t);
0538 virtual int fileid_reset(const char *, u_int32_t);
0539 virtual int get_alloc(db_malloc_fcn_type *, db_realloc_fcn_type *,
0540 db_free_fcn_type *);
0541 virtual void *get_app_private() const;
0542 virtual int get_home(const char **);
0543 virtual int get_open_flags(u_int32_t *);
0544 virtual void msg(const char *, ...);
0545 virtual int open(const char *, u_int32_t, int);
0546 virtual int remove(const char *, u_int32_t);
0547 virtual int stat_print(u_int32_t flags);
0548
0549 virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type,
0550 db_free_fcn_type);
0551 virtual void set_app_private(void *);
0552 virtual int get_backup_callbacks(
0553 int (**)(DbEnv *, const char *, const char *, void **),
0554 int (**)(DbEnv *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *),
0555 int (**)(DbEnv *, const char *, void *));
0556 virtual int set_backup_callbacks(
0557 int (*)(DbEnv *, const char *, const char *, void **),
0558 int (*)(DbEnv *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *),
0559 int (*)(DbEnv *, const char *, void *));
0560 virtual int get_backup_config(DB_BACKUP_CONFIG, u_int32_t *);
0561 virtual int set_backup_config(DB_BACKUP_CONFIG, u_int32_t);
0562 virtual int get_blob_dir(const char **);
0563 virtual int set_blob_dir(const char *);
0564 virtual int get_blob_threshold(u_int32_t *);
0565 virtual int set_blob_threshold(u_int32_t, u_int32_t);
0566 virtual int get_cachesize(u_int32_t *, u_int32_t *, int *);
0567 virtual int set_cachesize(u_int32_t, u_int32_t, int);
0568 virtual int get_cache_max(u_int32_t *, u_int32_t *);
0569 virtual int set_cache_max(u_int32_t, u_int32_t);
0570 virtual int get_create_dir(const char **);
0571 virtual int set_create_dir(const char *);
0572 virtual int get_data_dirs(const char ***);
0573 virtual int set_data_dir(const char *);
0574 virtual int get_encrypt_flags(u_int32_t *);
0575 virtual int get_intermediate_dir_mode(const char **);
0576 virtual int set_intermediate_dir_mode(const char *);
0577 virtual int get_isalive(
0578 int (**)(DbEnv *, pid_t, db_threadid_t, u_int32_t));
0579 virtual int set_isalive(
0580 int (*)(DbEnv *, pid_t, db_threadid_t, u_int32_t));
0581 virtual int set_encrypt(const char *, u_int32_t);
0582 virtual void get_errcall(
0583 void (**)(const DbEnv *, const char *, const char *));
0584 virtual void set_errcall(
0585 void (*)(const DbEnv *, const char *, const char *));
0586 virtual void get_errfile(FILE **);
0587 virtual void set_errfile(FILE *);
0588 virtual void get_errpfx(const char **);
0589 virtual void set_errpfx(const char *);
0590 virtual int set_event_notify(void (*)(DbEnv *, u_int32_t, void *));
0591 virtual int get_ext_file_dir(const char **);
0592 virtual int set_ext_file_dir(const char *);
0593 virtual int get_ext_file_threshold(u_int32_t *);
0594 virtual int set_ext_file_threshold(u_int32_t, u_int32_t);
0595 virtual int get_flags(u_int32_t *);
0596 virtual int set_flags(u_int32_t, int);
0597 virtual bool is_bigendian();
0598 virtual int lsn_reset(const char *, u_int32_t);
0599 virtual int get_feedback(void (**)(DbEnv *, int, int));
0600 virtual int set_feedback(void (*)(DbEnv *, int, int));
0601 virtual int get_lg_bsize(u_int32_t *);
0602 virtual int set_lg_bsize(u_int32_t);
0603 virtual int get_lg_dir(const char **);
0604 virtual int set_lg_dir(const char *);
0605 virtual int get_lg_filemode(int *);
0606 virtual int set_lg_filemode(int);
0607 virtual int get_lg_max(u_int32_t *);
0608 virtual int set_lg_max(u_int32_t);
0609 virtual int get_lg_regionmax(u_int32_t *);
0610 virtual int set_lg_regionmax(u_int32_t);
0611 virtual int get_lk_conflicts(const u_int8_t **, int *);
0612 virtual int set_lk_conflicts(u_int8_t *, int);
0613 virtual int get_lk_detect(u_int32_t *);
0614 virtual int set_lk_detect(u_int32_t);
0615 virtual int get_lk_max_lockers(u_int32_t *);
0616 virtual int set_lk_max_lockers(u_int32_t);
0617 virtual int get_lk_max_locks(u_int32_t *);
0618 virtual int set_lk_max_locks(u_int32_t);
0619 virtual int get_lk_max_objects(u_int32_t *);
0620 virtual int set_lk_max_objects(u_int32_t);
0621 virtual int get_lk_partitions(u_int32_t *);
0622 virtual int set_lk_partitions(u_int32_t);
0623 virtual int get_lk_priority(u_int32_t, u_int32_t *);
0624 virtual int set_lk_priority(u_int32_t, u_int32_t);
0625 virtual int get_lk_tablesize(u_int32_t *);
0626 virtual int set_lk_tablesize(u_int32_t);
0627 virtual int get_memory_init(DB_MEM_CONFIG, u_int32_t *);
0628 virtual int set_memory_init(DB_MEM_CONFIG, u_int32_t);
0629 virtual int get_memory_max(u_int32_t *, u_int32_t *);
0630 virtual int set_memory_max(u_int32_t, u_int32_t);
0631 virtual int get_metadata_dir(const char **);
0632 virtual int set_metadata_dir(const char *);
0633 virtual int get_mp_mmapsize(size_t *);
0634 virtual int set_mp_mmapsize(size_t);
0635 virtual int get_mp_max_openfd(int *);
0636 virtual int set_mp_max_openfd(int);
0637 virtual int get_mp_max_write(int *, db_timeout_t *);
0638 virtual int set_mp_max_write(int, db_timeout_t);
0639 virtual int get_mp_pagesize(u_int32_t *);
0640 virtual int set_mp_pagesize(u_int32_t);
0641 virtual int get_mp_tablesize(u_int32_t *);
0642 virtual int set_mp_tablesize(u_int32_t);
0643 virtual void get_msgcall(
0644 void (**)(const DbEnv *, const char *, const char *));
0645 virtual void set_msgcall(
0646 void (*)(const DbEnv *, const char *, const char *));
0647 virtual void get_msgfile(FILE **);
0648 virtual void set_msgfile(FILE *);
0649 virtual void get_msgpfx(const char **);
0650 virtual void set_msgpfx(const char *);
0651 virtual int set_paniccall(void (*)(DbEnv *, int));
0652 virtual int get_region_dir(const char **);
0653 virtual int set_region_dir(const char *);
0654 virtual int get_shm_key(long *);
0655 virtual int set_shm_key(long);
0656 virtual int get_slices(DbEnv ***);
0657 virtual u_int32_t get_slice_count();
0658 virtual int get_timeout(db_timeout_t *, u_int32_t);
0659 virtual int set_timeout(db_timeout_t, u_int32_t);
0660 virtual int get_tmp_dir(const char **);
0661 virtual int set_tmp_dir(const char *);
0662 virtual int get_tx_max(u_int32_t *);
0663 virtual int set_tx_max(u_int32_t);
0664 virtual int get_app_dispatch(
0665 int (**)(DbEnv *, Dbt *, DbLsn *, db_recops));
0666 virtual int set_app_dispatch(int (*)(DbEnv *,
0667 Dbt *, DbLsn *, db_recops));
0668 virtual int get_tx_timestamp(time_t *);
0669 virtual int set_tx_timestamp(time_t *);
0670 virtual int get_verbose(u_int32_t which, int *);
0671 virtual int set_verbose(u_int32_t which, int);
0672
0673
0674
0675 static char *version(int *major, int *minor, int *patch);
0676 static char *full_version(int *family, int *release,
0677 int *major, int *minor, int *patch);
0678
0679
0680 static char *strerror(int);
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691 virtual __DB_STD(ostream) *get_error_stream();
0692 virtual void set_error_stream(__DB_STD(ostream) *);
0693 virtual __DB_STD(ostream) *get_message_stream();
0694 virtual void set_message_stream(__DB_STD(ostream) *);
0695
0696
0697 static void runtime_error(DbEnv *dbenv, const char *caller, int err,
0698 int error_policy);
0699 static void runtime_error_dbt(DbEnv *dbenv, const char *caller, Dbt *dbt,
0700 int error_policy);
0701 static void runtime_error_lock_get(DbEnv *dbenv, const char *caller,
0702 int err, db_lockop_t op, db_lockmode_t mode,
0703 Dbt *obj, DbLock lock, int index,
0704 int error_policy);
0705
0706
0707
0708 virtual int lock_detect(u_int32_t flags, u_int32_t atype, int *aborted);
0709 virtual int lock_get(u_int32_t locker, u_int32_t flags, Dbt *obj,
0710 db_lockmode_t lock_mode, DbLock *lock);
0711 virtual int lock_id(u_int32_t *idp);
0712 virtual int lock_id_free(u_int32_t id);
0713 virtual int lock_put(DbLock *lock);
0714 virtual int lock_stat(DB_LOCK_STAT **statp, u_int32_t flags);
0715 virtual int lock_stat_print(u_int32_t flags);
0716 virtual int lock_vec(u_int32_t locker, u_int32_t flags,
0717 DB_LOCKREQ list[], int nlist, DB_LOCKREQ **elistp);
0718
0719
0720
0721 virtual int log_archive(char **list[], u_int32_t flags);
0722 static int log_compare(const DbLsn *lsn0, const DbLsn *lsn1);
0723 virtual int log_cursor(DbLogc **cursorp, u_int32_t flags);
0724 virtual int log_file(DbLsn *lsn, char *namep, size_t len);
0725 virtual int log_flush(const DbLsn *lsn);
0726 virtual int log_get_config(u_int32_t, int *);
0727 virtual int log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags);
0728 virtual int log_printf(DbTxn *, const char *, ...);
0729 virtual int log_set_config(u_int32_t, int);
0730 virtual int log_stat(DB_LOG_STAT **spp, u_int32_t flags);
0731 virtual int log_stat_print(u_int32_t flags);
0732 virtual int log_verify(DB_LOG_VERIFY_CONFIG *);
0733
0734
0735
0736 virtual int memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags);
0737 virtual int memp_register(int ftype,
0738 pgin_fcn_type pgin_fcn,
0739 pgout_fcn_type pgout_fcn);
0740 virtual int memp_stat(DB_MPOOL_STAT
0741 **gsp, DB_MPOOL_FSTAT ***fsp, u_int32_t flags);
0742 virtual int memp_stat_print(u_int32_t flags);
0743 virtual int memp_sync(DbLsn *lsn);
0744 virtual int memp_trickle(int pct, int *nwrotep);
0745
0746
0747
0748 virtual int mutex_alloc(u_int32_t, db_mutex_t *);
0749 virtual int mutex_free(db_mutex_t);
0750 virtual int mutex_get_align(u_int32_t *);
0751 virtual int mutex_get_increment(u_int32_t *);
0752 virtual int mutex_get_init(u_int32_t *);
0753 virtual int mutex_get_max(u_int32_t *);
0754 virtual int mutex_get_tas_spins(u_int32_t *);
0755 virtual int mutex_lock(db_mutex_t);
0756 virtual int mutex_set_align(u_int32_t);
0757 virtual int mutex_set_increment(u_int32_t);
0758 virtual int mutex_set_init(u_int32_t);
0759 virtual int mutex_set_max(u_int32_t);
0760 virtual int mutex_set_tas_spins(u_int32_t);
0761 virtual int mutex_stat(DB_MUTEX_STAT **, u_int32_t);
0762 virtual int mutex_stat_print(u_int32_t);
0763 virtual int mutex_unlock(db_mutex_t);
0764
0765
0766
0767 virtual int txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags);
0768 virtual int txn_checkpoint(u_int32_t kbyte, u_int32_t min,
0769 u_int32_t flags);
0770 virtual int txn_recover(DbPreplist *preplist, long count,
0771 long *retp, u_int32_t flags);
0772 virtual int txn_stat(DB_TXN_STAT **statp, u_int32_t flags);
0773 virtual int txn_stat_print(u_int32_t flags);
0774
0775
0776
0777 virtual int rep_elect(u_int32_t, u_int32_t, u_int32_t);
0778 virtual int rep_flush();
0779 virtual int rep_process_message(Dbt *, Dbt *, int, DbLsn *);
0780 virtual int rep_start(Dbt *, u_int32_t);
0781 virtual int rep_stat(DB_REP_STAT **statp, u_int32_t flags);
0782 virtual int rep_stat_print(u_int32_t flags);
0783 virtual int rep_get_clockskew(u_int32_t *, u_int32_t *);
0784 virtual int rep_set_clockskew(u_int32_t, u_int32_t);
0785 virtual int rep_get_limit(u_int32_t *, u_int32_t *);
0786 virtual int rep_set_limit(u_int32_t, u_int32_t);
0787 virtual int rep_set_transport(int, int (*)(DbEnv *,
0788 const Dbt *, const Dbt *, const DbLsn *, int, u_int32_t));
0789 virtual int rep_set_request(u_int32_t, u_int32_t);
0790 virtual int rep_get_request(u_int32_t *, u_int32_t *);
0791 virtual int get_thread_count(u_int32_t *);
0792 virtual int set_thread_count(u_int32_t);
0793 virtual int get_thread_id_fn(
0794 void (**)(DbEnv *, pid_t *, db_threadid_t *));
0795 virtual int set_thread_id(void (*)(DbEnv *, pid_t *, db_threadid_t *));
0796 virtual int get_thread_id_string_fn(
0797 char *(**)(DbEnv *, pid_t, db_threadid_t, char *));
0798 virtual int set_thread_id_string(char *(*)(DbEnv *,
0799 pid_t, db_threadid_t, char *));
0800 virtual int rep_set_config(u_int32_t, int);
0801 virtual int rep_get_config(u_int32_t, int *);
0802 virtual int rep_sync(u_int32_t flags);
0803
0804
0805
0806 virtual int rep_get_nsites(u_int32_t *n);
0807 virtual int rep_set_nsites(u_int32_t n);
0808 virtual int rep_get_priority(u_int32_t *priorityp);
0809 virtual int rep_set_priority(u_int32_t priority);
0810 virtual int rep_get_timeout(int which, db_timeout_t *timeout);
0811 virtual int rep_set_timeout(int which, db_timeout_t timeout);
0812 virtual int rep_set_view(int (*)(DbEnv *,
0813 const char *, int *, u_int32_t));
0814 virtual int repmgr_channel(int eid, DbChannel **channel,
0815 u_int32_t flags);
0816 virtual int repmgr_get_ack_policy(int *policy);
0817 virtual int repmgr_set_ack_policy(int policy);
0818 virtual int repmgr_get_incoming_queue_max(u_int32_t *gbytesp,
0819 u_int32_t *bytesp);
0820 virtual int repmgr_set_incoming_queue_max(u_int32_t gbytes,
0821 u_int32_t bytes);
0822 virtual int repmgr_set_socket(int (*approval_func)(DbEnv *,
0823 DB_REPMGR_SOCKET, int *, u_int32_t));
0824 virtual int repmgr_set_ssl_config(int config_type, char *value);
0825 virtual int repmgr_local_site(DbSite **site);
0826 virtual int repmgr_msg_dispatch(void (*) (DbEnv *,
0827 DbChannel *, Dbt *, u_int32_t, u_int32_t), u_int32_t flags);
0828 virtual int repmgr_site(const char *host, u_int port, DbSite **site,
0829 u_int32_t flags);
0830 virtual int repmgr_site_by_eid(int eid, DbSite **site);
0831 virtual int repmgr_site_list(u_int *countp, DB_REPMGR_SITE **listp);
0832 virtual int repmgr_start(int nthreads, u_int32_t flags);
0833 virtual int repmgr_stat(DB_REPMGR_STAT **statp, u_int32_t flags);
0834 virtual int repmgr_stat_print(u_int32_t flags);
0835
0836
0837
0838 virtual ENV *get_ENV()
0839 {
0840 return imp_->env;
0841 }
0842
0843 virtual DB_ENV *get_DB_ENV()
0844 {
0845 return imp_;
0846 }
0847
0848 virtual const DB_ENV *get_const_DB_ENV() const
0849 {
0850 return imp_;
0851 }
0852
0853 static DbEnv* get_DbEnv(DB_ENV *dbenv)
0854 {
0855 return dbenv ? (DbEnv *)dbenv->api1_internal : 0;
0856 }
0857
0858 static const DbEnv* get_const_DbEnv(const DB_ENV *dbenv)
0859 {
0860 return dbenv ? (const DbEnv *)dbenv->api1_internal : 0;
0861 }
0862
0863 u_int32_t get_create_flags() const
0864 {
0865 return construct_flags_;
0866 }
0867
0868
0869 static DbEnv* wrap_DB_ENV(DB_ENV *dbenv);
0870
0871
0872 static bool slices_enabled();
0873
0874
0875
0876
0877
0878 static int _app_dispatch_intercept(DB_ENV *dbenv, DBT *dbt, DB_LSN *lsn,
0879 db_recops op);
0880 static int _backup_close_intercept(DB_ENV *dbenv,
0881 const char *dbname, void *handle);
0882 static int _backup_open_intercept(DB_ENV *dbenv,
0883 const char *dbname, const char *target, void **handle);
0884 static int _backup_write_intercept(DB_ENV *dbenv, u_int32_t off_gbytes,
0885 u_int32_t off_bytes, u_int32_t size, u_int8_t *buf, void *handle);
0886 static void _paniccall_intercept(DB_ENV *dbenv, int errval);
0887 static int _partial_rep_intercept(DB_ENV *dbenv,
0888 const char *name, int *result, u_int32_t flags);
0889 static void _feedback_intercept(DB_ENV *dbenv, int opcode, int pct);
0890 static void _event_func_intercept(DB_ENV *dbenv, u_int32_t, void *);
0891 static int _isalive_intercept(DB_ENV *dbenv, pid_t pid,
0892 db_threadid_t thrid, u_int32_t flags);
0893 static int _rep_send_intercept(DB_ENV *dbenv, const DBT *cntrl,
0894 const DBT *data, const DB_LSN *lsn, int id, u_int32_t flags);
0895 static void _stream_error_function(const DB_ENV *dbenv,
0896 const char *prefix, const char *message);
0897 static void _stream_message_function(const DB_ENV *dbenv,
0898 const char *prefix, const char *message);
0899 static void _thread_id_intercept(DB_ENV *dbenv, pid_t *pidp,
0900 db_threadid_t *thridp);
0901 static char *_thread_id_string_intercept(DB_ENV *dbenv, pid_t pid,
0902 db_threadid_t thrid, char *buf);
0903 static void _message_dispatch_intercept(DB_ENV *dbenv,
0904 DB_CHANNEL *dbchannel, DBT *request, u_int32_t nrequest,
0905 u_int32_t cb_flags);
0906 static int _repmgr_set_socket_intercept(DB_ENV *dbenv,
0907 DB_REPMGR_SOCKET socket, int *result, u_int32_t flags);
0908
0909 private:
0910 void cleanup();
0911 int initialize(DB_ENV *dbenv);
0912 int error_policy();
0913
0914
0915 DbEnv(DB_ENV *, u_int32_t flags);
0916
0917
0918 DbEnv(const DbEnv &);
0919 void operator = (const DbEnv &);
0920
0921
0922 DB_ENV *imp_;
0923 DbEnv **slices_;
0924 int construct_error_;
0925 u_int32_t construct_flags_;
0926 bool internally_managed_;
0927 __DB_STD(ostream) *error_stream_;
0928 __DB_STD(ostream) *message_stream_;
0929
0930 int (*app_dispatch_callback_)(DbEnv *, Dbt *, DbLsn *, db_recops);
0931 int (*backup_close_callback_)(DbEnv *, const char *, void *);
0932 int (*backup_open_callback_)(
0933 DbEnv *, const char *, const char *, void **);
0934 int (*backup_write_callback_)(
0935 DbEnv *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *);
0936 int (*isalive_callback_)(DbEnv *, pid_t, db_threadid_t, u_int32_t);
0937 void (*error_callback_)(const DbEnv *, const char *, const char *);
0938 void (*feedback_callback_)(DbEnv *, int, int);
0939 void (*message_callback_)(const DbEnv *, const char *, const char *);
0940 void (*paniccall_callback_)(DbEnv *, int);
0941 int (*partial_rep_callback_)(DbEnv *, const char *, int *, u_int32_t);
0942 void (*event_func_callback_)(DbEnv *, u_int32_t, void *);
0943 int (*rep_send_callback_)(DbEnv *, const Dbt *, const Dbt *,
0944 const DbLsn *, int, u_int32_t);
0945 void (*thread_id_callback_)(DbEnv *, pid_t *, db_threadid_t *);
0946 char *(*thread_id_string_callback_)(DbEnv *, pid_t, db_threadid_t,
0947 char *);
0948 void (*message_dispatch_callback_)(DbEnv *, DbChannel *, Dbt *,
0949 u_int32_t, u_int32_t);
0950 int (*repmgr_set_socket_callback_)(DbEnv *, DB_REPMGR_SOCKET socket,
0951 int *result, u_int32_t flags);
0952 };
0953
0954
0955
0956
0957 class _exported DbHeapRecordId : private DB_HEAP_RID
0958 {
0959 public:
0960 db_pgno_t get_pgno() const { return pgno; }
0961 void set_pgno(db_pgno_t value) { pgno = value; }
0962
0963 db_indx_t get_indx() const { return indx; }
0964 void set_indx(db_indx_t value) { indx = value; }
0965
0966 DB_HEAP_RID *get_DB_HEAP_RID() { return (DB_HEAP_RID *)this; }
0967 const DB_HEAP_RID *get_const_DB_HEAP_RID() const
0968 { return (const DB_HEAP_RID *)this; }
0969
0970 static DbHeapRecordId* get_DbHeapRecordId(DB_HEAP_RID *rid)
0971 { return (DbHeapRecordId *)rid; }
0972 static const DbHeapRecordId* get_const_DbHeapRecordId(DB_HEAP_RID *rid)
0973 { return (const DbHeapRecordId *)rid; }
0974
0975 DbHeapRecordId(db_pgno_t pgno, db_indx_t indx);
0976 DbHeapRecordId();
0977 ~DbHeapRecordId();
0978 DbHeapRecordId(const DbHeapRecordId &);
0979 DbHeapRecordId &operator = (const DbHeapRecordId &);
0980 };
0981
0982
0983
0984
0985 class _exported DbLock
0986 {
0987 friend class DbEnv;
0988
0989 public:
0990 DbLock();
0991 DbLock(const DbLock &);
0992 DbLock &operator = (const DbLock &);
0993
0994 protected:
0995
0996
0997
0998
0999 DbLock(DB_LOCK);
1000 DB_LOCK lock_;
1001 };
1002
1003
1004
1005
1006 class _exported DbLogc : protected DB_LOGC
1007 {
1008 friend class DbEnv;
1009
1010 public:
1011 int close(u_int32_t _flags);
1012 int get(DbLsn *lsn, Dbt *data, u_int32_t _flags);
1013 int version(u_int32_t *versionp, u_int32_t _flags);
1014
1015 private:
1016
1017
1018
1019
1020
1021 DbLogc();
1022 ~DbLogc();
1023
1024
1025 DbLogc(const Dbc &);
1026 DbLogc &operator = (const Dbc &);
1027 };
1028
1029
1030
1031
1032 class _exported DbLsn : public DB_LSN
1033 {
1034 friend class DbEnv;
1035 friend class DbLogc;
1036 };
1037
1038
1039
1040
1041 class _exported DbMpoolFile
1042 {
1043 friend class DbEnv;
1044 friend class Db;
1045
1046 public:
1047 int close(u_int32_t flags);
1048 int get(db_pgno_t *pgnoaddr, DbTxn *txn, u_int32_t flags, void *pagep);
1049 int get_clear_len(u_int32_t *len);
1050 int get_fileid(u_int8_t *fileid);
1051 int get_flags(u_int32_t *flagsp);
1052 int get_ftype(int *ftype);
1053 int get_last_pgno(db_pgno_t *pgnop);
1054 int get_lsn_offset(int32_t *offsetp);
1055 int get_maxsize(u_int32_t *gbytes, u_int32_t *bytes);
1056 int get_pgcookie(DBT *dbt);
1057 int get_priority(DB_CACHE_PRIORITY *priorityp);
1058 int get_transactional(void);
1059 int open(const char *file, u_int32_t flags, int mode, size_t pagesize);
1060 int put(void *pgaddr, DB_CACHE_PRIORITY priority, u_int32_t flags);
1061 int set_clear_len(u_int32_t len);
1062 int set_fileid(u_int8_t *fileid);
1063 int set_flags(u_int32_t flags, int onoff);
1064 int set_ftype(int ftype);
1065 int set_lsn_offset(int32_t offset);
1066 int set_maxsize(u_int32_t gbytes, u_int32_t bytes);
1067 int set_pgcookie(DBT *dbt);
1068 int set_priority(DB_CACHE_PRIORITY priority);
1069 int sync();
1070
1071 virtual DB_MPOOLFILE *get_DB_MPOOLFILE()
1072 {
1073 return imp_;
1074 }
1075
1076 virtual const DB_MPOOLFILE *get_const_DB_MPOOLFILE() const
1077 {
1078 return imp_;
1079 }
1080
1081 private:
1082 DB_MPOOLFILE *imp_;
1083
1084
1085
1086
1087
1088
1089
1090
1091 DbMpoolFile();
1092
1093
1094 protected:
1095 virtual ~DbMpoolFile();
1096
1097 private:
1098
1099 DbMpoolFile(const DbMpoolFile &);
1100 void operator = (const DbMpoolFile &);
1101 };
1102
1103
1104
1105
1106 class _exported DbPreplist
1107 {
1108 public:
1109 DbTxn *txn;
1110 u_int8_t gid[DB_GID_SIZE];
1111 };
1112
1113
1114
1115
1116 class _exported DbSequence
1117 {
1118 public:
1119 DbSequence(Db *db, u_int32_t flags);
1120 virtual ~DbSequence();
1121
1122 int open(DbTxn *txnid, Dbt *key, u_int32_t flags);
1123 int initial_value(db_seq_t value);
1124 int close(u_int32_t flags);
1125 int remove(DbTxn *txnid, u_int32_t flags);
1126 int stat(DB_SEQUENCE_STAT **sp, u_int32_t flags);
1127 int stat_print(u_int32_t flags);
1128
1129 int get(DbTxn *txnid, u_int32_t delta, db_seq_t *retp, u_int32_t flags);
1130 int get_cachesize(u_int32_t *sizep);
1131 int set_cachesize(u_int32_t size);
1132 int get_flags(u_int32_t *flagsp);
1133 int set_flags(u_int32_t flags);
1134 int get_range(db_seq_t *minp, db_seq_t *maxp);
1135 int set_range(db_seq_t min, db_seq_t max);
1136
1137 Db *get_db();
1138 Dbt *get_key();
1139
1140 virtual DB_SEQUENCE *get_DB_SEQUENCE()
1141 {
1142 return imp_;
1143 }
1144
1145 virtual const DB_SEQUENCE *get_const_DB_SEQUENCE() const
1146 {
1147 return imp_;
1148 }
1149
1150 static DbSequence* get_DbSequence(DB_SEQUENCE *seq)
1151 {
1152 return (DbSequence *)seq->api_internal;
1153 }
1154
1155 static const DbSequence* get_const_DbSequence(const DB_SEQUENCE *seq)
1156 {
1157 return (const DbSequence *)seq->api_internal;
1158 }
1159
1160
1161 static DbSequence* wrap_DB_SEQUENCE(DB_SEQUENCE *seq);
1162
1163 private:
1164 DbSequence(DB_SEQUENCE *seq);
1165
1166 DbSequence(const DbSequence &);
1167 DbSequence &operator = (const DbSequence &);
1168
1169 DB_SEQUENCE *imp_;
1170 DBT key_;
1171 };
1172
1173
1174
1175
1176 class _exported DbSite
1177 {
1178 friend class DbEnv;
1179
1180 public:
1181 int close();
1182 int get_address(const char **hostp, u_int *port);
1183 int get_config(u_int32_t which, u_int32_t *value);
1184 int get_eid(int *eidp);
1185 int remove();
1186 int set_config(u_int32_t which, u_int32_t value);
1187
1188 virtual DB_SITE *get_DB_SITE()
1189 {
1190 return imp_;
1191 }
1192
1193 virtual const DB_SITE *get_const_DB_SITE() const
1194 {
1195 return imp_;
1196 }
1197
1198 private:
1199 DbSite();
1200 virtual ~DbSite();
1201
1202
1203 DbSite(const DbSite &);
1204 DbSite &operator = (const DbSite &);
1205 DB_SITE *imp_;
1206 };
1207
1208
1209
1210
1211 class _exported DbStream : protected DB_STREAM
1212 {
1213 friend class Dbc;
1214
1215 public:
1216 int close(u_int32_t flags);
1217 int read(Dbt *data, db_off_t offset, u_int32_t size, u_int32_t flags);
1218 int size(db_off_t *size, u_int32_t flags);
1219 int write(Dbt *data, db_off_t offset, u_int32_t flags);
1220
1221 private:
1222
1223
1224
1225
1226
1227 DbStream();
1228 ~DbStream();
1229
1230
1231 DbStream(const DbStream &);
1232 DbStream &operator = (const DbStream &);
1233
1234 };
1235
1236
1237
1238
1239 class _exported DbTxn
1240 {
1241 friend class DbEnv;
1242
1243 public:
1244 int abort();
1245 int commit(u_int32_t flags);
1246 int discard(u_int32_t flags);
1247 u_int32_t id();
1248 int get_name(const char **namep);
1249 int get_priority(u_int32_t *priorityp);
1250 int prepare(u_int8_t *gid);
1251 int set_name(const char *name);
1252 int set_priority(u_int32_t priority);
1253 int set_timeout(db_timeout_t timeout, u_int32_t flags);
1254
1255 virtual DB_TXN *get_DB_TXN()
1256 {
1257 return imp_;
1258 }
1259
1260 virtual const DB_TXN *get_const_DB_TXN() const
1261 {
1262 return imp_;
1263 }
1264
1265 static DbTxn* get_DbTxn(DB_TXN *txn)
1266 {
1267 return (DbTxn *)txn->api_internal;
1268 }
1269
1270 static const DbTxn* get_const_DbTxn(const DB_TXN *txn)
1271 {
1272 return (const DbTxn *)txn->api_internal;
1273 }
1274
1275
1276 static DbTxn* wrap_DB_TXN(DB_TXN *txn);
1277 void remove_child_txn(DbTxn *kid);
1278 void add_child_txn(DbTxn *kid);
1279
1280 void set_parent(DbTxn *ptxn)
1281 {
1282 parent_txn_ = ptxn;
1283 }
1284
1285 private:
1286 DB_TXN *imp_;
1287
1288
1289
1290
1291
1292
1293
1294
1295 DbTxn *parent_txn_;
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305 DbTxn(DbTxn *ptxn);
1306
1307 DbTxn(DB_TXN *txn, DbTxn *ptxn);
1308 virtual ~DbTxn();
1309
1310
1311 DbTxn(const DbTxn &);
1312 void operator = (const DbTxn &);
1313
1314
1315
1316
1317
1318
1319 struct __children {
1320 DbTxn *tqh_first;
1321 DbTxn **tqh_last;
1322 } children;
1323
1324
1325
1326
1327
1328
1329 struct {
1330 DbTxn *tqe_next;
1331 DbTxn **tqe_prev;
1332 } child_entry;
1333 };
1334
1335
1336
1337
1338 class _exported Dbt : private DBT
1339 {
1340 friend class Db;
1341 friend class Dbc;
1342 friend class DbEnv;
1343 friend class DbLogc;
1344 friend class DbSequence;
1345 friend class DbStream;
1346
1347 public:
1348
1349 void *get_data() const { return data; }
1350 void set_data(void *value) { data = value; }
1351
1352
1353 u_int32_t get_size() const { return size; }
1354 void set_size(u_int32_t value) { size = value; }
1355
1356
1357 u_int32_t get_ulen() const { return ulen; }
1358 void set_ulen(u_int32_t value) { ulen = value; }
1359
1360
1361 u_int32_t get_dlen() const { return dlen; }
1362 void set_dlen(u_int32_t value) { dlen = value; }
1363
1364
1365 u_int32_t get_doff() const { return doff; }
1366 void set_doff(u_int32_t value) { doff = value; }
1367
1368
1369 u_int32_t get_flags() const { return flags; }
1370 void set_flags(u_int32_t value) { flags = value; }
1371
1372
1373 DBT *get_DBT() { return (DBT *)this; }
1374 const DBT *get_const_DBT() const { return (const DBT *)this; }
1375
1376 static Dbt* get_Dbt(DBT *dbt) { return (Dbt *)dbt; }
1377 static const Dbt* get_const_Dbt(const DBT *dbt)
1378 { return (const Dbt *)dbt; }
1379
1380 Dbt(void *data, u_int32_t size);
1381 Dbt();
1382 ~Dbt();
1383 Dbt(const Dbt &);
1384 Dbt &operator = (const Dbt &);
1385
1386 private:
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396 };
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407 class _exported DbMultipleIterator
1408 {
1409 public:
1410 DbMultipleIterator(const Dbt &dbt);
1411 protected:
1412 u_int8_t *data_;
1413 u_int32_t *p_;
1414 };
1415
1416 class _exported DbMultipleKeyDataIterator : private DbMultipleIterator
1417 {
1418 public:
1419 DbMultipleKeyDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {}
1420 bool next(Dbt &key, Dbt &data);
1421 };
1422
1423 class _exported DbMultipleRecnoDataIterator : private DbMultipleIterator
1424 {
1425 public:
1426 DbMultipleRecnoDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {}
1427 bool next(db_recno_t &recno, Dbt &data);
1428 };
1429
1430 class _exported DbMultipleDataIterator : private DbMultipleIterator
1431 {
1432 public:
1433 DbMultipleDataIterator(const Dbt &dbt) : DbMultipleIterator(dbt) {}
1434 bool next(Dbt &data);
1435 };
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446 class _exported DbMultipleBuilder
1447 {
1448 public:
1449 DbMultipleBuilder(Dbt &dbt);
1450 protected:
1451 Dbt &dbt_;
1452 void *p_;
1453 };
1454
1455 class _exported DbMultipleDataBuilder : DbMultipleBuilder
1456 {
1457 public:
1458 DbMultipleDataBuilder(Dbt &dbt) : DbMultipleBuilder(dbt) {}
1459 bool append(void *dbuf, size_t dlen);
1460 bool reserve(void *&ddest, size_t dlen);
1461 };
1462
1463 class _exported DbMultipleKeyDataBuilder : DbMultipleBuilder
1464 {
1465 public:
1466 DbMultipleKeyDataBuilder(Dbt &dbt) : DbMultipleBuilder(dbt) {}
1467 bool append(void *kbuf, size_t klen, void *dbuf, size_t dlen);
1468 bool reserve(void *&kdest, size_t klen, void *&ddest, size_t dlen);
1469 };
1470
1471 class _exported DbMultipleRecnoDataBuilder
1472 {
1473 public:
1474 DbMultipleRecnoDataBuilder(Dbt &dbt);
1475 bool append(db_recno_t recno, void *dbuf, size_t dlen);
1476 bool reserve(db_recno_t recno, void *&ddest, size_t dlen);
1477 protected:
1478 Dbt &dbt_;
1479 void *p_;
1480 };
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492 class _exported DbException : public __DB_STD(exception)
1493 {
1494 public:
1495 virtual ~DbException() throw();
1496 DbException(int err);
1497 DbException(const char *description);
1498 DbException(const char *description, int err);
1499 DbException(const char *prefix, const char *description, int err);
1500 int get_errno() const;
1501 virtual const char *what() const throw();
1502 DbEnv *get_env() const;
1503 void set_env(DbEnv *dbenv);
1504
1505 DbException(const DbException &);
1506 DbException &operator = (const DbException &);
1507
1508 private:
1509 void describe(const char *prefix, const char *description);
1510
1511 char *what_;
1512 int err_;
1513 DbEnv *dbenv_;
1514 };
1515
1516
1517
1518
1519
1520 class _exported DbDeadlockException : public DbException
1521 {
1522 public:
1523 virtual ~DbDeadlockException() throw();
1524 DbDeadlockException(const char *description);
1525
1526 DbDeadlockException(const DbDeadlockException &);
1527 DbDeadlockException &operator = (const DbDeadlockException &);
1528 };
1529
1530
1531
1532
1533
1534
1535
1536 class _exported DbLockNotGrantedException : public DbException
1537 {
1538 public:
1539 virtual ~DbLockNotGrantedException() throw();
1540 DbLockNotGrantedException(const char *prefix, db_lockop_t op,
1541 db_lockmode_t mode, const Dbt *obj, const DbLock lock, int index);
1542 DbLockNotGrantedException(const char *description);
1543
1544 DbLockNotGrantedException(const DbLockNotGrantedException &);
1545 DbLockNotGrantedException &operator =
1546 (const DbLockNotGrantedException &);
1547
1548 db_lockop_t get_op() const;
1549 db_lockmode_t get_mode() const;
1550 const Dbt* get_obj() const;
1551 DbLock *get_lock() const;
1552 int get_index() const;
1553
1554 private:
1555 db_lockop_t op_;
1556 db_lockmode_t mode_;
1557 const Dbt *obj_;
1558 DbLock *lock_;
1559 int index_;
1560 };
1561
1562
1563
1564
1565
1566 class _exported DbMemoryException : public DbException
1567 {
1568 public:
1569 virtual ~DbMemoryException() throw();
1570 DbMemoryException(Dbt *dbt);
1571 DbMemoryException(const char *prefix, Dbt *dbt);
1572
1573 DbMemoryException(const DbMemoryException &);
1574 DbMemoryException &operator = (const DbMemoryException &);
1575
1576 Dbt *get_dbt() const;
1577 private:
1578 Dbt *dbt_;
1579 };
1580
1581
1582
1583
1584
1585 class _exported DbRepHandleDeadException : public DbException
1586 {
1587 public:
1588 virtual ~DbRepHandleDeadException() throw();
1589 DbRepHandleDeadException(const char *description);
1590
1591 DbRepHandleDeadException(const DbRepHandleDeadException &);
1592 DbRepHandleDeadException &operator = (const DbRepHandleDeadException &);
1593 };
1594
1595
1596
1597
1598
1599 class _exported DbRunRecoveryException : public DbException
1600 {
1601 public:
1602 virtual ~DbRunRecoveryException() throw();
1603 DbRunRecoveryException(const char *description);
1604
1605 DbRunRecoveryException(const DbRunRecoveryException &);
1606 DbRunRecoveryException &operator = (const DbRunRecoveryException &);
1607 };
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617 #ifdef _MSC_VER
1618 #pragma warning(pop)
1619 #endif
1620
1621 #endif