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

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_update_scan_hpp
  14. #define ODBC_CODEGEN_Code_update_scan_hpp
  15. #include <common/common.hpp>
  16. #include "Code_base.hpp"
  17. #include "Code_dml.hpp"
  18. #include "Code_table.hpp"
  19. #include "Code_pred.hpp"
  20. #include "Code_query.hpp"
  21. /**
  22.  * @class Plan_update_scan
  23.  * @brief Update in PlanTree
  24.  */
  25. class Plan_update_scan : public Plan_dml {
  26. public:
  27.     Plan_update_scan(Plan_root* root);
  28.     virtual ~Plan_update_scan();
  29.     Plan_base* analyze(Ctx& ctx, Ctl& ctl);
  30.     void describe(Ctx& ctx);
  31.     Exec_base* codegen(Ctx& ctx, Ctl& ctl);
  32.     void print(Ctx& ctx);
  33.     // children
  34.     void setTable(Plan_table* table);
  35.     void setDmlRow(Plan_dml_row* dmlRow);
  36.     void setQuery(Plan_query* query);
  37. protected:
  38.     Plan_table* m_table;
  39.     Plan_dml_row* m_dmlRow;
  40.     Plan_query* m_query;
  41. };
  42. inline
  43. Plan_update_scan::Plan_update_scan(Plan_root* root) :
  44.     Plan_dml(root),
  45.     m_table(0),
  46.     m_dmlRow(0),
  47.     m_query(0)
  48. {
  49. }
  50. // children
  51. inline void
  52. Plan_update_scan::setTable(Plan_table* table)
  53. {
  54.     ctx_assert(table != 0);
  55.     m_table = table;
  56. }
  57. inline void
  58. Plan_update_scan::setDmlRow(Plan_dml_row* dmlRow)
  59. {
  60.     ctx_assert(dmlRow != 0);
  61.     m_dmlRow = dmlRow;
  62. }
  63. inline void
  64. Plan_update_scan::setQuery(Plan_query* query)
  65. {
  66.     ctx_assert(query != 0);
  67.     m_query = query;
  68. }
  69. /**
  70.  * @class Exec_update_scan
  71.  * @brief Insert in ExecTree
  72.  */
  73. class Exec_update_scan : public Exec_dml {
  74. public:
  75.     class Code : public Exec_dml::Code {
  76.     public:
  77. Code();
  78. virtual ~Code();
  79.     protected:
  80. friend class Plan_update_scan;
  81. friend class Exec_update_scan;
  82. unsigned m_attrCount;
  83. NdbAttrId* m_attrId;
  84.     };
  85.     class Data : public Exec_dml::Data {
  86.     public:
  87. Data();
  88. virtual ~Data();
  89.     protected:
  90. friend class Exec_update_scan;
  91.     };
  92.     Exec_update_scan(Exec_root* root);
  93.     virtual ~Exec_update_scan();
  94.     void alloc(Ctx& ctx, Ctl& ctl);
  95.     void execImpl(Ctx& ctx, Ctl& ctl);
  96.     void close(Ctx& ctx);
  97.     void print(Ctx& ctx);
  98.     // children
  99.     const Code& getCode() const;
  100.     Data& getData() const;
  101.     void setQuery(Exec_query* query);
  102. protected:
  103.     Exec_query* m_query;
  104. };
  105. inline
  106. Exec_update_scan::Code::Code() :
  107.     m_attrCount(0),
  108.     m_attrId(0)
  109. {
  110. }
  111. inline
  112. Exec_update_scan::Data::Data()
  113. {
  114. }
  115. inline
  116. Exec_update_scan::Exec_update_scan(Exec_root* root) :
  117.     Exec_dml(root),
  118.     m_query(0)
  119. {
  120. }
  121. // children
  122. inline const Exec_update_scan::Code&
  123. Exec_update_scan::getCode() const
  124. {
  125.     const Code* code = static_cast<const Code*>(m_code);
  126.     return *code;
  127. }
  128. inline Exec_update_scan::Data&
  129. Exec_update_scan::getData() const
  130. {
  131.     Data* data = static_cast<Data*>(m_data);
  132.     return *data;
  133. }
  134. inline void
  135. Exec_update_scan::setQuery(Exec_query* query)
  136. {
  137.     ctx_assert(query != 0 && m_query == 0);
  138.     m_query = query;
  139. }
  140. #endif