2000-07-31 21:29:14 +02:00
|
|
|
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
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 for more details.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
|
|
|
|
/* YACC and LEX Definitions */
|
|
|
|
|
|
|
|
/* These may not be declared yet */
|
|
|
|
class Table_ident;
|
|
|
|
class sql_exchange;
|
|
|
|
class LEX_COLUMN;
|
|
|
|
|
2001-09-27 20:45:48 +02:00
|
|
|
// The following hack is needed because mysql_yacc.cc does not define
|
2000-07-31 21:29:14 +02:00
|
|
|
// YYSTYPE before including this file
|
|
|
|
|
|
|
|
#ifdef MYSQL_YACC
|
|
|
|
#define LEX_YYSTYPE void *
|
|
|
|
#else
|
|
|
|
#include "lex_symbol.h"
|
|
|
|
#include "sql_yacc.h"
|
|
|
|
#define LEX_YYSTYPE YYSTYPE *
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum enum_sql_command {
|
2000-11-13 22:55:10 +01:00
|
|
|
SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
|
|
|
|
SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
|
|
|
|
SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
|
|
|
|
|
|
|
|
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
|
2000-12-15 12:18:52 +01:00
|
|
|
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS,
|
2000-11-13 22:55:10 +01:00
|
|
|
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
|
|
|
|
SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE,
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
|
|
|
|
SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB,
|
2000-11-13 22:55:10 +01:00
|
|
|
SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
|
|
|
|
SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
|
|
|
|
SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
|
|
|
|
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
|
2000-07-31 21:29:14 +02:00
|
|
|
SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
|
2000-11-13 22:55:10 +01:00
|
|
|
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
|
2000-10-14 10:16:17 +02:00
|
|
|
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
|
2000-12-18 22:22:20 +01:00
|
|
|
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS,
|
2001-05-29 03:18:23 +02:00
|
|
|
SQLCOM_SHOW_OPEN_TABLES, SQLCOM_LOAD_MASTER_DATA,
|
2001-05-31 02:50:56 +02:00
|
|
|
SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
|
2001-12-26 16:55:24 +01:00
|
|
|
SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_MULTI_UPDATE,
|
2001-12-17 22:24:51 +01:00
|
|
|
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
|
2002-02-14 17:58:24 +01:00
|
|
|
SQLCOM_EMPTY_QUERY,
|
2001-12-13 19:06:44 +01:00
|
|
|
SQLCOM_END
|
2000-07-31 21:29:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum lex_states { STATE_START, STATE_CHAR, STATE_IDENT,
|
|
|
|
STATE_IDENT_SEP,
|
|
|
|
STATE_IDENT_START,
|
|
|
|
STATE_FOUND_IDENT,
|
|
|
|
STATE_SIGNED_NUMBER,
|
|
|
|
STATE_REAL,
|
2001-07-04 08:39:58 +02:00
|
|
|
STATE_HEX_NUMBER,
|
2000-07-31 21:29:14 +02:00
|
|
|
STATE_CMP_OP,
|
|
|
|
STATE_LONG_CMP_OP,
|
|
|
|
STATE_STRING,
|
|
|
|
STATE_COMMENT,
|
|
|
|
STATE_END,
|
|
|
|
STATE_OPERATOR_OR_IDENT,
|
|
|
|
STATE_NUMBER_IDENT,
|
|
|
|
STATE_INT_OR_REAL,
|
|
|
|
STATE_REAL_OR_POINT,
|
|
|
|
STATE_BOOL,
|
|
|
|
STATE_EOL,
|
|
|
|
STATE_ESCAPE,
|
|
|
|
STATE_LONG_COMMENT,
|
|
|
|
STATE_END_LONG_COMMENT,
|
|
|
|
STATE_COLON,
|
|
|
|
STATE_SET_VAR,
|
|
|
|
STATE_USER_END,
|
|
|
|
STATE_HOSTNAME,
|
|
|
|
STATE_SKIP,
|
|
|
|
STATE_USER_VARIABLE_DELIMITER
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef List<Item> List_item;
|
|
|
|
|
|
|
|
typedef struct st_lex_master_info
|
|
|
|
{
|
|
|
|
char* host, *user, *password,*log_file_name;
|
|
|
|
uint port, connect_retry;
|
|
|
|
ulonglong pos;
|
2001-07-05 01:14:31 +02:00
|
|
|
ulong server_id;
|
2002-03-16 02:44:44 +01:00
|
|
|
char* relay_log_name;
|
|
|
|
ulong relay_log_pos;
|
2000-07-31 21:29:14 +02:00
|
|
|
} LEX_MASTER_INFO;
|
|
|
|
|
2001-06-03 16:07:26 +02:00
|
|
|
|
2002-03-26 14:06:05 +01:00
|
|
|
enum sub_select_type {UNSPECIFIED_TYPE,UNION_TYPE, INTERSECT_TYPE, EXCEPT_TYPE, NOT_A_SELECT, DERIVED_TABLE_TYPE};
|
2001-06-03 16:07:26 +02:00
|
|
|
|
|
|
|
/* The state of the lex parsing for selects */
|
|
|
|
|
|
|
|
typedef struct st_select_lex {
|
|
|
|
enum sub_select_type linkage;
|
|
|
|
char *db,*db1,*table1,*db2,*table2; /* For outer join using .. */
|
|
|
|
Item *where,*having;
|
|
|
|
ha_rows select_limit,offset_limit;
|
|
|
|
ulong options;
|
|
|
|
List<List_item> expr_list;
|
|
|
|
List<List_item> when_list;
|
|
|
|
SQL_LIST order_list,table_list,group_list;
|
|
|
|
List<Item> item_list;
|
2001-08-02 05:29:50 +02:00
|
|
|
List<String> interval_list,use_index, *use_index_ptr,
|
|
|
|
ignore_index, *ignore_index_ptr;
|
2001-06-03 16:07:26 +02:00
|
|
|
List<Item_func_match> ftfunc_list;
|
|
|
|
uint in_sum_expr, sort_default;
|
2001-10-19 16:43:30 +02:00
|
|
|
bool create_refs, braces;
|
2002-03-26 14:06:05 +01:00
|
|
|
st_select_lex *next, *prev;
|
2001-06-03 16:07:26 +02:00
|
|
|
} SELECT_LEX;
|
|
|
|
|
|
|
|
|
2001-06-28 09:49:16 +02:00
|
|
|
class Set_option :public Sql_alloc {
|
|
|
|
public:
|
|
|
|
const char *name;
|
|
|
|
Item *item;
|
|
|
|
uint name_length;
|
|
|
|
bool type; /* 1 if global */
|
|
|
|
Set_option(bool par_type, const char *par_name, uint length,
|
|
|
|
Item *par_item)
|
|
|
|
:name(par_name), item(par_item), name_length(length), type(par_type) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
/* The state of the lex parsing. This is saved in the THD struct */
|
|
|
|
|
|
|
|
typedef struct st_lex {
|
|
|
|
uint yylineno,yytoklen; /* Simulate lex */
|
|
|
|
LEX_YYSTYPE yylval;
|
2002-03-26 14:06:05 +01:00
|
|
|
SELECT_LEX select_lex, *select, *last_select;
|
2000-07-31 21:29:14 +02:00
|
|
|
uchar *ptr,*tok_start,*tok_end,*end_of_query;
|
|
|
|
char *length,*dec,*change,*name;
|
2000-09-16 18:06:21 +02:00
|
|
|
char *backup_dir; /* For RESTORE/BACKUP */
|
2000-10-27 06:11:55 +02:00
|
|
|
char* to_log; /* For PURGE MASTER LOGS TO */
|
2001-09-30 04:46:20 +02:00
|
|
|
char* x509_subject,*x509_issuer,*ssl_cipher;
|
|
|
|
enum SSL_type ssl_type; /* defined in violite.h */
|
2000-07-31 21:29:14 +02:00
|
|
|
String *wild;
|
|
|
|
sql_exchange *exchange;
|
|
|
|
|
|
|
|
List<key_part_spec> col_list;
|
|
|
|
List<Alter_drop> drop_list;
|
|
|
|
List<Alter_column> alter_list;
|
2001-06-03 16:07:26 +02:00
|
|
|
List<String> interval_list;
|
2000-07-31 21:29:14 +02:00
|
|
|
List<st_lex_user> users_list;
|
|
|
|
List<LEX_COLUMN> columns;
|
|
|
|
List<Key> key_list;
|
|
|
|
List<create_field> create_list;
|
2001-06-03 16:07:26 +02:00
|
|
|
List<Item> *insert_list,field_list,value_list;
|
|
|
|
List<List_item> many_values;
|
2001-06-28 09:49:16 +02:00
|
|
|
List<Set_option> option_list;
|
2001-06-03 16:07:26 +02:00
|
|
|
SQL_LIST proc_list, auxilliary_table_list;
|
2000-07-31 21:29:14 +02:00
|
|
|
TYPELIB *interval;
|
|
|
|
create_field *last_field;
|
2001-06-03 16:07:26 +02:00
|
|
|
Item *default_value;
|
2000-07-31 21:29:14 +02:00
|
|
|
CONVERT *convert_set;
|
2000-09-14 01:39:07 +02:00
|
|
|
LEX_USER *grant_user;
|
2000-07-31 21:29:14 +02:00
|
|
|
gptr yacc_yyss,yacc_yyvs;
|
2001-10-08 06:24:04 +02:00
|
|
|
THD *thd;
|
2000-07-31 21:29:14 +02:00
|
|
|
udf_func udf;
|
2000-09-14 01:39:07 +02:00
|
|
|
HA_CHECK_OPT check_opt; // check/repair options
|
|
|
|
HA_CREATE_INFO create_info;
|
2000-09-17 02:23:30 +02:00
|
|
|
LEX_MASTER_INFO mi; // used by CHANGE MASTER
|
2000-09-14 01:39:07 +02:00
|
|
|
ulong thread_id,type;
|
|
|
|
enum_sql_command sql_command;
|
|
|
|
enum lex_states next_state;
|
|
|
|
enum enum_duplicates duplicates;
|
2001-03-21 00:02:22 +01:00
|
|
|
enum enum_tx_isolation tx_isolation;
|
2001-04-07 00:18:33 +02:00
|
|
|
enum enum_ha_read_modes ha_read_mode;
|
|
|
|
enum ha_rkey_function ha_rkey_mode;
|
2001-05-11 22:26:12 +02:00
|
|
|
enum enum_enable_or_disable alter_keys_onoff;
|
2001-12-26 15:49:10 +01:00
|
|
|
uint grant,grant_tot_col,which_columns, union_option, mqh;
|
2000-09-14 01:39:07 +02:00
|
|
|
thr_lock_type lock_option;
|
2001-06-03 16:07:26 +02:00
|
|
|
bool drop_primary,drop_if_exists,local_file;
|
2002-03-26 14:06:05 +01:00
|
|
|
bool in_comment,ignore_space,verbose,simple_alter, option_type, derived_tables;
|
2002-03-10 05:48:06 +01:00
|
|
|
uint slave_thd_opt;
|
2000-07-31 21:29:14 +02:00
|
|
|
} LEX;
|
|
|
|
|
|
|
|
|
|
|
|
void lex_init(void);
|
|
|
|
void lex_free(void);
|
|
|
|
LEX *lex_start(THD *thd, uchar *buf,uint length);
|
|
|
|
void lex_end(LEX *lex);
|
|
|
|
|
|
|
|
extern pthread_key(LEX*,THR_LEX);
|
|
|
|
|
|
|
|
extern LEX_STRING tmp_table_alias;
|
|
|
|
|
|
|
|
#define current_lex (¤t_thd->lex)
|