1 /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef SQL_THD_INTERNAL_API_INCLUDED 24 #define SQL_THD_INTERNAL_API_INCLUDED 25 26 /* 27 This file defines THD-related API calls that are meant for internal 28 usage (e.g. InnoDB, Thread Pool) only. There are therefore no stabilty 29 guarantees. 30 */ 31 32 #include "my_global.h" 33 #include "my_thread.h" 34 #include "mysql/psi/psi.h" 35 36 class THD; 37 38 /** 39 Set up various THD data for a new connection 40 41 @param thd THD object 42 @param stack_start Start of stack for connection 43 @param bound True if bound to a physical thread. 44 @param psi_key Instrumentation key for the thread. 45 */ 46 int thd_init(THD *thd, char *stack_start, bool bound, PSI_thread_key psi_key); 47 48 /** 49 Create a THD and do proper initialization of it. 50 51 @param enable_plugins Should dynamic plugin support be enabled? 52 @param background_thread Is this a background thread? 53 @param bound True if bound to a physical thread. 54 @param psi_key Instrumentation key for the thread. 55 56 @note Dynamic plugin support is only possible for THDs that 57 are created after the server has initialized properly. 58 @note THDs for background threads are currently not added to 59 the global THD list. So they will e.g. not be visible in 60 SHOW PROCESSLIST and the server will not wait for them to 61 terminate during shutdown. 62 */ 63 THD *create_thd(bool enable_plugins, bool background_thread, bool bound, PSI_thread_key psi_key); 64 65 /** 66 Cleanup the THD object, remove it from the global list of THDs 67 and delete it. 68 69 @param THD pointer to THD object. 70 */ 71 void destroy_thd(THD *thd); 72 73 /** 74 Set thread stack in THD object 75 76 @param thd Thread object 77 @param stack_start Start of stack to set in THD object 78 */ 79 void thd_set_thread_stack(THD *thd, const char *stack_start); 80 81 /** 82 Test a file path whether it is same as mysql data directory path. 83 84 @param path null terminated character string 85 86 @return 87 @retval true The path is different from mysql data directory. 88 @retval false The path is same as mysql data directory. 89 */ 90 bool is_mysql_datadir_path(const char *path); 91 92 /** 93 Create a temporary file. 94 95 @details 96 The temporary file is created in a location specified by the parameter 97 path. if path is null, then it will be created on the location given 98 by the mysql server configuration (--tmpdir option). The caller 99 does not need to delete the file, it will be deleted automatically. 100 101 @param path location for creating temporary file 102 @param prefix prefix for temporary file name 103 @retval -1 error 104 @retval >=0 a file handle that can be passed to dup or my_close 105 */ 106 107 int mysql_tmpfile_path(const char *path, const char *prefix); 108 109 #endif // SQL_THD_INTERNAL_API_INCLUDED 110