MySQL  8.0.27
Source Code Documentation
channel_info.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013, 2021, Oracle and/or its affiliates.
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, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License, version 2.0, for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24 
25 #ifndef SQL_CHANNEL_INFO_INCLUDED
26 #define SQL_CHANNEL_INFO_INCLUDED
27 
28 #include <sys/types.h>
29 
30 #include "my_inttypes.h"
31 #include "my_systime.h" // my_micro_time
32 #include "violite.h"
33 
34 class THD;
35 
36 typedef Vio Vio;
37 
38 /**
39  This abstract base class represents connection channel information
40  about a new connection. Its subclasses encapsulate differences
41  between different connection channel types.
42 
43  Currently we support local and TCP/IP sockets (all platforms),
44  named pipes and shared memory (Windows only).
45 */
46 class Channel_info {
48 
49  protected:
50  /**
51  Create and initialize a Vio object.
52 
53  @returns a pointer to the initialized a vio object.
54  */
55  virtual Vio *create_and_init_vio() const = 0;
56 
58 
59  public:
60  virtual ~Channel_info() = default;
61 
62  /**
63  Instantiate and initialize THD object and vio.
64 
65  @returns pointer to initialized THD object.
66  @retval NULL THD object allocation fails.
67  */
68  virtual THD *create_thd();
69 
70  /**
71  Send error back to the client and close the channel.
72 
73  @param errorcode code indicating type of error.
74  @param error operating system specific error code.
75  @param senderror true if the error need to be sent to
76  client else false.
77  */
78  virtual void send_error_and_close_channel(uint errorcode, int error,
79  bool senderror);
80 
83  }
84 
87  }
88 
89  virtual bool is_admin_connection() const { return false; }
90 };
91 
92 #endif // SQL_CHANNEL_INFO_INCLUDED.
Vio Vio
Definition: channel_info.h:34
This abstract base class represents connection channel information about a new connection.
Definition: channel_info.h:46
virtual THD * create_thd()
Instantiate and initialize THD object and vio.
Definition: channel_info.cc:39
virtual bool is_admin_connection() const
Definition: channel_info.h:89
ulonglong prior_thr_create_utime
Definition: channel_info.h:47
void set_prior_thr_create_utime()
Definition: channel_info.h:85
Channel_info()
Definition: channel_info.h:57
virtual void send_error_and_close_channel(uint errorcode, int error, bool senderror)
Send error back to the client and close the channel.
Definition: channel_info.cc:56
ulonglong get_prior_thr_create_utime() const
Definition: channel_info.h:81
virtual ~Channel_info()=default
virtual Vio * create_and_init_vio() const =0
Create and initialize a Vio object.
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Defines for getting and processing the current system type programmatically.
unsigned long long int my_micro_time()
Return time in microseconds.
Definition: my_systime.h:185
Definition: violite.h:323
unsigned int uint
Definition: uca-dump.cc:29
Vio Lite.