summaryrefslogtreecommitdiff
path: root/sql/structs.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/structs.h')
-rw-r--r--sql/structs.h199
1 files changed, 172 insertions, 27 deletions
diff --git a/sql/structs.h b/sql/structs.h
index 27b9725815b..46947b50502 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -29,6 +29,7 @@
#include <mysql_com.h> /* USERNAME_LENGTH */
struct TABLE;
+class Type_handler;
class Field;
class Index_statistics;
@@ -38,7 +39,7 @@ typedef struct st_date_time_format {
uchar positions[8];
char time_separator; /* Separator between hour and minute */
uint flag; /* For future */
- LEX_STRING format;
+ LEX_CSTRING format;
} DATE_TIME_FORMAT;
@@ -109,8 +110,8 @@ typedef struct st_key {
ext_key_part_map.is_set(1) == false
*/
key_part_map ext_key_part_map;
+ LEX_CSTRING name;
uint block_size;
- uint name_length;
enum ha_key_alg algorithm;
/*
The flag is on if statistical data for the index prefixes
@@ -124,10 +125,9 @@ typedef struct st_key {
union
{
plugin_ref parser; /* Fulltext [pre]parser */
- LEX_STRING *parser_name; /* Fulltext [pre]parser name */
+ LEX_CSTRING *parser_name; /* Fulltext [pre]parser name */
};
KEY_PART_INFO *key_part;
- char *name; /* Name of key */
/* Unique name for cache; db + \0 + table_name + \0 + key_name + \0 */
uchar *cache_name;
/*
@@ -148,11 +148,8 @@ typedef struct st_key {
*/
Index_statistics *collected_stats;
- union {
- int bdb_return_if_eq;
- } handler;
TABLE *table;
- LEX_STRING comment;
+ LEX_CSTRING comment;
/** reference to the list of options or NULL */
engine_option_value *option_list;
ha_index_option_struct *option_struct; /* structure with parsed options */
@@ -203,24 +200,39 @@ extern const char *show_comp_option_name[];
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
-typedef struct st_lex_user {
- LEX_STRING user, host, plugin, auth;
- LEX_STRING pwtext, pwhash;
+
+struct AUTHID
+{
+ LEX_CSTRING user, host;
+ void init() { memset(this, 0, sizeof(*this)); }
+ void copy(MEM_ROOT *root, const LEX_CSTRING *usr, const LEX_CSTRING *host);
bool is_role() const { return user.str[0] && !host.str[0]; }
- void set_lex_string(LEX_STRING *l, char *buf)
+ void set_lex_string(LEX_CSTRING *l, char *buf)
{
if (is_role())
*l= user;
else
- l->length= strxmov(l->str= buf, user.str, "@", host.str, NullS) - buf;
+ {
+ l->str= buf;
+ l->length= strxmov(buf, user.str, "@", host.str, NullS) - buf;
+ }
}
+ void parse(const char *str, size_t length);
+ bool read_from_mysql_proc_row(THD *thd, TABLE *table);
+};
+
+
+struct LEX_USER: public AUTHID
+{
+ LEX_CSTRING plugin, auth;
+ LEX_CSTRING pwtext, pwhash;
void reset_auth()
{
pwtext.length= pwhash.length= plugin.length= auth.length= 0;
pwtext.str= pwhash.str= 0;
- plugin.str= auth.str= const_cast<char*>("");
+ plugin.str= auth.str= "";
}
-} LEX_USER;
+};
/*
This structure specifies the maximum amount of resources which
@@ -315,7 +327,7 @@ typedef struct st_user_stats
typedef struct st_table_stats
{
char table[NAME_LEN * 2 + 2]; // [db] + '\0' + [table] + '\0'
- uint table_name_length;
+ size_t table_name_length;
ulonglong rows_read, rows_changed;
ulonglong rows_changed_x_indexes;
/* Stores enum db_type, but forward declarations cannot be done */
@@ -326,7 +338,7 @@ typedef struct st_index_stats
{
// [db] + '\0' + [table] + '\0' + [index] + '\0'
char index[NAME_LEN * 3 + 3];
- uint index_name_length; /* Length of 'index' */
+ size_t index_name_length; /* Length of 'index' */
ulonglong rows_read;
} INDEX_STATS;
@@ -578,27 +590,31 @@ public:
struct Lex_field_type_st: public Lex_length_and_dec_st
{
private:
- enum_field_types m_type;
- void set(enum_field_types type, const char *length, const char *dec)
+ const Type_handler *m_handler;
+ void set(const Type_handler *handler, const char *length, const char *dec)
{
- m_type= type;
+ m_handler= handler;
Lex_length_and_dec_st::set(length, dec);
}
public:
- void set(enum_field_types type, Lex_length_and_dec_st length_and_dec)
+ void set(const Type_handler *handler, Lex_length_and_dec_st length_and_dec)
{
- m_type= type;
+ m_handler= handler;
Lex_length_and_dec_st::operator=(length_and_dec);
}
- void set(enum_field_types type, const char *length)
+ void set(const Type_handler *handler, const char *length)
{
- set(type, length, 0);
+ set(handler, length, 0);
}
- void set(enum_field_types type)
+ void set(const Type_handler *handler)
{
- set(type, 0, 0);
+ set(handler, 0, 0);
+ }
+ void set_handler(const Type_handler *handler)
+ {
+ m_handler= handler;
}
- enum_field_types field_type() const { return m_type; }
+ const Type_handler *type_handler() const { return m_handler; }
};
@@ -629,6 +645,135 @@ public:
};
+struct Lex_spblock_handlers_st
+{
+public:
+ int hndlrs;
+ void init(int count) { hndlrs= count; }
+};
+
+
+struct Lex_spblock_st: public Lex_spblock_handlers_st
+{
+public:
+ int vars;
+ int conds;
+ int curs;
+ void init()
+ {
+ vars= conds= hndlrs= curs= 0;
+ }
+ void init_using_vars(uint nvars)
+ {
+ vars= nvars;
+ conds= hndlrs= curs= 0;
+ }
+ void join(const Lex_spblock_st &b1, const Lex_spblock_st &b2)
+ {
+ vars= b1.vars + b2.vars;
+ conds= b1.conds + b2.conds;
+ hndlrs= b1.hndlrs + b2.hndlrs;
+ curs= b1.curs + b2.curs;
+ }
+};
+
+
+class Lex_spblock: public Lex_spblock_st
+{
+public:
+ Lex_spblock() { init(); }
+ Lex_spblock(const Lex_spblock_handlers_st &other)
+ {
+ vars= conds= curs= 0;
+ hndlrs= other.hndlrs;
+ }
+};
+
+
+struct Lex_for_loop_bounds_st
+{
+public:
+ class sp_assignment_lex *m_index; // The first iteration value (or cursor)
+ class sp_assignment_lex *m_target_bound; // The last iteration value
+ int8 m_direction;
+ bool m_implicit_cursor;
+ bool is_for_loop_cursor() const { return m_target_bound == NULL; }
+};
+
+
+class Lex_for_loop_bounds_intrange: public Lex_for_loop_bounds_st
+{
+public:
+ Lex_for_loop_bounds_intrange(int8 direction,
+ class sp_assignment_lex *left_expr,
+ class sp_assignment_lex *right_expr)
+ {
+ m_direction= direction;
+ m_index= direction > 0 ? left_expr : right_expr;
+ m_target_bound= direction > 0 ? right_expr : left_expr;
+ m_implicit_cursor= false;
+ }
+};
+
+
+struct Lex_for_loop_st
+{
+public:
+ class sp_variable *m_index; // The first iteration value (or cursor)
+ class sp_variable *m_target_bound; // The last iteration value
+ int m_cursor_offset;
+ int8 m_direction;
+ bool m_implicit_cursor;
+ void init()
+ {
+ m_index= 0;
+ m_target_bound= 0;
+ m_direction= 0;
+ m_implicit_cursor= false;
+ }
+ void init(const Lex_for_loop_st &other)
+ {
+ *this= other;
+ }
+ bool is_for_loop_cursor() const { return m_target_bound == NULL; }
+ bool is_for_loop_explicit_cursor() const
+ {
+ return is_for_loop_cursor() && !m_implicit_cursor;
+ }
+};
+
+
+enum trim_spec { TRIM_LEADING, TRIM_TRAILING, TRIM_BOTH };
+
+struct Lex_trim_st
+{
+ Item *m_remove;
+ Item *m_source;
+ trim_spec m_spec;
+public:
+ void set(trim_spec spec, Item *remove, Item *source)
+ {
+ m_spec= spec;
+ m_remove= remove;
+ m_source= source;
+ }
+ void set(trim_spec spec, Item *source)
+ {
+ set(spec, NULL, source);
+ }
+ Item *make_item_func_trim_std(THD *thd) const;
+ Item *make_item_func_trim_oracle(THD *thd) const;
+ Item *make_item_func_trim(THD *thd) const;
+};
+
+
+class Lex_trim: public Lex_trim_st
+{
+public:
+ Lex_trim(trim_spec spec, Item *source) { set(spec, source); }
+};
+
+
class Load_data_param
{
protected: