service_rpl_transaction_ctx.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MYSQL_SERVICE_RPL_TRANSACTION_CTX_INCLUDED
  19. /**
  20. @file include/mysql/service_rpl_transaction_ctx.h
  21. This service provides a function for plugins to report if a transaction of a
  22. given THD should continue or be aborted.
  23. SYNOPSIS
  24. set_transaction_ctx()
  25. should be called during RUN_HOOK macro, on which we know that thread is
  26. on plugin context and it is before
  27. Rpl_transaction_ctx::is_transaction_rollback() check.
  28. */
  29. #ifndef MYSQL_ABI_CHECK
  30. #include <stdlib.h>
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. struct st_transaction_termination_ctx
  36. {
  37. unsigned long m_thread_id;
  38. unsigned int m_flags; // reserved
  39. /*
  40. If the instruction is to rollback the transaction,
  41. then this flag is set to false.
  42. Note: type is char like on my_bool.
  43. */
  44. char m_rollback_transaction;
  45. /*
  46. If the plugin has generated a GTID, then the follwoing
  47. fields MUST be set.
  48. Note: type is char like on my_bool.
  49. */
  50. char m_generated_gtid;
  51. int m_sidno;
  52. long long int m_gno;
  53. };
  54. typedef struct st_transaction_termination_ctx Transaction_termination_ctx;
  55. extern struct rpl_transaction_ctx_service_st {
  56. int (*set_transaction_ctx)(Transaction_termination_ctx transaction_termination_ctx);
  57. } *rpl_transaction_ctx_service;
  58. #ifdef MYSQL_DYNAMIC_PLUGIN
  59. #define set_transaction_ctx(transaction_termination_ctx) \
  60. (rpl_transaction_ctx_service->set_transaction_ctx((transaction_termination_ctx)))
  61. #else
  62. int set_transaction_ctx(Transaction_termination_ctx transaction_termination_ctx);
  63. #endif
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #define MYSQL_SERVICE_RPL_TRANSACTION_CTX_INCLUDED
  68. #endif