summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/examples/ha_archive.cc11
-rw-r--r--sql/field.cc9
-rw-r--r--sql/item.h3
-rw-r--r--sql/item_strfunc.cc12
-rw-r--r--sql/sql_cache.cc2
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_lex.h3
-rw-r--r--sql/sql_list.h4
-rw-r--r--sql/sql_parse.cc9
-rw-r--r--sql/sql_string.h2
-rw-r--r--sql/sql_yacc.yy30
-rw-r--r--sql/table.cc1
12 files changed, 64 insertions, 24 deletions
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc
index b33b5102e69..ccc3ef713b8 100644
--- a/sql/examples/ha_archive.cc
+++ b/sql/examples/ha_archive.cc
@@ -115,6 +115,8 @@
data - The data is stored in a "row +blobs" format.
*/
+/* If the archive storage engine has been inited */
+static bool archive_inited= 0;
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
static HASH archive_open_tables;
@@ -158,6 +160,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
bool archive_db_init()
{
+ archive_inited= 1;
VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST));
return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) archive_get_key, 0, 0));
@@ -177,8 +180,12 @@ bool archive_db_init()
bool archive_db_end()
{
- hash_free(&archive_open_tables);
- VOID(pthread_mutex_destroy(&archive_mutex));
+ if (archive_inited)
+ {
+ hash_free(&archive_open_tables);
+ VOID(pthread_mutex_destroy(&archive_mutex));
+ }
+ archive_inited= 0;
return FALSE;
}
diff --git a/sql/field.cc b/sql/field.cc
index f51b06028f7..c1520653084 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2432,6 +2432,13 @@ void Field_medium::sql_type(String &res) const
** long int
****************************************************************************/
+static bool test_if_minus(CHARSET_INFO *cs,
+ const char *s, const char *e)
+{
+ my_wc_t wc;
+ return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-';
+}
+
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
@@ -2734,7 +2741,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
from+= tmp;
if (unsigned_flag)
{
- if (!len || *from == '-')
+ if (!len || test_if_minus(cs, from, from + len))
{
tmp=0; // Set negative to 0
error= 1;
diff --git a/sql/item.h b/sql/item.h
index e2e72dbee40..299bc6c081b 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -121,8 +121,7 @@ public:
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); }
- static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root)
- { TRASH(ptr, size); }
+ static void operator delete(void *ptr, MEM_ROOT *mem_root) {}
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 02f33d39465..091de8e3a01 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1665,7 +1665,8 @@ String *Item_func_format::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
double nr= args[0]->val_real();
- uint32 diff,length,str_length;
+ int diff;
+ uint32 length, str_length;
uint dec;
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
@@ -1690,9 +1691,12 @@ String *Item_func_format::val_str(String *str)
pos[0]= pos[-(int) diff];
while (diff)
{
- pos[0]=pos[-(int) diff]; pos--;
- pos[0]=pos[-(int) diff]; pos--;
- pos[0]=pos[-(int) diff]; pos--;
+ *pos= *(pos - diff);
+ pos--;
+ *pos= *(pos - diff);
+ pos--;
+ *pos= *(pos - diff);
+ pos--;
pos[0]=',';
pos--;
diff--;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index e38e417e6df..b2f7922f1db 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1438,7 +1438,7 @@ ulong Query_cache::init_cache()
init();
approx_additional_data_size = (sizeof(Query_cache) +
sizeof(gptr)*(def_query_hash_size+
- def_query_hash_size));
+ def_table_hash_size));
if (query_cache_size < approx_additional_data_size)
goto err;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 32c9e2a50f7..0dae2d37062 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -767,6 +767,8 @@ struct Item_change_record: public ilink
Item *old_value;
/* Placement new was hidden by `new' in ilink (TODO: check): */
static void *operator new(size_t size, void *mem) { return mem; }
+ static void operator delete(void *ptr, size_t size) {}
+ static void operator delete(void *ptr, void *mem) { /* never called */ }
};
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 5d232d60e79..2dd885c3658 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -285,8 +285,7 @@ public:
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); }
- static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root)
- { TRASH(ptr, size); }
+ static void operator delete(void *ptr, MEM_ROOT *mem_root) {}
st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
virtual ~st_select_lex_node() {}
inline st_select_lex_node* get_master() { return master; }
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 85da553f64a..55d9d668bdd 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -35,8 +35,8 @@ public:
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); }
- static void operator delete(void *ptr, size_t size, MEM_ROOT *mem_root)
- { TRASH(ptr, size); }
+ static void operator delete(void *ptr, MEM_ROOT *mem_root)
+ { /* never called */ }
static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); }
#ifdef HAVE_purify
bool dummy;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 0a0258465fb..03aa640a139 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -708,12 +708,12 @@ static int check_connection(THD *thd)
{
uint connect_errors= 0;
NET *net= &thd->net;
+ ulong pkt_len= 0;
+ char *end;
DBUG_PRINT("info",
("New connection received on %s", vio_description(net->vio)));
- vio_in_addr(net->vio,&thd->remote.sin_addr);
-
if (!thd->host) // If TCP/IP connection
{
char ip[30];
@@ -723,6 +723,7 @@ static int check_connection(THD *thd)
if (!(thd->ip= my_strdup(ip,MYF(0))))
return (ER_OUT_OF_RESOURCES);
thd->host_or_ip= thd->ip;
+ vio_in_addr(net->vio,&thd->remote.sin_addr);
#if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread)
/* Fast local hostname resolve for Win32 */
if (!strcmp(thd->ip,"127.0.0.1"))
@@ -758,10 +759,10 @@ static int check_connection(THD *thd)
DBUG_PRINT("info",("Host: %s",thd->host));
thd->host_or_ip= thd->host;
thd->ip= 0;
+ /* Reset sin_addr */
+ bzero((char*) &thd->remote, sizeof(thd->remote));
}
vio_keepalive(net->vio, TRUE);
- ulong pkt_len= 0;
- char *end;
{
/* buff[] needs to big enough to hold the server_version variable */
char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64];
diff --git a/sql/sql_string.h b/sql/sql_string.h
index a5c7cf77630..f9f0b1b6242 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -73,7 +73,7 @@ public:
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr_arg,size_t size)
{ TRASH(ptr_arg, size); }
- static void operator delete(void *ptr_arg,size_t size, MEM_ROOT *mem_root)
+ static void operator delete(void *ptr_arg, MEM_ROOT *mem_root)
{ TRASH(ptr_arg, size); }
~String() { free(); }
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c4649c57269..37e1ef70b84 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3811,7 +3811,10 @@ select:
select_init:
SELECT_SYM select_init2
|
- '(' SELECT_SYM select_part2 ')'
+ '(' select_paren ')' union_opt;
+
+select_paren:
+ SELECT_SYM select_part2
{
LEX *lex= Lex;
SELECT_LEX * sel= lex->current_select;
@@ -3830,7 +3833,8 @@ select_init:
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
sel->master_unit()->fake_select_lex;
- } union_opt;
+ }
+ | '(' select_paren ')';
select_init2:
select_part2
@@ -4990,7 +4994,7 @@ table_factor:
}
| '{' ident table_ref LEFT OUTER JOIN_SYM table_ref ON expr '}'
{ add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; }
- | '(' SELECT_SYM select_derived ')' opt_table_alias
+ | '(' select_derived union_opt ')' opt_table_alias
{
LEX *lex=Lex;
SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
@@ -5004,6 +5008,24 @@ table_factor:
lex->current_select->add_joined_table($$);
};
+
+select_derived:
+ SELECT_SYM select_derived2
+ | '(' select_derived ')'
+ {
+ SELECT_LEX *sel= Select;
+ if (sel->set_braces(1))
+ {
+ yyerror(ER(ER_SYNTAX_ERROR));
+ YYABORT;
+ }
+ /* select in braces, can't contain global parameters */
+ if (sel->master_unit()->fake_select_lex)
+ sel->master_unit()->global_parameters=
+ sel->master_unit()->fake_select_lex;
+ }
+ ;
+
select_derived:
{
LEX *lex= Lex;
@@ -5026,7 +5048,7 @@ select_derived:
{
Select->parsing_place= NO_MATTER;
}
- opt_select_from union_opt
+ opt_select_from
;
opt_outer:
diff --git a/sql/table.cc b/sql/table.cc
index a78d245ba9d..69a132329c0 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -661,7 +661,6 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
if (!(field->flags & BINARY_FLAG))
keyinfo->flags|= HA_END_SPACE_KEY;
}
- set_if_bigger(share->max_key_length, keyinfo->key_length);
if (field->type() == MYSQL_TYPE_BIT)
key_part->key_part_flag|= HA_BIT_PART;