diff options
author | Sinisa@sinisa.nasamreza.org <> | 2002-10-16 16:57:42 +0300 |
---|---|---|
committer | Sinisa@sinisa.nasamreza.org <> | 2002-10-16 16:57:42 +0300 |
commit | 0f663d346fdccbe89a79098e846a963cf18d606a (patch) | |
tree | e8005fa25c90ddd09b6592c35b76c89c324ae509 /sql | |
parent | cd5ff6301ed68b253ccffbb10e70ff3b80ded7cf (diff) | |
parent | 8fa2611d87c863cb8bc165847bc212d43414e830 (diff) | |
download | mariadb-git-0f663d346fdccbe89a79098e846a963cf18d606a.tar.gz |
Merge sinisa@work.mysql.com:/home/bk/mysql-4.1
into sinisa.nasamreza.org:/mnt/work/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 4 | ||||
-rw-r--r-- | sql/init.cc | 1 | ||||
-rw-r--r-- | sql/item_subselect.cc | 4 | ||||
-rw-r--r-- | sql/log.cc | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/net_pkg.cc | 4 | ||||
-rw-r--r-- | sql/sql_db.cc | 7 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 24 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 1 | ||||
-rw-r--r-- | sql/sql_select.cc | 102 | ||||
-rw-r--r-- | sql/sql_show.cc | 5 | ||||
-rw-r--r-- | sql/sql_union.cc | 4 |
14 files changed, 99 insertions, 64 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 02f1d33b1dc..f75f431ad52 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3155,8 +3155,8 @@ innobase_drop_database( memcpy(namebuf, ptr, len); namebuf[len] = '/'; namebuf[len + 1] = '\0'; -#ifdef __WIN__ - casedn_str(namebuf); +#ifdef FN_NO_CASE_SENCE + my_casedn_str(system_charset_info, namebuf); #endif trx = trx_allocate_for_mysql(); diff --git a/sql/init.cc b/sql/init.cc index 052ee16925e..8834fd3a89c 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -24,7 +24,6 @@ void unireg_init(ulong options) { uint i; double nr; - CHARSET_INFO *cs; DBUG_ENTER("unireg_init"); MYSYS_PROGRAM_DONT_USE_CURSES(); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index de9c7e11313..456ce5f22ba 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -152,9 +152,7 @@ String *Item_singleval_subselect::val_str (String *str) assign_null(); return 0; } - // Assign temporary buffer with stored value - str_value.set(string_value, 0, string_value.length()); - return &str_value; + return &string_value; } Item_exists_subselect::Item_exists_subselect(THD *thd, diff --git a/sql/log.cc b/sql/log.cc index 59f99e3460e..8cb1577d745 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -973,7 +973,6 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command, last_time=skr; struct tm tm_tmp; struct tm *start; - ulong length; localtime_r(&skr,&tm_tmp); start=&tm_tmp; /* Note that my_b_write() assumes it knows the length for this */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index d8281af6bd1..551466d5192 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -392,6 +392,8 @@ int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex, bool fake_select_lex); void fix_tables_pointers(SELECT_LEX *select_lex); +int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, + select_result *result); int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type, select_result *result); int mysql_union(THD *thd, LEX *lex,select_result *result); diff --git a/sql/net_pkg.cc b/sql/net_pkg.cc index 9f91db95052..1da625e776f 100644 --- a/sql/net_pkg.cc +++ b/sql/net_pkg.cc @@ -273,12 +273,12 @@ send_eof(THD *thd, bool no_flush) { if (!no_flush && (thd->client_capabilities & CLIENT_PROTOCOL_41)) { - char buff[5]; + uchar buff[5]; uint tmp= min(thd->total_warn_count, 65535); buff[0]=254; int2store(buff+1, tmp); int2store(buff+3, 0); // No flags yet - VOID(my_net_write(net,buff,5)); + VOID(my_net_write(net,(char*) buff,5)); VOID(net_flush(net)); } else diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 1d843b78d4e..58b12bca00d 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -69,7 +69,6 @@ static bool write_db_opt(const char *path, HA_CREATE_INFO *create) error=0; my_close(file,MYF(0)); } -exit: return error; } @@ -104,7 +103,7 @@ static bool load_db_opt(const char *path, HA_CREATE_INFO *create) IO_CACHE cache; init_io_cache(&cache, file, IO_SIZE, READ_CACHE, 0, 0, MYF(0)); - while ((int) (nbytes= my_b_gets(&cache, (byte*) buf, sizeof(buf))) > 0) + while ((int) (nbytes= my_b_gets(&cache, (char*) buf, sizeof(buf))) > 0) { char *pos= buf+nbytes-1; /* Remove end space and control characters */ @@ -251,10 +250,8 @@ exit2: int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) { char path[FN_REFLEN+16]; - MY_DIR *dirp; long result=1; int error = 0; - register File file; uint create_options = create_info ? create_info->options : 0; DBUG_ENTER("mysql_alter_db"); @@ -602,7 +599,7 @@ bool mysql_change_db(THD *thd, const char *name) int mysqld_show_create_db(THD *thd, const char *dbname) { - int length, db_length; + int length; char path[FN_REFLEN], *to; uint db_access; bool found_libchar; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 46206079084..9f09afc78a6 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -955,6 +955,7 @@ void st_select_lex::init_query() table_list.first= 0; table_list.next= (byte**) &table_list.first; item_list.empty(); + join= 0; } void st_select_lex::init_select() @@ -973,7 +974,6 @@ void st_select_lex::init_select() ftfunc_list= &ftfunc_list_alloc; linkage= UNSPECIFIED_TYPE; depended= having_fix_field= 0; - } /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 51b1b88f24a..28d6d93e194 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -210,7 +210,7 @@ private: SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group SELECT_LEXs */ -class st_lex; +struct st_lex; class st_select_lex; class THD; class select_result; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 135fb14043b..ed8d4112410 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1287,6 +1287,7 @@ mysql_execute_command(THD *thd) int res= 0; LEX *lex= &thd->lex; TABLE_LIST *tables= (TABLE_LIST*) lex->select_lex.table_list.first; + TABLE_LIST *cursor; SELECT_LEX *select_lex= &lex->select_lex; SELECT_LEX_UNIT *unit= &lex->unit; DBUG_ENTER("mysql_execute_command"); @@ -1343,7 +1344,7 @@ mysql_execute_command(THD *thd) DBUG_VOID_RETURN; } //check rights - for (TABLE_LIST *cursor= tables; + for (cursor= tables; cursor; cursor= cursor->next) if (cursor->derived) @@ -1361,7 +1362,7 @@ mysql_execute_command(THD *thd) } thd->send_explain_fields(explain_result); // EXPLAIN derived tables - for (TABLE_LIST *cursor= tables; + for (cursor= tables; cursor; cursor= cursor->next) if (cursor->derived) @@ -1468,24 +1469,7 @@ mysql_execute_command(THD *thd) else thd->send_explain_fields(explain_result); fix_tables_pointers(select_lex); - for ( SELECT_LEX *sl= select_lex; - sl && res == 0; - sl= sl->next_select_in_list()) - { - SELECT_LEX *first= sl->master_unit()->first_select(); - res= mysql_explain_select(thd, sl, - ((select_lex==sl)? - ((sl->next_select_in_list())?"PRIMARY": - "SIMPLE"): - ((sl == first)? - ((sl->depended)?"DEPENDENT SUBSELECT": - "SUBSELECT"): - ((sl->depended)?"DEPENDENT UNION": - "UNION"))), - explain_result); - } - if (res > 0) - res= -res; // mysql_explain_select do not report error + res= mysql_explain_union(thd, &thd->lex.unit, explain_result); MYSQL_LOCK *save_lock= thd->lock; thd->lock= (MYSQL_LOCK *)0; explain_result->send_eof(); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index a085795fa76..bd115f0fc1e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -634,7 +634,6 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) { MEM_ROOT thd_root = thd->mem_root; PREP_STMT stmt; - bool error; DBUG_ENTER("mysql_stmt_prepare"); bzero((char*) &stmt, sizeof(stmt)); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 09d41e2891b..ede643cab83 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -171,7 +171,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) result->abort(); if (res || thd->net.report_error) { - send_error(thd, 0, MYF(0)); + send_error(thd, 0, NullS); res= 1; } delete result; @@ -213,7 +213,7 @@ JOIN::prepare(TABLE_LIST *tables_init, SELECT_LEX_UNIT *unit, bool fake_select_lex) { DBUG_ENTER("JOIN::prepare"); - + conds= conds_init; order= order_init; group_list= group_init; @@ -348,7 +348,7 @@ int JOIN::optimize() { DBUG_ENTER("JOIN::optimize"); - + #ifdef HAVE_REF_TO_FIELDS // Not done yet /* Add HAVING to WHERE if possible */ if (having && !group_list && ! sum_func_count) @@ -1018,36 +1018,60 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex, bool fake_select_lex) { - JOIN *join = new JOIN(thd, fields, select_options, result); - DBUG_ENTER("mysql_select"); - thd->proc_info="init"; - thd->used_tables=0; // Updated by setup_fields - if (join->prepare(tables, conds, order, group, having, proc_param, - select_lex, unit, fake_select_lex)) + bool free_join= 1; + JOIN *join; + if (!fake_select_lex && select_lex->join != 0) { - DBUG_RETURN(-1); + //here is EXPLAIN of subselect or derived table + join= select_lex->join; + join->result= result; + if (!join->procedure && result->prepare(join->fields_list, unit)) + { + DBUG_RETURN(-1); + } + join->select_options= select_options; + free_join= 0; } - switch (join->optimize()) { + else + { + join= new JOIN(thd, fields, select_options, result); + thd->proc_info="init"; + thd->used_tables=0; // Updated by setup_fields + + if (join->prepare(tables, conds, order, group, having, proc_param, + select_lex, unit, fake_select_lex)) + { + DBUG_RETURN(-1); + } + } + + switch (join->optimize()) + { case 1: DBUG_RETURN(join->error); case -1: goto err; - } + } - if (join->global_optimize()) + if (free_join && join->global_optimize()) goto err; join->exec(); err: - thd->limit_found_rows = join->send_records; - thd->examined_row_count = join->examined_rows; - thd->proc_info="end"; - int error= (fake_select_lex?0:join->cleanup(thd)) || thd->net.report_error; - delete join; - DBUG_RETURN(error); + if (free_join) + { + thd->limit_found_rows = join->send_records; + thd->examined_row_count = join->examined_rows; + thd->proc_info="end"; + int error= (fake_select_lex?0:join->cleanup(thd)) || thd->net.report_error; + delete join; + DBUG_RETURN(error); + } + else + DBUG_RETURN(0); } /***************************************************************************** @@ -3605,6 +3629,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::COND_ITEM: case Item::FIELD_AVG_ITEM: case Item::FIELD_STD_ITEM: + case Item::SUBSELECT_ITEM: /* The following can only happen with 'CREATE TABLE ... SELECT' */ case Item::INT_ITEM: case Item::REAL_ITEM: @@ -7176,7 +7201,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, bool distinct,const char *message) { List<Item> field_list; - Item *item; List<Item> item_list; THD *thd=join->thd; SELECT_LEX *select_lex = &(join->thd->lex.select_lex); @@ -7190,7 +7214,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (message) { - item_list.push_back(new Item_int((int)thd->lex.select->select_number)); + item_list.push_back(new Item_int((int32) thd->lex.select->select_number)); item_list.push_back(new Item_string(thd->lex.select->type, strlen(thd->lex.select->type), default_charset_info)); @@ -7217,7 +7241,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, tmp2.length(0); item_list.empty(); - item_list.push_back(new Item_int((int)thd->lex.select->select_number)); + item_list.push_back(new Item_int((int32) thd->lex.select->select_number)); item_list.push_back(new Item_string(thd->lex.select->type, strlen(thd->lex.select->type), default_charset_info)); @@ -7365,9 +7389,43 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, result->send_error(0,NullS); } } + for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit(); + unit; + unit= unit->next_unit()) + { + if (mysql_explain_union(thd, unit, result)) + DBUG_VOID_RETURN; + } DBUG_VOID_RETURN; } +int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) +{ + int res= 0; + SELECT_LEX *first= unit->first_select(); + for (SELECT_LEX *sl= first; + sl; + sl= sl->next_select()) + { + res= mysql_explain_select(thd, sl, + (((&thd->lex.select_lex)==sl)? + ((sl->next_select_in_list())?"PRIMARY": + "SIMPLE"): + ((sl == first)? + ((sl->depended)?"DEPENDENT SUBSELECT": + "SUBSELECT"): + ((sl->depended)?"DEPENDENT UNION": + "UNION"))), + result); + if (res) + break; + + } + if (res > 0) + res= -res; // mysql_explain_select do not report error + return res; +} + int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type, select_result *result) { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 214cd321562..d6fe2f3772a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -230,7 +230,7 @@ int mysqld_show_table_types(THD *thd) const char *option_name= show_comp_option_name[(int) *types->value]; if (*types->value == SHOW_OPTION_YES && - !strcasecmp(default_type_name, types->type)) + !my_strcasecmp(system_charset_info, default_type_name, types->type)) option_name= "DEFAULT"; net_store_data(packet, option_name); net_store_data(packet, types->comment); @@ -1398,7 +1398,6 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) int mysqld_show_charsets(THD *thd, const char *wild) { - uint i; char buff[8192]; String packet2(buff,sizeof(buff),default_charset_info); List<Item> field_list; @@ -1425,7 +1424,7 @@ int mysqld_show_charsets(THD *thd, const char *wild) net_store_data(&packet2,convert,cs[0]->name); net_store_data(&packet2,(uint32) cs[0]->number); net_store_data(&packet2,(uint32) cs[0]->strxfrm_multiply); - net_store_data(&packet2,(uint32) cs[0]->mbmaxlen ? cs[0]->mbmaxlen : 1); + net_store_data(&packet2,(uint32) (cs[0]->mbmaxlen ? cs[0]->mbmaxlen : 1)); if (my_net_write(&thd->net, (char*) packet2.ptr(),packet2.length())) goto err; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 74cb8f6ffea..01b0eb9e6ec 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -116,7 +116,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result) TMP_TABLE_PARAM tmp_table_param; this->thd= thd; this->result= result; - SELECT_LEX *lex_select_save= thd->lex.select; + SELECT_LEX *lex_select_save= thd->lex.select, *sl; /* Global option */ if (((void*)(global_parameters)) == ((void*)this)) @@ -184,7 +184,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result) // prepare selects joins.empty(); - for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) + for (sl= first_select(); sl; sl= sl->next_select()) { JOIN *join= new JOIN(thd, sl->item_list, sl->options | thd->options | SELECT_NO_UNLOCK | |