MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
polyglot_result.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025, 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 designed to work 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 either included with
14 * the program or referenced in the documentation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License, version 2.0, for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef MYSQLSHDK_SCRIPTING_POLYGLOT_OBJECTS_POLYGLOT_RESULT_H_
27#define MYSQLSHDK_SCRIPTING_POLYGLOT_OBJECTS_POLYGLOT_RESULT_H_
28
29#include <string>
30#include <vector>
31
36
37namespace shcore {
38namespace polyglot {
39
40class PolyResult : public Object_bridge {
41 public:
42 explicit PolyResult(const std::shared_ptr<jit_executor::db::IResult> &result);
43 ~PolyResult() override = default;
44
45 std::string class_name() const override { return "Result"; }
46
47 Value call(const std::string &name, const Argument_list &args) override;
48
49 private:
50 std::vector<std::string> *methods() const override { return &m_methods; }
51
52 std::vector<std::string> get_column_names() const;
53
54 std::shared_ptr<Row> fetch_one() const;
57 bool next_result();
58
59 static std::vector<std::string> m_methods;
60 std::shared_ptr<jit_executor::db::IResult> m_result;
61
62 // NOTE: In order to avoid filling the cache all the time, but only when
63 // needed, these functions are marked as const and the attributes mutable
64 // because the functions that will trigger filling the cache are const:
65 // get_member() and get_column_names()
66 void reset_column_cache();
67 void update_column_cache() const;
68
70 mutable std::vector<std::string> m_column_names;
71};
72
73} // namespace polyglot
74} // namespace shcore
75
76#endif // MYSQLSHDK_SCRIPTING_POLYGLOT_OBJECTS_POLYGLOT_RESULT_H_
Definition: polyglot_object_bridge.h:38
Definition: polyglot_result.h:40
std::shared_ptr< jit_executor::db::IResult > m_result
Definition: polyglot_result.h:60
~PolyResult() override=default
std::shared_ptr< Row > fetch_one() const
Definition: polyglot_result.cc:80
std::vector< std::string > * methods() const override
Definition: polyglot_result.h:50
std::string class_name() const override
Definition: polyglot_result.h:45
shcore::Array_t fetch_all() const
Definition: polyglot_result.cc:94
std::vector< std::string > m_column_names
Definition: polyglot_result.h:70
static std::vector< std::string > m_methods
Definition: polyglot_result.h:59
Value call(const std::string &name, const Argument_list &args) override
Calls the named method with the given args.
Definition: polyglot_result.cc:114
shcore::Dictionary_t fetch_one_object() const
Definition: polyglot_result.cc:104
void update_column_cache() const
Definition: polyglot_result.cc:55
shcore::Array_t m_columns
Definition: polyglot_result.h:69
std::vector< std::string > get_column_names() const
Definition: polyglot_result.cc:75
PolyResult(const std::shared_ptr< jit_executor::db::IResult > &result)
Definition: polyglot_result.cc:47
bool next_result()
Definition: polyglot_result.cc:109
void reset_column_cache()
Definition: polyglot_result.cc:50
Definition: file_system_exceptions.h:34
Value::Array_type_ref Array_t
Definition: jit_executor_value.h:431
std::vector< Value > Argument_list
Definition: jit_executor_value.h:429
Value::Map_type_ref Dictionary_t
Definition: jit_executor_value.h:430
Definition: result.h:30
Pointer to a function that may be implemented in any language.
Definition: jit_executor_value.h:130