summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-12-06 17:15:54 +0200
committerunknown <monty@mysql.com>2004-12-06 17:15:54 +0200
commita1fba2daccee3c7c5d46cded39fda7ee7f0d6eae (patch)
treeadca7e39f11a6ff5883c21958f614b2e665a3d84 /sql
parent796bd7de96a1d1ec422708b90df5328388201c10 (diff)
downloadmariadb-git-a1fba2daccee3c7c5d46cded39fda7ee7f0d6eae.tar.gz
After merge fixes
Fixed compiler warnings Fix core dump when sending SIGHUP to mysqld mysql-test/r/drop_temp_table.result: After merge fixes mysql-test/r/grant.result: After merge fixes mysql-test/r/group_min_max.result: After merge fixes mysql-test/r/innodb.result: After merge fixes mysql-test/r/insert_select.result: After merge fixes mysql-test/r/rpl_charset.result: After merge fixes mysql-test/r/rpl_create_database.result: After merge fixes mysql-test/r/rpl_loaddata_rule_m.result: After merge fixes mysql-test/t/rpl_charset.test: After merge fixes mysql-test/t/rpl_create_database.test: After merge fixes sql-common/client.c: After merge fixes sql/item.cc: After merge fixes sql/mysqld.cc: Fix core dump when sending SIGHUP to mysqld sql/sql_acl.cc: Better comment sql/sql_derived.cc: Fixed comment Added missing DBUG_RETURN sql/sql_insert.cc: Fixed compiler warnings After merge fixes sql/sql_lex.cc: After merge fixes Removed compiler warnings sql/sql_parse.cc: After merge fixes sql/sql_select.cc: More debugging sql/sql_table.cc: Added missing DBUG_VOID_RETURN sql/sql_update.cc: Fixed compiler warning sql/sql_view.cc: Added missing DBUG_RETURN Fixed compiler warnings Added flag to signal that the view is a derived table
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc2
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/sql_acl.cc3
-rw-r--r--sql/sql_derived.cc6
-rw-r--r--sql/sql_insert.cc27
-rw-r--r--sql/sql_lex.cc3
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_select.cc50
-rw-r--r--sql/sql_table.cc1
-rw-r--r--sql/sql_update.cc6
-rw-r--r--sql/sql_view.cc5
11 files changed, 70 insertions, 47 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 001fbef9505..03bbbe2ad49 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -187,6 +187,7 @@ Item_ident::Item_ident(THD *thd, Item_ident *item)
void Item_ident::cleanup()
{
DBUG_ENTER("Item_ident::cleanup");
+#ifdef CANT_BE_USED_AS_MEMORY_IS_FREED
DBUG_PRINT("enter", ("b:%s(%s), t:%s(%s), f:%s(%s)",
db_name ? db_name : "(null)",
orig_db_name ? orig_db_name : "(null)",
@@ -194,6 +195,7 @@ void Item_ident::cleanup()
orig_table_name ? orig_table_name : "(null)",
field_name ? field_name : "(null)",
orig_field_name ? orig_field_name : "(null)"));
+#endif
Item::cleanup();
db_name= orig_db_name;
table_name= orig_table_name;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5e0cc47ecc5..42ae6982eb0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2128,7 +2128,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
{
reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
- REFRESH_STATUS | REFRESH_GRANT |
+ REFRESH_GRANT |
REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, NULL); // Flush logs
mysql_print_status((THD*) 0); // Send debug some info
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index b69ee068407..4d4923d16b8 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -446,7 +446,8 @@ void acl_free(bool end)
SYNOPSIS
acl_reload()
- thd Thread handle
+ thd Thread handle. Note that this may be NULL if we refresh
+ because we got a signal
*/
void acl_reload(THD *thd)
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 10ef6a081b6..69511018880 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -77,7 +77,7 @@ mysql_handle_derived(LEX *lex, int (*processor)(THD*, LEX*, TABLE_LIST*))
Create temporary table structure (but do not fill it)
SYNOPSIS
- mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
+ mysql_derived_prepare()
thd Thread handle
lex LEX for this thread
orig_table_list TABLE_LIST for the upper SELECT
@@ -103,6 +103,7 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
{
SELECT_LEX_UNIT *unit= orig_table_list->derived;
int res= 0;
+ DBUG_ENTER("mysql_derived_prepare");
if (unit)
{
SELECT_LEX *first_select= unit->first_select();
@@ -110,7 +111,6 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
select_union *derived_result;
bool is_union= first_select->next_select() &&
first_select->next_select()->linkage == UNION_TYPE;
- DBUG_ENTER("mysql_derived");
if (!(derived_result= new select_union(0)))
DBUG_RETURN(1); // out of memory
@@ -173,7 +173,7 @@ exit:
}
else if (orig_table_list->ancestor)
orig_table_list->set_ancestor();
- return (res);
+ DBUG_RETURN(res);
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 77a669e4c96..0814c7a747e 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -116,7 +116,8 @@ check_insert_fields(THD *thd, TABLE_LIST *table_list, List<Item> &fields,
Item *item;
TABLE_LIST *tbl= 0;
table_map map= 0;
- while (item= it++)
+
+ while ((item= it++))
map|= item->used_tables();
if (table_list->check_single_table(&tbl, map) || tbl == 0)
{
@@ -1840,19 +1841,23 @@ bool select_insert::send_data(List<Item> &values)
DBUG_RETURN(0);
}
- thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
+ thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
store_values(values);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (thd->net.report_error)
DBUG_RETURN(1);
- switch (table_list->view_check_option(thd,
- thd->lex->duplicates == DUP_IGNORE)) {
- case VIEW_CHECK_SKIP:
- DBUG_RETURN(0);
- case VIEW_CHECK_ERROR:
- DBUG_RETURN(1);
+ if (table_list) // Not CREATE ... SELECT
+ {
+ switch (table_list->view_check_option(thd,
+ thd->lex->duplicates ==
+ DUP_IGNORE)) {
+ case VIEW_CHECK_SKIP:
+ DBUG_RETURN(0);
+ case VIEW_CHECK_ERROR:
+ DBUG_RETURN(1);
+ }
}
- if (!(error= write_record(table,&info)) && table->next_number_field)
+ if (!(error= write_record(thd, table,&info)) && table->next_number_field)
{
/* Clear for next record */
table->next_number_field->reset();
@@ -1866,9 +1871,9 @@ bool select_insert::send_data(List<Item> &values)
void select_insert::store_values(List<Item> &values)
{
if (fields->elements)
- fill_record(*fields, values, 1);
+ fill_record(thd, *fields, values, 1);
else
- fill_record(table->field, values, 1);
+ fill_record(thd, table->field, values, 1);
}
void select_insert::send_error(uint errcode,const char *err)
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 8a705a7438b..12e4d912f15 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -144,8 +144,9 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex->select_lex.init_order();
lex->select_lex.group_list.empty();
lex->describe= 0;
- lex->subqueries= lex->derived_tables= FALSE;
+ lex->subqueries= FALSE;
lex->view_prepare_mode= FALSE;
+ lex->derived_tables= 0;
lex->lock_option= TL_READ;
lex->found_colon= 0;
lex->safe_to_cache_query= 1;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 44adc28d41d..168632f7578 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -615,7 +615,7 @@ end:
}
-static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0)
+static void reset_mqh(LEX_USER *lu, bool get_them= 0)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
(void) pthread_mutex_lock(&LOCK_user_conn);
@@ -3396,7 +3396,7 @@ create_error:
{
if (mysql_bin_log.is_open())
{
- Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
+ Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
}
send_ok(thd);
@@ -3512,7 +3512,7 @@ create_error:
List_iterator <LEX_USER> str_list(lex->users_list);
LEX_USER *user;
while ((user=str_list++))
- reset_mqh(thd,user);
+ reset_mqh(user);
}
}
}
@@ -5637,7 +5637,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
acl_reload(thd);
grant_reload(thd);
if (mqh_used)
- reset_mqh(thd,(LEX_USER *) NULL,TRUE);
+ reset_mqh((LEX_USER *) NULL,TRUE);
}
#endif
if (options & REFRESH_LOG)
@@ -5713,7 +5713,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
}
if (options & REFRESH_HOSTS)
hostname_cache_refresh();
- if (options & REFRESH_STATUS)
+ if (thd && (options & REFRESH_STATUS))
refresh_status();
if (options & REFRESH_THREADS)
flush_thread_cache();
@@ -5743,7 +5743,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
}
#endif
if (options & REFRESH_USER_RESOURCES)
- reset_mqh(thd,(LEX_USER *) NULL);
+ reset_mqh((LEX_USER *) NULL);
if (write_to_binlog)
*write_to_binlog= tmp_write_to_binlog;
return result;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ba9933a3d15..1049c074ce1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1249,7 +1249,7 @@ JOIN::exec()
/* Copy data to the temporary table */
thd->proc_info= "Copying to tmp table";
-
+ DBUG_PRINT("info", ("%s", thd->proc_info));
if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0)))
{
error= tmp_error;
@@ -1377,6 +1377,7 @@ JOIN::exec()
}
thd->proc_info="Copying to group table";
+ DBUG_PRINT("info", ("%s", thd->proc_info));
tmp_error= -1;
if (curr_join != this)
{
@@ -1615,6 +1616,7 @@ JOIN::exec()
else
{
thd->proc_info="Sending data";
+ DBUG_PRINT("info", ("%s", thd->proc_info));
error= do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records;
thd->examined_row_count= curr_join->examined_rows;
@@ -1910,6 +1912,8 @@ void
Cursor::close()
{
THD *thd= join->thd;
+ DBUG_ENTER("Cursor::close");
+
join->join_free(0);
if (unit)
{
@@ -1940,6 +1944,7 @@ Cursor::close()
}
join= 0;
unit= 0;
+ DBUG_VOID_RETURN;
}
@@ -4718,11 +4723,12 @@ get_best_combination(JOIN *join)
KEYUSE *keyuse;
uint table_count;
THD *thd=join->thd;
+ DBUG_ENTER("get_best_combination");
table_count=join->tables;
if (!(join->join_tab=join_tab=
(JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*table_count)))
- return TRUE;
+ DBUG_RETURN(TRUE);
join->full_join=0;
@@ -4736,6 +4742,7 @@ get_best_combination(JOIN *join)
form->reginfo.join_tab=j;
if (!*j->on_expr_ref)
form->reginfo.not_exists_optimize=0; // Only with LEFT JOIN
+ DBUG_PRINT("info",("type: %d", j->type));
if (j->type == JT_CONST)
continue; // Handled in make_join_stat..
@@ -4751,13 +4758,13 @@ get_best_combination(JOIN *join)
join->full_join=1;
}
else if (create_ref_for_key(join, j, keyuse, used_tables))
- return TRUE; // Something went wrong
+ DBUG_RETURN(TRUE); // Something went wrong
}
for (i=0 ; i < table_count ; i++)
join->map2table[join->join_tab[i].table->tablenr]=join->join_tab+i;
update_depend_map(join);
- return 0;
+ DBUG_RETURN(0);
}
@@ -4770,6 +4777,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
uint keyparts,length,key;
TABLE *table;
KEY *keyinfo;
+ DBUG_ENTER("create_ref_for_key");
/* Use best key from find_best */
table=j->table;
@@ -4819,7 +4827,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
(keyparts+1)))) ||
!(j->ref.items= (Item**) thd->alloc(sizeof(Item*)*keyparts)))
{
- return TRUE;
+ DBUG_RETURN(TRUE);
}
j->ref.key_buff2=j->ref.key_buff+ALIGN_SIZE(length);
j->ref.key_err=1;
@@ -4832,7 +4840,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
{
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
if (keyuse->used_tables)
- return TRUE; // not supported yet. SerG
+ DBUG_RETURN(TRUE); // not supported yet. SerG
j->type=JT_FT;
}
@@ -4856,7 +4864,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
maybe_null ? (char*) key_buff : 0,
keyinfo->key_part[i].length, keyuse->val);
if (thd->is_fatal_error)
- return TRUE;
+ DBUG_RETURN(TRUE);
tmp.copy();
}
else
@@ -4876,7 +4884,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
} /* not ftkey */
*ref_key=0; // end_marker
if (j->type == JT_FT)
- return 0;
+ DBUG_RETURN(0);
if (j->type == JT_CONST)
j->table->const_table= 1;
else if (((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY |
@@ -4900,7 +4908,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
}
else
j->type=JT_EQ_REF;
- return 0;
+ DBUG_RETURN(0);
}
@@ -4963,10 +4971,11 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
{
TABLE **tableptr;
JOIN_TAB *join_tab;
+ DBUG_ENTER("make_simple_join");
if (!(tableptr=(TABLE**) join->thd->alloc(sizeof(TABLE*))) ||
!(join_tab=(JOIN_TAB*) join->thd->alloc(sizeof(JOIN_TAB))))
- return TRUE;
+ DBUG_RETURN(TRUE);
join->join_tab=join_tab;
join->table=tableptr; tableptr[0]=tmp_table;
join->tables=1;
@@ -4996,10 +5005,11 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
join_tab->not_used_in_distinct=0;
join_tab->read_first_record= join_init_read_record;
join_tab->join=join;
+ join_tab->ref.key_parts= 0;
bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record));
tmp_table->status=0;
tmp_table->null_row=0;
- return FALSE;
+ DBUG_RETURN(FALSE);
}
@@ -8122,6 +8132,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_length=0;
keyinfo->rec_per_key=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
+ keyinfo->name= (char*) "group_key";
for (; group ; group=group->next,key_part_info++)
{
Field *field=(*group->item)->get_tmp_table_field();
@@ -8192,7 +8203,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_part=key_part_info;
keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL;
keyinfo->key_length=(uint16) reclength;
- keyinfo->name=(char*) "tmp";
+ keyinfo->name= (char*) "distinct_key";
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
if (null_pack_length)
{
@@ -11973,6 +11984,8 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
{
List_iterator_fast<Item> it(all_fields);
Item *item_field,*item;
+ DBUG_ENTER("change_to_use_tmp_fields");
+
res_selected_fields.empty();
res_all_fields.empty();
@@ -11996,8 +12009,8 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
else
item_field= (Item*) new Item_field(field);
if (!item_field)
- return TRUE; // Fatal error
- item_field->name= item->name; /*lint -e613 */
+ DBUG_RETURN(TRUE); // Fatal error
+ item_field->name= item->name;
#ifndef DBUG_OFF
if (_db_on_ && !item_field->name)
{
@@ -12021,7 +12034,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
for (i= 0; i < border; i++)
itr++;
itr.sublist(res_selected_fields, elements);
- return FALSE;
+ DBUG_RETURN(FALSE);
}
@@ -12092,10 +12105,11 @@ change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array,
static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
{
Item_sum *func;
+ DBUG_ENTER("setup_sum_funcs");
while ((func= *(func_ptr++)))
if (func->setup(thd))
- return TRUE;
- return FALSE;
+ DBUG_RETURN(TRUE);
+ DBUG_RETURN(FALSE);
}
@@ -12617,10 +12631,10 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item_list.push_back(new Item_string(join_type_str[tab->type],
strlen(join_type_str[tab->type]),
cs));
- uint j;
/* Build "possible_keys" value and add it to item_list */
if (!tab->keys.is_clear_all())
{
+ uint j;
for (j=0 ; j < table->keys ; j++)
{
if (tab->keys.is_set(j))
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a1e09d74620..c0ddfdb2f07 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1670,6 +1670,7 @@ void close_cached_table(THD *thd, TABLE *table)
/* When lock on LOCK_open is freed other threads can continue */
pthread_cond_broadcast(&COND_refresh);
+ DBUG_VOID_RETURN;
}
static int send_check_errmsg(THD *thd, TABLE_LIST* table,
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 7c55f281f38..9613e39d403 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -776,12 +776,10 @@ bool mysql_multi_update_prepare(THD *thd)
*/
List_iterator_fast<Item> it(*fields);
Item *item;
- while (item= it++)
- {
+ while ((item= it++))
item->cleanup();
- }
- /* We have to cleunup translation tables of views. */
+ /* We have to cleanup translation tables of views. */
for (TABLE_LIST *tbl= table_list; tbl; tbl= tbl->next_global)
tbl->cleanup_items();
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index ec63bb92c54..993a4d1987b 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -312,7 +312,7 @@ bool mysql_create_view(THD *thd,
send_ok(thd);
lex->link_first_table_back(view, link_to_local);
- return 0;
+ DBUG_RETURN(0);
err:
thd->proc_info= "end";
@@ -793,7 +793,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
/* re-nest tables of VIEW */
{
List_iterator_fast<TABLE_LIST> ti(nested_join->join_list);
- while(tbl= ti++)
+ while ((tbl= ti++))
{
tbl->join_list= &nested_join->join_list;
tbl->embedding= table;
@@ -832,6 +832,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
view_select->linkage= DERIVED_TABLE_TYPE;
table->updatable= 0;
table->effective_with_check= VIEW_CHECK_NONE;
+ old_lex->subqueries= TRUE;
/* SELECT tree link */
lex->unit.include_down(table->select_lex);