Code_delete_index.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef ODBC_CODEGEN_Code_delete_index_hpp
  14. #define ODBC_CODEGEN_Code_delete_index_hpp
  15. #include <common/common.hpp>
  16. #include "Code_dml.hpp"
  17. #include "Code_query.hpp"
  18. #include "Code_table.hpp"
  19. /**
  20.  * @class Plan_delete_index
  21.  * @brief Delete by primary key
  22.  */
  23. class Plan_delete_index : public Plan_dml {
  24. public:
  25.     Plan_delete_index(Plan_root* root);
  26.     virtual ~Plan_delete_index();
  27.     Plan_base* analyze(Ctx& ctx, Ctl& ctl);
  28.     void describe(Ctx& ctx);
  29.     Exec_base* codegen(Ctx& ctx, Ctl& ctl);
  30.     void print(Ctx& ctx);
  31.     // children
  32.     void setQuery(Plan_query* query);
  33.     void setTable(Plan_table* table, Plan_table::Index* index);
  34. protected:
  35.     Plan_query* m_query;
  36.     Plan_table* m_table;
  37.     Plan_table::Index* m_index;
  38. };
  39. inline
  40. Plan_delete_index::Plan_delete_index(Plan_root* root) :
  41.     Plan_dml(root),
  42.     m_query(0),
  43.     m_table(0)
  44. {
  45. }
  46. inline void
  47. Plan_delete_index::setQuery(Plan_query* query)
  48. {
  49.     ctx_assert(query != 0);
  50.     m_query = query;
  51. }
  52. inline void
  53. Plan_delete_index::setTable(Plan_table* table, Plan_table::Index* index)
  54. {
  55.     ctx_assert(table != 0 && index != 0 && index == &table->m_indexList[index->m_pos] && index->m_pos != 0);
  56.     m_table = table;
  57.     m_index = index;
  58. }
  59. /**
  60.  * @class Exec_delete_index
  61.  * @brief Delete by primary key
  62.  */
  63. class Exec_delete_index : public Exec_dml {
  64. public:
  65.     class Code : public Exec_dml::Code {
  66.     public:
  67. Code(unsigned keyCount);
  68. virtual ~Code();
  69.     protected:
  70. friend class Plan_delete_index;
  71. friend class Exec_delete_index;
  72. const char* m_tableName;
  73. const char* m_indexName;
  74. unsigned m_keyCount;
  75. SqlSpecs m_keySpecs; // key types
  76. NdbAttrId* m_keyId;
  77. Exec_expr** m_keyMatch; // XXX pointers for now
  78.     };
  79.     class Data : public Exec_dml::Data {
  80.     public:
  81. Data();
  82. virtual ~Data();
  83.     protected:
  84. friend class Exec_delete_index;
  85.     };
  86.     Exec_delete_index(Exec_root* root);
  87.     virtual ~Exec_delete_index();
  88.     void alloc(Ctx& ctx, Ctl& ctl);
  89.     void execImpl(Ctx& ctx, Ctl& ctl);
  90.     void close(Ctx& ctx);
  91.     void print(Ctx& ctx);
  92.     // children
  93.     const Code& getCode() const;
  94.     Data& getData() const;
  95.     void setQuery(Exec_query* query);
  96. protected:
  97.     Exec_query* m_query;
  98. };
  99. inline
  100. Exec_delete_index::Code::Code(unsigned keyCount) :
  101.     m_tableName(0),
  102.     m_indexName(0),
  103.     m_keyCount(keyCount),
  104.     m_keySpecs(keyCount),
  105.     m_keyId(0),
  106.     m_keyMatch(0)
  107. {
  108. }
  109. inline
  110. Exec_delete_index::Data::Data()
  111. {
  112. }
  113. inline
  114. Exec_delete_index::Exec_delete_index(Exec_root* root) :
  115.     Exec_dml(root),
  116.     m_query(0)
  117. {
  118. }
  119. // children
  120. inline const Exec_delete_index::Code&
  121. Exec_delete_index::getCode() const
  122. {
  123.     const Code* code = static_cast<const Code*>(m_code);
  124.     return *code;
  125. }
  126. inline Exec_delete_index::Data&
  127. Exec_delete_index::getData() const
  128. {
  129.     Data* data = static_cast<Data*>(m_data);
  130.     return *data;
  131. }
  132. inline void
  133. Exec_delete_index::setQuery(Exec_query* query)
  134. {
  135.     ctx_assert(query != 0 && m_query == 0);
  136.     m_query = query;
  137. }
  138. #endif