diff options
author | unknown <monty@mysql.com> | 2005-09-25 21:22:23 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-09-25 21:22:23 +0300 |
commit | 466b46a66af37310b7d050448ab08913cb09671e (patch) | |
tree | 8f55cf36de04a78555166306a41f58ce8628a240 /sql | |
parent | b337566babce87b4a5854f18586206525a4ba1b7 (diff) | |
download | mariadb-git-466b46a66af37310b7d050448ab08913cb09671e.tar.gz |
Fixed error found during review of new pushed code
client/mysql.cc:
Don't use c_ptr() for cgets() and ensure buffer is not overwritten
mysql-test/r/cast.result:
More test for CAST(0x.... as signed)
sql/opt_sum.cc:
Fix bugs found during review
- Changed code to be able to remove one if
- Ensure that count == 0 only if is_exact_count == TRUE
sql/sql_delete.cc:
Ensure 'allow_sum_func' is reset before call to setup_conds
sql/sql_lex.cc:
allow_sum_func doesn't have to be reset for each query
(It's to be reset in setup_fields() or before call to setup_conds()
sql/sql_load.cc:
Move set of auto_increment_field_not_null so that it's not set if field value is NULL
sql/sql_prepare.cc:
allow_sum_func doesn't have to be reset for each query
(It's to be reset in setup_fields() or before call to setup_conds()
sql/sql_update.cc:
Ensure 'allow_sum_func' is reset before call to setup_conds
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_sum.cc | 14 | ||||
-rw-r--r-- | sql/sql_delete.cc | 5 | ||||
-rw-r--r-- | sql/sql_lex.cc | 1 | ||||
-rw-r--r-- | sql/sql_load.cc | 10 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 1 | ||||
-rw-r--r-- | sql/sql_update.cc | 1 |
6 files changed, 16 insertions, 16 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 3ac72e5a6f9..cfb5b3695a3 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -108,7 +108,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) WHERE t2.field IS NULL; */ if (tl->table->map & where_tables) - const_result= 0; + return 0; } else used_tables|= tl->table->map; @@ -119,7 +119,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) may be used as the real count. */ if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT) + { is_exact_count= FALSE; + count= 1; // ensure count != 0 + } else { tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); @@ -127,9 +130,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) } } - if (!const_result) - return 0; - /* Iterate through all items in the SELECT clause and replace COUNT(), MIN() and MAX() with constants (if possible). @@ -150,8 +150,8 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null && !outer_tables && is_exact_count) { - ((Item_sum_count*) item)->make_const(count); - recalc_const_item= 1; + ((Item_sum_count*) item)->make_const(count); + recalc_const_item= 1; } else const_result= 0; @@ -234,7 +234,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) } if (!count) { - /* If count != 1, then we know that is_exact_count == TRUE. */ + /* If count == 0, then we know that is_exact_count == TRUE. */ ((Item_sum_min*) item_sum)->clear(); /* Set to NULL. */ } else diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7248adf6993..1dd52a2ba74 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -27,8 +27,8 @@ #include "ha_innodb.h" #include "sql_select.h" -int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, - ha_rows limit, ulong options) +int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, + SQL_LIST *order, ha_rows limit, ulong options) { int error; TABLE *table; @@ -266,6 +266,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) select_lex.table_list.first); DBUG_ENTER("mysql_prepare_delete"); + thd->allow_sum_func= 0; if (setup_conds(thd, delete_table_list, conds) || setup_ftfuncs(&thd->lex->select_lex)) DBUG_RETURN(-1); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 07017451bad..8636b6542fc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -160,7 +160,6 @@ void lex_start(THD *thd, uchar *buf,uint length) lex->duplicates= DUP_ERROR; lex->ignore= 0; lex->proc_list.first= 0; - thd->allow_sum_func= 0; } void lex_end(LEX *lex) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index f590038f899..4d09da70ef7 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -429,8 +429,6 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields, while ((sql_field= (Item_field*) it++)) { Field *field= sql_field->field; - if (field == table->next_number_field) - table->auto_increment_field_not_null= TRUE; if (pos == read_info.row_end) { thd->cuted_fields++; /* Not enough fields */ @@ -443,11 +441,13 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields, { uint length; byte save_chr; + if (field == table->next_number_field) + table->auto_increment_field_not_null= TRUE; if ((length=(uint) (read_info.row_end-pos)) > field->field_length) length=field->field_length; save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc - field->store((char*) pos,length,read_info.read_charset); + field->store((char*) pos,length,read_info.read_charset); pos[length]=save_chr; if ((pos+=length) > read_info.row_end) pos= read_info.row_end; /* Fills rest with space */ @@ -522,8 +522,6 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, length=(uint) (read_info.row_end-pos); Field *field=sql_field->field; - if (field == table->next_number_field) - table->auto_increment_field_not_null= TRUE; if (!read_info.enclosed && (enclosed_length && length == 4 && !memcmp(pos,"NULL",4)) || (length == 1 && read_info.found_null)) @@ -540,6 +538,8 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, } continue; } + if (field == table->next_number_field) + table->auto_increment_field_not_null= TRUE; field->set_notnull(); read_info.row_end[0]=0; // Safe to change end marker field->store((char*) read_info.row_start,length,read_info.read_charset); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c8f417c9b9b..8a50d0bd50e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1738,7 +1738,6 @@ static void reset_stmt_for_execute(Prepared_statement *stmt) lex->current_select= &lex->select_lex; if (lex->result) lex->result->cleanup(); - thd->allow_sum_func= 0; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 6c12381b4bd..2857bce09ed 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -426,6 +426,7 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, bzero((char*) &tables,sizeof(tables)); // For ORDER BY tables.table= table; tables.alias= table_list->alias; + thd->allow_sum_func= 0; if (setup_tables(update_table_list) || setup_conds(thd, update_table_list, conds) || |