19
19
Obj defines the basic set of operations for each database object.
24
Serialize object state into a buffer. The buffer actually should be a
25
binary buffer. String class is used here just because we don't have
26
convenient primitive for binary buffers.
28
Serialization format is opaque to the client, i.e. the client should
29
not make any assumptions about the format or the content of the
32
Serialization format can be changed in the future versions. However,
33
the server must be able to materialize objects coded in any previous
36
@param[in] thd Server thread context.
37
@param[in] serialialization Buffer to serialize the object
40
@retval FALSE on success.
41
@retval TRUE on error.
43
virtual bool serialize(THD *thd, String *serialialization) = 0;
25
bool serialize(THD *thd, String *serialialization);
47
28
Return the name of the object.
58
39
virtual const String *get_db_name() = 0;
61
Create the object in the database.
63
@param[in] thd Server thread context.
66
@retval FALSE on success.
67
@retval TRUE on error.
69
virtual bool execute(THD *thd) = 0;
41
bool execute(THD *thd);
77
50
Read the object state from a given buffer and restores object state to
78
51
the point, where it can be executed.
87
60
virtual bool materialize(uint serialization_version,
88
61
const String *serialialization) = 0;
63
/// Primitive implementing @c serialize() method.
64
virtual bool do_serialize(THD *thd, String *serialialization) = 0;
66
/// Primitive implementing @c execute() method.
67
virtual bool do_execute(THD *thd) = 0;
115
friend Obj *materialize_tablespace(const String *,
122
Create the object in the database.
124
@param[in] thd Server thread context.
126
@return error status.
127
@retval FALSE on success.
128
@retval TRUE on error.
130
@note The real work is done inside @c do_execute() primitive which should be
131
defied in derived classes. This method prepares appropriate context and calls
135
bool Obj::execute(THD *thd)
137
ulong saved_sql_mode= thd->variables.sql_mode;
138
thd->variables.sql_mode= 0;
140
set_var_collation_client saved_charset_settings(
141
thd->variables.character_set_client,
142
thd->variables.character_set_results,
143
thd->variables.collation_connection);
145
set_var_collation_client new_charset_settings(::system_charset_info,
146
::system_charset_info,
147
::system_charset_info);
148
new_charset_settings.update(thd);
150
bool ret= do_execute(thd);
152
saved_charset_settings.update(thd);
153
thd->variables.sql_mode= saved_sql_mode;
159
Serialize object state into a buffer. The buffer actually should be a
160
binary buffer. String class is used here just because we don't have
161
convenient primitive for binary buffers.
163
Serialization format is opaque to the client, i.e. the client should
164
not make any assumptions about the format or the content of the
167
Serialization format can be changed in the future versions. However,
168
the server must be able to materialize objects coded in any previous
171
@param[in] thd Server thread context.
172
@param[in] serialialization Buffer to serialize the object
174
@return error status.
175
@retval FALSE on success.
176
@retval TRUE on error.
178
@note The real work is done inside @c do_serialize() primitive which should be
179
defied in derived classes. This method prepares appropriate context and calls
183
bool Obj::serialize(THD *thd, String *serialization)
185
ulong saved_sql_mode= thd->variables.sql_mode;
186
thd->variables.sql_mode= 0;
188
bool ret= do_serialize(thd, serialization);
190
thd->variables.sql_mode= saved_sql_mode;
138
195
///////////////////////////////////////////////////////////////////////////
445
502
uint serialization_version,
446
503
const String *serialialization);
505
Obj *materialize_tablespace(const String *ts_name,
506
uint serialization_version,
507
const String *serialialization);
448
509
///////////////////////////////////////////////////////////////////////////
450
511
bool is_internal_db_name(const String *db_name);
461
522
bool check_db_existence(const String *db_name);
525
This method returns a @c TablespaceObj object if the table has a tablespace.
527
Obj *get_tablespace_for_table(THD *thd,
528
const String *db_name,
529
const String *tbl_name);
532
This method determines if a materialized tablespace exists on the
533
system. This compares the name and all saved attributes of the
534
tablespace. A FALSE return would mean either the tablespace does
535
not exist or the tablespace attributes are different.
537
bool tablespace_exists(THD *thd,
541
This method determines if the tablespace referenced by name exists on the
542
system. Returns a TablespaceObj if it exists or NULL if it doesn't.
544
Obj *is_tablespace(THD *thd,
545
const String *ts_name);
548
This method returns a description of the tablespace useful for communicating
551
const String *describe_tablespace(Obj *ts);
463
553
///////////////////////////////////////////////////////////////////////////
515
605
List<LEX_STRING> *db_list);
608
The following class is used to manage name locks on a list of tables.
610
This class uses a list of type List<Obj> to establish the table list
611
that will be used to manage locks on the tables.
616
Name_locker(THD *thd) { m_thd= thd; }
619
free_table_list(m_table_list);
624
Gets name locks on table list.
626
int get_name_locks(List<Obj> *tables, thr_lock_type lock);
629
Releases name locks on table list.
631
int release_name_locks();
634
TABLE_LIST *m_table_list; ///< The list of tables to obtain locks on.
635
THD *m_thd; ///< Thread context.
638
Builds a table list from the list of objects passed to constructor.
640
TABLE_LIST *build_table_list(List<Obj> *tables, thr_lock_type lock);
641
void free_table_list(TABLE_LIST*);
517
644
} // obs namespace
519
646
#endif // SI_OBJECTS_H_