summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-07-28 16:10:14 +0300
committerunknown <monty@mysql.com>2005-07-28 16:10:14 +0300
commit79f75d8fad96e7b1da588eb850a25f9e9697ac2e (patch)
treeaf22629d2c36ae4196e6f23584c4cecc393b874e /sql
parent520ebda4f22a4471ddedddf1a63561787f31c409 (diff)
downloadmariadb-git-79f75d8fad96e7b1da588eb850a25f9e9697ac2e.tar.gz
Cleanups during review of new code
Ensure mysql_close() is called if mysql_set_character_set() fails libmysql/libmysql.c: Indentation cleanup mysql-test/r/select.result: Fix bad merge & align code with 4.1 mysql-test/r/type_newdecimal.result: Added test of extreme case mysql-test/t/select.test: Fix bad merge & align code with 4.1 mysql-test/t/type_newdecimal.test: Added test of extreme case mysys/charset.c: Removed not used variable mysys/default.c: Simplify code sql-common/client.c: Ensure mysql_close() is called if mysql_set_character_set() fails sql/log.cc: strmov(strmov()) -> strxmov() sql/sp.cc: Indentation fixes sql/sql_acl.cc: Indentation fixes sql/sql_base.cc: Added commments Moved variable to inner block sql/sql_show.cc: Simple optimization (removed loop variable) sql/sql_trigger.cc: strmov(strmov()) -> strxmov() strings/decimal.c: Indentation fixes
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc2
-rw-r--r--sql/sp.cc5
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_base.cc16
-rw-r--r--sql/sql_show.cc18
-rw-r--r--sql/sql_trigger.cc3
6 files changed, 25 insertions, 23 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 7b67a11ab53..540e482f578 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2209,7 +2209,7 @@ bool flush_error_log()
On Windows is necessary a temporary file for to rename
the current error file.
*/
- strmov(strmov(err_temp, err_renamed),"-tmp");
+ strxmov(err_temp, err_renamed,"-tmp",NullS);
(void) my_delete(err_temp, MYF(0));
if (freopen(err_temp,"a+",stdout))
{
diff --git a/sql/sp.cc b/sql/sp.cc
index a277c6bd253..dec0eee0095 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1443,7 +1443,9 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
Sroutine_hash_entry **last_cached_routine_ptr=
(Sroutine_hash_entry **)lex->sroutines_list.next;
for (int i= 0; i < (int)TRG_EVENT_MAX; i++)
+ {
for (int j= 0; j < (int)TRG_ACTION_MAX; j++)
+ {
if (triggers->bodies[i][j])
{
(void)triggers->bodies[i][j]->add_used_tables_to_table_list(thd,
@@ -1451,7 +1453,8 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
sp_update_stmt_used_routines(thd, lex,
&triggers->bodies[i][j]->m_sroutines);
}
-
+ }
+ }
(void)sp_cache_routines_and_add_tables_aux(thd, lex,
*last_cached_routine_ptr);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 04666469e9c..1b3d8cc914a 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3547,9 +3547,9 @@ bool check_grant_db(THD *thd,const char *db)
{
char helping [NAME_LEN+USERNAME_LENGTH+2];
uint len;
- bool error=1;
+ bool error= 1;
- len = (uint) (strmov(strmov(helping,thd->priv_user)+1,db)-helping)+ 1;
+ len= (uint) (strmov(strmov(helping,thd->priv_user)+1,db)-helping)+ 1;
rw_rdlock(&LOCK_grant);
for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 65bb0ec047b..930a176f6fa 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1043,26 +1043,26 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (thd->locked_tables || thd->prelocked_mode)
{ // Using table locks
TABLE *best_table= 0;
- int best_distance= INT_MIN, distance;
+ int best_distance= INT_MIN;
for (table=thd->open_tables; table ; table=table->next)
{
if (table->s->key_length == key_length &&
!memcmp(table->s->table_cache_key, key, key_length) &&
!my_strcasecmp(system_charset_info, table->alias, alias) &&
- table->query_id != thd->query_id && /* skip tables already used by this query */
+ table->query_id != thd->query_id && /* skip tables already used */
!(thd->prelocked_mode && table->query_id))
{
- distance= ((int) table->reginfo.lock_type -
- (int) table_list->lock_type);
+ int distance= ((int) table->reginfo.lock_type -
+ (int) table_list->lock_type);
/*
Find a table that either has the exact lock type requested,
or has the best suitable lock. In case there is no locked
table that has an equal or higher lock than requested,
- we still maitain the best_table to produce an error message
- about wrong lock mode on the table. The best_table is changed
+ we us the closest matching lock to be able to produce an error
+ message about wrong lock mode on the table. The best_table is changed
if bd < 0 <= d or bd < d < 0 or 0 <= d < bd.
- distance < 0 - we have not enough high lock mode
+ distance < 0 - No suitable lock found
distance > 0 - we have lock mode higher then we require
distance == 0 - we have lock mode exactly which we need
*/
@@ -1071,7 +1071,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{
best_distance= distance;
best_table= table;
- if (best_distance == 0)
+ if (best_distance == 0) // Found perfect lock
break;
}
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 6989eacf334..b9ab93cd66f 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3543,9 +3543,8 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
if (table_list->schema_table_reformed) // show command
{
SELECT_LEX *sel= lex->current_select;
- uint i= 0;
Item *item;
- Field_translator *transl;
+ Field_translator *transl, *org_transl;
if (table_list->field_translation)
{
@@ -3566,16 +3565,17 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
{
DBUG_RETURN(1);
}
- while ((item= it++))
+ for (org_transl= transl; (item= it++); transl++)
{
- char *name= item->name;
- transl[i].item= item;
- if (!item->fixed && item->fix_fields(thd, &transl[i].item))
+ transl->item= item;
+ transl->name= item->name;
+ if (!item->fixed && item->fix_fields(thd, &transl->item))
+ {
DBUG_RETURN(1);
- transl[i++].name= name;
+ }
}
- table_list->field_translation= transl;
- table_list->field_translation_end= transl + sel->item_list.elements;
+ table_list->field_translation= org_transl;
+ table_list->field_translation_end= transl;
}
DBUG_RETURN(0);
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index a7aee95197e..ee16b219421 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -564,8 +564,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
alloc_root(&table->mem_root, triggers->sroutines_key.length)))
DBUG_RETURN(1);
triggers->sroutines_key.str[0]= TYPE_ENUM_TRIGGER;
- strmov(strmov(strmov(triggers->sroutines_key.str+1, db), "."),
- table_name);
+ strxmov(triggers->sroutines_key.str+1, db, ".", table_name, NullS);
/*
TODO: This could be avoided if there is no triggers