plugin_audit.h.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. typedef char my_bool;
  2. typedef void * MYSQL_PLUGIN;
  3. extern struct my_snprintf_service_st {
  4. size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
  5. size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
  6. } *my_snprintf_service;
  7. size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
  8. size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
  9. struct st_mysql_lex_string
  10. {
  11. char *str;
  12. size_t length;
  13. };
  14. typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
  15. extern struct thd_alloc_service_st {
  16. void *(*thd_alloc_func)(void*, unsigned int);
  17. void *(*thd_calloc_func)(void*, unsigned int);
  18. char *(*thd_strdup_func)(void*, const char *);
  19. char *(*thd_strmake_func)(void*, const char *, unsigned int);
  20. void *(*thd_memdup_func)(void*, const void*, unsigned int);
  21. MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
  22. const char *, unsigned int, int);
  23. } *thd_alloc_service;
  24. void *thd_alloc(void* thd, unsigned int size);
  25. void *thd_calloc(void* thd, unsigned int size);
  26. char *thd_strdup(void* thd, const char *str);
  27. char *thd_strmake(void* thd, const char *str, unsigned int size);
  28. void *thd_memdup(void* thd, const void* str, unsigned int size);
  29. MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
  30. const char *str, unsigned int size,
  31. int allocate_lex_string);
  32. typedef enum _thd_wait_type_e {
  33. THD_WAIT_SLEEP= 1,
  34. THD_WAIT_DISKIO= 2,
  35. THD_WAIT_ROW_LOCK= 3,
  36. THD_WAIT_GLOBAL_LOCK= 4,
  37. THD_WAIT_META_DATA_LOCK= 5,
  38. THD_WAIT_TABLE_LOCK= 6,
  39. THD_WAIT_USER_LOCK= 7,
  40. THD_WAIT_BINLOG= 8,
  41. THD_WAIT_GROUP_COMMIT= 9,
  42. THD_WAIT_SYNC= 10,
  43. THD_WAIT_NET= 11,
  44. THD_WAIT_LAST= 12
  45. } thd_wait_type;
  46. extern struct thd_wait_service_st {
  47. void (*thd_wait_begin_func)(void*, int);
  48. void (*thd_wait_end_func)(void*);
  49. } *thd_wait_service;
  50. void thd_wait_begin(void* thd, int wait_type);
  51. void thd_wait_end(void* thd);
  52. extern struct progress_report_service_st {
  53. void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
  54. void (*thd_progress_report_func)(void* thd,
  55. unsigned long long progress,
  56. unsigned long long max_progress);
  57. void (*thd_progress_next_stage_func)(void* thd);
  58. void (*thd_progress_end_func)(void* thd);
  59. const char *(*set_thd_proc_info_func)(void*, const char *info,
  60. const char *func,
  61. const char *file,
  62. unsigned int line);
  63. } *progress_report_service;
  64. void thd_progress_init(void* thd, unsigned int max_stage);
  65. void thd_progress_report(void* thd,
  66. unsigned long long progress,
  67. unsigned long long max_progress);
  68. void thd_progress_next_stage(void* thd);
  69. void thd_progress_end(void* thd);
  70. const char *set_thd_proc_info(void*, const char * info, const char *func,
  71. const char *file, unsigned int line);
  72. extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
  73. enum thd_kill_levels {
  74. THD_IS_NOT_KILLED=0,
  75. THD_ABORT_SOFTLY=50,
  76. THD_ABORT_ASAP=100,
  77. };
  78. extern struct kill_statement_service_st {
  79. enum thd_kill_levels (*thd_kill_level_func)(const void*);
  80. } *thd_kill_statement_service;
  81. enum thd_kill_levels thd_kill_level(const void*);
  82. typedef long my_time_t;
  83. enum enum_mysql_timestamp_type
  84. {
  85. MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
  86. MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
  87. };
  88. typedef struct st_mysql_time
  89. {
  90. unsigned int year, month, day, hour, minute, second;
  91. unsigned long second_part;
  92. my_bool neg;
  93. enum enum_mysql_timestamp_type time_type;
  94. } MYSQL_TIME;
  95. extern struct thd_timezone_service_st {
  96. my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
  97. void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
  98. } *thd_timezone_service;
  99. my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
  100. void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
  101. extern struct my_sha1_service_st {
  102. void (*my_sha1_type)(unsigned char*, const char*, size_t);
  103. void (*my_sha1_multi_type)(unsigned char*, ...);
  104. size_t (*my_sha1_context_size_type)();
  105. void (*my_sha1_init_type)(void *);
  106. void (*my_sha1_input_type)(void *, const unsigned char *, size_t);
  107. void (*my_sha1_result_type)(void *, unsigned char *);
  108. } *my_sha1_service;
  109. void my_sha1(unsigned char*, const char*, size_t);
  110. void my_sha1_multi(unsigned char*, ...);
  111. size_t my_sha1_context_size();
  112. void my_sha1_init(void *context);
  113. void my_sha1_input(void *context, const unsigned char *buf, size_t len);
  114. void my_sha1_result(void *context, unsigned char *digest);
  115. extern struct my_md5_service_st {
  116. void (*my_md5_type)(unsigned char*, const char*, size_t);
  117. void (*my_md5_multi_type)(unsigned char*, ...);
  118. size_t (*my_md5_context_size_type)();
  119. void (*my_md5_init_type)(void *);
  120. void (*my_md5_input_type)(void *, const unsigned char *, size_t);
  121. void (*my_md5_result_type)(void *, unsigned char *);
  122. } *my_md5_service;
  123. void my_md5(unsigned char*, const char*, size_t);
  124. void my_md5_multi(unsigned char*, ...);
  125. size_t my_md5_context_size();
  126. void my_md5_init(void *context);
  127. void my_md5_input(void *context, const unsigned char *buf, size_t len);
  128. void my_md5_result(void *context, unsigned char *digest);
  129. typedef struct logger_handle_st LOGGER_HANDLE;
  130. extern struct logger_service_st {
  131. void (*logger_init_mutexes)();
  132. LOGGER_HANDLE* (*open)(const char *path,
  133. unsigned long long size_limit,
  134. unsigned int rotations);
  135. int (*close)(LOGGER_HANDLE *log);
  136. int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
  137. int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
  138. int (*write)(LOGGER_HANDLE *log, const char *buffer, size_t size);
  139. int (*rotate)(LOGGER_HANDLE *log);
  140. } *logger_service;
  141. void logger_init_mutexes();
  142. LOGGER_HANDLE *logger_open(const char *path,
  143. unsigned long long size_limit,
  144. unsigned int rotations);
  145. int logger_close(LOGGER_HANDLE *log);
  146. int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
  147. int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
  148. int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
  149. int logger_rotate(LOGGER_HANDLE *log);
  150. extern struct thd_autoinc_service_st {
  151. void (*thd_get_autoinc_func)(const void* thd,
  152. unsigned long* off, unsigned long* inc);
  153. } *thd_autoinc_service;
  154. void thd_get_autoinc(const void* thd,
  155. unsigned long* off, unsigned long* inc);
  156. extern struct thd_error_context_service_st {
  157. const char *(*thd_get_error_message_func)(const void* thd);
  158. unsigned int (*thd_get_error_number_func)(const void* thd);
  159. unsigned long (*thd_get_error_row_func)(const void* thd);
  160. void (*thd_inc_error_row_func)(void* thd);
  161. char *(*thd_get_error_context_description_func)(void* thd,
  162. char *buffer,
  163. unsigned int length,
  164. unsigned int max_query_length);
  165. } *thd_error_context_service;
  166. const char *thd_get_error_message(const void* thd);
  167. unsigned int thd_get_error_number(const void* thd);
  168. unsigned long thd_get_error_row(const void* thd);
  169. void thd_inc_error_row(void* thd);
  170. char *thd_get_error_context_description(void* thd,
  171. char *buffer, unsigned int length,
  172. unsigned int max_query_length);
  173. typedef int MYSQL_THD_KEY_T;
  174. extern struct thd_specifics_service_st {
  175. int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
  176. void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
  177. void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
  178. int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
  179. } *thd_specifics_service;
  180. int thd_key_create(MYSQL_THD_KEY_T *key);
  181. void thd_key_delete(MYSQL_THD_KEY_T *key);
  182. void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
  183. int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
  184. struct encryption_service_st {
  185. unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
  186. unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
  187. unsigned char* buffer, unsigned int* length);
  188. unsigned int (*encryption_ctx_size_func)(unsigned int key_id, unsigned int key_version);
  189. int (*encryption_ctx_init_func)(void *ctx, const unsigned char* key, unsigned int klen,
  190. const unsigned char* iv, unsigned int ivlen,
  191. int flags, unsigned int key_id,
  192. unsigned int key_version);
  193. int (*encryption_ctx_update_func)(void *ctx, const unsigned char* src, unsigned int slen,
  194. unsigned char* dst, unsigned int* dlen);
  195. int (*encryption_ctx_finish_func)(void *ctx, unsigned char* dst, unsigned int* dlen);
  196. unsigned int (*encryption_encrypted_length_func)(unsigned int slen, unsigned int key_id, unsigned int key_version);
  197. };
  198. extern struct encryption_service_st encryption_handler;
  199. static inline unsigned int encryption_key_id_exists(unsigned int id)
  200. {
  201. return encryption_handler.encryption_key_get_latest_version_func(id) != (~(unsigned int)0);
  202. }
  203. static inline unsigned int encryption_key_version_exists(unsigned int id, unsigned int version)
  204. {
  205. unsigned int unused;
  206. return encryption_handler.encryption_key_get_func((id),(version),(NULL),(&unused)) != (~(unsigned int)0);
  207. }
  208. static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
  209. unsigned char* dst, unsigned int* dlen,
  210. const unsigned char* key, unsigned int klen,
  211. const unsigned char* iv, unsigned int ivlen,
  212. int flags, unsigned int key_id, unsigned int key_version)
  213. {
  214. void *ctx= alloca(encryption_handler.encryption_ctx_size_func((key_id),(key_version)));
  215. int res1, res2;
  216. unsigned int d1, d2;
  217. if ((res1= encryption_handler.encryption_ctx_init_func((ctx),(key),(klen),(iv),(ivlen),(flags),(key_id),(key_version))))
  218. return res1;
  219. res1= encryption_handler.encryption_ctx_update_func((ctx),(src),(slen),(dst),(&d1));
  220. res2= encryption_handler.encryption_ctx_finish_func((ctx),(dst + d1),(&d2));
  221. *dlen= d1 + d2;
  222. return res1 ? res1 : res2;
  223. }
  224. struct st_encryption_scheme_key {
  225. unsigned int version;
  226. unsigned char key[16];
  227. };
  228. struct st_encryption_scheme {
  229. unsigned char iv[16];
  230. struct st_encryption_scheme_key key[3];
  231. unsigned int keyserver_requests;
  232. unsigned int key_id;
  233. unsigned int type;
  234. void (*locker)(struct st_encryption_scheme *self, int release);
  235. };
  236. extern struct encryption_scheme_service_st {
  237. int (*encryption_scheme_encrypt_func)
  238. (const unsigned char* src, unsigned int slen,
  239. unsigned char* dst, unsigned int* dlen,
  240. struct st_encryption_scheme *scheme,
  241. unsigned int key_version, unsigned int i32_1,
  242. unsigned int i32_2, unsigned long long i64);
  243. int (*encryption_scheme_decrypt_func)
  244. (const unsigned char* src, unsigned int slen,
  245. unsigned char* dst, unsigned int* dlen,
  246. struct st_encryption_scheme *scheme,
  247. unsigned int key_version, unsigned int i32_1,
  248. unsigned int i32_2, unsigned long long i64);
  249. } *encryption_scheme_service;
  250. int encryption_scheme_encrypt(const unsigned char* src, unsigned int slen,
  251. unsigned char* dst, unsigned int* dlen,
  252. struct st_encryption_scheme *scheme,
  253. unsigned int key_version, unsigned int i32_1,
  254. unsigned int i32_2, unsigned long long i64);
  255. int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
  256. unsigned char* dst, unsigned int* dlen,
  257. struct st_encryption_scheme *scheme,
  258. unsigned int key_version, unsigned int i32_1,
  259. unsigned int i32_2, unsigned long long i64);
  260. struct st_mysql_xid {
  261. long formatID;
  262. long gtrid_length;
  263. long bqual_length;
  264. char data[128];
  265. };
  266. typedef struct st_mysql_xid MYSQL_XID;
  267. enum enum_mysql_show_type
  268. {
  269. SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
  270. SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
  271. SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
  272. SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
  273. SHOW_always_last
  274. };
  275. enum enum_var_type
  276. {
  277. SHOW_OPT_DEFAULT= 0, SHOW_OPT_SESSION, SHOW_OPT_GLOBAL
  278. };
  279. struct st_mysql_show_var {
  280. const char *name;
  281. void *value;
  282. enum enum_mysql_show_type type;
  283. };
  284. struct system_status_var;
  285. typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
  286. struct st_mysql_sys_var;
  287. struct st_mysql_value;
  288. typedef int (*mysql_var_check_func)(void* thd,
  289. struct st_mysql_sys_var *var,
  290. void *save, struct st_mysql_value *value);
  291. typedef void (*mysql_var_update_func)(void* thd,
  292. struct st_mysql_sys_var *var,
  293. void *var_ptr, const void *save);
  294. struct st_mysql_plugin
  295. {
  296. int type;
  297. void *info;
  298. const char *name;
  299. const char *author;
  300. const char *descr;
  301. int license;
  302. int (*init)(void *);
  303. int (*deinit)(void *);
  304. unsigned int version;
  305. struct st_mysql_show_var *status_vars;
  306. struct st_mysql_sys_var **system_vars;
  307. void * __reserved1;
  308. unsigned long flags;
  309. };
  310. struct st_maria_plugin
  311. {
  312. int type;
  313. void *info;
  314. const char *name;
  315. const char *author;
  316. const char *descr;
  317. int license;
  318. int (*init)(void *);
  319. int (*deinit)(void *);
  320. unsigned int version;
  321. struct st_mysql_show_var *status_vars;
  322. struct st_mysql_sys_var **system_vars;
  323. const char *version_info;
  324. unsigned int maturity;
  325. };
  326. enum enum_ftparser_mode
  327. {
  328. MYSQL_FTPARSER_SIMPLE_MODE= 0,
  329. MYSQL_FTPARSER_WITH_STOPWORDS= 1,
  330. MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
  331. };
  332. enum enum_ft_token_type
  333. {
  334. FT_TOKEN_EOF= 0,
  335. FT_TOKEN_WORD= 1,
  336. FT_TOKEN_LEFT_PAREN= 2,
  337. FT_TOKEN_RIGHT_PAREN= 3,
  338. FT_TOKEN_STOPWORD= 4
  339. };
  340. typedef struct st_mysql_ftparser_boolean_info
  341. {
  342. enum enum_ft_token_type type;
  343. int yesno;
  344. int weight_adjust;
  345. char wasign;
  346. char trunc;
  347. char prev;
  348. char *quot;
  349. } MYSQL_FTPARSER_BOOLEAN_INFO;
  350. typedef struct st_mysql_ftparser_param
  351. {
  352. int (*mysql_parse)(struct st_mysql_ftparser_param *,
  353. const char *doc, int doc_len);
  354. int (*mysql_add_word)(struct st_mysql_ftparser_param *,
  355. const char *word, int word_len,
  356. MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
  357. void *ftparser_state;
  358. void *mysql_ftparam;
  359. const struct charset_info_st *cs;
  360. const char *doc;
  361. int length;
  362. unsigned int flags;
  363. enum enum_ftparser_mode mode;
  364. } MYSQL_FTPARSER_PARAM;
  365. struct st_mysql_ftparser
  366. {
  367. int interface_version;
  368. int (*parse)(MYSQL_FTPARSER_PARAM *param);
  369. int (*init)(MYSQL_FTPARSER_PARAM *param);
  370. int (*deinit)(MYSQL_FTPARSER_PARAM *param);
  371. };
  372. struct st_mysql_daemon
  373. {
  374. int interface_version;
  375. };
  376. struct st_mysql_information_schema
  377. {
  378. int interface_version;
  379. };
  380. struct st_mysql_storage_engine
  381. {
  382. int interface_version;
  383. };
  384. struct handlerton;
  385. struct Mysql_replication {
  386. int interface_version;
  387. };
  388. struct st_mysql_value
  389. {
  390. int (*value_type)(struct st_mysql_value *);
  391. const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
  392. int (*val_real)(struct st_mysql_value *, double *realbuf);
  393. int (*val_int)(struct st_mysql_value *, long long *intbuf);
  394. int (*is_unsigned)(struct st_mysql_value *);
  395. };
  396. int thd_in_lock_tables(const void* thd);
  397. int thd_tablespace_op(const void* thd);
  398. long long thd_test_options(const void* thd, long long test_options);
  399. int thd_sql_command(const void* thd);
  400. void **thd_ha_data(const void* thd, const struct handlerton *hton);
  401. void thd_storage_lock_wait(void* thd, long long value);
  402. int thd_tx_isolation(const void* thd);
  403. int thd_tx_is_read_only(const void* thd);
  404. int thd_rpl_is_parallel(const void* thd);
  405. int mysql_tmpfile(const char *prefix);
  406. unsigned long thd_get_thread_id(const void* thd);
  407. void thd_get_xid(const void* thd, MYSQL_XID *xid);
  408. void mysql_query_cache_invalidate4(void* thd,
  409. const char *key, unsigned int key_length,
  410. int using_trx);
  411. void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
  412. void thd_set_ha_data(void* thd, const struct handlerton *hton,
  413. const void *ha_data);
  414. void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
  415. struct mysql_event_general
  416. {
  417. unsigned int event_subclass;
  418. int general_error_code;
  419. unsigned long general_thread_id;
  420. const char *general_user;
  421. unsigned int general_user_length;
  422. const char *general_command;
  423. unsigned int general_command_length;
  424. const char *general_query;
  425. unsigned int general_query_length;
  426. struct charset_info_st *general_charset;
  427. unsigned long long general_time;
  428. unsigned long long general_rows;
  429. unsigned long long query_id;
  430. const char *database;
  431. unsigned int database_length;
  432. };
  433. struct mysql_event_connection
  434. {
  435. unsigned int event_subclass;
  436. int status;
  437. unsigned long thread_id;
  438. const char *user;
  439. unsigned int user_length;
  440. const char *priv_user;
  441. unsigned int priv_user_length;
  442. const char *external_user;
  443. unsigned int external_user_length;
  444. const char *proxy_user;
  445. unsigned int proxy_user_length;
  446. const char *host;
  447. unsigned int host_length;
  448. const char *ip;
  449. unsigned int ip_length;
  450. const char *database;
  451. unsigned int database_length;
  452. };
  453. struct mysql_event_table
  454. {
  455. unsigned int event_subclass;
  456. unsigned long thread_id;
  457. const char *user;
  458. const char *priv_user;
  459. const char *priv_host;
  460. const char *external_user;
  461. const char *proxy_user;
  462. const char *host;
  463. const char *ip;
  464. const char *database;
  465. unsigned int database_length;
  466. const char *table;
  467. unsigned int table_length;
  468. int read_only;
  469. const char *new_database;
  470. unsigned int new_database_length;
  471. const char *new_table;
  472. unsigned int new_table_length;
  473. unsigned long long query_id;
  474. };
  475. struct st_mysql_audit
  476. {
  477. int interface_version;
  478. void (*release_thd)(void*);
  479. void (*event_notify)(void*, unsigned int, const void *);
  480. unsigned long class_mask[1];
  481. };