summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-03-16 16:11:01 +0200
committermonty@mysql.com <>2005-03-16 16:11:01 +0200
commit594ef41b2d981bac7dc18ffaaf3e78c970ae4d65 (patch)
tree91072764c1f84696f62c39d4e54fea6a1c35c516 /sql
parent8e54dece315d7e96ce2e4eccf01adfabe660a63a (diff)
downloadmariadb-git-594ef41b2d981bac7dc18ffaaf3e78c970ae4d65.tar.gz
Cleanup during reviews
Removed some optional arguments Fixed portability problem in federated tests
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc38
-rw-r--r--sql/field.h2
-rw-r--r--sql/ha_federated.cc2
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item_func.cc8
-rw-r--r--sql/item_sum.cc4
-rw-r--r--sql/lock.cc2
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/mysql_priv.h33
-rw-r--r--sql/opt_range.cc6
-rw-r--r--sql/sql_base.cc6
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_error.cc5
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_parse.cc17
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_rename.cc2
-rw-r--r--sql/sql_select.cc9
-rw-r--r--sql/sql_show.cc17
-rw-r--r--sql/sql_string.cc12
-rw-r--r--sql/sql_table.cc282
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_yacc.yy16
23 files changed, 242 insertions, 231 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 26575d97f69..b6dd00d62a7 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5328,11 +5328,11 @@ Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table)
int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
{
- int error= 0;
uint32 not_used, copy_length;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
- bool lost_only_spaces= FALSE;
+ int error_code= 0;
+ enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN;
/* Convert character set if necessary */
if (String::needs_conversion(length, cs, field_charset, &not_used))
@@ -5342,7 +5342,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
from= tmpstr.ptr();
length= tmpstr.length();
if (conv_errors)
- error= 1;
+ error_code= WARN_DATA_TRUNCATED;
}
/*
Make sure we don't break a multibyte sequence
@@ -5359,30 +5359,26 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
int2store(ptr, copy_length);
// Check if we lost something other than just trailing spaces
- if ((copy_length < length) && table->in_use->count_cuted_fields)
+ if ((copy_length < length) && table->in_use->count_cuted_fields &&
+ !error_code)
{
const char *end= from + length;
from+= copy_length;
from+= field_charset->cset->scan(field_charset, from, end, MY_SEQ_SPACES);
- /*
- If we lost only spaces then produce a NOTE, not a WARNING.
- But if we have already had errors (e.g with charset conversion),
- then don't reset level to NOTE.
- */
- if (from == end && !error)
- lost_only_spaces= TRUE;
- error= 1;
+ /* If we lost only spaces then produce a NOTE, not a WARNING */
+ if (from == end)
+ level= MYSQL_ERROR::WARN_LEVEL_NOTE;
+ error_code= WARN_DATA_TRUNCATED;
}
- if (error)
+ if (error_code)
{
- if (lost_only_spaces)
- set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
- else if (table->in_use->abort_on_warning)
- set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
- else
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ if (level == MYSQL_ERROR::WARN_LEVEL_WARN &&
+ table->in_use->abort_on_warning)
+ error_code= ER_DATA_TOO_LONG;
+ set_warning(level, error_code, 1);
+ return 1;
}
- return error;
+ return 0;
}
@@ -7562,7 +7558,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
false - otherwise
*/
bool
-Field::set_warning(const uint level, const uint code, int cuted_increment)
+Field::set_warning(uint level, uint code, int cuted_increment)
{
THD *thd= table->in_use;
if (thd->count_cuted_fields)
diff --git a/sql/field.h b/sql/field.h
index 083af27d6d9..5b13ba1042a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -279,7 +279,7 @@ public:
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; }
virtual void set_charset(CHARSET_INFO *charset) { }
- bool set_warning(const unsigned int level, const unsigned int code,
+ bool set_warning(unsigned int level, unsigned int code,
int cuted_increment);
bool check_int(const char *str, int length, const char *int_end,
CHARSET_INFO *cs);
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index 215a8daf200..25f6e62a9ae 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -662,7 +662,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
error:
my_error(error_num, MYF(0),
- "this connection string is not in the correct format!\n");
+ "connection string is not in the correct format",0);
DBUG_RETURN(1);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index f33f987ef77..20c96849c0f 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -834,7 +834,7 @@ int ha_recover(HASH *commit_list)
for now, only InnoDB supports 2pc. It means we can always safely
rollback all pending transactions, without risking inconsistent data
*/
- DBUG_ASSERT(total_ha_2pc == opt_bin_log+1); // only InnoDB and binlog
+ DBUG_ASSERT(total_ha_2pc == (ulong) opt_bin_log+1); // only InnoDB and binlog
tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK
dry_run=FALSE;
#endif
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 680f3608d0d..bec91f7e90a 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4370,19 +4370,19 @@ Item_func_sp::Item_func_sp(sp_name *name)
{
maybe_null= 1;
m_name->init_qname(current_thd);
- dummy_table= (TABLE *)sql_alloc(sizeof(TABLE));
- bzero(dummy_table, sizeof(TABLE));
+ dummy_table= (TABLE*) sql_calloc(sizeof(TABLE));
}
+
Item_func_sp::Item_func_sp(sp_name *name, List<Item> &list)
:Item_func(list), m_name(name), m_sp(NULL)
{
maybe_null= 1;
m_name->init_qname(current_thd);
- dummy_table= (TABLE *)sql_alloc(sizeof(TABLE));
- bzero(dummy_table, sizeof(TABLE));
+ dummy_table= (TABLE*) sql_calloc(sizeof(TABLE));
}
+
const char *
Item_func_sp::func_name() const
{
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 174e2ba4b85..b18653ed5a4 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -727,7 +727,7 @@ Item_sum_avg_distinct::fix_length_and_dec()
AVG() will divide val by count. We need to reserve digits
after decimal point as the result can be fractional.
*/
- decimals+= 4;
+ decimals= min(decimals + 4, NOT_FIXED_DEC);
}
@@ -927,7 +927,7 @@ void Item_sum_variance::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_variance::fix_length_and_dec");
maybe_null= null_value= 1;
- decimals= args[0]->decimals + 4;
+ decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
switch (args[0]->result_type()) {
case REAL_RESULT:
case STRING_RESULT:
diff --git a/sql/lock.cc b/sql/lock.cc
index 35b93c79fee..507e802d2e8 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -562,7 +562,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
my_free((gptr) table,MYF(0));
DBUG_RETURN(-1);
}
- if (remove_table_from_cache(thd, db, table_list->table_name))
+ if (remove_table_from_cache(thd, db, table_list->table_name, 0))
DBUG_RETURN(1); // Table is in use
DBUG_RETURN(0);
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index ff7445029d0..e37fb865003 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2575,7 +2575,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
"data truncated" warning but which is absorbed and never gets to the
error log); still we init it to avoid a Valgrind message.
*/
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
TABLE_LIST tables;
bzero((char*) &tables,sizeof(tables));
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 86fc04b3622..229b15adbfc 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -632,10 +632,11 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
int mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
- bool group, bool modify_item, uint convert_blob_length);
+ bool group, bool modify_item,
+ uint convert_blob_length);
int prepare_create_field(create_field *sql_field,
- uint &blob_columns,
- int &timestamps, int &timestamps_with_niladic,
+ uint *blob_columns,
+ int *timestamps, int *timestamps_with_niladic,
uint table_flags);
int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
List<create_field> &fields,
@@ -661,7 +662,7 @@ bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
uint order_num, ORDER *order,
enum enum_duplicates handle_duplicates,
bool ignore,
- ALTER_INFO *alter_info, bool do_send_ok=1);
+ ALTER_INFO *alter_info, bool do_send_ok);
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok);
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
HA_CREATE_INFO *create_info,
@@ -705,7 +706,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
bool *refresh);
TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table);
TABLE *find_locked_table(THD *thd, const char *db,const char *table_name);
-bool reopen_table(TABLE *table,bool locked=0);
+bool reopen_table(TABLE *table,bool locked);
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
void close_old_data_files(THD *thd, TABLE *table, bool abort_locks,
bool send_refresh);
@@ -769,7 +770,7 @@ void append_identifier(THD *thd, String *packet, const char *name,
uint length);
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
-int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd = -1);
+int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
@@ -790,7 +791,7 @@ void calc_sum_of_all_status(STATUS_VAR *to);
extern LEX_STRING information_schema_name;
LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
const char* str, uint length,
- bool allocate_lex_string= 0);
+ bool allocate_lex_string);
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
@@ -806,7 +807,7 @@ bool get_schema_tables_result(JOIN *join);
/* sql_prepare.cc */
bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
- LEX_STRING *name=NULL);
+ LEX_STRING *name);
void mysql_stmt_execute(THD *thd, char *packet, uint packet_length);
void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name);
void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length);
@@ -821,11 +822,11 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint
const char *msg);
void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
uint code, const char *format, ...);
-void mysql_reset_errors(THD *thd, bool force= false);
+void mysql_reset_errors(THD *thd, bool force);
bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
/* sql_handler.cc */
-bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen= 0);
+bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen);
bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
@@ -854,15 +855,15 @@ create_field * new_create_field(THD *thd, char *field_name, enum_field_types typ
List<String> *interval_list, CHARSET_INFO *cs,
uint uint_geom_type);
void store_position_for_column(const char *name);
-bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc=0);
+bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
void add_join_on(TABLE_LIST *b,Item *expr);
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b);
bool add_proc_to_list(THD *thd, Item *item);
TABLE *unlink_open_table(THD *thd,TABLE *list,TABLE *find);
SQL_SELECT *make_select(TABLE *head, table_map const_tables,
- table_map read_tables, COND *conds, int *error,
- bool allow_null_cond= false);
+ table_map read_tables, COND *conds,
+ bool allow_null_cond, int *error);
extern Item **not_found_item;
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
find_item_error_report_type report_error,
@@ -905,13 +906,13 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
TABLE_LIST *unique_table(TABLE_LIST *table, TABLE_LIST *table_list);
TABLE **find_temporary_table(THD *thd, const char *db, const char *table_name);
bool close_temporary_table(THD *thd, const char *db, const char *table_name);
-void close_temporary(TABLE *table, bool delete_table=1);
+void close_temporary(TABLE *table, bool delete_table);
bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
const char *table_name);
void remove_db_from_cache(const char *db);
void flush_tables();
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
- bool return_if_owned_by_thd=0);
+ bool return_if_owned_by_thd);
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
void copy_field_from_tmp_record(Field *field,int offset);
bool fill_record(THD *thd, List<Item> &fields, List<Item> &values,
@@ -1170,7 +1171,7 @@ void unlock_table_name(THD *thd, TABLE_LIST *table_list);
bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
bool lock_table_names(THD *thd, TABLE_LIST *table_list);
void unlock_table_names(THD *thd, TABLE_LIST *table_list,
- TABLE_LIST *last_table= 0);
+ TABLE_LIST *last_table);
/* old unireg functions */
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 812d5a41cbc..fe1780b92a7 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -650,8 +650,10 @@ int imerge_list_or_tree(PARAM *param,
*/
SQL_SELECT *make_select(TABLE *head, table_map const_tables,
- table_map read_tables, COND *conds, int *error,
- bool allow_null_cond)
+ table_map read_tables, COND *conds,
+ bool allow_null_cond,
+ int *error)
+
{
SQL_SELECT *select;
DBUG_ENTER("make_select");
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 09640eb3f57..4750fe1386f 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -633,7 +633,7 @@ void close_temporary_tables(THD *thd)
table->s->table_name,"`,", NullS);
}
next=table->next;
- close_temporary(table);
+ close_temporary(table, 1);
}
if (query && found_user_tables && mysql_bin_log.is_open())
{
@@ -798,7 +798,7 @@ bool close_temporary_table(THD *thd, const char *db, const char *table_name)
return 1;
table= *prev;
*prev= table->next;
- close_temporary(table);
+ close_temporary(table, 1);
if (thd->slave_thread)
--slave_open_temp_tables;
return 0;
@@ -1606,7 +1606,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
if (ha_create_table_from_engine(thd, db, name, TRUE) != 0)
goto err;
- mysql_reset_errors(thd, true); // Clear warnings
+ mysql_reset_errors(thd, 1); // Clear warnings
thd->clear_error(); // Clear error message
continue;
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index d49d654cb87..642564f5d7a 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -96,7 +96,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
table->used_keys.clear_all();
table->quick_keys.clear_all(); // Can't use 'only index'
- select=make_select(table,0,0,conds,&error);
+ select=make_select(table, 0, 0, conds, 0, &error);
if (error)
DBUG_RETURN(TRUE);
if ((select && select->check_quick(thd, safe_update, limit)) || !limit)
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 4420f2d16ad..281ac7169c0 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -80,7 +80,8 @@ void mysql_reset_errors(THD *thd, bool force)
thd->warn_id= thd->query_id;
free_root(&thd->warn_root,MYF(0));
bzero((char*) thd->warn_count, sizeof(thd->warn_count));
- if (force) thd->total_warn_count= 0;
+ if (force)
+ thd->total_warn_count= 0;
thd->warn_list.empty();
thd->row_count= 1; // by default point to row 1
}
@@ -113,7 +114,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
DBUG_RETURN(0);
if (thd->query_id != thd->warn_id)
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
thd->got_warning= 1;
if (thd->spcont &&
thd->spcont->find_handler(code,
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index f5490da7e85..fa3e2070a28 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -562,7 +562,7 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables,
/* Assume that no indexes cover all required fields */
table->used_keys.clear_all();
- SQL_SELECT *res= make_select(table,0,0,cond,error);
+ SQL_SELECT *res= make_select(table, 0, 0, cond, 0, error);
if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) ||
(res->quick && res->quick->reset()))
{
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c1793f0b026..547dc9fd0f8 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1623,7 +1623,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
case COM_PREPARE:
{
- mysql_stmt_prepare(thd, packet, packet_length);
+ mysql_stmt_prepare(thd, packet, packet_length, 0);
break;
}
case COM_CLOSE_STMT:
@@ -2261,7 +2261,7 @@ mysql_execute_command(THD *thd)
*/
if (all_tables || &lex->select_lex != lex->all_selects_list ||
lex->spfuns.records || lex->spprocs.records)
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
#ifdef HAVE_REPLICATION
if (thd->slave_thread)
@@ -2935,7 +2935,8 @@ unsent_create_error:
lex->key_list,
select_lex->order_list.elements,
(ORDER *) select_lex->order_list.first,
- lex->duplicates, lex->ignore, &lex->alter_info);
+ lex->duplicates, lex->ignore, &lex->alter_info,
+ 1);
}
break;
}
@@ -3764,7 +3765,7 @@ unsent_create_error:
if (check_db_used(thd, all_tables) ||
check_table_access(thd, SELECT_ACL, all_tables, 0))
goto error;
- res= mysql_ha_open(thd, first_table);
+ res= mysql_ha_open(thd, first_table, 0);
break;
case SQLCOM_HA_CLOSE:
DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -4109,7 +4110,7 @@ unsent_create_error:
sp= sp_find_procedure(thd, lex->spname);
else
sp= sp_find_function(thd, lex->spname);
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
if (! sp)
result= SP_KEY_NOT_FOUND;
else
@@ -4150,7 +4151,7 @@ unsent_create_error:
sp= sp_find_procedure(thd, lex->spname);
else
sp= sp_find_function(thd, lex->spname);
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
if (sp)
{
db= thd->strdup(sp->m_db.str);
@@ -6491,7 +6492,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list,
fields, keys, 0, (ORDER*)0,
- DUP_ERROR, 0, &alter_info));
+ DUP_ERROR, 0, &alter_info, 1));
}
@@ -6509,7 +6510,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list,
fields, keys, 0, (ORDER*)0,
- DUP_ERROR, 0, alter_info));
+ DUP_ERROR, 0, alter_info, 1));
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5cd4753c229..7862717bb18 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1782,7 +1782,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
thd->current_arena= stmt;
mysql_init_query(thd, (uchar *) thd->query, thd->query_length);
/* Reset warnings from previous command */
- mysql_reset_errors(thd);
+ mysql_reset_errors(thd, 0);
lex= thd->lex;
lex->safe_to_cache_query= 0;
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 8bc1891ef1b..8fe17198cf0 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -90,7 +90,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
send_ok(thd);
}
- unlock_table_names(thd, table_list);
+ unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
err:
pthread_mutex_unlock(&LOCK_open);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 162e5b887ab..b970c184489 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -675,8 +675,8 @@ JOIN::optimize()
/* Handle the case where we have an OUTER JOIN without a WHERE */
conds=new Item_int((longlong) 1,1); // Always true
}
- select=make_select(*table, const_table_map,
- const_table_map, conds, &error, true);
+ select= make_select(*table, const_table_map,
+ const_table_map, conds, 1, &error);
if (error)
{ /* purecov: inspected */
error= -1; /* purecov: inspected */
@@ -2398,7 +2398,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
select= make_select(s->table, found_const_table_map,
found_const_table_map,
*s->on_expr_ref ? *s->on_expr_ref : conds,
- &error, true);
+ 1, &error);
if (!select)
DBUG_RETURN(1);
records= get_quick_record_count(join->thd, select, s->table,
@@ -12495,7 +12495,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
error=(int) cond->add(join_tab->select->cond);
join_tab->select_cond=join_tab->select->cond=cond;
}
- else if ((join_tab->select=make_select(join_tab->table, 0, 0, cond,&error)))
+ else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0,
+ &error)))
join_tab->select_cond=cond;
DBUG_RETURN(error ? TRUE : FALSE);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 293c5f5d275..124ce1805db 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -704,14 +704,17 @@ static void append_directory(THD *thd, String *packet, const char *dir_type,
packet->append(dir_type);
packet->append(" DIRECTORY='", 12);
#ifdef __WIN__
- char *winfilename = thd->memdup(filename, length);
- for (uint i=0; i < length; i++)
- if (winfilename[i] == '\\')
- winfilename[i] = '/';
- packet->append(winfilename, length);
-#else
- packet->append(filename, length);
+ /* Convert \ to / to be able to create table on unix */
+ char *winfilename= (char*) thd->memdup(filename, length);
+ char *pos, *end;
+ for (pos= winfilename, end= pos+length ; pos < end ; pos++)
+ {
+ if (*pos == '\\')
+ *pos = '/';
+ }
+ filename= winfilename;
#endif
+ packet->append(filename, length);
packet->append('\'');
}
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 226a80201a1..0424723d97f 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -686,16 +686,16 @@ void String::qs_append(double *d)
void String::qs_append(int i)
{
- char *buff = Ptr + str_length;
- sprintf(buff,"%d", i);
- str_length += strlen(buff);
+ char *buff= Ptr + str_length;
+ char *end= int10_to_str(i, buff, -10);
+ str_length+= (int) (end-buff);
}
void String::qs_append(uint i)
{
- char *buff = Ptr + str_length;
- sprintf(buff,"%u", i);
- str_length += strlen(buff);
+ char *buff= Ptr + str_length;
+ char *end= int10_to_str(i, buff, 10);
+ str_length+= (int) (end-buff);
}
/*
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 2f872b2ad05..48e3cb14261 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -208,7 +208,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (!drop_temporary)
{
abort_locked_tables(thd,db,table->table_name);
- while (remove_table_from_cache(thd,db,table->table_name) && !thd->killed)
+ while (remove_table_from_cache(thd, db, table->table_name, 0) &&
+ !thd->killed)
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
@@ -291,7 +292,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
}
- unlock_table_names(thd, tables);
+ unlock_table_names(thd, tables, (TABLE_LIST*) 0);
thd->no_warnings_for_error= 0;
DBUG_RETURN(error);
}
@@ -451,150 +452,151 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
*/
int prepare_create_field(create_field *sql_field,
- uint &blob_columns,
- int &timestamps, int &timestamps_with_niladic,
+ uint *blob_columns,
+ int *timestamps, int *timestamps_with_niladic,
uint table_flags)
{
DBUG_ENTER("prepare_field");
- {
- /* This code came from mysql_prepare_table.
- Indent preserved to make patching easier */
- DBUG_ASSERT(sql_field->charset);
-
- switch (sql_field->sql_type) {
- case FIELD_TYPE_BLOB:
- case FIELD_TYPE_MEDIUM_BLOB:
- case FIELD_TYPE_TINY_BLOB:
- case FIELD_TYPE_LONG_BLOB:
- sql_field->pack_flag=FIELDFLAG_BLOB |
- pack_length_to_packflag(sql_field->pack_length -
- portable_sizeof_char_ptr);
- if (sql_field->charset->state & MY_CS_BINSORT)
- sql_field->pack_flag|=FIELDFLAG_BINARY;
- sql_field->length=8; // Unireg field length
- sql_field->unireg_check=Field::BLOB_FIELD;
- blob_columns++;
- break;
- case FIELD_TYPE_GEOMETRY:
+
+ /*
+ This code came from mysql_prepare_table.
+ Indent preserved to make patching easier
+ */
+ DBUG_ASSERT(sql_field->charset);
+
+ switch (sql_field->sql_type) {
+ case FIELD_TYPE_BLOB:
+ case FIELD_TYPE_MEDIUM_BLOB:
+ case FIELD_TYPE_TINY_BLOB:
+ case FIELD_TYPE_LONG_BLOB:
+ sql_field->pack_flag=FIELDFLAG_BLOB |
+ pack_length_to_packflag(sql_field->pack_length -
+ portable_sizeof_char_ptr);
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ sql_field->length=8; // Unireg field length
+ sql_field->unireg_check=Field::BLOB_FIELD;
+ blob_columns++;
+ break;
+ case FIELD_TYPE_GEOMETRY:
#ifdef HAVE_SPATIAL
- if (!(table_flags & HA_CAN_GEOMETRY))
- {
- my_printf_error(ER_CHECK_NOT_IMPLEMENTED, ER(ER_CHECK_NOT_IMPLEMENTED),
- MYF(0), "GEOMETRY");
- DBUG_RETURN(1);
- }
- sql_field->pack_flag=FIELDFLAG_GEOM |
- pack_length_to_packflag(sql_field->pack_length -
- portable_sizeof_char_ptr);
- if (sql_field->charset->state & MY_CS_BINSORT)
- sql_field->pack_flag|=FIELDFLAG_BINARY;
- sql_field->length=8; // Unireg field length
- sql_field->unireg_check=Field::BLOB_FIELD;
- blob_columns++;
- break;
-#else
- my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0),
- sym_group_geom.name, sym_group_geom.needed_define);
+ if (!(table_flags & HA_CAN_GEOMETRY))
+ {
+ my_printf_error(ER_CHECK_NOT_IMPLEMENTED, ER(ER_CHECK_NOT_IMPLEMENTED),
+ MYF(0), "GEOMETRY");
DBUG_RETURN(1);
+ }
+ sql_field->pack_flag=FIELDFLAG_GEOM |
+ pack_length_to_packflag(sql_field->pack_length -
+ portable_sizeof_char_ptr);
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ sql_field->length=8; // Unireg field length
+ sql_field->unireg_check=Field::BLOB_FIELD;
+ blob_columns++;
+ break;
+#else
+ my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0),
+ sym_group_geom.name, sym_group_geom.needed_define);
+ DBUG_RETURN(1);
#endif /*HAVE_SPATIAL*/
- case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_VARCHAR:
#ifndef QQ_ALL_HANDLERS_SUPPORT_VARCHAR
- if (table_flags & HA_NO_VARCHAR)
- {
- /* convert VARCHAR to CHAR because handler is not yet up to date */
- sql_field->sql_type= MYSQL_TYPE_VAR_STRING;
- sql_field->pack_length= calc_pack_length(sql_field->sql_type,
- (uint) sql_field->length);
- if ((sql_field->length / sql_field->charset->mbmaxlen) >
- MAX_FIELD_CHARLENGTH)
- {
- my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH),
- MYF(0), sql_field->field_name, MAX_FIELD_CHARLENGTH);
- DBUG_RETURN(1);
- }
- }
-#endif
- /* fall through */
- case FIELD_TYPE_STRING:
- sql_field->pack_flag=0;
- if (sql_field->charset->state & MY_CS_BINSORT)
- sql_field->pack_flag|=FIELDFLAG_BINARY;
- break;
- case FIELD_TYPE_ENUM:
- sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
- FIELDFLAG_INTERVAL;
- if (sql_field->charset->state & MY_CS_BINSORT)
- sql_field->pack_flag|=FIELDFLAG_BINARY;
- sql_field->unireg_check=Field::INTERVAL_FIELD;
- check_duplicates_in_interval("ENUM",sql_field->field_name,
- sql_field->interval,
- sql_field->charset);
- break;
- case FIELD_TYPE_SET:
- sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
- FIELDFLAG_BITFIELD;
- if (sql_field->charset->state & MY_CS_BINSORT)
- sql_field->pack_flag|=FIELDFLAG_BINARY;
- sql_field->unireg_check=Field::BIT_FIELD;
- check_duplicates_in_interval("SET",sql_field->field_name,
- sql_field->interval,
- sql_field->charset);
- break;
- case FIELD_TYPE_DATE: // Rest of string types
- case FIELD_TYPE_NEWDATE:
- case FIELD_TYPE_TIME:
- case FIELD_TYPE_DATETIME:
- case FIELD_TYPE_NULL:
- sql_field->pack_flag=f_settype((uint) sql_field->sql_type);
- break;
- case FIELD_TYPE_BIT:
- if (!(table_flags & HA_CAN_BIT_FIELD))
+ if (table_flags & HA_NO_VARCHAR)
+ {
+ /* convert VARCHAR to CHAR because handler is not yet up to date */
+ sql_field->sql_type= MYSQL_TYPE_VAR_STRING;
+ sql_field->pack_length= calc_pack_length(sql_field->sql_type,
+ (uint) sql_field->length);
+ if ((sql_field->length / sql_field->charset->mbmaxlen) >
+ MAX_FIELD_CHARLENGTH)
{
- my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "BIT FIELD");
+ my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH),
+ MYF(0), sql_field->field_name, MAX_FIELD_CHARLENGTH);
DBUG_RETURN(1);
}
- sql_field->pack_flag= FIELDFLAG_NUMBER;
- break;
- case FIELD_TYPE_NEWDECIMAL:
- sql_field->pack_flag=(FIELDFLAG_NUMBER |
- (sql_field->flags & UNSIGNED_FLAG ? 0 :
- FIELDFLAG_DECIMAL) |
- (sql_field->flags & ZEROFILL_FLAG ?
- FIELDFLAG_ZEROFILL : 0) |
- (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
- break;
- case FIELD_TYPE_TIMESTAMP:
- /* We should replace old TIMESTAMP fields with their newer analogs */
- if (sql_field->unireg_check == Field::TIMESTAMP_OLD_FIELD)
+ }
+#endif
+ /* fall through */
+ case FIELD_TYPE_STRING:
+ sql_field->pack_flag=0;
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ break;
+ case FIELD_TYPE_ENUM:
+ sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
+ FIELDFLAG_INTERVAL;
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ sql_field->unireg_check=Field::INTERVAL_FIELD;
+ check_duplicates_in_interval("ENUM",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset);
+ break;
+ case FIELD_TYPE_SET:
+ sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
+ FIELDFLAG_BITFIELD;
+ if (sql_field->charset->state & MY_CS_BINSORT)
+ sql_field->pack_flag|=FIELDFLAG_BINARY;
+ sql_field->unireg_check=Field::BIT_FIELD;
+ check_duplicates_in_interval("SET",sql_field->field_name,
+ sql_field->interval,
+ sql_field->charset);
+ break;
+ case FIELD_TYPE_DATE: // Rest of string types
+ case FIELD_TYPE_NEWDATE:
+ case FIELD_TYPE_TIME:
+ case FIELD_TYPE_DATETIME:
+ case FIELD_TYPE_NULL:
+ sql_field->pack_flag=f_settype((uint) sql_field->sql_type);
+ break;
+ case FIELD_TYPE_BIT:
+ if (!(table_flags & HA_CAN_BIT_FIELD))
+ {
+ my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "BIT FIELD");
+ DBUG_RETURN(1);
+ }
+ sql_field->pack_flag= FIELDFLAG_NUMBER;
+ break;
+ case FIELD_TYPE_NEWDECIMAL:
+ sql_field->pack_flag=(FIELDFLAG_NUMBER |
+ (sql_field->flags & UNSIGNED_FLAG ? 0 :
+ FIELDFLAG_DECIMAL) |
+ (sql_field->flags & ZEROFILL_FLAG ?
+ FIELDFLAG_ZEROFILL : 0) |
+ (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
+ break;
+ case FIELD_TYPE_TIMESTAMP:
+ /* We should replace old TIMESTAMP fields with their newer analogs */
+ if (sql_field->unireg_check == Field::TIMESTAMP_OLD_FIELD)
+ {
+ if (!timestamps)
{
- if (!timestamps)
- {
- sql_field->unireg_check= Field::TIMESTAMP_DNUN_FIELD;
- timestamps_with_niladic++;
- }
- else
- sql_field->unireg_check= Field::NONE;
+ sql_field->unireg_check= Field::TIMESTAMP_DNUN_FIELD;
+ timestamps_with_niladic++;
}
- else if (sql_field->unireg_check != Field::NONE)
- timestamps_with_niladic++;
-
- timestamps++;
- /* fall-through */
- default:
- sql_field->pack_flag=(FIELDFLAG_NUMBER |
- (sql_field->flags & UNSIGNED_FLAG ? 0 :
- FIELDFLAG_DECIMAL) |
- (sql_field->flags & ZEROFILL_FLAG ?
- FIELDFLAG_ZEROFILL : 0) |
- f_settype((uint) sql_field->sql_type) |
- (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
- break;
- }
- if (!(sql_field->flags & NOT_NULL_FLAG))
- sql_field->pack_flag|= FIELDFLAG_MAYBE_NULL;
- if (sql_field->flags & NO_DEFAULT_VALUE_FLAG)
- sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT;
- }
+ else
+ sql_field->unireg_check= Field::NONE;
+ }
+ else if (sql_field->unireg_check != Field::NONE)
+ timestamps_with_niladic++;
+
+ timestamps++;
+ /* fall-through */
+ default:
+ sql_field->pack_flag=(FIELDFLAG_NUMBER |
+ (sql_field->flags & UNSIGNED_FLAG ? 0 :
+ FIELDFLAG_DECIMAL) |
+ (sql_field->flags & ZEROFILL_FLAG ?
+ FIELDFLAG_ZEROFILL : 0) |
+ f_settype((uint) sql_field->sql_type) |
+ (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
+ break;
+ }
+ if (!(sql_field->flags & NOT_NULL_FLAG))
+ sql_field->pack_flag|= FIELDFLAG_MAYBE_NULL;
+ if (sql_field->flags & NO_DEFAULT_VALUE_FLAG)
+ sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT;
DBUG_RETURN(0);
}
@@ -857,8 +859,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
DBUG_ASSERT(sql_field->charset != 0);
- if (prepare_create_field(sql_field, blob_columns,
- timestamps, timestamps_with_niladic,
+ if (prepare_create_field(sql_field, &blob_columns,
+ &timestamps, &timestamps_with_niladic,
file->table_flags()))
DBUG_RETURN(-1);
if (sql_field->sql_type == FIELD_TYPE_BLOB ||
@@ -1765,7 +1767,7 @@ static void wait_while_table_is_used(THD *thd,TABLE *table,
mysql_lock_abort(thd, table); // end threads waiting on lock
/* Wait until all there are no other threads that has this table open */
- while (remove_table_from_cache(thd, table->s->db, table->s->table_name))
+ while (remove_table_from_cache(thd, table->s->db, table->s->table_name, 0))
{
dropping_tables++;
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
@@ -2134,7 +2136,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
"Waiting to get writelock");
mysql_lock_abort(thd,table->table);
while (remove_table_from_cache(thd, table->table->s->db,
- table->table->s->table_name) &&
+ table->table->s->table_name, 0) &&
! thd->killed)
{
dropping_tables++;
@@ -2249,7 +2251,7 @@ send_result_message:
{
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(thd, table->table->s->db,
- table->table->s->table_name);
+ table->table->s->table_name, 0);
pthread_mutex_unlock(&LOCK_open);
/* May be something modified consequently we have to invalidate cache */
query_cache_invalidate3(thd, table->table, 0);
@@ -3558,7 +3560,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (table)
{
VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Use new file
- remove_table_from_cache(thd,db,table_name); // Mark all in-use copies old
+ remove_table_from_cache(thd,db,table_name, 0); // Mark in-use copies old
mysql_lock_abort(thd,table); // end threads waiting on lock
}
VOID(quick_rm_table(old_db_type,db,old_name));
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 477a283448a..e215141ff0a 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -229,7 +229,7 @@ int mysql_update(THD *thd,
// Don't count on usage of 'only index' when calculating which key to use
table->used_keys.clear_all();
- select=make_select(table,0,0,conds,&error);
+ select= make_select(table, 0, 0, conds, 0, &error);
if (error ||
(select && select->check_quick(thd, safe_update, limit)) || !limit)
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 56dd6409eba..cb247f900d8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1386,14 +1386,18 @@ create_function_tail:
uint unused1= 0;
int unused2= 0;
- if (!(new_field= new_create_field(YYTHD, "", (enum enum_field_types)$8,
- lex->length, lex->dec, lex->type,
- (Item *)0, (Item *) 0, &cmt, 0, &lex->interval_list,
- (lex->charset ? lex->charset : default_charset_info),
- lex->uint_geom_type)))
+ if (!(new_field= new_create_field(YYTHD, "",
+ (enum enum_field_types)$8,
+ lex->length, lex->dec, lex->type,
+ (Item *)0, (Item *) 0, &cmt, 0,
+ &lex->interval_list,
+ (lex->charset ? lex->charset :
+ default_charset_info),
+ lex->uint_geom_type)))
YYABORT;
- if (prepare_create_field(new_field, unused1, unused2, unused2, 0))
+ if (prepare_create_field(new_field, &unused1, &unused2, &unused2,
+ 0))
YYABORT;
sp->m_returns= new_field->sql_type;