~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/sql_parse.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-11-08 11:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20111108113113-3ulw01fvi4vn8m25
Tags: upstream-5.5.17
ImportĀ upstreamĀ versionĀ 5.5.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
#ifndef SQL_PARSE_INCLUDED
 
17
#define SQL_PARSE_INCLUDED
 
18
 
 
19
#include "my_global.h"                          /* NO_EMBEDDED_ACCESS_CHECKS */
 
20
#include "sql_acl.h"                            /* GLOBAL_ACLS */
 
21
 
 
22
class Comp_creator;
 
23
class Item;
 
24
class Object_creation_ctx;
 
25
class Parser_state;
 
26
struct TABLE_LIST;
 
27
class THD;
 
28
class Table_ident;
 
29
struct LEX;
 
30
 
 
31
enum enum_mysql_completiontype {
 
32
  ROLLBACK_RELEASE=-2, ROLLBACK=1,  ROLLBACK_AND_CHAIN=7,
 
33
  COMMIT_RELEASE=-1,   COMMIT=0,    COMMIT_AND_CHAIN=6
 
34
};
 
35
 
 
36
extern "C" int test_if_data_home_dir(const char *dir);
 
37
 
 
38
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
 
39
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
 
40
int mysql_multi_update_prepare(THD *thd);
 
41
int mysql_multi_delete_prepare(THD *thd);
 
42
bool mysql_insert_select_prepare(THD *thd);
 
43
bool update_precheck(THD *thd, TABLE_LIST *tables);
 
44
bool delete_precheck(THD *thd, TABLE_LIST *tables);
 
45
bool insert_precheck(THD *thd, TABLE_LIST *tables);
 
46
bool create_table_precheck(THD *thd, TABLE_LIST *tables,
 
47
                           TABLE_LIST *create_table);
 
48
 
 
49
bool parse_sql(THD *thd,
 
50
               Parser_state *parser_state,
 
51
               Object_creation_ctx *creation_ctx);
 
52
 
 
53
uint kill_one_thread(THD *thd, ulong id, bool only_kill_query);
 
54
 
 
55
void free_items(Item *item);
 
56
void cleanup_items(Item *item);
 
57
 
 
58
Comp_creator *comp_eq_creator(bool invert);
 
59
Comp_creator *comp_ge_creator(bool invert);
 
60
Comp_creator *comp_gt_creator(bool invert);
 
61
Comp_creator *comp_le_creator(bool invert);
 
62
Comp_creator *comp_lt_creator(bool invert);
 
63
Comp_creator *comp_ne_creator(bool invert);
 
64
 
 
65
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
 
66
                         enum enum_schema_tables schema_table_idx);
 
67
void get_default_definer(THD *thd, LEX_USER *definer);
 
68
LEX_USER *create_default_definer(THD *thd);
 
69
LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
 
70
LEX_USER *get_current_user(THD *thd, LEX_USER *user);
 
71
bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
 
72
                              uint max_byte_length);
 
73
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
 
74
                              uint max_char_length, CHARSET_INFO *cs,
 
75
                              bool no_error);
 
76
CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
 
77
bool check_host_name(LEX_STRING *str);
 
78
bool check_identifier_name(LEX_STRING *str, uint max_char_length,
 
79
                           uint err_code, const char *param_for_err_msg);
 
80
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
 
81
bool sqlcom_can_generate_row_events(const THD *thd);
 
82
bool is_update_query(enum enum_sql_command command);
 
83
bool is_log_table_write_query(enum enum_sql_command command);
 
84
bool alloc_query(THD *thd, const char *packet, uint packet_length);
 
85
void mysql_init_select(LEX *lex);
 
86
void mysql_parse(THD *thd, char *rawbuf, uint length,
 
87
                 Parser_state *parser_state);
 
88
void mysql_reset_thd_for_next_command(THD *thd);
 
89
bool mysql_new_select(LEX *lex, bool move_down);
 
90
void create_select_for_variable(const char *var_name);
 
91
void create_table_set_open_action_and_adjust_tables(LEX *lex);
 
92
void mysql_init_multi_delete(LEX *lex);
 
93
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
 
94
void create_table_set_open_action_and_adjust_tables(LEX *lex);
 
95
pthread_handler_t handle_bootstrap(void *arg);
 
96
int mysql_execute_command(THD *thd);
 
97
bool do_command(THD *thd);
 
98
void do_handle_bootstrap(THD *thd);
 
99
bool dispatch_command(enum enum_server_command command, THD *thd,
 
100
                      char* packet, uint packet_length);
 
101
void log_slow_statement(THD *thd);
 
102
bool append_file_to_dir(THD *thd, const char **filename_ptr,
 
103
                        const char *table_name);
 
104
bool append_file_to_dir(THD *thd, const char **filename_ptr,
 
105
                        const char *table_name);
 
106
void execute_init_command(THD *thd, LEX_STRING *init_command,
 
107
                          mysql_rwlock_t *var_lock);
 
108
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
 
109
                       char *length, char *decimal,
 
110
                       uint type_modifier,
 
111
                       Item *default_value, Item *on_update_value,
 
112
                       LEX_STRING *comment,
 
113
                       char *change, List<String> *interval_list,
 
114
                       CHARSET_INFO *cs,
 
115
                       uint uint_geom_type);
 
116
bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group, bool asc);
 
117
void add_join_on(TABLE_LIST *b,Item *expr);
 
118
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields,
 
119
                      SELECT_LEX *lex);
 
120
bool add_proc_to_list(THD *thd, Item *item);
 
121
bool push_new_name_resolution_context(THD *thd,
 
122
                                      TABLE_LIST *left_op,
 
123
                                      TABLE_LIST *right_op);
 
124
void store_position_for_column(const char *name);
 
125
void init_update_queries(void);
 
126
bool check_simple_select();
 
127
Item *negate_expression(THD *thd, Item *expr);
 
128
bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
 
129
 
 
130
/* Variables */
 
131
 
 
132
extern const char* any_db;
 
133
extern uint sql_command_flags[];
 
134
extern uint server_command_flags[];
 
135
extern const LEX_STRING command_name[];
 
136
extern uint server_command_flags[];
 
137
 
 
138
/* Inline functions */
 
139
inline bool check_identifier_name(LEX_STRING *str, uint err_code)
 
140
{
 
141
  return check_identifier_name(str, NAME_CHAR_LEN, err_code, "");
 
142
}
 
143
 
 
144
inline bool check_identifier_name(LEX_STRING *str)
 
145
{
 
146
  return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
 
147
}
 
148
 
 
149
#ifndef NO_EMBEDDED_ACCESS_CHECKS
 
150
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
 
151
bool check_single_table_access(THD *thd, ulong privilege,
 
152
                           TABLE_LIST *tables, bool no_errors);
 
153
bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
 
154
                          bool is_proc, bool no_errors);
 
155
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
 
156
bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
 
157
bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
 
158
                  GRANT_INTERNAL_INFO *grant_internal_info,
 
159
                  bool dont_check_global_grants, bool no_errors);
 
160
bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
 
161
                        bool any_combination_of_privileges_will_do,
 
162
                        uint number,
 
163
                        bool no_errors);
 
164
#else
 
165
inline bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables)
 
166
{ return false; }
 
167
inline bool check_single_table_access(THD *thd, ulong privilege,
 
168
                           TABLE_LIST *tables, bool no_errors)
 
169
{ return false; }
 
170
inline bool check_routine_access(THD *thd,ulong want_access,char *db,
 
171
                                 char *name, bool is_proc, bool no_errors)
 
172
{ return false; }
 
173
inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
 
174
{
 
175
  table->grant.privilege= want_access;
 
176
  return false;
 
177
}
 
178
inline bool check_some_routine_access(THD *thd, const char *db,
 
179
                                      const char *name, bool is_proc)
 
180
{ return false; }
 
181
inline bool check_access(THD *, ulong, const char *, ulong *save_priv,
 
182
                         GRANT_INTERNAL_INFO *, bool, bool)
 
183
{
 
184
  if (save_priv)
 
185
    *save_priv= GLOBAL_ACLS;
 
186
  return false;
 
187
}
 
188
inline bool
 
189
check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
 
190
                   bool any_combination_of_privileges_will_do,
 
191
                   uint number,
 
192
                   bool no_errors)
 
193
{ return false; }
 
194
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
 
195
 
 
196
/* These were under the INNODB_COMPATIBILITY_HOOKS */
 
197
 
 
198
bool check_global_access(THD *thd, ulong want_access);
 
199
 
 
200
inline bool is_supported_parser_charset(CHARSET_INFO *cs)
 
201
{
 
202
  return test(cs->mbminlen == 1);
 
203
}
 
204
 
 
205
 
 
206
#endif /* SQL_PARSE_INCLUDED */