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 CURSOR_BY_THREAD_CONNECT_ATTR_H
24 #define CURSOR_BY_THREAD_CONNECT_ATTR_H
25 
26 #include "pfs_column_types.h"
27 #include "pfs_engine_table.h"
28 #include "pfs_instr.h"
29 
30 /**
31   \addtogroup Performance_schema_tables
32   @{
33 */
34 
35 /**
36   Position of a cursor on abstract table
37   PERFORMANCE_SCHEMA.SESSION_CONNECT_ATTRS.
38 */
39 struct pos_connect_attr_by_thread_by_attr
40 : public PFS_double_index
41 {
pos_connect_attr_by_thread_by_attrpos_connect_attr_by_thread_by_attr42   pos_connect_attr_by_thread_by_attr()
43     : PFS_double_index(0, 0)
44   {}
45 
next_threadpos_connect_attr_by_thread_by_attr46   inline void next_thread(void)
47   {
48     m_index_1++;
49     m_index_2= 0;
50   }
51 
resetpos_connect_attr_by_thread_by_attr52   inline void reset(void)
53   {
54     m_index_1= 0;
55     m_index_2= 0;
56   }
57 };
58 
59 /** Cursor CURSOR_BY_THREAD_CONNECT_ATTR. */
60 class cursor_by_thread_connect_attr : public PFS_engine_table
61 {
62 public:
63   static ha_rows get_row_count();
64 
65   virtual int rnd_next();
66   virtual int rnd_pos(const void *pos);
67   virtual void reset_position(void);
68 
69 protected:
70   cursor_by_thread_connect_attr(const PFS_engine_table_share *share);
71 
72 public:
~cursor_by_thread_connect_attr()73   ~cursor_by_thread_connect_attr()
74   {}
75 
76 protected:
77   virtual void make_row(PFS_thread *thread, uint ordinal)= 0;
78   /** True if row exists */
79   bool m_row_exists;
80 
81 private:
82   /** Current position. */
83   pos_connect_attr_by_thread_by_attr m_pos;
84   /** Next position. */
85   pos_connect_attr_by_thread_by_attr m_next_pos;
86 };
87 
88 /** @} */
89 #endif
90