From 3e21b667bcf164779674e0c08d8c1b9044acc2b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Nov 2003 02:01:15 +0200 Subject: Fixed UNION fields type/length detecting mysql-test/r/union.result: new results with max union field length detecting type conversion tests mysql-test/t/union.test: type conversion tests sql/field.h: field converion support sql/item.cc: fixed printing field of internal temporary table of SELECT (reference from HAVING clause) layout fix new item for storing field type sql/item.h: new item for storing field type sql/item_subselect.cc: new subquery item length/dec detecting sql/mysql_priv.h: we do not need pre-inited tables and fields sql/sql_base.cc: we do not need double fix_fielding sql/sql_class.h: we do not need double fix_fielding sql/sql_derived.cc: preparing moved before temporary table creation sql/sql_lex.h: we do not need pre-inited tables and fields new lists to store fields types and fields of temporary table sql/sql_parse.cc: we do not need pre-inited tables and fields sql/sql_prepare.cc: we do not need pre-inited tables and fields sql/sql_select.cc: we do not need pre-inited tables and fields support mysql_select call from derived tables after it preparing (in derived table routing) support of crreating temporary table fields from Item_type_holder sql/sql_select.h: we do not need pre-inited tables and fields sql/sql_union.cc: we do not need pre-inited tables and fields check of columns number in union moved to prepare() prepering of SELECTS moved before temporary table creation, fixed union columns type/length detecting sql/sql_update.cc: we do not need pre-inited tables and fields --- sql/sql_derived.cc | 152 +++++++++++++++++++++++------------------------------ 1 file changed, 66 insertions(+), 86 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 719686a56c3..591c6579a46 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -62,16 +62,15 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *org_table_list) { - SELECT_LEX *select_cursor= unit->first_select(); - List item_list; + SELECT_LEX *first_select= unit->first_select(); TABLE *table; int res; select_union *derived_result; - TABLE_LIST *tables= (TABLE_LIST *)select_cursor->table_list.first; + TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; TMP_TABLE_PARAM tmp_table_param; - bool is_union= select_cursor->next_select() && - select_cursor->next_select()->linkage == UNION_TYPE; - bool is_subsel= select_cursor->first_inner_unit() ? 1: 0; + bool is_union= first_select->next_select() && + first_select->next_select()->linkage == UNION_TYPE; + bool is_subsel= first_select->first_inner_unit() ? 1: 0; SELECT_LEX *save_current_select= lex->current_select; DBUG_ENTER("mysql_derived"); @@ -112,16 +111,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - lex->current_select= select_cursor; - TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; - /* Setting up. A must if a join or IGNORE, USE or similar are utilised */ - if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, - select_cursor->with_wild)) - { - res= -1; + if(!(derived_result= new select_union(0))) + DBUG_RETURN(1); // out of memory + + // st_select_lex_unit::prepare coppectly work for single select + if ((res= unit->prepare(thd, derived_result))) goto exit; - } /* This is done in order to redo all field optimisations when any of the @@ -133,30 +128,16 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - item_list= select_cursor->item_list; - select_cursor->with_wild= 0; - if (select_cursor->setup_ref_array(thd, - select_cursor->order_list.elements + - select_cursor->group_list.elements) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, - item_list, 0, 0, 1)) - { - res= -1; - goto exit; - } - // Item list should be fix_fielded yet another time in JOIN::prepare - unfix_item_list(item_list); - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= item_list.elements; + tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, + if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, - (select_cursor->options | thd->options | + (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, org_table_list->alias))) @@ -164,70 +145,69 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, res= -1; goto exit; } - - if ((derived_result=new select_union(table))) + derived_result->set_table(table); + derived_result->tmp_table_param=tmp_table_param; + + unit->offset_limit_cnt= first_select->offset_limit; + unit->select_limit_cnt= first_select->select_limit+ + first_select->offset_limit; + if (unit->select_limit_cnt < first_select->select_limit) + unit->select_limit_cnt= HA_POS_ERROR; + if (unit->select_limit_cnt == HA_POS_ERROR) + first_select->options&= ~OPTION_FOUND_ROWS; + + if (is_union) + res= mysql_union(thd, lex, derived_result, unit); + else + res= mysql_select(thd, &first_select->ref_pointer_array, + (TABLE_LIST*) first_select->table_list.first, + first_select->with_wild, + first_select->item_list, first_select->where, + (first_select->order_list.elements+ + first_select->group_list.elements), + (ORDER *) first_select->order_list.first, + (ORDER *) first_select->group_list.first, + first_select->having, (ORDER*) NULL, + (first_select->options | thd->options | + SELECT_NO_UNLOCK), + derived_result, unit, first_select); + + if (!res) { - derived_result->tmp_table_param=tmp_table_param; - unit->offset_limit_cnt= select_cursor->offset_limit; - unit->select_limit_cnt= select_cursor->select_limit+ - select_cursor->offset_limit; - if (unit->select_limit_cnt < select_cursor->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; - if (unit->select_limit_cnt == HA_POS_ERROR) - select_cursor->options&= ~OPTION_FOUND_ROWS; - - if (is_union) - res= mysql_union(thd, lex, derived_result, unit, 1); + /* + Here we entirely fix both TABLE_LIST and list of SELECT's as + there were no derived tables + */ + if (derived_result->flush()) + res= 1; else - res= mysql_select(thd, &select_cursor->ref_pointer_array, - (TABLE_LIST*) select_cursor->table_list.first, - select_cursor->with_wild, - select_cursor->item_list, select_cursor->where, - (select_cursor->order_list.elements+ - select_cursor->group_list.elements), - (ORDER *) select_cursor->order_list.first, - (ORDER *) select_cursor->group_list.first, - select_cursor->having, (ORDER*) NULL, - (select_cursor->options | thd->options | - SELECT_NO_UNLOCK), - derived_result, unit, select_cursor, 1); - - if (!res) { - /* - Here we entirely fix both TABLE_LIST and list of SELECT's as - there were no derived tables - */ - if (derived_result->flush()) - res= 1; - else - { - org_table_list->real_name=table->real_name; - org_table_list->table=table; - table->derived_select_number= select_cursor->select_number; - table->tmp_table= TMP_TABLE; + org_table_list->real_name=table->real_name; + org_table_list->table=table; + table->derived_select_number= first_select->select_number; + table->tmp_table= TMP_TABLE; #ifndef NO_EMBEDDED_ACCESS_CHECKS - org_table_list->grant.privilege= SELECT_ACL; + org_table_list->grant.privilege= SELECT_ACL; #endif - if (lex->describe) + if (lex->describe) + { + // to fix a problem in EXPLAIN + if (tables) { - // to fix a problem in EXPLAIN - if (tables) - { - for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) - if (cursor->table_list) - cursor->table_list->table=cursor->table; - } + for (TABLE_LIST *cursor= tables; cursor; cursor= cursor->next) + if (cursor->table_list) + cursor->table_list->table=cursor->table; } - else - unit->exclude_tree(); - org_table_list->db= (char *)""; - // Force read of table stats in the optimizer - table->file->info(HA_STATUS_VARIABLE); } + else + unit->exclude_tree(); + org_table_list->db= (char *)""; + // Force read of table stats in the optimizer + table->file->info(HA_STATUS_VARIABLE); } - delete derived_result; } + delete derived_result; + if (res) free_tmp_table(thd, table); else -- cgit v1.2.1 From 381a8db6a63aa70ddb49c3145bcff36d628da176 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Nov 2003 21:26:43 +0200 Subject: after review fixes mysql-test/r/union.result: new tests, more correct results for old one mysql-test/t/union.test: new tests, more correct results for old one sql/field.cc: new way to make field types csting sql/field.h: new way to make field types csting sql/item.cc: new way to make field types csting sql/sql_derived.cc: fixed typo sql/sql_lex.h: comment added --- sql/sql_derived.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 591c6579a46..20a1f7f0124 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -114,7 +114,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, if(!(derived_result= new select_union(0))) DBUG_RETURN(1); // out of memory - // st_select_lex_unit::prepare coppectly work for single select + // st_select_lex_unit::prepare correctly work for single select if ((res= unit->prepare(thd, derived_result))) goto exit; -- cgit v1.2.1 From 358799ecf75912539c498e082b56d3a2a920b392 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Nov 2003 20:12:26 +0200 Subject: avoiding coping tmptable_param sql/sql_union.cc: fixed layout --- sql/sql_derived.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 20a1f7f0124..2de56d715ea 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -128,14 +128,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= unit->types.elements; + bzero((char*) &derived_result->tmp_table_param, sizeof(tmp_table_param)); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, - (ORDER*) 0, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, (first_select->options | thd->options | TMP_TABLE_ALL_COLUMNS), @@ -146,7 +146,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, goto exit; } derived_result->set_table(table); - derived_result->tmp_table_param=tmp_table_param; unit->offset_limit_cnt= first_select->offset_limit; unit->select_limit_cnt= first_select->select_limit+ -- cgit v1.2.1 From 443a157c6aa6bff7ed7b8dedc9c9c83be0eb8b58 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Nov 2003 09:34:41 +0200 Subject: removed unused variable --- sql/sql_derived.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 2de56d715ea..efc15ffcb18 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -67,7 +67,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, int res; select_union *derived_result; TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; - TMP_TABLE_PARAM tmp_table_param; bool is_union= first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE; bool is_subsel= first_select->first_inner_unit() ? 1: 0; @@ -128,7 +127,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &derived_result->tmp_table_param, sizeof(tmp_table_param)); + bzero((char*) &derived_result->tmp_table_param, sizeof(TMP_TABLE_PARAM)); derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be -- cgit v1.2.1 From 76bf7d2224287b40ecfd2bac62b2dd45561affb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 12:18:13 +0200 Subject: Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order --- sql/sql_derived.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 20a1f7f0124..8e6f5b27ab0 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -67,7 +67,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, int res; select_union *derived_result; TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; - TMP_TABLE_PARAM tmp_table_param; bool is_union= first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE; bool is_subsel= first_select->first_inner_unit() ? 1: 0; @@ -111,7 +110,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - if(!(derived_result= new select_union(0))) + if (!(derived_result= new select_union(0))) DBUG_RETURN(1); // out of memory // st_select_lex_unit::prepare correctly work for single select @@ -128,13 +127,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= unit->types.elements; + derived_result->tmp_table_param.init(); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, (first_select->options | thd->options | @@ -146,7 +146,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, goto exit; } derived_result->set_table(table); - derived_result->tmp_table_param=tmp_table_param; unit->offset_limit_cnt= first_select->offset_limit; unit->select_limit_cnt= first_select->select_limit+ @@ -206,7 +205,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, table->file->info(HA_STATUS_VARIABLE); } } - delete derived_result; if (res) free_tmp_table(thd, table); @@ -218,6 +216,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } exit: + delete derived_result; lex->current_select= save_current_select; close_thread_tables(thd, 0, 1); } -- cgit v1.2.1