MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cursor_by_thread_connect_attr.cc
1 /* Copyright (c) 2008, 2011, 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 #include "my_global.h"
17 #include "cursor_by_thread_connect_attr.h"
18 
19 cursor_by_thread_connect_attr::cursor_by_thread_connect_attr(
20  const PFS_engine_table_share *share) :
21  PFS_engine_table(share, &m_pos), m_row_exists(false)
22 {}
23 
25 {
26  PFS_thread *thread;
27 
28  for (m_pos.set_at(&m_next_pos);
29  m_pos.has_more_thread();
30  m_pos.next_thread())
31  {
32  thread= &thread_array[m_pos.m_index_1];
33 
34  if (thread->m_lock.is_populated())
35  {
36  make_row(thread, m_pos.m_index_2);
37  if (m_row_exists)
38  {
39  m_next_pos.set_after(&m_pos);
40  return 0;
41  }
42  }
43  }
44  return HA_ERR_END_OF_FILE;
45 }
46 
47 
49 {
50  PFS_thread *thread;
51 
52  set_position(pos);
53  DBUG_ASSERT(m_pos.m_index_1 < thread_max);
54 
55  thread= &thread_array[m_pos.m_index_1];
56  if (!thread->m_lock.is_populated())
57  return HA_ERR_RECORD_DELETED;
58 
59  make_row(thread, m_pos.m_index_2);
60  if (m_row_exists)
61  return 0;
62 
63  return HA_ERR_RECORD_DELETED;
64 }
65 
66 
68 {
69  m_pos.reset();
70  m_next_pos.reset();
71 }