1/* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
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 as published by
5 the Free Software Foundation; version 2 of the License.
6
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
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#ifndef TABLE_SESSION_CONNECT_H
17#define TABLE_SESSION_CONNECT_H
18
19#include "pfs_column_types.h"
20#include "cursor_by_thread_connect_attr.h"
21#include "table_helper.h"
22
23#define MAX_ATTR_NAME_CHARS 32
24#define MAX_ATTR_VALUE_CHARS 1024
25#define MAX_UTF8_BYTES 6
26
27/** symbolic names for field offsets, keep in sync with field_types */
28enum field_offsets {
29 FO_PROCESS_ID,
30 FO_ATTR_NAME,
31 FO_ATTR_VALUE,
32 FO_ORDINAL_POSITION
33};
34
35/**
36 A row of PERFORMANCE_SCHEMA.SESSION_CONNECT_ATTRS and
37 PERFORMANCE_SCHEMA.SESSION_ACCOUNT_CONNECT_ATTRS.
38*/
39struct row_session_connect_attrs
40{
41 /** Column PROCESS_ID. */
42 ulong m_process_id;
43 /** Column ATTR_NAME. In UTF-8 */
44 char m_attr_name[MAX_ATTR_NAME_CHARS * MAX_UTF8_BYTES];
45 /** Length in bytes of @c m_attr_name. */
46 uint m_attr_name_length;
47 /** Column ATTR_VALUE. In UTF-8 */
48 char m_attr_value[MAX_ATTR_VALUE_CHARS * MAX_UTF8_BYTES];
49 /** Length in bytes of @c m_attr_name. */
50 uint m_attr_value_length;
51 /** Column ORDINAL_POSITION. */
52 ulong m_ordinal_position;
53};
54
55class table_session_connect : public cursor_by_thread_connect_attr
56{
57protected:
58 table_session_connect(const PFS_engine_table_share *share);
59
60public:
61 ~table_session_connect();
62
63protected:
64 virtual void make_row(PFS_thread *pfs, uint ordinal);
65 virtual bool thread_fits(PFS_thread *thread);
66 virtual int read_row_values(TABLE *table, unsigned char *buf,
67 Field **fields, bool read_all);
68protected:
69 /** Current row. */
70 row_session_connect_attrs m_row;
71 /** Safe copy of @c PFS_thread::m_session_connect_attrs. */
72 char *m_copy_session_connect_attrs;
73 /** Safe copy of @c PFS_thread::m_session_connect_attrs_length. */
74 uint m_copy_session_connect_attrs_length;
75};
76
77/** @} */
78#endif
79