db.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #ifndef _DB_H
  6. #define _DB_H
  7. #include <stdint.h>
  8. #include <sys/types.h>
  9. typedef struct __toku_dbt DBT;
  10. // port: this is currently not used
  11. struct simple_dbt {
  12. uint32_t len;
  13. void *data;
  14. };
  15. // engine status info
  16. // engine status is passed to handlerton as an array of
  17. // TOKU_ENGINE_STATUS_ROW_S[]
  18. typedef enum {
  19. STATUS_FS_STATE = 0, // interpret as file system state (redzone) enum
  20. STATUS_UINT64, // interpret as uint64_t
  21. STATUS_CHARSTR, // interpret as char *
  22. STATUS_UNIXTIME, // interpret as time_t
  23. STATUS_TOKUTIME, // interpret as tokutime_t
  24. STATUS_PARCOUNT, // interpret as PARTITIONED_COUNTER
  25. STATUS_DOUBLE // interpret as double
  26. } toku_engine_status_display_type;
  27. typedef enum {
  28. TOKU_ENGINE_STATUS = (1ULL << 0), // Include when asking for engine status
  29. TOKU_GLOBAL_STATUS =
  30. (1ULL << 1), // Include when asking for information_schema.global_status
  31. } toku_engine_status_include_type;
  32. typedef struct __toku_engine_status_row {
  33. const char *keyname; // info schema key, should not change across revisions
  34. // without good reason
  35. const char
  36. *columnname; // column for mysql, e.g. information_schema.global_status.
  37. // TOKUDB_ will automatically be prefixed.
  38. const char *legend; // the text that will appear at user interface
  39. toku_engine_status_display_type type; // how to interpret the value
  40. toku_engine_status_include_type
  41. include; // which kinds of callers should get read this row?
  42. union {
  43. double dnum;
  44. uint64_t num;
  45. const char *str;
  46. char datebuf[26];
  47. struct partitioned_counter *parcount;
  48. } value;
  49. } *TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S;
  50. #define DB_BUFFER_SMALL -30999
  51. #define DB_LOCK_DEADLOCK -30995
  52. #define DB_LOCK_NOTGRANTED -30994
  53. #define DB_NOTFOUND -30989
  54. #define DB_KEYEXIST -30996
  55. #define DB_DBT_MALLOC 8
  56. #define DB_DBT_REALLOC 64
  57. #define DB_DBT_USERMEM 256
  58. /* PerconaFT specific error codes */
  59. #define TOKUDB_OUT_OF_LOCKS -100000
  60. typedef void (*lock_wait_callback)(void *arg, uint64_t requesting_txnid,
  61. uint64_t blocking_txnid);
  62. struct __toku_dbt {
  63. void *data;
  64. size_t size;
  65. size_t ulen;
  66. // One of DB_DBT_XXX flags
  67. uint32_t flags;
  68. };
  69. #endif