Code_query_scan.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_query_scan_hpp
  14. #define ODBC_CODEGEN_Code_query_scan_hpp
  15. #include <common/common.hpp>
  16. #include "Code_query.hpp"
  17. #include "Code_table.hpp"
  18. #include "Code_pred.hpp"
  19. class Ctx;
  20. class StmtArea;
  21. class NdbConnection;
  22. class NdbOperation;
  23. class NdbRecAttr;
  24. /*
  25.  * Table scan.
  26.  */
  27. class Plan_query_scan : public Plan_query {
  28. public:
  29.     Plan_query_scan(Plan_root* root);
  30.     virtual ~Plan_query_scan();
  31.     Plan_base* analyze(Ctx& ctx, Ctl& ctl);
  32.     Exec_base* codegen(Ctx& ctx, Ctl& ctl);
  33.     void print(Ctx& ctx);
  34.     void setTable(Plan_table* table);
  35.     void setInterp(Plan_pred* interp);
  36.     void setExclusive();
  37. protected:
  38.     Plan_table* m_table;
  39.     Plan_pred* m_interp;
  40.     bool m_exclusive; // exclusive
  41. };
  42. inline
  43. Plan_query_scan::Plan_query_scan(Plan_root* root) :
  44.     Plan_query(root),
  45.     m_table(0),
  46.     m_interp(0),
  47.     m_exclusive(false)
  48. {
  49. }
  50. inline void
  51. Plan_query_scan::setTable(Plan_table* table)
  52. {
  53.     ctx_assert(table != 0);
  54.     m_table = table;
  55. }
  56. inline void
  57. Plan_query_scan::setInterp(Plan_pred* interp)
  58. {
  59.     ctx_assert(interp != 0);
  60.     m_interp = interp;
  61. }
  62. inline void
  63. Plan_query_scan::setExclusive()
  64. {
  65.     m_exclusive = true;
  66. }
  67. class Exec_query_scan : public Exec_query {
  68. public:
  69.     class Code : public Exec_query::Code {
  70.     public:
  71. Code(unsigned attrCount);
  72. virtual ~Code();
  73.     protected:
  74. friend class Plan_query_scan;
  75. friend class Exec_query_scan;
  76. char* m_tableName;
  77. unsigned m_attrCount;
  78. SqlSpecs m_sqlSpecs;
  79. NdbAttrId* m_attrId;
  80. bool m_exclusive;
  81.     };
  82.     class Data : public Exec_query::Data {
  83.     public:
  84. Data(Exec_query_scan* node, const SqlSpecs& sqlSpecs);
  85. virtual ~Data();
  86.     protected:
  87. friend class Exec_query_scan;
  88. SqlRow m_sqlRow;
  89. NdbConnection* m_con;
  90. NdbOperation* m_op;
  91. NdbRecAttr** m_recAttr;
  92. unsigned m_parallel; // parallelism could be runtime option
  93.     };
  94.     Exec_query_scan(Exec_root* root);
  95.     virtual ~Exec_query_scan();
  96.     void alloc(Ctx& ctx, Ctl& ctl);
  97.     void execImpl(Ctx& ctx, Ctl& ctl);
  98.     bool fetchImpl(Ctx& ctx, Ctl& ctl);
  99.     void close(Ctx& ctx);
  100.     void print(Ctx& ctx);
  101.     // children
  102.     const Code& getCode() const;
  103.     Data& getData() const;
  104.     void setInterp(Exec_pred* interp);
  105. protected:
  106.     Exec_pred* m_interp;
  107. };
  108. inline
  109. Exec_query_scan::Code::Code(unsigned attrCount) :
  110.     Exec_query::Code(m_sqlSpecs),
  111.     m_tableName(0),
  112.     m_attrCount(attrCount),
  113.     m_sqlSpecs(attrCount),
  114.     m_attrId(0),
  115.     m_exclusive(false)
  116. {
  117. }
  118. inline
  119. Exec_query_scan::Data::Data(Exec_query_scan* node, const SqlSpecs& sqlSpecs) :
  120.     Exec_query::Data(node, m_sqlRow),
  121.     m_sqlRow(sqlSpecs),
  122.     m_con(0),
  123.     m_op(0),
  124.     m_recAttr(0),
  125.     m_parallel(1)
  126. {
  127. }
  128. inline
  129. Exec_query_scan::Exec_query_scan(Exec_root* root) :
  130.     Exec_query(root),
  131.     m_interp(0)
  132. {
  133. }
  134. // children
  135. inline const Exec_query_scan::Code&
  136. Exec_query_scan::getCode() const
  137. {
  138.     const Code* code = static_cast<const Code*>(m_code);
  139.     return *code;
  140. }
  141. inline Exec_query_scan::Data&
  142. Exec_query_scan::getData() const
  143. {
  144.     Data* data = static_cast<Data*>(m_data);
  145.     return *data;
  146. }
  147. inline void
  148. Exec_query_scan::setInterp(Exec_pred* interp)
  149. {
  150.     ctx_assert(interp != 0);
  151.     m_interp = interp;
  152. }
  153. #endif