PageRenderTime 29ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/SN-NG4.2/db4/cxx/cxx_db.cpp

https://gitlab.com/OpenSourceMirror/sourcenav
C++ | 668 lines | 446 code | 104 blank | 118 comment | 41 complexity | 7f5f48fbd2bc6b66f9fe47a77bb03e7b MD5 | raw file
  1. /*-
  2. * See the file LICENSE for redistribution information.
  3. *
  4. * Copyright (c) 1997,2007 Oracle. All rights reserved.
  5. *
  6. * $Id: cxx_db.cpp,v 12.20 2007/06/28 13:02:50 mjc Exp $
  7. */
  8. #include "db_config.h"
  9. #include "db_int.h"
  10. #include "db_cxx.h"
  11. #include "dbinc/cxx_int.h"
  12. #include "dbinc/db_page.h"
  13. #include "dbinc_auto/db_auto.h"
  14. #include "dbinc_auto/crdel_auto.h"
  15. #include "dbinc/db_dispatch.h"
  16. #include "dbinc_auto/db_ext.h"
  17. #include "dbinc_auto/common_ext.h"
  18. // Helper macros for simple methods that pass through to the
  19. // underlying C method. It may return an error or raise an exception.
  20. // Note this macro expects that input _argspec is an argument
  21. // list element (e.g., "char *arg") and that _arglist is the arguments
  22. // that should be passed through to the C method (e.g., "(db, arg)")
  23. //
  24. #define DB_METHOD(_name, _argspec, _arglist, _retok) \
  25. int Db::_name _argspec \
  26. { \
  27. int ret; \
  28. DB *db = unwrap(this); \
  29. \
  30. ret = db->_name _arglist; \
  31. if (!_retok(ret)) \
  32. DB_ERROR(env_, "Db::" # _name, ret, error_policy()); \
  33. return (ret); \
  34. }
  35. #define DB_DESTRUCTOR(_name, _argspec, _arglist, _retok) \
  36. int Db::_name _argspec \
  37. { \
  38. int ret; \
  39. DB *db = unwrap(this); \
  40. \
  41. if (!db) { \
  42. DB_ERROR(env_, "Db::" # _name, EINVAL, error_policy()); \
  43. return (EINVAL); \
  44. } \
  45. ret = db->_name _arglist; \
  46. cleanup(); \
  47. if (!_retok(ret)) \
  48. DB_ERROR(env_, "Db::" # _name, ret, error_policy()); \
  49. return (ret); \
  50. }
  51. #define DB_METHOD_QUIET(_name, _argspec, _arglist) \
  52. int Db::_name _argspec \
  53. { \
  54. DB *db = unwrap(this); \
  55. \
  56. return (db->_name _arglist); \
  57. }
  58. #define DB_METHOD_VOID(_name, _argspec, _arglist) \
  59. void Db::_name _argspec \
  60. { \
  61. DB *db = unwrap(this); \
  62. \
  63. db->_name _arglist; \
  64. }
  65. // A truism for the Db object is that there is a valid
  66. // DB handle from the constructor until close().
  67. // After the close, the DB handle is invalid and
  68. // no operations are permitted on the Db (other than
  69. // destructor). Leaving the Db handle open and not
  70. // doing a close is generally considered an error.
  71. //
  72. // We used to allow Db objects to be closed and reopened.
  73. // This implied always keeping a valid DB object, and
  74. // coordinating the open objects between Db/DbEnv turned
  75. // out to be overly complicated. Now we do not allow this.
  76. Db::Db(DbEnv *env, u_int32_t flags)
  77. : imp_(0)
  78. , env_(env)
  79. , mpf_(0)
  80. , construct_error_(0)
  81. , flags_(0)
  82. , construct_flags_(flags)
  83. , append_recno_callback_(0)
  84. , associate_callback_(0)
  85. , bt_compare_callback_(0)
  86. , bt_prefix_callback_(0)
  87. , dup_compare_callback_(0)
  88. , feedback_callback_(0)
  89. , h_compare_callback_(0)
  90. , h_hash_callback_(0)
  91. {
  92. if (env_ == 0)
  93. flags_ |= DB_CXX_PRIVATE_ENV;
  94. if ((construct_error_ = initialize()) != 0)
  95. DB_ERROR(env_, "Db::Db", construct_error_, error_policy());
  96. }
  97. // If the DB handle is still open, we close it. This is to make stack
  98. // allocation of Db objects easier so that they are cleaned up in the error
  99. // path. If the environment was closed prior to this, it may cause a trap, but
  100. // an error message is generated during the environment close. Applications
  101. // should call close explicitly in normal (non-exceptional) cases to check the
  102. // return value.
  103. //
  104. Db::~Db()
  105. {
  106. DB *db;
  107. db = unwrap(this);
  108. if (db != NULL) {
  109. (void)db->close(db, 0);
  110. cleanup();
  111. }
  112. }
  113. // private method to initialize during constructor.
  114. // initialize must create a backing DB object,
  115. // and if that creates a new DB_ENV, it must be tied to a new DbEnv.
  116. //
  117. int Db::initialize()
  118. {
  119. DB *db;
  120. DB_ENV *cenv = unwrap(env_);
  121. int ret;
  122. u_int32_t cxx_flags;
  123. cxx_flags = construct_flags_ & DB_CXX_NO_EXCEPTIONS;
  124. // Create a new underlying DB object.
  125. // We rely on the fact that if a NULL DB_ENV* is given,
  126. // one is allocated by DB.
  127. //
  128. if ((ret = db_create(&db, cenv,
  129. construct_flags_ & ~cxx_flags)) != 0)
  130. return (ret);
  131. // Associate the DB with this object
  132. imp_ = db;
  133. db->api_internal = this;
  134. // Create a new DbEnv from a DB_ENV* if it was created locally.
  135. // It is deleted in Db::close().
  136. //
  137. if ((flags_ & DB_CXX_PRIVATE_ENV) != 0)
  138. env_ = new DbEnv(db->dbenv, cxx_flags);
  139. // Create a DbMpoolFile from the DB_MPOOLFILE* in the DB handle.
  140. mpf_ = new DbMpoolFile();
  141. mpf_->imp_ = db->mpf;
  142. return (0);
  143. }
  144. // private method to cleanup after destructor or during close.
  145. // If the environment was created by this Db object, we need to delete it.
  146. //
  147. void Db::cleanup()
  148. {
  149. if (imp_ != 0) {
  150. imp_ = 0;
  151. // we must dispose of the DbEnv object if
  152. // we created it. This will be the case
  153. // if a NULL DbEnv was passed into the constructor.
  154. // The underlying DB_ENV object will be inaccessible
  155. // after the close, so we must clean it up now.
  156. //
  157. if ((flags_ & DB_CXX_PRIVATE_ENV) != 0) {
  158. env_->cleanup();
  159. delete env_;
  160. env_ = 0;
  161. }
  162. delete mpf_;
  163. }
  164. }
  165. // Return a tristate value corresponding to whether we should
  166. // throw exceptions on errors:
  167. // ON_ERROR_RETURN
  168. // ON_ERROR_THROW
  169. // ON_ERROR_UNKNOWN
  170. //
  171. int Db::error_policy()
  172. {
  173. if (env_ != NULL)
  174. return (env_->error_policy());
  175. else {
  176. // If the env_ is null, that means that the user
  177. // did not attach an environment, so the correct error
  178. // policy can be deduced from constructor flags
  179. // for this Db.
  180. //
  181. if ((construct_flags_ & DB_CXX_NO_EXCEPTIONS) != 0) {
  182. return (ON_ERROR_RETURN);
  183. }
  184. else {
  185. return (ON_ERROR_THROW);
  186. }
  187. }
  188. }
  189. DB_DESTRUCTOR(close, (u_int32_t flags), (db, flags), DB_RETOK_STD)
  190. DB_METHOD(compact, (DbTxn *txnid, Dbt *start, Dbt *stop,
  191. DB_COMPACT *c_data, u_int32_t flags, Dbt *end),
  192. (db, unwrap(txnid), start, stop, c_data, flags, end), DB_RETOK_STD)
  193. // The following cast implies that Dbc can be no larger than DBC
  194. DB_METHOD(cursor, (DbTxn *txnid, Dbc **cursorp, u_int32_t flags),
  195. (db, unwrap(txnid), (DBC **)cursorp, flags),
  196. DB_RETOK_STD)
  197. DB_METHOD(del, (DbTxn *txnid, Dbt *key, u_int32_t flags),
  198. (db, unwrap(txnid), key, flags),
  199. DB_RETOK_DBDEL)
  200. void Db::err(int error, const char *format, ...)
  201. {
  202. DB *db = unwrap(this);
  203. DB_REAL_ERR(db->dbenv, error, DB_ERROR_SET, 1, format);
  204. }
  205. void Db::errx(const char *format, ...)
  206. {
  207. DB *db = unwrap(this);
  208. DB_REAL_ERR(db->dbenv, 0, DB_ERROR_NOT_SET, 1, format);
  209. }
  210. DB_METHOD(exists, (DbTxn *txnid, Dbt *key, u_int32_t flags),
  211. (db, unwrap(txnid), key, flags), DB_RETOK_EXISTS)
  212. DB_METHOD(fd, (int *fdp), (db, fdp), DB_RETOK_STD)
  213. int Db::get(DbTxn *txnid, Dbt *key, Dbt *value, u_int32_t flags)
  214. {
  215. DB *db = unwrap(this);
  216. int ret;
  217. ret = db->get(db, unwrap(txnid), key, value, flags);
  218. if (!DB_RETOK_DBGET(ret)) {
  219. if (ret == DB_BUFFER_SMALL)
  220. DB_ERROR_DBT(env_, "Db::get", value, error_policy());
  221. else
  222. DB_ERROR(env_, "Db::get", ret, error_policy());
  223. }
  224. return (ret);
  225. }
  226. int Db::get_byteswapped(int *isswapped)
  227. {
  228. DB *db = (DB *)unwrapConst(this);
  229. return (db->get_byteswapped(db, isswapped));
  230. }
  231. DbEnv *Db::get_env()
  232. {
  233. DB *db = (DB *)unwrapConst(this);
  234. DB_ENV *dbenv = db->get_env(db);
  235. return (dbenv != NULL ? DbEnv::get_DbEnv(dbenv) : NULL);
  236. }
  237. DbMpoolFile *Db::get_mpf()
  238. {
  239. return (mpf_);
  240. }
  241. DB_METHOD(get_dbname, (const char **filenamep, const char **dbnamep),
  242. (db, filenamep, dbnamep), DB_RETOK_STD)
  243. DB_METHOD(get_open_flags, (u_int32_t *flagsp), (db, flagsp), DB_RETOK_STD)
  244. int Db::get_type(DBTYPE *dbtype)
  245. {
  246. DB *db = (DB *)unwrapConst(this);
  247. return (db->get_type(db, dbtype));
  248. }
  249. // Dbc is a "compatible" subclass of DBC - that is, no virtual functions
  250. // or even extra data members, so these casts, although technically
  251. // non-portable, "should" always be okay.
  252. DB_METHOD(join, (Dbc **curslist, Dbc **cursorp, u_int32_t flags),
  253. (db, (DBC **)curslist, (DBC **)cursorp, flags), DB_RETOK_STD)
  254. DB_METHOD(key_range,
  255. (DbTxn *txnid, Dbt *key, DB_KEY_RANGE *results, u_int32_t flags),
  256. (db, unwrap(txnid), key, results, flags), DB_RETOK_STD)
  257. // If an error occurred during the constructor, report it now.
  258. // Otherwise, call the underlying DB->open method.
  259. //
  260. int Db::open(DbTxn *txnid, const char *file, const char *database,
  261. DBTYPE type, u_int32_t flags, int mode)
  262. {
  263. int ret;
  264. DB *db = unwrap(this);
  265. if (construct_error_ != 0)
  266. ret = construct_error_;
  267. else
  268. ret = db->open(db, unwrap(txnid), file, database, type, flags,
  269. mode);
  270. if (!DB_RETOK_STD(ret))
  271. DB_ERROR(env_, "Db::open", ret, error_policy());
  272. return (ret);
  273. }
  274. int Db::pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *value, u_int32_t flags)
  275. {
  276. DB *db = unwrap(this);
  277. int ret;
  278. ret = db->pget(db, unwrap(txnid), key, pkey, value, flags);
  279. /* The logic here is identical to Db::get - reuse the macro. */
  280. if (!DB_RETOK_DBGET(ret)) {
  281. if (ret == DB_BUFFER_SMALL && DB_OVERFLOWED_DBT(value))
  282. DB_ERROR_DBT(env_, "Db::pget", value, error_policy());
  283. else
  284. DB_ERROR(env_, "Db::pget", ret, error_policy());
  285. }
  286. return (ret);
  287. }
  288. DB_METHOD(put, (DbTxn *txnid, Dbt *key, Dbt *value, u_int32_t flags),
  289. (db, unwrap(txnid), key, value, flags), DB_RETOK_DBPUT)
  290. DB_DESTRUCTOR(rename,
  291. (const char *file, const char *database, const char *newname,
  292. u_int32_t flags),
  293. (db, file, database, newname, flags), DB_RETOK_STD)
  294. DB_DESTRUCTOR(remove, (const char *file, const char *database, u_int32_t flags),
  295. (db, file, database, flags), DB_RETOK_STD)
  296. DB_METHOD(truncate, (DbTxn *txnid, u_int32_t *countp, u_int32_t flags),
  297. (db, unwrap(txnid), countp, flags), DB_RETOK_STD)
  298. DB_METHOD(stat, (DbTxn *txnid, void *sp, u_int32_t flags),
  299. (db, unwrap(txnid), sp, flags), DB_RETOK_STD)
  300. DB_METHOD(stat_print, (u_int32_t flags), (db, flags), DB_RETOK_STD)
  301. DB_METHOD(sync, (u_int32_t flags), (db, flags), DB_RETOK_STD)
  302. DB_METHOD(upgrade,
  303. (const char *name, u_int32_t flags), (db, name, flags), DB_RETOK_STD)
  304. ////////////////////////////////////////////////////////////////////////
  305. //
  306. // callbacks
  307. //
  308. // *_intercept_c are 'glue' functions that must be declared
  309. // as extern "C" so to be typesafe. Using a C++ method, even
  310. // a static class method with 'correct' arguments, will not pass
  311. // the test; some picky compilers do not allow mixing of function
  312. // pointers to 'C' functions with function pointers to C++ functions.
  313. //
  314. // One wart with this scheme is that the *_callback_ method pointer
  315. // must be declared public to be accessible by the C intercept.
  316. // It's possible to accomplish the goal without this, and with
  317. // another public transfer method, but it's just too much overhead.
  318. // These callbacks are supposed to be *fast*.
  319. //
  320. // The DBTs we receive in these callbacks from the C layer may be
  321. // manufactured there, but we want to treat them as a Dbts.
  322. // Technically speaking, these DBTs were not constructed as a Dbts,
  323. // but it should be safe to cast them as such given that Dbt is a
  324. // *very* thin extension of the DBT. That is, Dbt has no additional
  325. // data elements, does not use virtual functions, virtual inheritance,
  326. // multiple inheritance, RTI, or any other language feature that
  327. // causes the structure to grow or be displaced. Although this may
  328. // sound risky, a design goal of C++ is complete structure
  329. // compatibility with C, and has the philosophy 'if you don't use it,
  330. // you shouldn't incur the overhead'. If the C/C++ compilers you're
  331. // using on a given machine do not have matching struct layouts, then
  332. // a lot more things will be broken than just this.
  333. //
  334. // The alternative, creating a Dbt here in the callback, and populating
  335. // it from the DBT, is just too slow and cumbersome to be very useful.
  336. // These macros avoid a lot of boilerplate code for callbacks
  337. #define DB_CALLBACK_C_INTERCEPT(_name, _rettype, _cargspec, \
  338. _return, _cxxargs) \
  339. extern "C" _rettype _db_##_name##_intercept_c _cargspec \
  340. { \
  341. Db *cxxthis; \
  342. \
  343. /* We don't have a dbenv handle at this point. */ \
  344. DB_ASSERT(NULL, cthis != NULL); \
  345. cxxthis = Db::get_Db(cthis); \
  346. DB_ASSERT(cthis->dbenv, cxxthis != NULL); \
  347. DB_ASSERT(cthis->dbenv, cxxthis->_name##_callback_ != 0); \
  348. \
  349. _return (*cxxthis->_name##_callback_) _cxxargs; \
  350. }
  351. #define DB_SET_CALLBACK(_cxxname, _name, _cxxargspec, _cb) \
  352. int Db::_cxxname _cxxargspec \
  353. { \
  354. DB *cthis = unwrap(this); \
  355. \
  356. _name##_callback_ = _cb; \
  357. return ((*(cthis->_cxxname))(cthis, \
  358. (_cb) ? _db_##_name##_intercept_c : NULL)); \
  359. }
  360. /* associate callback - doesn't quite fit the pattern because of the flags */
  361. DB_CALLBACK_C_INTERCEPT(associate,
  362. int, (DB *cthis, const DBT *key, const DBT *data, DBT *retval),
  363. return, (cxxthis, Dbt::get_const_Dbt(key), Dbt::get_const_Dbt(data),
  364. Dbt::get_Dbt(retval)))
  365. int Db::associate(DbTxn *txn, Db *secondary, int (*callback)(Db *, const Dbt *,
  366. const Dbt *, Dbt *), u_int32_t flags)
  367. {
  368. DB *cthis = unwrap(this);
  369. /* Since the secondary Db is used as the first argument
  370. * to the callback, we store the C++ callback on it
  371. * rather than on 'this'.
  372. */
  373. secondary->associate_callback_ = callback;
  374. return ((*(cthis->associate))(cthis, unwrap(txn), unwrap(secondary),
  375. (callback) ? _db_associate_intercept_c : NULL, flags));
  376. }
  377. DB_CALLBACK_C_INTERCEPT(feedback,
  378. void, (DB *cthis, int opcode, int pct),
  379. /* no return */ (void), (cxxthis, opcode, pct))
  380. DB_SET_CALLBACK(set_feedback, feedback,
  381. (void (*arg)(Db *cxxthis, int opcode, int pct)), arg)
  382. DB_CALLBACK_C_INTERCEPT(append_recno,
  383. int, (DB *cthis, DBT *data, db_recno_t recno),
  384. return, (cxxthis, Dbt::get_Dbt(data), recno))
  385. DB_SET_CALLBACK(set_append_recno, append_recno,
  386. (int (*arg)(Db *cxxthis, Dbt *data, db_recno_t recno)), arg)
  387. DB_CALLBACK_C_INTERCEPT(bt_compare,
  388. int, (DB *cthis, const DBT *data1, const DBT *data2),
  389. return,
  390. (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2)))
  391. DB_SET_CALLBACK(set_bt_compare, bt_compare,
  392. (int (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg)
  393. DB_CALLBACK_C_INTERCEPT(bt_prefix,
  394. size_t, (DB *cthis, const DBT *data1, const DBT *data2),
  395. return,
  396. (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2)))
  397. DB_SET_CALLBACK(set_bt_prefix, bt_prefix,
  398. (size_t (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg)
  399. DB_CALLBACK_C_INTERCEPT(dup_compare,
  400. int, (DB *cthis, const DBT *data1, const DBT *data2),
  401. return,
  402. (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2)))
  403. DB_SET_CALLBACK(set_dup_compare, dup_compare,
  404. (int (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg)
  405. DB_CALLBACK_C_INTERCEPT(h_compare,
  406. int, (DB *cthis, const DBT *data1, const DBT *data2),
  407. return,
  408. (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2)))
  409. DB_SET_CALLBACK(set_h_compare, h_compare,
  410. (int (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg)
  411. DB_CALLBACK_C_INTERCEPT(h_hash,
  412. u_int32_t, (DB *cthis, const void *data, u_int32_t len),
  413. return, (cxxthis, data, len))
  414. DB_SET_CALLBACK(set_h_hash, h_hash,
  415. (u_int32_t (*arg)(Db *cxxthis, const void *data, u_int32_t len)), arg)
  416. // This is a 'glue' function declared as extern "C" so it will
  417. // be compatible with picky compilers that do not allow mixing
  418. // of function pointers to 'C' functions with function pointers
  419. // to C++ functions.
  420. //
  421. extern "C"
  422. int _verify_callback_c(void *handle, const void *str_arg)
  423. {
  424. char *str;
  425. __DB_STD(ostream) *out;
  426. str = (char *)str_arg;
  427. out = (__DB_STD(ostream) *)handle;
  428. (*out) << str;
  429. if (out->fail())
  430. return (EIO);
  431. return (0);
  432. }
  433. int Db::verify(const char *name, const char *subdb,
  434. __DB_STD(ostream) *ostr, u_int32_t flags)
  435. {
  436. DB *db = unwrap(this);
  437. int ret;
  438. if (!db)
  439. ret = EINVAL;
  440. else {
  441. ret = __db_verify_internal(db, name, subdb, ostr,
  442. _verify_callback_c, flags);
  443. // After a DB->verify (no matter if success or failure),
  444. // the underlying DB object must not be accessed.
  445. //
  446. cleanup();
  447. }
  448. if (!DB_RETOK_STD(ret))
  449. DB_ERROR(env_, "Db::verify", ret, error_policy());
  450. return (ret);
  451. }
  452. DB_METHOD(set_bt_compare, (bt_compare_fcn_type func),
  453. (db, func), DB_RETOK_STD)
  454. DB_METHOD(get_bt_minkey, (u_int32_t *bt_minkeyp),
  455. (db, bt_minkeyp), DB_RETOK_STD)
  456. DB_METHOD(set_bt_minkey, (u_int32_t bt_minkey),
  457. (db, bt_minkey), DB_RETOK_STD)
  458. DB_METHOD(set_bt_prefix, (bt_prefix_fcn_type func),
  459. (db, func), DB_RETOK_STD)
  460. DB_METHOD(set_dup_compare, (dup_compare_fcn_type func),
  461. (db, func), DB_RETOK_STD)
  462. DB_METHOD(get_encrypt_flags, (u_int32_t *flagsp),
  463. (db, flagsp), DB_RETOK_STD)
  464. DB_METHOD(set_encrypt, (const char *passwd, u_int32_t flags),
  465. (db, passwd, flags), DB_RETOK_STD)
  466. DB_METHOD_VOID(get_errfile, (FILE **errfilep), (db, errfilep))
  467. DB_METHOD_VOID(set_errfile, (FILE *errfile), (db, errfile))
  468. DB_METHOD_VOID(get_errpfx, (const char **errpfx), (db, errpfx))
  469. DB_METHOD_VOID(set_errpfx, (const char *errpfx), (db, errpfx))
  470. DB_METHOD(get_flags, (u_int32_t *flagsp), (db, flagsp),
  471. DB_RETOK_STD)
  472. DB_METHOD(set_flags, (u_int32_t flags), (db, flags),
  473. DB_RETOK_STD)
  474. DB_METHOD(set_h_compare, (h_compare_fcn_type func),
  475. (db, func), DB_RETOK_STD)
  476. DB_METHOD(get_h_ffactor, (u_int32_t *h_ffactorp),
  477. (db, h_ffactorp), DB_RETOK_STD)
  478. DB_METHOD(set_h_ffactor, (u_int32_t h_ffactor),
  479. (db, h_ffactor), DB_RETOK_STD)
  480. DB_METHOD(set_h_hash, (h_hash_fcn_type func),
  481. (db, func), DB_RETOK_STD)
  482. DB_METHOD(get_h_nelem, (u_int32_t *h_nelemp),
  483. (db, h_nelemp), DB_RETOK_STD)
  484. DB_METHOD(set_h_nelem, (u_int32_t h_nelem),
  485. (db, h_nelem), DB_RETOK_STD)
  486. DB_METHOD(get_lorder, (int *db_lorderp), (db, db_lorderp),
  487. DB_RETOK_STD)
  488. DB_METHOD(set_lorder, (int db_lorder), (db, db_lorder),
  489. DB_RETOK_STD)
  490. DB_METHOD_VOID(get_msgfile, (FILE **msgfilep), (db, msgfilep))
  491. DB_METHOD_VOID(set_msgfile, (FILE *msgfile), (db, msgfile))
  492. DB_METHOD_QUIET(get_multiple, (), (db))
  493. DB_METHOD(get_pagesize, (u_int32_t *db_pagesizep),
  494. (db, db_pagesizep), DB_RETOK_STD)
  495. DB_METHOD(set_pagesize, (u_int32_t db_pagesize),
  496. (db, db_pagesize), DB_RETOK_STD)
  497. DB_METHOD(get_priority, (DB_CACHE_PRIORITY *priorityp),
  498. (db, priorityp), DB_RETOK_STD)
  499. DB_METHOD(set_priority, (DB_CACHE_PRIORITY priority),
  500. (db, priority), DB_RETOK_STD)
  501. DB_METHOD(get_re_delim, (int *re_delimp),
  502. (db, re_delimp), DB_RETOK_STD)
  503. DB_METHOD(set_re_delim, (int re_delim),
  504. (db, re_delim), DB_RETOK_STD)
  505. DB_METHOD(get_re_len, (u_int32_t *re_lenp),
  506. (db, re_lenp), DB_RETOK_STD)
  507. DB_METHOD(set_re_len, (u_int32_t re_len),
  508. (db, re_len), DB_RETOK_STD)
  509. DB_METHOD(get_re_pad, (int *re_padp),
  510. (db, re_padp), DB_RETOK_STD)
  511. DB_METHOD(set_re_pad, (int re_pad),
  512. (db, re_pad), DB_RETOK_STD)
  513. DB_METHOD(get_re_source, (const char **re_source),
  514. (db, re_source), DB_RETOK_STD)
  515. DB_METHOD(set_re_source, (const char *re_source),
  516. (db, re_source), DB_RETOK_STD)
  517. DB_METHOD(get_q_extentsize, (u_int32_t *extentsizep),
  518. (db, extentsizep), DB_RETOK_STD)
  519. DB_METHOD(set_q_extentsize, (u_int32_t extentsize),
  520. (db, extentsize), DB_RETOK_STD)
  521. DB_METHOD_QUIET(set_alloc, (db_malloc_fcn_type malloc_fcn,
  522. db_realloc_fcn_type realloc_fcn, db_free_fcn_type free_fcn),
  523. (db, malloc_fcn, realloc_fcn, free_fcn))
  524. void Db::set_errcall(void (*arg)(const DbEnv *, const char *, const char *))
  525. {
  526. env_->set_errcall(arg);
  527. }
  528. void Db::set_msgcall(void (*arg)(const DbEnv *, const char *))
  529. {
  530. env_->set_msgcall(arg);
  531. }
  532. void *Db::get_app_private() const
  533. {
  534. return unwrapConst(this)->app_private;
  535. }
  536. void Db::set_app_private(void *value)
  537. {
  538. unwrap(this)->app_private = value;
  539. }
  540. DB_METHOD(get_cachesize, (u_int32_t *gbytesp, u_int32_t *bytesp, int *ncachep),
  541. (db, gbytesp, bytesp, ncachep), DB_RETOK_STD)
  542. DB_METHOD(set_cachesize, (u_int32_t gbytes, u_int32_t bytes, int ncache),
  543. (db, gbytes, bytes, ncache), DB_RETOK_STD)
  544. int Db::set_paniccall(void (*callback)(DbEnv *, int))
  545. {
  546. return (env_->set_paniccall(callback));
  547. }
  548. __DB_STD(ostream) *Db::get_error_stream()
  549. {
  550. return env_->get_error_stream();
  551. }
  552. void Db::set_error_stream(__DB_STD(ostream) *error_stream)
  553. {
  554. env_->set_error_stream(error_stream);
  555. }
  556. __DB_STD(ostream) *Db::get_message_stream()
  557. {
  558. return env_->get_message_stream();
  559. }
  560. void Db::set_message_stream(__DB_STD(ostream) *message_stream)
  561. {
  562. env_->set_message_stream(message_stream);
  563. }
  564. DB_METHOD_QUIET(get_transactional, (), (db))