ruby-mdbx/ext/mdbx_ext/mdbx_ext.h
mahlon@martini.nu 81ee69295c Checkpoint.
- Fix a couple of edge cases while switching between collections.
  - Raise error if attempting to switch collections mid-transaction.
  - Add logic for re-entrancy with long-running transactions.
  - Revert to the prior collection if passing a block to #collection.
  - Add a predicate to tell if you're currently within a long-running transaction.
  - Add separate commit/rollback to long-running transactions.

FossilOrigin-Name: 711239e6fc2f25479a26fb54805da1e5db792f97f28a8b5724e0b38eb11cdb07
2021-01-25 00:36:40 +00:00

67 lines
1.4 KiB
C

#include <ruby.h>
#include "extconf.h"
#include "mdbx.h"
#ifndef MDBX_EXT_0_9_2
#define MDBX_EXT_0_9_2
#define RMDBX_TXN_ROLLBACK 0
#define RMDBX_TXN_COMMIT 1
/*
* A struct encapsulating an instance's DB
* state and settings.
*/
struct rmdbx_db {
MDBX_env *env;
MDBX_dbi dbi;
MDBX_txn *txn;
MDBX_cursor *cursor;
struct {
int env_flags;
int mode;
int open;
int max_collections;
int max_readers;
uint64_t max_size;
} settings;
struct {
int open;
int retain_txn;
} state;
char *path;
char *subdb;
};
typedef struct rmdbx_db rmdbx_db_t;
static const rb_data_type_t rmdbx_db_data;
extern void rmdbx_free( void *db ); /* forward declaration for the allocator */
/* ------------------------------------------------------------
* Globals
* ------------------------------------------------------------ */
extern VALUE rmdbx_mMDBX;
extern VALUE rmdbx_cDatabase;
extern VALUE rmdbx_eDatabaseError;
extern VALUE rmdbx_eRollback;
/* ------------------------------------------------------------
* Functions
* ------------------------------------------------------------ */
extern void Init_rmdbx ( void );
extern void rmdbx_init_database ( void );
extern void rmdbx_open_txn( rmdbx_db_t*, int );
extern void rmdbx_close_txn( rmdbx_db_t*, int );
extern VALUE rmdbx_gather_stats( rmdbx_db_t* );
#endif /* define MDBX_EXT_0_9_2 */