1 /* 2 * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License, version 2.0, 6 * as published by the Free Software Foundation. 7 * 8 * This program is also distributed with certain software (including 9 * but not limited to OpenSSL) that is licensed under separate terms, 10 * as designated in a particular file or component or in included license 11 * documentation. The authors of MySQL hereby grant you an additional 12 * permission to link the program and your derivative works with the 13 * separately licensed software that they have included with MySQL. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License, version 2.0, for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 23 * 02110-1301 USA 24 */ 25 26 #ifndef _SQL_DATA_RESULT_H_ 27 #define _SQL_DATA_RESULT_H_ 28 29 #include "sql_data_context.h" 30 31 32 namespace xpl 33 { 34 class PFS_string; 35 36 class Sql_data_result 37 { 38 public: 39 Sql_data_result(Sql_data_context &context); 40 41 void disable_binlog(); 42 void restore_binlog(); 43 44 void query(const ngs::PFS_string &query); 45 46 void get_next_field(long &value); 47 void get_next_field(bool &value); 48 void get_next_field(std::string &value); 49 void get_next_field(const char * &value); 50 void get_next_field(char * &value); 51 52 bool next_row(); 53 long statement_warn_count(); size()54 Buffering_command_delegate::Resultset::size_type size() const { return m_result_set.size(); } 55 get(T & value)56 template<typename T> Sql_data_result &get(T &value) 57 { 58 get_next_field(value); 59 return *this; 60 } 61 62 private: 63 typedef Callback_command_delegate::Field_value Field_value; 64 typedef Buffering_command_delegate::Resultset Resultset; 65 66 Field_value *get_value(); 67 Field_value &validate_field_index_no_null(const enum_field_types field_type); 68 void validate_field_index(const enum_field_types field_type) const; 69 void validate_field_index(const enum_field_types field_type1, const enum_field_types field_type2) const; 70 void validate_field_index_common() const; 71 72 Resultset m_result_set; 73 Sql_data_context::Result_info m_result_info; 74 std::vector<Command_delegate::Field_type> m_field_types; 75 std::size_t m_field_index; 76 Resultset::iterator m_row_index; 77 Sql_data_context &m_context; 78 }; 79 80 } // namespace xpl 81 82 #endif // _SQL_DATA_RESULT_H_ 83