1 /* Copyright (c) 2012, 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 Foundation,
21   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 #ifndef TABLE_SESSION_CONNECT_H
24 #define TABLE_SESSION_CONNECT_H
25 
26 #include "pfs_column_types.h"
27 #include "cursor_by_thread_connect_attr.h"
28 #include "table_helper.h"
29 
30 #define MAX_ATTR_NAME_CHARS 32
31 #define MAX_ATTR_VALUE_CHARS 1024
32 #define MAX_UTF8_BYTES 6
33 
34 /** symbolic names for field offsets, keep in sync with field_types */
35 enum field_offsets {
36   FO_PROCESS_ID,
37   FO_ATTR_NAME,
38   FO_ATTR_VALUE,
39   FO_ORDINAL_POSITION
40 };
41 
42 /**
43   A row of PERFORMANCE_SCHEMA.SESSION_CONNECT_ATTRS and
44   PERFORMANCE_SCHEMA.SESSION_ACCOUNT_CONNECT_ATTRS.
45 */
46 struct row_session_connect_attrs
47 {
48   /** Column PROCESS_ID. */
49   ulong m_process_id;
50   /** Column ATTR_NAME. In UTF-8 */
51   char m_attr_name[MAX_ATTR_NAME_CHARS * MAX_UTF8_BYTES];
52   /** Length in bytes of @c m_attr_name. */
53   uint m_attr_name_length;
54   /** Column ATTR_VALUE. In UTF-8 */
55   char m_attr_value[MAX_ATTR_VALUE_CHARS * MAX_UTF8_BYTES];
56   /** Length in bytes of @c m_attr_name. */
57   uint m_attr_value_length;
58   /** Column ORDINAL_POSITION. */
59   ulong m_ordinal_position;
60 };
61 
62 /** Abstract table PERFORMANCE_SCHEMA.SESSION_CONNECT_ATTRS. */
63 class table_session_connect : public cursor_by_thread_connect_attr
64 {
65 protected:
66   table_session_connect(const PFS_engine_table_share *share);
67 
68 public:
69   ~table_session_connect();
70 
71 protected:
72   virtual void make_row(PFS_thread *pfs, uint ordinal);
73   virtual bool thread_fits(PFS_thread *thread);
74   virtual int read_row_values(TABLE *table, unsigned char *buf,
75                               Field **fields, bool read_all);
76 protected:
77   /** Fields definition. */
78   static TABLE_FIELD_DEF m_field_def;
79   /** Current row. */
80   row_session_connect_attrs m_row;
81   /** Safe copy of @c PFS_thread::m_session_connect_attrs. */
82   char *m_copy_session_connect_attrs;
83   /** Safe copy of @c PFS_thread::m_session_connect_attrs_length. */
84   uint m_copy_session_connect_attrs_length;
85 };
86 
87 /** @} */
88 #endif
89