summaryrefslogtreecommitdiff
path: root/sql/sql_lex.h
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2002-08-30 12:40:40 +0300
committerunknown <monty@narttu.mysql.fi>2002-08-30 12:40:40 +0300
commit9421f1dae99e0f2d6100b31a3641b2cd0ad68e58 (patch)
tree1bb81fd601075133af9ee99bd7ac94baf5ffc46c /sql/sql_lex.h
parentcfc861537da2f256f11823b3a4997a033eec73dc (diff)
parent1895448e66b39542d58a77e705449b92414ff3f7 (diff)
downloadmariadb-git-9421f1dae99e0f2d6100b31a3641b2cd0ad68e58.tar.gz
Merge with 4.0.3
Some simple optimzations, more comments and indentation changes. Add ` around database in 'use database' in binary log. Moved max_error_count and max_warning_count to variables struct. Removed SHOW_WARNS_COUNT and SHOW_ERRORS_COUNT calls. Changed string functions to use character set of first string argument as default return characterset (Each string function can change the above assumption if needed) BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BUILD/SETUP.sh: Auto merged BitKeeper/deleted/.del-getopt.h~a9ae679fa84f395: Auto merged BitKeeper/deleted/.del-getvar.c~2a29ff383970fd31: Auto merged Docs/manual.texi: Auto merged SSL/cacert.pem: Auto merged SSL/client-cert.pem: Auto merged SSL/client-key.pem: Auto merged SSL/server-cert.pem: Auto merged SSL/server-key.pem: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged isam/isamlog.c: Auto merged isam/pack_isam.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/ft_dump.c: Auto merged myisam/ft_parser.c: Auto merged myisam/ft_static.c: Auto merged myisam/ft_test1.c: Auto merged myisam/ft_update.c: Auto merged myisam/mi_create.c: Auto merged myisam/mi_key.c: Auto merged myisam/mi_open.c: Auto merged myisam/mi_static.c: Auto merged myisam/mi_test1.c: Auto merged myisam/mi_test2.c: Auto merged myisam/mi_test3.c: Auto merged myisam/mi_update.c: Auto merged myisam/mi_write.c: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamdef.h: Auto merged myisam/myisamlog.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/create.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_math.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/merge.result: Auto merged mysql-test/r/myisam.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/r/select_found.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/t/create.test: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/select_found.test: Auto merged mysql-test/t/union.test: Auto merged mysys/default.c: Auto merged mysys/mf_iocache2.c: Auto merged mysys/my_error.c: Auto merged mysys/my_init.c: Auto merged scripts/mysql_config.sh: Auto merged sql/convert.cc: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/hostname.cc: Auto merged sql/item.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/key.cc: Auto merged sql/log.cc: Auto merged sql/net_pkg.cc: Auto merged sql/opt_range.cc: Auto merged sql/opt_range.h: Auto merged sql/opt_sum.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_db.cc: Auto merged sql/sql_handler.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_string.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_test.cc: Auto merged sql/time.cc: Auto merged sql/unireg.cc: Auto merged strings/Makefile.am: Auto merged strings/ctype-latin1_de.c: Auto merged strings/ctype-tis620.c: Auto merged tools/mysqlmanager.c: Auto merged BitKeeper/deleted/.del-sslopt-case.h~224c80e75dad4997: merge with 4.0.3 BitKeeper/triggers/post-commit: merge with 4.0.3 client/mysql.cc: merge with 4.0.3 + simple optimsation client/mysqltest.c: merge with 4.0.3 (Indentation change) configure.in: merge with 4.0.3 extra/resolve_stack_dump.c: merge with 4.0.3 (Indentation change) include/Makefile.am: merge with 4.0.3 include/myisam.h: merge with 4.0.3 (Indentation change) include/mysql.h: merge with 4.0.3 (removed not used structure) include/mysqld_error.h: merge with 4.0.3 libmysql/Makefile.shared: merge with 4.0.3 libmysql/libmysql.c: merge with 4.0.3 (Indentation change) libmysqld/Makefile.am: merge with 4.0.3 myisam/ft_boolean_search.c: merge with 4.0.3 (Indentation change) myisam/ft_nlq_search.c: merge with 4.0.3 (Indentation change) myisam/mi_check.c: merge with 4.0.3 myisam/mi_search.c: merge with 4.0.3 myisam/mi_unique.c: merge with 4.0.3 mysys/Makefile.am: merge with 4.0.3 mysys/mf_casecnv.c: merge with 4.0.3 sql-bench/server-cfg.sh: Removed 8000 max row limit for Innodb sql/Makefile.am: merge with 4.0.3 sql/field.cc: Indentation cleanup Changed sprintf -> my_sprintf sql/field.h: merge with 4.0.3 sql/ha_heap.cc: merge with 4.0.3 (Indentation change) sql/item.h: merge with 4.0.3 (Indentation change) sql/item_cmpfunc.cc: merge with 4.0.3 sql/item_cmpfunc.h: Removed size_of() from items Indentation cleanup sql/item_create.cc: merge sql/item_create.h: merge sql/item_func.cc: Added comments Changed string functions to use character set of first string argument as default return characterset Simple optimizations. Removed return of uninitalized variable. sql/item_func.h: merge sql/item_strfunc.cc: merge with 4.0.3 (Indentation change) sql/item_strfunc.h: removed size_of() sql/item_uniq.h: removed size_of() sql/lex.h: merge with 4.0.3 (Indentation change) sql/log_event.cc: Add ` around database in 'use database' in binary log. sql/mysql_priv.h: merge with 4.0.3 sql/mysqld.cc: merge with 4.0.3 (Indentation change) sql/share/czech/errmsg.txt: merge sql/share/danish/errmsg.txt: merge sql/share/dutch/errmsg.txt: merge sql/share/english/errmsg.txt: merge sql/share/estonian/errmsg.txt: merge sql/share/french/errmsg.txt: merge sql/share/german/errmsg.txt: merge sql/share/greek/errmsg.txt: merge sql/share/hungarian/errmsg.txt: merge sql/share/italian/errmsg.txt: merge sql/share/japanese/errmsg.txt: merge sql/share/korean/errmsg.txt: merge sql/share/norwegian-ny/errmsg.txt: merge sql/share/norwegian/errmsg.txt: merge sql/share/polish/errmsg.txt: merge sql/share/portuguese/errmsg.txt: merge sql/share/romanian/errmsg.txt: merge sql/share/russian/errmsg.txt: merge sql/share/slovak/errmsg.txt: merge sql/share/spanish/errmsg.txt: merge sql/share/swedish/errmsg.txt: merge sql/share/ukrainian/errmsg.txt: merge sql/sql_acl.cc: merge with 4.0.3 sql/sql_base.cc: More comments Fixed bug in send_fields() when using convert sql/sql_class.cc: merge sql/sql_class.h: Merge with 4.0.3 Moved max_error_count and max_warning_count to variables struct. sql/sql_delete.cc: merge with 4.0.3 (Indentation change) sql/sql_lex.h: merge with 4.0.3 sql/sql_parse.cc: Removed SHOW_WARNS_COUNT and SHOW_ERRORS_COUNT. (Should be retrived from variables) sql/sql_select.cc: merge with 4.0.3 sql/sql_show.cc: merge with 4.0.3 sql/sql_union.cc: merge with 4.0.3 sql/sql_update.cc: merge with 4.0.3 sql/sql_yacc.yy: merge with 4.0.3 Indentation cleanup sql/structs.h: merge with 4.0.3 sql/table.cc: merge with 4.0.3 sql/table.h: merge with 4.0.3
Diffstat (limited to 'sql/sql_lex.h')
-rw-r--r--sql/sql_lex.h218
1 files changed, 193 insertions, 25 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 9be8703b6c5..6aef99886e9 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -46,10 +46,12 @@ enum enum_sql_command {
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS,
SQLCOM_SHOW_INNODB_STATUS,
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
- SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE,
+ SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
+ SQLCOM_SHOW_CREATE_DB,
SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
- SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB,
+ SQLCOM_GRANT,
+ SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
@@ -62,7 +64,8 @@ enum enum_sql_command {
SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_MULTI_UPDATE,
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
- SQLCOM_EMPTY_QUERY,
+ SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
+ SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES,
SQLCOM_END
};
@@ -78,6 +81,7 @@ enum lex_states
STATE_IDENT_OR_KEYWORD
};
+
typedef List<Item> List_item;
typedef struct st_lex_master_info
@@ -93,7 +97,8 @@ typedef struct st_lex_master_info
enum sub_select_type
{
- UNSPECIFIED_TYPE, UNION_TYPE, INTERSECT_TYPE, EXCEPT_TYPE, OLAP_TYPE, NOT_A_SELECT
+ UNSPECIFIED_TYPE,UNION_TYPE, INTERSECT_TYPE,
+ EXCEPT_TYPE, GLOBAL_OPTIONS_TYPE, DERIVED_TABLE_TYPE, OLAP_TYPE
};
enum olap_type
@@ -101,27 +106,182 @@ enum olap_type
UNSPECIFIED_OLAP_TYPE, CUBE_TYPE, ROLLUP_TYPE
};
-/* The state of the lex parsing for selects */
+/*
+ The state of the lex parsing for selects
+
+ All select describing structures linked with following pointers:
+ - list of neighbors (next/prev) (prev of first element point to slave
+ pointer of upper structure)
+ - one level units for unit (union) structure
+ - member of one union(unit) for ordinary select_lex
+ - pointer to master
+ - outer select_lex for unit (union)
+ - unit structure for ordinary select_lex
+ - pointer to slave
+ - first list element of select_lex belonged to this unit for unit
+ - first unit in list of units that belong to this select_lex (as
+ subselects or derived tables) for ordinary select_lex
+ - list of all select_lex (for group operation like correcting list of opened
+ tables)
+ for example for following query:
-typedef struct st_select_lex
-{
+ select *
+ from table1
+ where table1.field IN (select * from table1_1_1 union
+ select * from table1_1_2)
+ union
+ select *
+ from table2
+ where table2.field=(select (select f1 from table2_1_1_1_1
+ where table2_1_1_1_1.f2=table2_1_1.f3)
+ from table2_1_1
+ where table2_1_1.f1=table2.f2)
+ union
+ select * from table3;
+
+ we will have following structure:
+
+
+ main unit
+ select1 select2 select3
+ |^^ |^
+ s||| ||master
+ l||| |+---------------------------------+
+ a||| +---------------------------------+|
+ v|||master slave ||
+ e||+-------------------------+ ||
+ V| neighbor | V|
+ unit 1.1<==================>unit1.2 unit2.1
+ select1.1.1 select 1.1.2 select1.2.1 select2.1.1 select2.1.2
+ |^
+ ||
+ V|
+ unit2.1.1.1
+ select2.1.1.1.1
+
+
+ relation in main unit will be following:
+
+ main unit
+ |^^^
+ ||||
+ |||+------------------------------+
+ ||+--------------+ |
+ slave||master | |
+ V| neighbor | neighbor |
+ select1<========>select2<========>select3
+
+ list of all select_lex will be following (as it will be constructed by
+ parser):
+
+ select1->select2->select3->select2.1.1->select 2.1.2->select2.1.1.1.1-+
+ |
+ +---------------------------------------------------------------------+
+ |
+ +->select1.1.1->select1.1.2
+
+*/
+
+/*
+ Base class for st_select_lex (SELECT_LEX) &
+ st_select_lex_unit (SELECT_LEX_UNIT)
+*/
+class st_select_lex_node {
+protected:
+ st_select_lex_node *next, **prev, /* neighbor list */
+ *master, *slave, /* vertical links */
+ *link_next, **link_prev; /* list of whole SELECT_LEX */
+public:
+ ulong options;
enum sub_select_type linkage;
+ SQL_LIST order_list; /* ORDER clause */
+ ha_rows select_limit, offset_limit; /* LIMIT clause parameters */
+ void init_query();
+ void init_select();
+ void include_down(st_select_lex_node *upper);
+ void include_neighbour(st_select_lex_node *before);
+ void include_global(st_select_lex_node **plink);
+ void exclude();
+private:
+ void fast_exclude();
+};
+
+/*
+ SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
+ SELECT_LEXs
+*/
+class st_lex;
+class st_select_lex;
+class st_select_lex_unit: public st_select_lex_node {
+public:
+ /*
+ Pointer to 'last' select or pointer to unit where stored
+ global parameters for union
+ */
+ st_select_lex_node *global_parameters;
+ /* LIMIT clause runtime counters */
+ ha_rows select_limit_cnt, offset_limit_cnt;
+ void init_query();
+ bool create_total_list(THD *thd, st_lex *lex, TABLE_LIST **result);
+ st_select_lex* outer_select() { return (st_select_lex*) master; }
+ st_select_lex* first_select() { return (st_select_lex*) slave; }
+ st_select_lex_unit* next_unit() { return (st_select_lex_unit*) next; }
+
+ friend void mysql_init_query(THD *thd);
+private:
+ bool create_total_list_n_last_return(THD *thd, st_lex *lex,
+ TABLE_LIST ***result);
+};
+typedef class st_select_lex_unit SELECT_LEX_UNIT;
+
+/*
+ SELECT_LEX - store information of parsed SELECT_LEX statment
+*/
+class JOIN;
+class st_select_lex: public st_select_lex_node {
+public:
+ char *db, *db1, *table1, *db2, *table2; /* For outer join using .. */
+ Item *where, *having; /* WHERE & HAVING clauses */
enum olap_type olap;
- 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;
- List<String> interval_list,use_index, *use_index_ptr,
+ List<List_item> when_list; /* WHEN clause */
+ SQL_LIST table_list, group_list; /* FROM & GROUP BY clauses */
+ List<Item> item_list; /* list of fields & expressions */
+ List<String> interval_list, use_index, *use_index_ptr,
ignore_index, *ignore_index_ptr;
List<Item_func_match> ftfunc_list;
- uint in_sum_expr, sort_default;
- bool create_refs, braces;
- st_select_lex *next;
-} SELECT_LEX;
+ JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
+ uint in_sum_expr;
+ bool create_refs;
+ bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */
+ bool depended; /* depended from outer select subselect */
+ /* TRUE when having fix field called in processing of this SELECT */
+ bool having_fix_field;
+
+ void init_query();
+ void init_select();
+ st_select_lex_unit* master_unit() { return (st_select_lex_unit*) master; }
+ st_select_lex_unit* first_inner_unit()
+ {
+ return (st_select_lex_unit*) slave;
+ }
+ st_select_lex* outer_select()
+ {
+ return (st_select_lex*) master_unit()->outer_select();
+ }
+ st_select_lex* next_select() { return (st_select_lex*) next; }
+ st_select_lex* next_select_in_list()
+ {
+ return (st_select_lex*) link_next;
+ }
+ st_select_lex_node** next_select_in_list_addr()
+ {
+ return &link_next;
+ }
+
+ friend void mysql_init_query(THD *thd);
+};
+typedef class st_select_lex SELECT_LEX;
/* The state of the lex parsing. This is saved in the THD struct */
@@ -130,7 +290,10 @@ typedef struct st_lex
{
uint yylineno,yytoklen; /* Simulate lex */
LEX_YYSTYPE yylval;
- SELECT_LEX select_lex, *select, *last_selects;
+ SELECT_LEX_UNIT unit; /* most upper unit */
+ SELECT_LEX select_lex, /* first SELECT_LEX */
+ /* current SELECT_LEX in parsing */
+ *select;
uchar *ptr,*tok_start,*tok_end,*end_of_query;
char *length,*dec,*change,*name;
char *backup_dir; /* For RESTORE/BACKUP */
@@ -141,6 +304,7 @@ typedef struct st_lex
sql_exchange *exchange;
List<key_part_spec> col_list;
+ List<key_part_spec> ref_list;
List<Alter_drop> drop_list;
List<Alter_column> alter_list;
List<String> interval_list;
@@ -151,10 +315,11 @@ typedef struct st_lex
List<Item> *insert_list,field_list,value_list;
List<List_item> many_values;
List<set_var_base> var_list;
+ List<Item> param_list;
SQL_LIST proc_list, auxilliary_table_list;
TYPELIB *interval;
create_field *last_field;
- Item *default_value;
+ Item *default_value, *comment;
CONVERT *convert_set;
CONVERT *thd_convert_set; // Set with SET CHAR SET
LEX_USER *grant_user;
@@ -167,6 +332,7 @@ typedef struct st_lex
USER_RESOURCES mqh;
ulong thread_id,type;
enum_sql_command sql_command;
+ thr_lock_type lock_option;
enum lex_states next_state;
enum enum_duplicates duplicates;
enum enum_tx_isolation tx_isolation;
@@ -174,11 +340,13 @@ typedef struct st_lex
enum ha_rkey_function ha_rkey_mode;
enum enum_enable_or_disable alter_keys_onoff;
enum enum_var_type option_type;
- uint grant,grant_tot_col,which_columns, union_option;
- thr_lock_type lock_option;
- bool drop_primary,drop_if_exists,local_file, olap;
- bool in_comment,ignore_space,verbose,simple_alter;
+ uint grant, grant_tot_col, which_columns, union_option;
+ uint fk_delete_opt, fk_update_opt, fk_match_option;
+ bool drop_primary, drop_if_exists, local_file, olap;
+ bool in_comment, ignore_space, verbose, simple_alter;
+ bool derived_tables;
uint slave_thd_opt;
+ CHARSET_INFO *charset;
} LEX;