1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/* Copyright (c) 2017, 2025, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is designed to work with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have either included with
the program or referenced in the documentation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef RESOURCEGROUPS_RESOURCE_GROUP_SQL_CMD_H_
#define RESOURCEGROUPS_RESOURCE_GROUP_SQL_CMD_H_
#include "lex_string.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "sql/mem_root_array.h"
#include "sql/resourcegroups/resource_group_basic_types.h" // Type, Range
#include "sql/sql_cmd.h"
class PT_alter_resource_group;
class PT_create_resource_group;
class PT_drop_resource_group;
class PT_set_resource_group;
class THD;
namespace resourcegroups {
/**
Sql_cmd_create_resource_group represents CREATE RESOURCE GROUP statement.
*/
class Sql_cmd_create_resource_group : public Sql_cmd {
friend class ::PT_create_resource_group;
public:
Sql_cmd_create_resource_group(const LEX_CSTRING &name, const Type type,
const Mem_root_array<Range> *cpu_list,
int priority, bool enabled)
: m_name(name),
m_type(type),
m_cpu_list(cpu_list),
m_priority(priority),
m_enabled(enabled) {}
enum_sql_command sql_command_code() const override {
return SQLCOM_CREATE_RESOURCE_GROUP;
}
bool execute(THD *thd) override;
private:
const LEX_CSTRING m_name;
const Type m_type;
const Mem_root_array<Range> *m_cpu_list;
int m_priority;
bool m_enabled;
};
/**
Sql_cmd_alter_resource_group represents ALTER RESOURCE GROUP statement.
*/
class Sql_cmd_alter_resource_group : public Sql_cmd {
friend class ::PT_alter_resource_group;
public:
Sql_cmd_alter_resource_group(const LEX_CSTRING &name,
const Mem_root_array<Range> *cpu_list,
int priority, bool enable, bool force,
bool use_enable)
: m_name(name),
m_cpu_list(cpu_list),
m_priority(priority),
m_enable(enable),
m_force(force),
m_use_enable(use_enable) {}
enum_sql_command sql_command_code() const override {
return SQLCOM_ALTER_RESOURCE_GROUP;
}
bool execute(THD *thd) override;
private:
const LEX_CSTRING m_name;
const Mem_root_array<Range> *m_cpu_list;
int m_priority;
bool m_enable;
bool m_force;
bool m_use_enable;
};
/**
Sql_cmd_drop_resource_group represents DROP RESOURCE GROUP statement.
*/
class Sql_cmd_drop_resource_group : public Sql_cmd {
friend class ::PT_drop_resource_group;
public:
Sql_cmd_drop_resource_group(const LEX_CSTRING &name, bool force)
: m_name(name), m_force(force) {}
enum_sql_command sql_command_code() const override {
return SQLCOM_DROP_RESOURCE_GROUP;
}
bool execute(THD *thd) override;
private:
const LEX_CSTRING m_name;
bool m_force;
};
/**
Sql_cmd_set_resource_group represents SET RESOURCE GROUP statement.
*/
class Sql_cmd_set_resource_group final : public Sql_cmd {
friend class ::PT_set_resource_group;
public:
Sql_cmd_set_resource_group(const LEX_CSTRING &name,
Mem_root_array<ulonglong> *thread_id_list)
: m_name(name), m_thread_id_list(thread_id_list) {}
enum_sql_command sql_command_code() const override {
return SQLCOM_SET_RESOURCE_GROUP;
}
bool execute(THD *thd) override;
bool prepare(THD *thd) override;
private:
const LEX_CSTRING m_name;
Mem_root_array<ulonglong> *m_thread_id_list;
};
} // namespace resourcegroups
#endif // RESOURCEGROUPS_RESOURCE_GROUP_SQL_CMD_H_
|