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