From e8c1377b6014ebcbaed5ebf97cf62cfe7896f5c0 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 13 Mar 2025 21:56:04 +0800 Subject: [PATCH] Add symbolic constants --- cursor_get_operations.ha | 23 +++++++++++++++++++++++ flags_copy.ha | 2 ++ flags_db.ha | 7 +++++++ flags_env.ha | 11 +++++++++++ flags_write.ha | 7 +++++++ return_codes.ha | 24 ++++++++++++++++++++++++ diff --git a/cursor_get_operations.ha b/cursor_get_operations.ha new file mode 100644 index 0000000000000000000000000000000000000000..ad454c972c53822b16b083a59f922d2083619922 --- /dev/null +++ b/cursor_get_operations.ha @@ -0,0 +1,23 @@ +// This is the set of all operations for retrieving data +// using a cursor. +export type MDB_cursor_op = enum { + MDB_FIRST, // Position at first key/data item + MDB_FIRST_DUP, // Position at first data item of current key. Only for #MDB_DUPSORT + MDB_GET_BOTH, // Position at key/data pair. Only for #MDB_DUPSORT + MDB_GET_BOTH_RANGE, // position at key, nearest data. Only for #MDB_DUPSORT + MDB_GET_CURRENT, // Return key/data at current cursor position + MDB_GET_MULTIPLE, // Return up to a page of duplicate data items from current cursor position. Move cursor to prepare for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED + MDB_LAST, // Position at last key/data item + MDB_LAST_DUP, // Position at last data item of current key. Only for #MDB_DUPSORT + MDB_NEXT, // Position at next data item + MDB_NEXT_DUP, // Position at next data item of current key. Only for #MDB_DUPSORT + MDB_NEXT_MULTIPLE, // Return up to a page of duplicate data items from next cursor position. Move cursor to prepare for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED + MDB_NEXT_NODUP, // Position at first data item of next key + MDB_PREV, // Position at previous data item + MDB_PREV_DUP, // Position at previous data item of current key. Only for #MDB_DUPSORT + MDB_PREV_NODUP, // Position at last data item of previous key + MDB_SET, // Position at specified key + MDB_SET_KEY, // Position at specified key, return key + data + MDB_SET_RANGE, // Position at first key greater than or equal to specified key. + MDB_PREV_MULTIPLE, // Position at previous page and return up to a page of duplicate data items. Only for #MDB_DUPFIXED +}; diff --git a/flags_copy.ha b/flags_copy.ha new file mode 100644 index 0000000000000000000000000000000000000000..e0cab2cabe954046d1aad9f6dc9f55a65eb1c1a5 --- /dev/null +++ b/flags_copy.ha @@ -0,0 +1,2 @@ +export def MDB_CP_COMPACT = 0x01; // Compacting copy: Omit free space from copy, and renumber all pages sequentially. + diff --git a/flags_db.ha b/flags_db.ha new file mode 100644 index 0000000000000000000000000000000000000000..d195ca3935e1bdb98f0cfcc29dc3385f869b2245 --- /dev/null +++ b/flags_db.ha @@ -0,0 +1,7 @@ +export def MDB_REVERSEKEY = 0x02; // use reverse string keys +export def MDB_DUPSORT = 0x04; // use sorted duplicates +export def MDB_INTEGERKEY = 0x08; // numeric keys in native byte order: either unsigned int or size_t. The keys must all be of the same size. +export def MDB_DUPFIXED = 0x10; // with #MDB_DUPSORT, sorted dup items have fixed size +export def MDB_INTEGERDUP = 0x20; // with #MDB_DUPSORT, dups are #MDB_INTEGERKEY-style integers +export def MDB_REVERSEDUP = 0x40; // with #MDB_DUPSORT, use reverse string dups +export def MDB_CREATE = 0x40000; // create DB if not already existing diff --git a/flags_env.ha b/flags_env.ha new file mode 100644 index 0000000000000000000000000000000000000000..183ec2f097e80d7fc423a7e593c53ba16caf2e22 --- /dev/null +++ b/flags_env.ha @@ -0,0 +1,11 @@ +export def MDB_FIXEDMAP = 0x01; // mmap at a fixed address (experimental) +export def MDB_NOSUBDIR = 0x4000; // no environment directory +export def MDB_NOSYNC = 0x10000; // don't fsync after commit +export def MDB_RDONLY = 0x20000; // read only +export def MDB_NOMETASYNC = 0x40000; // don't fsync metapage after commit +export def MDB_WRITEMAP = 0x80000; // use writable mmap +export def MDB_MAPASYNC = 0x100000; // use asynchronous msync when #MDB_WRITEMAP is used +export def MDB_NOTLS = 0x200000; // tie reader locktable slots to #MDB_txn objects instead of to threads +export def MDB_NOLOCK = 0x400000; // don't do any locking, caller must manage their own locks +export def MDB_NORDAHEAD = 0x800000; // don't do readahead (no effect on Windows) +export def MDB_NOMEMINIT = 0x1000000; // don't initialize malloc'd memory before writing to datafile diff --git a/flags_write.ha b/flags_write.ha new file mode 100644 index 0000000000000000000000000000000000000000..b77a0719aca30574d5972100538d63f24aaa322b --- /dev/null +++ b/flags_write.ha @@ -0,0 +1,7 @@ +export def MDB_NOOVERWRITE = 0x10; // For put: Don't write if the key already exists. +export def MDB_NODUPDATA = 0x20; // Only for #MDB_DUPSORT: For put: don't write if the key and data pair already exist. For mdb_cursor_del: remove all duplicate data items. +export def MDB_CURRENT = 0x40; // For mdb_cursor_put: overwrite the current key/data pair +export def MDB_RESERVE = 0x10000; // For put: Just reserve space for data, don't copy it. Return a pointer to the reserved space. +export def MDB_APPEND = 0x20000; // Data is being appended, don't split full pages. +export def MDB_APPENDDUP = 0x40000; // Duplicate data is being appended, don't split full pages. +export def MDB_MULTIPLE = 0x80000; // Store multiple data items in one call. Only for #MDB_DUPFIXED. diff --git a/return_codes.ha b/return_codes.ha new file mode 100644 index 0000000000000000000000000000000000000000..c30ca4e639811fa55170c49e73b401b2bb780538 --- /dev/null +++ b/return_codes.ha @@ -0,0 +1,24 @@ +// BerkeleyDB uses -30800 to -30999, we'll go under them + +export def MDB_SUCCESS = 0; // Successful result +export def MDB_KEYEXIST = (-30799); // key/data pair already exists +export def MDB_NOTFOUND = (-30798); // key/data pair not found (EOF) +export def MDB_PAGE_NOTFOUND = (-30797); // Requested page not found - this usually indicates corruption +export def MDB_CORRUPTED = (-30796); // Located page was wrong type +export def MDB_PANIC = (-30795); // Update of meta page failed or environment had fatal error +export def MDB_VERSION_MISMATCH = (-30794); // Environment version mismatch +export def MDB_INVALID = (-30793); // File is not a valid LMDB file +export def MDB_MAP_FULL = (-30792); // Environment mapsize reached +export def MDB_DBS_FULL = (-30791); // Environment maxdbs reached +export def MDB_READERS_FULL = (-30790); // Environment maxreaders reached +export def MDB_TLS_FULL = (-30789); // Too many TLS keys in use - Windows only +export def MDB_TXN_FULL = (-30788); // Txn has too many dirty pages +export def MDB_CURSOR_FULL = (-30787); // Cursor stack too deep - internal error +export def MDB_PAGE_FULL = (-30786); // Page has not enough space - internal error +export def MDB_MAP_RESIZED = (-30785); // Database contents grew beyond environment mapsize +export def MDB_INCOMPATIBLE = (-30784); // Operation and DB incompatible, or DB type changed. This can mean: (1) The operation expects an #MDB_DUPSORT / #MDB_DUPFIXED database. (2) Opening a named DB when the unnamed DB has #MDB_DUPSORT / #MDB_INTEGERKEY. (3) Accessing a data record as a database, or vice versa. (4) The database was dropped and recreated with different flags. +export def MDB_BAD_RSLOT = (-30783); // Invalid reuse of reader locktable slot +export def MDB_BAD_TXN = (-30782); // Transaction must abort, has a child, or is invalid +export def MDB_BAD_VALSIZE = (-30781); // Unsupported size of key/DB name/data, or wrong DUPFIXED size +export def MDB_BAD_DBI = (-30780); // The specified DBI was changed unexpectedly +export def MDB_LAST_ERRCODE = MDB_BAD_DBI; // The last defined error code -- 2.48.1