1 /* Copyright (c) 2012, 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, 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 struct pos_connect_attr_by_thread_by_attr
36 : public PFS_double_index
37 {
pos_connect_attr_by_thread_by_attrpos_connect_attr_by_thread_by_attr38   pos_connect_attr_by_thread_by_attr()
39     : PFS_double_index(0, 0)
40   {}
41 
has_more_threadpos_connect_attr_by_thread_by_attr42   inline bool has_more_thread(void)
43   {
44     return (m_index_1 < thread_max);
45   }
46 
next_threadpos_connect_attr_by_thread_by_attr47   inline void next_thread(void)
48   {
49     m_index_1++;
50     m_index_2= 0;
51   }
52 
resetpos_connect_attr_by_thread_by_attr53   inline void reset(void)
54   {
55     m_index_1= 0;
56     m_index_2= 0;
57   }
58 };
59 
60 /** Cursor CURSOR_BY_THREAD_CONNECT_ATTR. */
61 class cursor_by_thread_connect_attr : public PFS_engine_table
62 {
63 public:
64   virtual int rnd_next();
65   virtual int rnd_pos(const void *pos);
66   virtual void reset_position(void);
67 
68 protected:
69   cursor_by_thread_connect_attr(const PFS_engine_table_share *share);
70 
71 public:
~cursor_by_thread_connect_attr()72   ~cursor_by_thread_connect_attr()
73   {}
74 
75 protected:
76   virtual void make_row(PFS_thread *thread, uint ordinal)= 0;
77   /** True if row exists */
78   bool m_row_exists;
79 
80 private:
81   /** Current position. */
82   pos_connect_attr_by_thread_by_attr m_pos;
83   /** Next position. */
84   pos_connect_attr_by_thread_by_attr m_next_pos;
85 };
86 
87 /** @} */
88 #endif
89