9
3

thread_pool_priv.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #error don't use
  2. /*
  3. Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. #ifndef THREAD_POOL_PRIV_INCLUDED
  16. #define THREAD_POOL_PRIV_INCLUDED
  17. /*
  18. The thread pool requires access to some MySQL server error codes, this is
  19. accessed from mysqld_error.h.
  20. We need access to the struct that defines the thread pool plugin interface
  21. which is accessed through scheduler.h.
  22. All accesses to THD variables and functions are defined in this header file.
  23. A thread pool can also use DEBUG_SYNC and must thus include
  24. debug_sync.h
  25. To handle definitions of Information Schema plugins it is also required
  26. to include sql_profile.h and table.h.
  27. */
  28. #include <mysqld_error.h> /* To get ER_ERROR_ON_READ */
  29. #define MYSQL_SERVER 1
  30. #include <scheduler.h>
  31. #include <debug_sync.h>
  32. #include <sql_profile.h>
  33. #include <table.h>
  34. #include <sql_list.h>
  35. /* Needed to get access to scheduler variables */
  36. void* thd_get_scheduler_data(THD *thd);
  37. void thd_set_scheduler_data(THD *thd, void *data);
  38. PSI_thread* thd_get_psi(THD *thd);
  39. void thd_set_psi(THD *thd, PSI_thread *psi);
  40. /* Interface to THD variables and functions */
  41. void thd_set_killed(THD *thd);
  42. void thd_clear_errors(THD *thd);
  43. void thd_set_thread_stack(THD *thd, char *stack_start);
  44. void thd_lock_thread_count(THD *thd);
  45. void thd_close_connection(THD *thd);
  46. THD *thd_get_current_thd();
  47. void thd_lock_data(THD *thd);
  48. void thd_unlock_data(THD *thd);
  49. bool thd_is_transaction_active(THD *thd);
  50. int thd_connection_has_data(THD *thd);
  51. void thd_set_net_read_write(THD *thd, uint val);
  52. uint thd_get_net_read_write(THD *thd);
  53. void thd_set_mysys_var(THD *thd, st_my_thread_var *mysys_var);
  54. ulong thd_get_net_wait_timeout(THD *thd);
  55. my_socket thd_get_fd(THD *thd);
  56. int thd_store_globals(THD* thd);
  57. THD *first_global_thread();
  58. THD *next_global_thread(THD *thd);
  59. /* Print to the MySQL error log */
  60. void sql_print_error(const char *format, ...);
  61. /* Store a table record */
  62. bool schema_table_store_record(THD *thd, TABLE *table);
  63. /*
  64. The thread pool must be able to execute statements using the connection
  65. state in THD object. This is the main objective of the thread pool to
  66. schedule the start of these commands.
  67. */
  68. bool do_command(THD *thd);
  69. /*
  70. The thread pool requires an interface to the connection logic in the
  71. MySQL Server since the thread pool will maintain the event logic on
  72. the TCP connection of the MySQL Server. Thus new connections, dropped
  73. connections will be discovered by the thread pool and it needs to
  74. ensure that the proper MySQL Server logic attached to these events is
  75. executed.
  76. */
  77. /* Initialise a new connection handler thread */
  78. bool init_new_connection_handler_thread();
  79. /* Set up connection thread before use as execution thread */
  80. bool setup_connection_thread_globals(THD *thd);
  81. /* Prepare connection as part of connection set-up */
  82. bool thd_prepare_connection(THD *thd);
  83. /* Release auditing before executing statement */
  84. void mysql_audit_release(THD *thd);
  85. /* Check if connection is still alive */
  86. bool thd_is_connection_alive(THD *thd);
  87. /* Close connection with possible error code */
  88. void close_connection(THD *thd, uint errcode);
  89. /* End the connection before closing it */
  90. void end_connection(THD *thd);
  91. /* Cleanup the THD object */
  92. void thd_cleanup(THD *thd);
  93. /* Decrement connection counter */
  94. void dec_connection_count();
  95. /* Destroy THD object */
  96. void delete_thd(THD *thd);
  97. /*
  98. thread_created is maintained by thread pool when activated since
  99. user threads are created by the thread pool (and also special
  100. threads to maintain the thread pool). This is done through
  101. inc_thread_created.
  102. max_connections is needed to calculate the maximum number of threads
  103. that is allowed to be started by the thread pool. The method
  104. get_max_connections() gets reference to this variable.
  105. connection_attrib is the thread attributes for connection threads,
  106. the method get_connection_attrib provides a reference to these
  107. attributes.
  108. */
  109. void inc_thread_created(void);
  110. ulong get_max_connections(void);
  111. pthread_attr_t *get_connection_attrib(void);
  112. #endif