From 651ead1a9fdb81aca96233a83636170ff24b853d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 16:35:17 +0300 Subject: [PATCH 1/2] A fix for a bug with long definition of SET or ENUM. Barkov approved it already --- mysql-test/r/type_set.result | 2 ++ mysql-test/t/type_set.test | 2 ++ sql/sql_parse.cc | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result index b0ea1b69e59..086f55a47a5 100644 --- a/mysql-test/r/type_set.result +++ b/mysql-test/r/type_set.result @@ -13,3 +13,5 @@ t1 CREATE TABLE `t1` ( `a` set('','a','b') NOT NULL default 'b' ) TYPE=MyISAM CHARSET=latin1 drop table t1; +CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8; +DROP TABLE t1; diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test index 4505e3f747b..6c0f162dc86 100644 --- a/mysql-test/t/type_set.test +++ b/mysql-test/t/type_set.test @@ -12,3 +12,5 @@ drop table t1; create table t1 (a set (' ','a','b ') not null default 'b '); show create table t1; drop table t1; +CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8; +DROP TABLE t1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ed68f487924..2ebe7479173 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3967,9 +3967,10 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, } } - if (new_field->length > MAX_FIELD_CHARLENGTH || + if ((new_field->length > MAX_FIELD_CHARLENGTH && type != FIELD_TYPE_SET && + type != FIELD_TYPE_ENUM) || (!new_field->length && !(new_field->flags & BLOB_FLAG) && - type != FIELD_TYPE_STRING && + type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING && type != FIELD_TYPE_GEOMETRY)) { net_printf(thd,ER_TOO_BIG_FIELDLENGTH,field_name, From a215238536848c1512ec0dd4c98739c090c473c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 13:56:32 +0300 Subject: [PATCH 2/2] fixing limit and SQL_CALC_FOUND_ROWS issues --- sql/sql_union.cc | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 6c3c5350966..cfed5083b71 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -123,7 +123,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, DBUG_RETURN(0); prepared= 1; res= 0; - found_rows_for_union= 0; + found_rows_for_union= first_select_in_union()->options & OPTION_FOUND_ROWS; TMP_TABLE_PARAM tmp_table_param; result= sel_result; t_and_f= tables_and_fields_initied; @@ -131,13 +131,6 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); thd->lex.current_select= select_cursor= first_select_in_union(); /* Global option */ - if (((void*)(global_parameters)) == ((void*)this)) - { - found_rows_for_union= first_select()->options & OPTION_FOUND_ROWS && - global_parameters->select_limit; - if (found_rows_for_union) - first_select()->options&= ~OPTION_FOUND_ROWS; - } if (t_and_f) { // Item list and tables will be initialized by mysql_derived @@ -256,6 +249,7 @@ int st_select_lex_unit::exec() { SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor=first_select_in_union(); + unsigned int add_rows=0; DBUG_ENTER("st_select_lex_unit::exec"); if (executed && !(dependent || uncacheable)) @@ -272,6 +266,7 @@ int st_select_lex_unit::exec() } for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) { + unsigned int rows; if (optimized) res= sl->join->reinit(); else @@ -286,6 +281,11 @@ int st_select_lex_unit::exec() select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) sl->options&= ~OPTION_FOUND_ROWS; + else if (found_rows_for_union) + { + rows= thd->select_limit; + sl->options|= OPTION_FOUND_ROWS; + } res= join->prepare(&sl->ref_pointer_array, (TABLE_LIST*) sl->table_list.first, sl->with_wild, @@ -321,6 +321,8 @@ int st_select_lex_unit::exec() thd->lex.current_select= lex_select_save; DBUG_RETURN(res); } + if (found_rows_for_union && !sl->braces && sl->options & OPTION_FOUND_ROWS) + add_rows+= (thd->limit_found_rows > rows) ? thd->limit_found_rows - rows : 0; } } optimized= 1; @@ -337,15 +339,17 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { SELECT_LEX *fake_select = new SELECT_LEX(&thd->lex); - offset_limit_cnt= (select_cursor->braces ? - global_parameters->offset_limit : 0); - select_limit_cnt= (select_cursor->braces ? - global_parameters->select_limit+ - global_parameters->offset_limit : HA_POS_ERROR); - if (select_limit_cnt < global_parameters->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit + if (select_cursor->braces) + { + offset_limit_cnt= global_parameters->offset_limit; + select_limit_cnt= global_parameters->select_limit + global_parameters->offset_limit; + if (select_limit_cnt < global_parameters->select_limit) + select_limit_cnt= HA_POS_ERROR; // no limit + } if (select_limit_cnt == HA_POS_ERROR) thd->options&= ~OPTION_FOUND_ROWS; + else if (found_rows_for_union && !describe) + thd->options|= OPTION_FOUND_ROWS; fake_select->ftfunc_list= &empty_list; fake_select->table_list.link_in_list((byte *)&result_table_list, (byte **)&result_table_list.next); @@ -357,7 +361,11 @@ int st_select_lex_unit::exec() thd->options | SELECT_NO_UNLOCK, result, this, fake_select, 0); if (found_rows_for_union && !res) - thd->limit_found_rows = (ulonglong)table->file->records; + { + thd->limit_found_rows= table->file->records; + if (!select_cursor->braces) + thd->limit_found_rows+= add_rows; + } fake_select->exclude(); delete fake_select; /*