21 #include "my_global.h"
22 #include "my_pthread.h"
31 THR_LOCK table_setup_objects::m_table_lock;
36 { C_STRING_WITH_LEN(
"OBJECT_TYPE") },
37 { C_STRING_WITH_LEN(
"enum(\'TABLE\')") },
41 { C_STRING_WITH_LEN(
"OBJECT_SCHEMA") },
42 { C_STRING_WITH_LEN(
"varchar(64)") },
46 { C_STRING_WITH_LEN(
"OBJECT_NAME") },
47 { C_STRING_WITH_LEN(
"varchar(64)") },
51 { C_STRING_WITH_LEN(
"ENABLED") },
52 { C_STRING_WITH_LEN(
"enum(\'YES\',\'NO\')") },
56 { C_STRING_WITH_LEN(
"TIMED") },
57 { C_STRING_WITH_LEN(
"enum(\'YES\',\'NO\')") },
63 table_setup_objects::m_field_def=
69 { C_STRING_WITH_LEN(
"setup_objects") },
72 table_setup_objects::write_row,
73 table_setup_objects::delete_all_rows,
74 table_setup_objects::get_row_count,
82 int update_derived_flags()
84 PFS_thread *thread= PFS_thread::get_current_thread();
85 if (unlikely(thread == NULL))
86 return HA_ERR_OUT_OF_MEM;
98 int table_setup_objects::write_row(
TABLE *
table,
unsigned char *
buf,
104 String object_schema_data(
"%", 1, &my_charset_utf8_bin);
105 String object_name_data(
"%", 1, &my_charset_utf8_bin);
106 String *object_schema= &object_schema_data;
107 String *object_name= &object_name_data;
113 for (; (f= *fields) ; fields++)
115 if (bitmap_is_set(table->write_set, f->field_index))
117 switch(f->field_index)
141 if (object_type != OBJECT_TYPE_TABLE)
142 return HA_ERR_NO_REFERENCED_ROW;
145 if ((enabled_value != ENUM_YES) && (enabled_value != ENUM_NO))
146 return HA_ERR_NO_REFERENCED_ROW;
149 if ((timed_value != ENUM_YES) && (timed_value != ENUM_NO))
150 return HA_ERR_NO_REFERENCED_ROW;
152 enabled= (enabled_value == ENUM_YES) ?
true :
false;
153 timed= (timed_value == ENUM_YES) ?
true :
false;
155 result= insert_setup_object(object_type, object_schema, object_name,
158 result= update_derived_flags();
162 int table_setup_objects::delete_all_rows(
void)
164 int result= reset_setup_object();
166 result= update_derived_flags();
170 ha_rows table_setup_objects::get_row_count(
void)
172 return setup_object_count();
175 table_setup_objects::table_setup_objects()
177 m_row_exists(false), m_pos(0), m_next_pos(0)
190 for (m_pos.
set_at(&m_next_pos);
191 m_pos.
m_index < setup_object_max;
194 pfs= &setup_object_array[m_pos.
m_index];
203 return HA_ERR_END_OF_FILE;
212 DBUG_ASSERT(m_pos.
m_index < setup_object_max);
213 pfs= &setup_object_array[m_pos.
m_index];
220 return HA_ERR_RECORD_DELETED;
250 if (unlikely(! m_row_exists))
251 return HA_ERR_RECORD_DELETED;
254 DBUG_ASSERT(table->s->null_bytes == 1);
257 for (; (f= *fields) ; fields++)
259 if (read_all || bitmap_is_set(table->read_set, f->field_index))
261 switch(f->field_index)
296 const unsigned char *,
304 for (; (f= *fields) ; fields++)
306 if (bitmap_is_set(table->write_set, f->field_index))
308 switch(f->field_index)
313 return HA_ERR_WRONG_COMMAND;
317 if ((value != ENUM_YES) && (value != ENUM_NO))
318 return HA_ERR_NO_REFERENCED_ROW;
324 if ((value != ENUM_YES) && (value != ENUM_NO))
325 return HA_ERR_NO_REFERENCED_ROW;
326 *m_row.
m_timed_ptr= (value == ENUM_YES) ?
true :
false;
334 result= update_derived_flags();
339 const unsigned char *buf,
342 DBUG_ASSERT(m_row_exists);
349 int result= delete_setup_object(object_type, &object_schema, &object_name);
352 result= update_derived_flags();