summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc7
-rw-r--r--sql/filesort.cc1
-rw-r--r--sql/ha_berkeley.cc1
-rw-r--r--sql/ha_innodb.cc1
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item_cmpfunc.cc1
-rw-r--r--sql/item_func.cc1
-rw-r--r--sql/item_row.cc1
-rw-r--r--sql/item_strfunc.cc6
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/lex.h2
-rw-r--r--sql/lock.cc3
-rw-r--r--sql/log.cc1
-rw-r--r--sql/log_event.cc8
-rw-r--r--sql/mf_iocache.cc1
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc1
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/password.c14
-rw-r--r--sql/protocol.cc1
-rw-r--r--sql/set_var.cc4
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/spatial.cc3
-rw-r--r--sql/sql_acl.cc1
-rw-r--r--sql/sql_base.cc1
-rw-r--r--sql/sql_cache.cc1
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_handler.cc1
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_lex.cc5
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_parse.cc1
-rw-r--r--sql/sql_prepare.cc1
-rw-r--r--sql/sql_repl.cc1
-rw-r--r--sql/sql_select.cc101
-rw-r--r--sql/sql_string.cc4
-rw-r--r--sql/sql_string.h2
-rw-r--r--sql/sql_table.cc1
-rw-r--r--sql/sql_yacc.yy13
40 files changed, 102 insertions, 108 deletions
diff --git a/sql/field.cc b/sql/field.cc
index a0fd8c12f9d..00bb409e82e 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2053,7 +2053,8 @@ String *Field_longlong::val_str(String *val_buffer,
#endif
longlongget(j,ptr);
- length=(uint) cs->longlong10_to_str(cs,to,mlength,unsigned_flag ? 10 : -10, j);
+ length=(uint) (cs->longlong10_to_str)(cs,to,mlength,
+ unsigned_flag ? 10 : -10, j);
val_buffer->length(length);
if (zerofill)
prepend_zeros(val_buffer);
@@ -3928,7 +3929,7 @@ int Field_string::store(longlong nr)
char buff[64];
int l;
CHARSET_INFO *cs=charset();
- l=cs->longlong10_to_str(cs,buff,sizeof(buff),-10,nr);
+ l= (cs->longlong10_to_str)(cs,buff,sizeof(buff),-10,nr);
return Field_string::store(buff,(uint)l,cs);
}
@@ -4095,7 +4096,7 @@ int Field_varstring::store(longlong nr)
char buff[64];
int l;
CHARSET_INFO *cs=charset();
- l=cs->longlong10_to_str(cs,buff,sizeof(buff),-10,nr);
+ l= (cs->longlong10_to_str)(cs,buff,sizeof(buff),-10,nr);
return Field_varstring::store(buff,(uint)l,cs);
}
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 00ef12839cf..0e0b2c8f33a 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -23,7 +23,6 @@
#endif
#include <m_ctype.h>
#include "sql_sort.h"
-#include "assert.h"
#ifndef THREAD
#define SKIP_DBUG_IN_FILESORT
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 6d2538279d9..cdb5a8c1219 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -55,7 +55,6 @@
#ifdef HAVE_BERKELEY_DB
#include <m_ctype.h>
#include <myisampack.h>
-#include <assert.h>
#include <hash.h>
#include "ha_berkeley.h"
#include "sql_manager.h"
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 6e2b08005df..c639431c0fa 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -32,7 +32,6 @@ InnoDB */
#ifdef HAVE_INNOBASE_DB
#include <m_ctype.h>
-#include <assert.h>
#include <hash.h>
#include <myisampack.h>
diff --git a/sql/item.cc b/sql/item.cc
index 53f63a977e0..6ae9b92295f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -22,7 +22,6 @@
#include "mysql_priv.h"
#include <m_ctype.h>
#include "my_dir.h"
-#include <assert.h>
/*****************************************************************************
** Item functions
@@ -1058,7 +1057,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
break;
if ((tmp= find_field_in_tables(thd, this,
sl->get_table_list(), &where,
- 0)) != not_found_field);
+ 0)) != not_found_field)
+ break;
if (sl->master_unit()->first_select()->linkage ==
DERIVED_TABLE_TYPE)
break; // do not look over derived table
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 83d05cf5398..1c579708503 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -23,7 +23,6 @@
#include "mysql_priv.h"
#include <m_ctype.h>
-#include "assert.h"
Item_bool_func2* Item_bool_func2::eq_creator(Item *a, Item *b)
{
return new Item_func_eq(a, b);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 6612f61b4a1..477b759be61 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -28,7 +28,6 @@
#include <time.h>
#include <ft_global.h>
#include <zlib.h>
-#include <assert.h>
/* return TRUE if item is a constant */
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 355228e45df..0c060b6d8db 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h"
-#include "assert.h"
Item_row::Item_row(List<Item> &arg):
Item(), used_tables_cache(0), array_holder(1), const_item_cache(1)
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index f9bda911eaf..66f0510cc3d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1321,12 +1321,14 @@ String *Item_func_password::val_str(String *str)
char* seed_ptr=key->c_ptr();
while (*seed_ptr)
{
- seed=seed*211+*seed_ptr; /* Use simple hashing */
+ seed=(seed*211+*seed_ptr) & 0xffffffffL; /* Use simple hashing */
seed_ptr++;
}
/* Use constants which allow nice random values even with small seed */
- randominit(&rand_st,seed*111111+33333333L,seed*1111+55555555L);
+ randominit(&rand_st,
+ (ulong) ((ulonglong) seed*111111+33333333L) & (ulong) 0xffffffff,
+ (ulong) ((ulonglong) seed*1111+55555555L) & (ulong) 0xffffffff);
make_scrambled_password(tmp_value,res->c_ptr(),use_old_passwords,
&rand_st);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index c5ecdc87d40..4ee851c2f84 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -494,7 +494,7 @@ void Item_in_subselect::single_value_transformer(THD *thd,
else
{
sl->item_list.empty();
- sl->item_list.push_back(new Item_int(1));
+ sl->item_list.push_back(new Item_int("Not_used", (longlong) 1, 21));
if (sl->table_list.elements)
{
item= (*func)(expr, new Item_asterisk_remover(this, item,
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 570f1e50922..273c5a3c1c3 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -22,7 +22,7 @@
#endif
#include "mysql_priv.h"
-#include "assert.h"
+
Item_sum::Item_sum(List<Item> &list)
{
arg_count=list.elements;
diff --git a/sql/lex.h b/sql/lex.h
index a505911ccf6..b17d3313c3f 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -136,7 +136,7 @@ static SYMBOL symbols[] = {
{ "DROP", SYM(DROP),0,0},
{ "DUMPFILE", SYM(DUMPFILE),0,0},
{ "DYNAMIC", SYM(DYNAMIC_SYM),0,0},
- { "DUPLICATE", SYM(DUPLICATE),0,0},
+ { "DUPLICATE", SYM(DUPLICATE_SYM),0,0},
{ "ERRORS", SYM(ERRORS),0,0},
{ "END", SYM(END),0,0},
{ "ELSE", SYM(ELSE),0,0},
diff --git a/sql/lock.cc b/sql/lock.cc
index 74d1109b203..8f342b28d67 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -68,8 +68,7 @@ TODO:
#include "mysql_priv.h"
#include <hash.h>
-#include <assert.h>
-#include <ha_myisammrg.h>
+#include "ha_myisammrg.h"
#ifndef MASTER
#include "../srclib/myisammrg/myrg_def.h"
#else
diff --git a/sql/log.cc b/sql/log.cc
index f14bbae2543..b0e904969e7 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -29,7 +29,6 @@
#include <my_dir.h>
#include <stdarg.h>
#include <m_ctype.h> // For test_if_number
-#include <assert.h>
#define files_charset_info my_charset_latin1
diff --git a/sql/log_event.cc b/sql/log_event.cc
index bf32aec91fb..509e62ba03b 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -24,8 +24,6 @@
#include <my_dir.h>
#endif /* MYSQL_CLIENT */
-#include <assert.h>
-
#define log_cs my_charset_latin1
/*****************************************************************************
@@ -1660,7 +1658,7 @@ void Rotate_log_event::pack_info(Protocol *protocol)
memcpy(buf, new_log_ident, ident_len);
b_pos+= ident_len;
b_pos= strmov(b_pos, ";pos=");
- b_pos=int10_to_str(pos, b_pos, 10);
+ b_pos=longlong10_to_str(pos, b_pos, 10);
if (flags & LOG_EVENT_FORCED_ROTATE_F)
b_pos= strmov(b_pos ,"; forced by master");
protocol->store(buf, b_pos-buf);
@@ -1797,7 +1795,7 @@ void Intvar_log_event::pack_info(Protocol *protocol)
char buf[64], *pos;
pos= strmov(buf, get_var_type_name());
*(pos++)='=';
- pos=int10_to_str(val, pos, -10);
+ pos= longlong10_to_str(val, pos, -10);
protocol->store(buf, pos-buf);
}
#endif
@@ -2010,7 +2008,7 @@ void Slave_log_event::pack_info(Protocol *protocol)
pos= strmov(pos, ",log=");
pos= strmov(pos, master_log);
pos= strmov(pos, ",pos=");
- pos= int10_to_str(master_pos, pos, 10);
+ pos= longlong10_to_str(master_pos, pos, 10);
protocol->store(buf, pos-buf);
}
#endif // !MYSQL_CLIENT
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index e7e72617c83..4b0575c8579 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -38,7 +38,6 @@
#include <errno.h>
static void my_aiowait(my_aio_result *result);
#endif
-#include <assert.h>
extern "C" {
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7a354ef5ff1..feb6675e787 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -24,6 +24,7 @@
#include <thr_lock.h>
#include <my_base.h> /* Needed by field.h */
#include <my_bitmap.h>
+#include <assert.h>
#ifdef __EMX__
#undef write /* remove pthread.h macro definition for EMX */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 85d088f8173..3b34f111e8d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -32,7 +32,6 @@
#include <nisam.h>
#include <thr_alarm.h>
#include <ft_global.h>
-#include <assert.h>
#define mysqld_charset my_charset_latin1
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 43066a29624..33309d35157 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -33,8 +33,6 @@
#include <m_ctype.h>
#include <nisam.h>
#include "sql_select.h"
-#include <assert.h>
-
#ifndef EXTRA_DEBUG
#define test_rb_tree(A,B) {}
diff --git a/sql/password.c b/sql/password.c
index 9b6189a161c..37040c20683 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -151,11 +151,8 @@ void create_random_string(int length,struct rand_struct *rand_st,char* target)
{
char* end=target+length;
/* Use pointer arithmetics as it is faster way to do so. */
- while (target<end)
- {
- *target=rnd(rand_st)*94+33;
- target++;
- }
+ for (; target<end ; target++)
+ *target= (char) (rnd(rand_st)*94+33);
}
@@ -296,7 +293,7 @@ void make_scrambled_password(char *to,const char *password,
{
to[0]=PVERSION41_CHAR; /* New passwords have version prefix */
/* Rnd returns number from 0 to 1 so this would be good salt generation.*/
- salt=rnd(rand_st)*65535+1;
+ salt=(unsigned short) (rnd(rand_st)*65535+1);
/* Use only 2 first bytes from it */
sprintf(to+1,"%04x",salt);
/* First hasing is done without salt */
@@ -556,7 +553,7 @@ void get_hash_and_password(ulong* salt, uint8 pversion, char* hash, unsigned cha
val=*(++salt);
for (t=3; t>=0; t--)
{
- bin_password[t]=val & 255;
+ bin_password[t]= (char) (val & 255);
val>>=8; /* Scroll 8 bits to get next part*/
}
bin_password+=4; /* Get to next 4 chars*/
@@ -575,8 +572,7 @@ void get_hash_and_password(ulong* salt, uint8 pversion, char* hash, unsigned cha
val=*salt;
for (t=3;t>=0;t--)
{
- bp[t]=val%256;
-
+ bp[t]= (uchar) (val & 255);
val>>=8; /* Scroll 8 bits to get next part*/
}
bp+=4; /* Get to next 4 chars*/
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 1fb7e85f877..d0d6a75214b 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -25,7 +25,6 @@
#include "mysql_priv.h"
#include <stdarg.h>
-#include <assert.h>
#ifndef EMBEDDED_LIBRARY
bool Protocol::net_store_data(const char *from, uint length)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 9208cf2eddd..cd02010c499 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -953,7 +953,7 @@ err:
bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{
- char buff[80], *value, *error= 0;
+ char buff[80], *error= 0;
uint error_len= 0;
String str(buff, sizeof(buff), system_charset_info), *res;
@@ -961,7 +961,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{
if (!(res= var->value->val_str(&str)))
goto err;
- (long) var->save_result.ulong_value= (ulong)
+ var->save_result.ulong_value= (ulong)
find_set(enum_names, res->c_ptr(), res->length(), &error, &error_len);
if (error_len)
{
diff --git a/sql/slave.cc b/sql/slave.cc
index bb53461a120..4572a265294 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -26,8 +26,6 @@
#include "repl_failsafe.h"
#include <thr_alarm.h>
#include <my_dir.h>
-#include <assert.h>
-
bool use_slave_mask = 0;
MY_BITMAP slave_error_mask;
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 5c6be3c221c..42dd74a697a 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -66,7 +66,8 @@ Geometry::GClassInfo *Geometry::find_class(const char *name, size_t len)
cur_rt < ci_collection_end; ++cur_rt)
{
if ((cur_rt->m_name[len] == 0) &&
- (strncasecmp(cur_rt->m_name, name, len) == 0))
+ (default_charset_info->strncasecmp(default_charset_info,
+ cur_rt->m_name, name, len) == 0))
{
return cur_rt;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 93f2dda1283..645d0439961 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -29,7 +29,6 @@
#include "sql_acl.h"
#include "hash_filo.h"
#include <m_ctype.h>
-#include <assert.h>
#include <stdarg.h>
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 16c71b437d2..847617d6462 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -24,7 +24,6 @@
#include <my_dir.h>
#include <hash.h>
#include <nisam.h>
-#include <assert.h>
#ifdef __WIN__
#include <io.h>
#endif
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index ef763bbeffe..df06bcfd5c0 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -307,7 +307,6 @@ TODO list:
#else
#include "../myisammrg/myrg_def.h"
#endif
-#include <assert.h>
#if defined(EXTRA_DEBUG) && !defined(DBUG_OFF)
#define MUTEX_LOCK(M) { DBUG_PRINT("lock", ("mutex lock 0x%lx", (ulong)(M))); \
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 95adcc4d974..0b6da3d9bcd 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -35,7 +35,6 @@
#include <io.h>
#endif
#include <mysys_err.h>
-#include <assert.h>
/*****************************************************************************
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index acf3fd2914a..ea5c07048ab 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -19,7 +19,6 @@
#include "mysql_priv.h"
#include "sql_select.h"
-#include <assert.h>
/* TODO:
HANDLER blabla OPEN [ AS foobar ] [ (column-list) ]
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 013101a0ecc..2bac815d12a 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -382,7 +382,7 @@ int mysqld_help(THD *thd, const char *mask)
if ((res= send_header_2(protocol)) ||
(count==0 &&
(search_categories(thd, 0, &categories_list, 0)<0 &&
- (res= 1))) ||
+ ((res= 1)))) ||
(res= send_variant_2_list(protocol,&categories_list,true)))
goto end;
}
@@ -396,7 +396,7 @@ int mysqld_help(THD *thd, const char *mask)
else if ((res= send_header_2(protocol)) ||
(res= send_variant_2_list(protocol,&function_list,false)) ||
(search_categories(thd, mask, &categories_list, 0)<0 &&
- (res=1)) ||
+ ((res=1))) ||
(res= send_variant_2_list(protocol,&categories_list,true)))
{
goto end;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e4fc3a5aec3..716e37b5cb7 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -21,7 +21,6 @@
#include "item_create.h"
#include <m_ctype.h>
#include <hash.h>
-#include <assert.h>
LEX_STRING tmp_table_alias= {(char*) "tmp-table",8};
@@ -235,7 +234,9 @@ static LEX_STRING get_quoted_token(LEX *lex,uint length, char quote)
yyUnget(); // ptr points now after last token char
tmp.length=lex->yytoklen=length;
tmp.str=(char*) lex->thd->alloc(tmp.length+1);
- for (from= (byte*) lex->tok_start, to= tmp.str, end= to+length ; to != end ;)
+ for (from= (byte*) lex->tok_start, to= (byte*) tmp.str, end= to+length ;
+ to != end ;
+ )
{
if ((*to++= *from++) == quote)
from++; // Skip double quotes
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 9fc00e5f56d..85a171e9fe4 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -303,7 +303,7 @@ public:
st_select_lex* outer_select();
st_select_lex* first_select() { return (st_select_lex*) slave; }
st_select_lex_unit* next_unit() { return (st_select_lex_unit*) next; }
- void st_select_lex_unit::exclude_level();
+ void exclude_level();
/* UNION methods */
int prepare(THD *thd, select_result *result);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 0c9ad2d6935..d5deabf606b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -21,7 +21,6 @@
#include <m_ctype.h>
#include <myisam.h>
#include <my_dir.h>
-#include <assert.h>
#define files_charset_info system_charset_info
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 0e1cdbe824f..e8ba7e91c7b 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -71,7 +71,6 @@ Long data handling:
#include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_select.h" // for JOIN
-#include <assert.h> // for DEBUG_ASSERT()
#include <m_ctype.h> // for isspace()
#define IS_PARAM_NULL(pos, param_no) pos[param_no/8] & (1 << param_no & 7)
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index a4a1cbd4ad6..522ec9f6aeb 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -24,7 +24,6 @@
#include "log_event.h"
#include "mini_client.h"
#include <my_dir.h>
-#include <assert.h>
extern const char* any_db;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a614b4d3fad..f758fef4fc9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@
#include <m_ctype.h>
#include <hash.h>
#include <ft_global.h>
-#include <assert.h>
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext" };
@@ -1258,7 +1257,6 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
table_map found_const_table_map,all_table_map;
TABLE **table_vector;
JOIN_TAB *stat,*stat_end,*s,**stat_ref;
- SQL_SELECT *select;
KEYUSE *keyuse,*start_keyuse;
table_map outer_join=0;
JOIN_TAB *stat_vector[MAX_TABLES+1];
@@ -1270,7 +1268,6 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
table_vector=(TABLE**) join->thd->alloc(sizeof(TABLE*)*(table_count*2));
if (!stat || !stat_ref || !table_vector)
DBUG_RETURN(1); // Eom /* purecov: inspected */
- select=0;
join->best_ref=stat_vector;
@@ -1454,7 +1451,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
{ // Found everything for ref.
int tmp;
ref_changed = 1;
- s->type=JT_CONST;
+ s->type= JT_CONST;
join->const_table_map|=table->map;
set_position(join,const_count++,s,start_keyuse);
if (create_ref_for_key(join, s, start_keyuse,
@@ -1505,23 +1502,44 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
if (s->const_keys)
{
ha_rows records;
- if (!select)
- select=make_select(s->table, found_const_table_map,
- found_const_table_map,
- and_conds(conds,s->on_expr),&error);
- records=get_quick_record_count(select,s->table, s->const_keys,
- join->row_limit);
+ SQL_SELECT *select;
+ select= make_select(s->table, found_const_table_map,
+ found_const_table_map,
+ s->on_expr ? s->on_expr : conds,
+ &error);
+ records= get_quick_record_count(select,s->table, s->const_keys,
+ join->row_limit);
s->quick=select->quick;
s->needed_reg=select->needed_reg;
select->quick=0;
+ if (records == 0 && s->table->reginfo.impossible_range)
+ {
+ /*
+ Impossible WHERE or ON expression
+ In case of ON, we mark that the we match one empty NULL row.
+ In case of WHERE, don't set found_const_table_map to get the
+ caller to abort with a zero row result.
+ */
+ join->const_table_map|= s->table->map;
+ set_position(join,const_count++,s,(KEYUSE*) 0);
+ s->type= JT_CONST;
+ if (s->on_expr)
+ {
+ /* Generate empty row */
+ s->info= "Impossible ON condition";
+ found_const_table_map|= s->table->map;
+ s->type= JT_CONST;
+ mark_as_null_row(s->table); // All fields are NULL
+ }
+ }
if (records != HA_POS_ERROR)
{
s->found_records=records;
s->read_time= (ha_rows) (s->quick ? s->quick->read_time : 0.0);
}
+ delete select;
}
}
- delete select;
/* Find best combination and return it */
join->join_tab=stat;
@@ -2617,7 +2635,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
keyparts != keyinfo->key_parts)
j->type=JT_REF; /* Must read with repeat */
else if (ref_key == j->ref.key_copy)
- { /* Should never be reached */
+ {
/*
This happen if we are using a constant expression in the ON part
of an LEFT JOIN.
@@ -7736,37 +7754,40 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
if (tab->info)
item_list.push_back(new Item_string(tab->info,strlen(tab->info),
default_charset_info));
- else if (tab->select)
+ else
{
- if (tab->use_quick == 2)
+ if (tab->select)
{
- sprintf(buff_ptr,"; Range checked for each record (index map: %u)",
- tab->keys);
- buff_ptr=strend(buff_ptr);
+ if (tab->use_quick == 2)
+ {
+ sprintf(buff_ptr,"; Range checked for each record (index map: %u)",
+ tab->keys);
+ buff_ptr=strend(buff_ptr);
+ }
+ else
+ buff_ptr=strmov(buff_ptr,"; Using where");
}
- else
- buff_ptr=strmov(buff_ptr,"; Using where");
- }
- if (key_read)
- buff_ptr= strmov(buff_ptr,"; Using index");
- if (table->reginfo.not_exists_optimize)
- buff_ptr= strmov(buff_ptr,"; Not exists");
- if (need_tmp_table)
- {
- need_tmp_table=0;
- buff_ptr= strmov(buff_ptr,"; Using temporary");
- }
- if (need_order)
- {
- need_order=0;
- buff_ptr= strmov(buff_ptr,"; Using filesort");
+ if (key_read)
+ buff_ptr= strmov(buff_ptr,"; Using index");
+ if (table->reginfo.not_exists_optimize)
+ buff_ptr= strmov(buff_ptr,"; Not exists");
+ if (need_tmp_table)
+ {
+ need_tmp_table=0;
+ buff_ptr= strmov(buff_ptr,"; Using temporary");
+ }
+ if (need_order)
+ {
+ need_order=0;
+ buff_ptr= strmov(buff_ptr,"; Using filesort");
+ }
+ if (distinct & test_all_bits(used_tables,thd->used_tables))
+ buff_ptr= strmov(buff_ptr,"; Distinct");
+ if (buff_ptr == buff)
+ buff_ptr+= 2; // Skip inital "; "
+ item_list.push_back(new Item_string(buff+2,(uint) (buff_ptr - buff)-2,
+ default_charset_info));
}
- if (distinct & test_all_bits(used_tables,thd->used_tables))
- buff_ptr= strmov(buff_ptr,"; Distinct");
- if (buff_ptr == buff)
- buff_ptr+= 2; // Skip inital "; "
- item_list.push_back(new Item_string(buff+2,(uint) (buff_ptr - buff)-2,
- default_charset_info));
// For next iteration
used_tables|=table->map;
if (result->send_data(item_list))
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 646621ac2eb..0d604d043cc 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -100,7 +100,7 @@ bool String::set(longlong num, CHARSET_INFO *cs)
if (alloc(l))
return TRUE;
- str_length=(uint32) cs->longlong10_to_str(cs,Ptr,l,-10,num);
+ str_length=(uint32) (cs->longlong10_to_str)(cs,Ptr,l,-10,num);
str_charset=cs;
return FALSE;
}
@@ -111,7 +111,7 @@ bool String::set(ulonglong num, CHARSET_INFO *cs)
if (alloc(l))
return TRUE;
- str_length=(uint32) cs->longlong10_to_str(cs,Ptr,l,10,num);
+ str_length=(uint32) (cs->longlong10_to_str)(cs,Ptr,l,10,num);
str_charset=cs;
return FALSE;
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index ad91b20f18c..6d54373f642 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -115,7 +115,7 @@ public:
Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
str_charset=cs;
}
- bool String::set_latin1(const char *str, uint32 arg_length);
+ bool set_latin1(const char *str, uint32 arg_length);
inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs)
{
if (!alloced)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f4642870af3..3f443c34287 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -23,7 +23,6 @@
#endif
#include <hash.h>
#include <myisam.h>
-#include <assert.h>
#ifdef __WIN__
#include <io.h>
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index f6743c868fe..d603748c443 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -208,7 +208,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token DES_KEY_FILE
%token DISABLE_SYM
%token DISTINCT
-%token DUPLICATE
+%token DUPLICATE_SYM
%token DYNAMIC_SYM
%token ENABLE_SYM
%token ENCLOSED
@@ -3183,7 +3183,7 @@ expr_or_default:
opt_insert_update:
/* empty */
- | ON DUPLICATE
+ | ON DUPLICATE_SYM
{ /* for simplisity, let's forget about
INSERT ... SELECT ... UPDATE
for a moment */
@@ -3872,8 +3872,9 @@ keyword:
| DES_KEY_FILE {}
| DIRECTORY_SYM {}
| DO_SYM {}
- | DUMPFILE {}
| DUAL_SYM {}
+ | DUMPFILE {}
+ | DUPLICATE_SYM {}
| DYNAMIC_SYM {}
| END {}
| ENUM {}
@@ -4571,11 +4572,7 @@ optional_order_or_limit:
{
THD *thd= YYTHD;
LEX *lex= &thd->lex;
- if (!lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
- {
- send_error(lex->thd, ER_SYNTAX_ERROR);
- YYABORT;
- }
+ DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
SELECT_LEX *sel= lex->current_select->select_lex();
sel->master_unit()->global_parameters=
sel->master_unit();