summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-02-26 15:28:07 +0100
committerSergei Golubchik <sergii@pisem.net>2014-02-26 15:28:07 +0100
commit0dc23679c867629ded5f9534d2ab6e8edf238aa0 (patch)
tree9cf966507fa2ef0fd17932b600d051df5f7bd2e5 /sql
parent6efa5efa7dd112b6ac2efdd84235a13cca51c4d4 (diff)
parent0b9a0a3517ca2b75655f3af5c372cf333d3d5fe2 (diff)
downloadmariadb-git-0dc23679c867629ded5f9534d2ab6e8edf238aa0.tar.gz
10.0-base merge
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt2
-rw-r--r--sql/custom_conf.h3
-rw-r--r--sql/event_scheduler.cc2
-rw-r--r--sql/event_scheduler.h2
-rw-r--r--sql/events.cc2
-rw-r--r--sql/events.h2
-rw-r--r--sql/field.h16
-rw-r--r--sql/filesort.cc133
-rw-r--r--sql/ha_ndbcluster_cond.cc2
-rw-r--r--sql/ha_ndbcluster_cond.h2
-rw-r--r--sql/ha_ndbcluster_tables.h3
-rw-r--r--sql/ha_partition.cc74
-rw-r--r--sql/hostname.cc4
-rw-r--r--sql/item.cc46
-rw-r--r--sql/item.h7
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_func.h4
-rw-r--r--sql/item_geofunc.cc6
-rw-r--r--sql/item_strfunc.cc28
-rw-r--r--sql/item_subselect.cc9
-rw-r--r--sql/item_subselect.h1
-rw-r--r--sql/item_sum.cc71
-rw-r--r--sql/item_sum.h43
-rw-r--r--sql/item_xmlfunc.cc5
-rw-r--r--sql/key.cc2
-rw-r--r--sql/key.h2
-rw-r--r--sql/lex_symbol.h3
-rw-r--r--sql/log.cc4
-rw-r--r--sql/log_event.cc20
-rw-r--r--sql/log_event.h9
-rw-r--r--sql/log_event_old.h9
-rw-r--r--sql/mem_root_array.h2
-rw-r--r--sql/my_decimal.h4
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/mysqld.h2
-rw-r--r--sql/opt_range.cc5
-rw-r--r--sql/opt_subselect.cc9
-rw-r--r--sql/opt_subselect.h2
-rw-r--r--sql/partition_element.h2
-rw-r--r--sql/partition_info.h2
-rw-r--r--sql/rpl_filter.cc2
-rw-r--r--sql/rpl_record.cc23
-rw-r--r--sql/rpl_record.h11
-rw-r--r--sql/rpl_utility.cc19
-rw-r--r--sql/scheduler.cc1
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/set_var.h1
-rw-r--r--sql/share/charsets/Index.xml2
-rw-r--r--sql/share/charsets/armscii8.xml3
-rw-r--r--sql/share/charsets/ascii.xml2
-rw-r--r--sql/share/charsets/cp1250.xml2
-rw-r--r--sql/share/charsets/cp852.xml3
-rw-r--r--sql/share/charsets/hebrew.xml2
-rw-r--r--sql/share/charsets/latin1.xml2
-rw-r--r--sql/share/charsets/latin2.xml2
-rw-r--r--sql/share/charsets/latin5.xml2
-rw-r--r--sql/signal_handler.cc4
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/spatial.cc3
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_admin.h2
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_audit.cc2
-rw-r--r--sql/sql_audit.h2
-rw-r--r--sql/sql_binlog.cc2
-rw-r--r--sql/sql_bitmap.h2
-rw-r--r--sql/sql_cache.cc1
-rw-r--r--sql/sql_connect.cc4
-rw-r--r--sql/sql_help.cc3
-rw-r--r--sql/sql_lifo_buffer.h3
-rw-r--r--sql/sql_manager.cc2
-rw-r--r--sql/sql_partition_admin.cc2
-rw-r--r--sql/sql_plugin.cc14
-rw-r--r--sql/sql_priv.h1
-rw-r--r--sql/sql_repl.cc4
-rw-r--r--sql/sql_select.cc18
-rw-r--r--sql/sql_select.h3
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_string.cc3
-rw-r--r--sql/sql_table.h1
-rw-r--r--sql/sql_trigger.cc2
-rw-r--r--sql/sql_udf.cc18
-rw-r--r--sql/sql_union.cc3
-rw-r--r--sql/sql_view.cc4
-rw-r--r--sql/strfunc.cc2
-rw-r--r--sql/sys_vars.cc2
-rw-r--r--sql/table.cc5
-rw-r--r--sql/table.h4
-rw-r--r--sql/transaction.h3
89 files changed, 511 insertions, 254 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 50da88c81b7..187a4e9de5e 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
+# Copyright (c) 2006, 2013, Oracle and/or its affiliates.
#
# 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
diff --git a/sql/custom_conf.h b/sql/custom_conf.h
index afef0219857..62fdb619c27 100644
--- a/sql/custom_conf.h
+++ b/sql/custom_conf.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2006 MySQL AB
+ Use is subject to license terms
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
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 92093e34b81..6091977cc8d 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2013, Oracle and/or its affiliates.
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
diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h
index 4f6b9349162..6ec7dccefb9 100644
--- a/sql/event_scheduler.h
+++ b/sql/event_scheduler.h
@@ -1,6 +1,6 @@
#ifndef _EVENT_SCHEDULER_H_
#define _EVENT_SCHEDULER_H_
-/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/events.cc b/sql/events.cc
index 040b73730e9..505710b3ccd 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2005, 2013, Oracle and/or its affiliates.
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
diff --git a/sql/events.h b/sql/events.h
index a6480e7241d..646fd257d52 100644
--- a/sql/events.h
+++ b/sql/events.h
@@ -1,6 +1,6 @@
#ifndef _EVENT_H_
#define _EVENT_H_
-/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/field.h b/sql/field.h
index 5a1607c1cbf..916f6211bee 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1,7 +1,7 @@
#ifndef FIELD_INCLUDED
#define FIELD_INCLUDED
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2011, Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
@@ -2400,18 +2400,6 @@ public:
{
store_length(ptr, packlength, number);
}
-
- /**
- Return the packed length plus the length of the data.
-
- This is used to determine the size of the data plus the
- packed length portion in the row data.
-
- @returns The length in the row plus the size of the data.
- */
- uint32 get_packed_size(const uchar *ptr_arg)
- {return packlength + get_length(ptr_arg, packlength);}
-
inline uint32 get_length(uint row_offset= 0)
{ return get_length(ptr+row_offset, this->packlength); }
uint32 get_length(const uchar *ptr, uint packlength);
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 183edf67466..4b9596a0e21 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -39,6 +39,7 @@
#include "sql_select.h"
#include "log_slow.h"
#include "debug_sync.h"
+#include "sql_base.h"
/// How to write record_ref.
#define WRITE_REF(file,from) \
@@ -386,6 +387,14 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
{
int kill_errno= thd->killed_errno();
DBUG_ASSERT(thd->is_error() || kill_errno || thd->killed == ABORT_QUERY);
+
+ /*
+ We replace the table->sort at the end.
+ Hence calling free_io_cache to make sure table->sort.io_cache
+ used for QUICK_INDEX_MERGE_SELECT is free.
+ */
+ free_io_cache(table);
+
my_printf_error(ER_FILSORT_ABORT,
"%s: %s",
MYF(0),
@@ -411,6 +420,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
DBUG_POP(); /* Ok to DBUG */
#endif
+ /* table->sort.io_cache should be free by this time */
+ DBUG_ASSERT(NULL == table->sort.io_cache);
+
// Assign the copy back!
table->sort= table_sort;
@@ -469,6 +481,84 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
}
#ifndef DBUG_OFF
+
+/* Buffer where record is returned */
+char dbug_print_row_buff[512];
+
+/* Temporary buffer for printing a column */
+char dbug_print_row_buff_tmp[512];
+
+/*
+ Print table's current row into a buffer and return a pointer to it.
+
+ This is intended to be used from gdb:
+
+ (gdb) p dbug_print_table_row(table)
+ $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)"
+ (gdb)
+
+ Only columns in table->read_set are printed
+*/
+
+const char* dbug_print_table_row(TABLE *table)
+{
+ Field **pfield;
+ String tmp(dbug_print_row_buff_tmp,
+ sizeof(dbug_print_row_buff_tmp),&my_charset_bin);
+
+ String output(dbug_print_row_buff, sizeof(dbug_print_row_buff),
+ &my_charset_bin);
+
+ output.length(0);
+ output.append(table->alias);
+ output.append("(");
+ bool first= true;
+
+ for (pfield= table->field; *pfield ; pfield++)
+ {
+ if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index))
+ continue;
+
+ if (first)
+ first= false;
+ else
+ output.append(",");
+
+ output.append((*pfield)->field_name? (*pfield)->field_name: "NULL");
+ }
+
+ output.append(")=(");
+
+ first= true;
+ for (pfield= table->field; *pfield ; pfield++)
+ {
+ Field *field= *pfield;
+
+ if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index))
+ continue;
+
+ if (first)
+ first= false;
+ else
+ output.append(",");
+
+ if (field->is_null())
+ output.append("NULL");
+ else
+ {
+ if (field->type() == MYSQL_TYPE_BIT)
+ (void) field->val_int_as_str(&tmp, 1);
+ else
+ field->val_str(&tmp);
+ output.append(tmp.ptr(), tmp.length());
+ }
+ }
+ output.append(")");
+
+ return output.c_ptr_safe();
+}
+
+
/*
Print a text, SQL-like record representation into dbug trace.
@@ -517,6 +607,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
fprintf(DBUG_FILE, "\n");
DBUG_UNLOCK_FILE;
}
+
#endif
@@ -640,6 +731,7 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
DBUG_RETURN(HA_POS_ERROR);
}
+ DEBUG_SYNC(thd, "after_index_merge_phase1");
for (;;)
{
if (quick_select)
@@ -737,12 +829,17 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
make_sortkey(param, fs_info->get_record_buffer(idx++), ref_pos);
}
}
- else
- file->unlock_row();
/* It does not make sense to read more keys in case of a fatal error */
if (thd->is_error())
break;
+
+ /*
+ We need to this after checking the error as the transaction may have
+ rolled back in case of a deadlock
+ */
+ if (!write_record)
+ file->unlock_row();
}
if (!quick_select)
{
@@ -885,8 +982,6 @@ static void make_sortkey(register Sort_param *param,
{
const CHARSET_INFO *cs=item->collation.collation;
char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' ');
- int diff;
- uint sort_field_length;
if (maybe_null)
*to++=1;
@@ -914,25 +1009,13 @@ static void make_sortkey(register Sort_param *param,
break;
}
length= res->length();
- sort_field_length= sort_field->length - sort_field->suffix_length;
- diff=(int) (sort_field_length - length);
- if (diff < 0)
- {
- diff=0;
- length= sort_field_length;
- }
- if (sort_field->suffix_length)
- {
- /* Store length last in result_string */
- store_length(to + sort_field_length, length,
- sort_field->suffix_length);
- }
if (sort_field->need_strxnfrm)
{
char *from=(char*) res->ptr();
uint tmp_length __attribute__((unused));
if ((uchar*) from == to)
{
+ DBUG_ASSERT(sort_field->length >= length);
set_if_smaller(length,sort_field->length);
memcpy(param->tmp_buffer,from,length);
from=param->tmp_buffer;
@@ -947,6 +1030,22 @@ static void make_sortkey(register Sort_param *param,
}
else
{
+ uint diff;
+ uint sort_field_length= sort_field->length -
+ sort_field->suffix_length;
+ if (sort_field_length < length)
+ {
+ diff= 0;
+ length= sort_field_length;
+ }
+ else
+ diff= sort_field_length - length;
+ if (sort_field->suffix_length)
+ {
+ /* Store length last in result_string */
+ store_length(to + sort_field_length, length,
+ sort_field->suffix_length);
+ }
my_strnxfrm(cs,(uchar*)to,length,(const uchar*)res->ptr(),length);
cs->cset->fill(cs, (char *)to+length,diff,fill_char);
}
diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc
index 22a7dbe55f7..fd80304d400 100644
--- a/sql/ha_ndbcluster_cond.cc
+++ b/sql/ha_ndbcluster_cond.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h
index 9ea0438a348..952b705bfc2 100644
--- a/sql/ha_ndbcluster_cond.h
+++ b/sql/ha_ndbcluster_cond.h
@@ -1,7 +1,7 @@
#ifndef HA_NDBCLUSTER_COND_INCLUDED
#define HA_NDBCLUSTER_COND_INCLUDED
-/* Copyright (C) 2000-2007 MySQL AB
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/ha_ndbcluster_tables.h b/sql/ha_ndbcluster_tables.h
index 6ed46123738..4d97ca2c254 100644
--- a/sql/ha_ndbcluster_tables.h
+++ b/sql/ha_ndbcluster_tables.h
@@ -1,7 +1,8 @@
#ifndef HA_NDBCLUSTER_TABLES_INCLUDED
#define HA_NDBCLUSTER_TABLES_INCLUDED
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (c) 2000-2003, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
+ Use is subject to license terms
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
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 5b484076bca..6f8d4b4af14 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -89,12 +89,13 @@ static handler *partition_create_handler(handlerton *hton,
static uint partition_flags();
static uint alter_table_flags(uint flags);
+extern "C" int cmp_key_then_part_id(void *key_p, uchar *ref1, uchar *ref2);
+
/*
If frm_error() is called then we will use this to to find out what file
extensions exist for the storage engine. This is also used by the default
rename_table and delete_table method in handler.cc.
*/
-
static const char *ha_partition_ext[]=
{
ha_par_ext, NullS
@@ -5119,8 +5120,8 @@ bool ha_partition::init_record_priority_queue()
}
m_start_key.key= (const uchar*)ptr;
/* Initialize priority queue, initialized to reading forward. */
- if (init_queue(&m_queue, used_parts, (uint) PARTITION_BYTES_IN_POS,
- 0, key_rec_cmp, (void*)m_curr_key_info, 0, 0))
+ if (init_queue(&m_queue, used_parts, 0,
+ 0, cmp_key_then_part_id, (void*)m_curr_key_info, 0, 0))
{
my_free(m_ordered_rec_buffer);
m_ordered_rec_buffer= NULL;
@@ -5330,6 +5331,52 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key,
}
+/*
+ @brief
+ Provide ordering by (key_value, partition_id).
+
+ @detail
+ Ordering by partition id is required so that key scans on key=const
+ return rows in rowid order (this is required for some variants of
+ index_merge to work).
+
+ In ha_partition, rowid is a (partition_id, underlying_table_rowid).
+ handle_ordered_index_scan must return rows ordered by (key, rowid).
+
+ If two rows have the same key value and come from different partitions,
+ it is sufficient to return them in the order of their partition_id.
+*/
+
+extern "C" int cmp_key_then_part_id(void *key_p, uchar *ref1, uchar *ref2)
+{
+ my_ptrdiff_t diff1, diff2;
+ int res;
+
+ if ((res= key_rec_cmp(key_p, ref1 + PARTITION_BYTES_IN_POS,
+ ref2 + PARTITION_BYTES_IN_POS)))
+ {
+ return res;
+ }
+
+ /* The following was taken from ha_partition::cmp_ref */
+ diff1= ref2[1] - ref1[1];
+ diff2= ref2[0] - ref1[0];
+ if (!diff1 && !diff2)
+ return 0;
+
+ if (diff1 > 0)
+ return(-1);
+
+ if (diff1 < 0)
+ return(+1);
+
+ if (diff2 > 0)
+ return(-1);
+
+ return(+1);
+}
+
+
/**
Common routine for a number of index_read variants
@@ -6151,7 +6198,7 @@ void ha_partition::return_top_record(uchar *buf)
int ha_partition::handle_ordered_index_scan_key_not_found()
{
int error;
- uint i;
+ uint i, old_elements= m_queue.elements;
uchar *part_buf= m_ordered_rec_buffer;
uchar *curr_rec_buf= NULL;
DBUG_ENTER("ha_partition::handle_ordered_index_scan_key_not_found");
@@ -6185,9 +6232,12 @@ int ha_partition::handle_ordered_index_scan_key_not_found()
bitmap_clear_all(&m_key_not_found_partitions);
m_key_not_found= false;
- /* Update m_top_entry, which may have changed. */
- uchar *key_buffer= queue_top(&m_queue);
- m_top_entry= uint2korr(key_buffer);
+ if (m_queue.elements > old_elements)
+ {
+ /* Update m_top_entry, which may have changed. */
+ uchar *key_buffer= queue_top(&m_queue);
+ m_top_entry= uint2korr(key_buffer);
+ }
DBUG_RETURN(0);
}
@@ -8448,6 +8498,16 @@ uint ha_partition::min_record_length(uint options) const
If they belong to different partitions we decide that they are not
the same record. Otherwise we use the particular handler to decide if
they are the same. Sort in partition id order if not equal.
+
+ MariaDB note:
+ Please don't merge the code from MySQL that does this:
+
+ We get two references and need to check if those records are the same.
+ If they belong to different partitions we decide that they are not
+ the same record. Otherwise we use the particular handler to decide if
+ they are the same. Sort in partition id order if not equal.
+
+ It is incorrect, MariaDB has an alternative fix.
*/
int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
diff --git a/sql/hostname.cc b/sql/hostname.cc
index 21e652a346f..8a4df816057 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2011, Monty Program Ab
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2014, SkySQL 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
diff --git a/sql/item.cc b/sql/item.cc
index 191857413c2..bcba505a265 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1681,17 +1681,28 @@ bool Item_name_const::is_null()
Item_name_const::Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
- if (!(valid_args= name_item->basic_const_item() &&
- (value_item->basic_const_item() ||
- ((value_item->type() == FUNC_ITEM) &&
- ((((Item_func *) value_item)->functype() ==
- Item_func::COLLATE_FUNC) ||
- ((((Item_func *) value_item)->functype() ==
- Item_func::NEG_FUNC) &&
- (((Item_func *) value_item)->key_item()->type() !=
- FUNC_ITEM)))))))
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
+ valid_args= true;
+ if (!name_item->basic_const_item())
+ goto err;
+
+ if (value_item->basic_const_item())
+ return; // ok
+
+ if (value_item->type() == FUNC_ITEM)
+ {
+ Item_func *value_func= (Item_func *) value_item;
+ if (value_func->functype() != Item_func::COLLATE_FUNC &&
+ value_func->functype() != Item_func::NEG_FUNC)
+ goto err;
+
+ if (value_func->key_item()->basic_const_item())
+ return; // ok
+ }
+
+err:
+ valid_args= false;
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
}
@@ -5228,8 +5239,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (any_privileges)
{
char *db, *tab;
- db= cached_table->get_db_name();
- tab= cached_table->get_table_name();
+ db= field->table->s->db.str;
+ tab= field->table->s->table_name.str;
if (!(have_privileges= (get_column_grant(thd, &field->table->grant,
db, tab, field_name) &
VIEW_ANY_ACL)))
@@ -5250,7 +5261,12 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
marker= thd->lex->current_select->cur_pos_in_select_list;
}
mark_non_agg_field:
- if (fixed && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
+ /*
+ table->pos_in_table_list can be 0 when fixing partition functions
+ or virtual fields.
+ */
+ if (fixed && (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) &&
+ field->table->pos_in_table_list)
{
/*
Mark selects according to presence of non aggregated fields.
@@ -5263,7 +5279,7 @@ mark_non_agg_field:
(the current level) or a stub added by non-SELECT queries.
*/
SELECT_LEX *select_lex= cached_table ?
- cached_table->select_lex : context->select_lex;
+ cached_table->select_lex : field->table->pos_in_table_list->select_lex;
if (!thd->lex->in_sum_func)
select_lex->set_non_agg_field_used(true);
else
@@ -8303,7 +8319,7 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
if (context->error_processor == &view_error_processor)
{
- TABLE_LIST *view= cached_table->top_table();
+ TABLE_LIST *view= field_arg->table->pos_in_table_list->top_table();
push_warning_printf(field_arg->table->in_use,
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_VIEW_FIELD,
diff --git a/sql/item.h b/sql/item.h
index de005c459ce..f96ae41ef46 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2105,7 +2105,11 @@ public:
tab->merge_keys.merge(field->part_of_key);
if (tab->read_set)
bitmap_fast_test_and_set(tab->read_set, field->field_index);
- if (field->vcol_info)
+ /*
+ Do not mark a self-referecing virtual column.
+ Such virtual columns are reported as invalid.
+ */
+ if (field->vcol_info && tab->vcol_set)
tab->mark_virtual_col(field);
}
}
@@ -3543,6 +3547,7 @@ public:
void cleanup()
{
null_ref_table= NULL;
+ item_equal= NULL;
Item_direct_ref::cleanup();
}
};
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 6159014a10c..4b3acf83f85 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1,7 +1,7 @@
#ifndef ITEM_CMPFUNC_INCLUDED
#define ITEM_CMPFUNC_INCLUDED
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2009, 2011, Monty Program Ab
+ Copyright (c) 2009, 2011, Monty Program 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
diff --git a/sql/item_func.h b/sql/item_func.h
index 4da5bfa91bb..aaba24a5841 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1,7 +1,7 @@
#ifndef ITEM_FUNC_INCLUDED
#define ITEM_FUNC_INCLUDED
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, SkySQL 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
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index aeef3e42817..1deda83907c 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -859,7 +859,7 @@ String *Item_func_spatial_operation::val_str(String *str_value)
str_value->length(0);
str_value->q_append(srid);
- if (!Geometry::create_from_opresult(&buffer1, str_value, res_receiver))
+ if (Geometry::create_from_opresult(&buffer1, str_value, res_receiver))
goto exit;
exit:
@@ -1116,6 +1116,8 @@ int Item_func_buffer::Transporter::start_line()
{
if (buffer_op == Gcalc_function::op_difference)
{
+ if (m_fn->reserve_op_buffer(1))
+ return 1;
m_fn->add_operation(Gcalc_function::op_false, 0);
skip_line= TRUE;
return 0;
@@ -1317,7 +1319,7 @@ String *Item_func_buffer::val_str(String *str_value)
str_value->length(0);
str_value->q_append(srid);
- if (!Geometry::create_from_opresult(&buffer, str_value, res_receiver))
+ if (Geometry::create_from_opresult(&buffer, str_value, res_receiver))
goto mem_error;
null_value= 0;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index e426489d0e9..57af832c151 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1163,6 +1163,7 @@ String *Item_func_reverse::val_str(String *str)
if ((l= my_ismbchar(res->charset(),ptr,end)))
{
tmp-= l;
+ DBUG_ASSERT(tmp >= tmp_value.ptr());
memcpy(tmp,ptr,l);
ptr+= l;
}
@@ -2092,18 +2093,35 @@ String *Item_func_trim::val_str(String *str)
ptr= (char*) res->ptr();
end= ptr+res->length();
r_ptr= remove_str->ptr();
- while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
- ptr+=remove_length;
#ifdef USE_MB
if (use_mb(res->charset()))
{
+ while (ptr + remove_length <= end)
+ {
+ uint num_bytes= 0;
+ while (num_bytes < remove_length)
+ {
+ uint len;
+ if ((len= my_ismbchar(res->charset(), ptr + num_bytes, end)))
+ num_bytes+= len;
+ else
+ ++num_bytes;
+ }
+ if (num_bytes != remove_length)
+ break;
+ if (memcmp(ptr, r_ptr, remove_length))
+ break;
+ ptr+= remove_length;
+ }
char *p=ptr;
register uint32 l;
loop:
while (ptr + remove_length < end)
{
- if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l;
- else ++ptr;
+ if ((l= my_ismbchar(res->charset(), ptr,end)))
+ ptr+= l;
+ else
+ ++ptr;
}
if (ptr + remove_length == end && !memcmp(ptr,r_ptr,remove_length))
{
@@ -2116,6 +2134,8 @@ String *Item_func_trim::val_str(String *str)
else
#endif /* USE_MB */
{
+ while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
+ ptr+=remove_length;
while (ptr + remove_length <= end &&
!memcmp(end-remove_length,r_ptr,remove_length))
end-=remove_length;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 35d137c4357..67af49c4f9f 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3341,7 +3341,7 @@ subselect_single_select_engine(THD *thd_arg, st_select_lex *select,
select_result_interceptor *result_arg,
Item_subselect *item_arg)
:subselect_engine(thd_arg, item_arg, result_arg),
- prepared(0), executed(0), optimize_error(0),
+ prepared(0), executed(0),
select_lex(select), join(0)
{
select_lex->master_unit()->item= item_arg;
@@ -3355,7 +3355,7 @@ int subselect_single_select_engine::get_identifier()
void subselect_single_select_engine::cleanup()
{
DBUG_ENTER("subselect_single_select_engine::cleanup");
- prepared= executed= optimize_error= 0;
+ prepared= executed= 0;
join= 0;
result->cleanup();
select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
@@ -3589,9 +3589,6 @@ int subselect_single_select_engine::exec()
{
DBUG_ENTER("subselect_single_select_engine::exec");
- if (optimize_error)
- DBUG_RETURN(1);
-
char const *save_where= thd->where;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
@@ -3604,7 +3601,7 @@ int subselect_single_select_engine::exec()
if (join->optimize())
{
thd->where= save_where;
- executed= optimize_error= 1;
+ executed= 1;
thd->lex->current_select= save_select;
DBUG_RETURN(join->error ? join->error : 1);
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index b8e929f3fc5..92b269d02f1 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -815,7 +815,6 @@ class subselect_single_select_engine: public subselect_engine
{
bool prepared; /* simple subselect is prepared */
bool executed; /* simple subselect is executed */
- bool optimize_error; /* simple subselect optimization failed */
st_select_lex *select_lex; /* corresponding select_lex */
JOIN * join; /* corresponding JOIN structure */
public:
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 32816551491..62db351150b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2008, 2013 Monty Program Ab
+ Copyright (c) 2008, 2014, SkySQL 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
@@ -261,7 +261,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
List_iterator<Item_field> of(outer_fields);
while ((field= of++))
{
- SELECT_LEX *sel= field->cached_table->select_lex;
+ SELECT_LEX *sel= field->field->table->pos_in_table_list->select_lex;
if (sel->nest_level < aggr_level)
{
if (in_sum_func)
@@ -1110,18 +1110,19 @@ void Aggregator_distinct::endup()
endup_done= TRUE;
}
}
- else
- {
- /*
- We don't have a tree only if 'setup()' hasn't been called;
- this is the case of sql_select.cc:return_zero_rows.
- */
- if (tree)
- table->field[0]->set_notnull();
- }
+ /*
+ We don't have a tree only if 'setup()' hasn't been called;
+ this is the case of sql_executor.cc:return_zero_rows.
+ */
if (tree && !endup_done)
{
+ /*
+ All tree's values are not NULL.
+ Note that value of field is changed as we walk the tree, in
+ Aggregator_distinct::unique_walk_function, but it's always not NULL.
+ */
+ table->field[0]->set_notnull();
/* go over the tree of distinct keys and calculate the aggregate value */
use_distinct_values= TRUE;
tree_walk_action func;
@@ -1417,7 +1418,7 @@ bool Item_sum_sum::add()
{
my_decimal value;
const my_decimal *val= aggr->arg_val_decimal(&value);
- if (!aggr->arg_is_null())
+ if (!aggr->arg_is_null(true))
{
my_decimal_add(E_DEC_FATAL_ERROR, dec_buffs + (curr_dec_buff^1),
val, dec_buffs + curr_dec_buff);
@@ -1428,7 +1429,7 @@ bool Item_sum_sum::add()
else
{
sum+= aggr->arg_val_real();
- if (!aggr->arg_is_null())
+ if (!aggr->arg_is_null(true))
null_value= 0;
}
DBUG_RETURN(0);
@@ -1554,9 +1555,27 @@ double Aggregator_simple::arg_val_real()
}
-bool Aggregator_simple::arg_is_null()
+bool Aggregator_simple::arg_is_null(bool use_null_value)
{
- return item_sum->args[0]->null_value;
+ Item **item= item_sum->args;
+ const uint item_count= item_sum->arg_count;
+ if (use_null_value)
+ {
+ for (uint i= 0; i < item_count; i++)
+ {
+ if (item[i]->null_value)
+ return true;
+ }
+ }
+ else
+ {
+ for (uint i= 0; i < item_count; i++)
+ {
+ if (item[i]->maybe_null && item[i]->is_null())
+ return true;
+ }
+ }
+ return false;
}
@@ -1574,10 +1593,17 @@ double Aggregator_distinct::arg_val_real()
}
-bool Aggregator_distinct::arg_is_null()
+bool Aggregator_distinct::arg_is_null(bool use_null_value)
{
- return use_distinct_values ? table->field[0]->is_null() :
- item_sum->args[0]->null_value;
+ if (use_distinct_values)
+ {
+ const bool rc= table->field[0]->is_null();
+ DBUG_ASSERT(!rc); // NULLs are never stored in 'tree'
+ return rc;
+ }
+ return use_null_value ?
+ item_sum->args[0]->null_value :
+ (item_sum->args[0]->maybe_null && item_sum->args[0]->is_null());
}
@@ -1595,11 +1621,8 @@ void Item_sum_count::clear()
bool Item_sum_count::add()
{
- for (uint i=0; i<arg_count; i++)
- {
- if (args[i]->maybe_null && args[i]->is_null())
- return 0;
- }
+ if (aggr->arg_is_null(false))
+ return 0;
count++;
return 0;
}
@@ -1691,7 +1714,7 @@ bool Item_sum_avg::add()
{
if (Item_sum_sum::add())
return TRUE;
- if (!aggr->arg_is_null())
+ if (!aggr->arg_is_null(true))
count++;
return FALSE;
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index e82e0ead1c2..d28c654c438 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -57,19 +57,8 @@ protected:
/* the aggregate function class to act on */
Item_sum *item_sum;
- /**
- When feeding back the data in endup() from Unique/temp table back to
- Item_sum::add() methods we must read the data from Unique (and not
- recalculate the functions that are given as arguments to the aggregate
- function.
- This flag is to tell the add() methods to take the data from the Unique
- instead by calling the relevant val_..() method
- */
-
- bool use_distinct_values;
-
public:
- Aggregator (Item_sum *arg): item_sum(arg), use_distinct_values(FALSE) {}
+ Aggregator (Item_sum *arg): item_sum(arg) {}
virtual ~Aggregator () {} /* Keep gcc happy */
enum Aggregator_type { SIMPLE_AGGREGATOR, DISTINCT_AGGREGATOR };
@@ -106,10 +95,16 @@ public:
/** Floating point value of being-aggregated argument */
virtual double arg_val_real() = 0;
/**
- NULLness of being-aggregated argument; can be called only after
- arg_val_decimal() or arg_val_real().
+ NULLness of being-aggregated argument.
+
+ @param use_null_value Optimization: to determine if the argument is NULL
+ we must, in the general case, call is_null() on it, which itself might
+ call val_*() on it, which might be costly. If you just have called
+ arg_val*(), you can pass use_null_value=true; this way, arg_is_null()
+ might avoid is_null() and instead do a cheap read of the Item's null_value
+ (updated by arg_val*()).
*/
- virtual bool arg_is_null() = 0;
+ virtual bool arg_is_null(bool use_null_value) = 0;
};
@@ -495,7 +490,7 @@ public:
Item *get_arg(uint i) { return args[i]; }
Item *set_arg(uint i, THD *thd, Item *new_val);
- uint get_arg_count() { return arg_count; }
+ uint get_arg_count() const { return arg_count; }
/* Initialization of distinct related members */
void init_aggregator()
@@ -626,10 +621,20 @@ class Aggregator_distinct : public Aggregator
*/
bool always_null;
+ /**
+ When feeding back the data in endup() from Unique/temp table back to
+ Item_sum::add() methods we must read the data from Unique (and not
+ recalculate the functions that are given as arguments to the aggregate
+ function.
+ This flag is to tell the arg_*() methods to take the data from the Unique
+ instead of calling the relevant val_..() method.
+ */
+ bool use_distinct_values;
+
public:
Aggregator_distinct (Item_sum *sum) :
Aggregator(sum), table(NULL), tmp_table_param(NULL), tree(NULL),
- always_null(FALSE) {}
+ always_null(false), use_distinct_values(false) {}
virtual ~Aggregator_distinct ();
Aggregator_type Aggrtype() { return DISTINCT_AGGREGATOR; }
@@ -639,7 +644,7 @@ public:
void endup();
virtual my_decimal *arg_val_decimal(my_decimal * value);
virtual double arg_val_real();
- virtual bool arg_is_null();
+ virtual bool arg_is_null(bool use_null_value);
bool unique_walk_function(void *element);
bool unique_walk_function_for_count(void *element);
@@ -666,7 +671,7 @@ public:
void endup() {};
virtual my_decimal *arg_val_decimal(my_decimal * value);
virtual double arg_val_real();
- virtual bool arg_is_null();
+ virtual bool arg_is_null(bool use_null_value);
};
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 456779beec1..75f0ed9ef5a 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2005, 2013, Oracle and/or its affiliates.
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
@@ -226,6 +226,9 @@ public:
{
max_length= MAX_BLOB_WIDTH;
collation.collation= pxml->charset();
+ // To avoid premature evaluation, mark all nodeset functions as non-const.
+ used_tables_cache= RAND_TABLE_BIT;
+ const_item_cache= false;
}
const char *func_name() const { return "nodeset"; }
bool check_vcol_func_processor(uchar *int_arg)
diff --git a/sql/key.cc b/sql/key.cc
index 2df9c7e0cb5..3556ecf82d7 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/key.h b/sql/key.h
index ba3102947b3..47b981f5298 100644
--- a/sql/key.h
+++ b/sql/key.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h
index 5f3c70a50a4..d48ca57df85 100644
--- a/sql/lex_symbol.h
+++ b/sql/lex_symbol.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2001, 2004 MySQL AB
+/* Copyright (c) 2000, 2001, 2004, 2006, 2007 MySQL AB
+ Use is subject to license terms
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
diff --git a/sql/log.cc b/sql/log.cc
index 33897073a3d..b5b3e1061f7 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, SkySQL 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
diff --git a/sql/log_event.cc b/sql/log_event.cc
index ad9336712cf..2b55db5dc78 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -17,6 +17,7 @@
#include "sql_priv.h"
+#include "mysqld_error.h"
#ifndef MYSQL_CLIENT
#include "my_global.h" // REQUIRED by log_event.h > m_string.h > my_bitmap.h
@@ -2465,6 +2466,14 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
else
{
my_b_printf(file, "### @%lu=", (ulong)i + 1);
+ size_t fsize= td->calc_field_size((uint)i, (uchar*) value);
+ if (value + fsize > m_rows_end)
+ {
+ my_b_printf(file, "***Corrupted replication event was detected."
+ " Not printing the value***\n");
+ value+= fsize;
+ return 0;
+ }
size_t size= log_event_print_value(file, value,
td->type(i), td->field_metadata(i),
typestr, sizeof(typestr));
@@ -5543,11 +5552,22 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
fields = (char*)field_lens + num_fields;
table_name = fields + field_block_len;
db = table_name + table_name_len + 1;
+ DBUG_EXECUTE_IF ("simulate_invalid_address",
+ db_len = data_len;);
fname = db + db_len + 1;
+ if ((db_len > data_len) || (fname > buf_end))
+ goto err;
fname_len = (uint) strlen(fname);
+ if ((fname_len > data_len) || (fname + fname_len > buf_end))
+ goto err;
// null termination is accomplished by the caller doing buf[event_len]=0
DBUG_RETURN(0);
+
+err:
+ // Invalid event.
+ table_name = 0;
+ DBUG_RETURN(1);
}
diff --git a/sql/log_event.h b/sql/log_event.h
index dd5cf320dab..cfdc65a2c40 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -4323,13 +4323,8 @@ protected:
DBUG_ASSERT(m_table);
ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
- int const result= ::unpack_row(rgi, m_table, m_width, m_curr_row,
- m_rows_end, &m_cols,
- &m_curr_row_end, &m_master_reclength);
- if (m_curr_row_end > m_rows_end)
- my_error(ER_SLAVE_CORRUPT_EVENT, MYF(0));
- ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
- return result;
+ return ::unpack_row(rgi, m_table, m_width, m_curr_row, &m_cols,
+ &m_curr_row_end, &m_master_reclength, m_rows_end);
}
#endif
diff --git a/sql/log_event_old.h b/sql/log_event_old.h
index 97fc24a1bef..7408e121f96 100644
--- a/sql/log_event_old.h
+++ b/sql/log_event_old.h
@@ -1,4 +1,4 @@
-/* Copyright 2007 MySQL AB.
+/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
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
@@ -207,11 +207,8 @@ protected:
{
DBUG_ASSERT(m_table);
ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
- int const result= ::unpack_row(rgi, m_table, m_width, m_curr_row,
- m_rows_end, &m_cols,
- &m_curr_row_end, &m_master_reclength);
- ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
- return result;
+ return ::unpack_row(rgi, m_table, m_width, m_curr_row, &m_cols,
+ &m_curr_row_end, &m_master_reclength, m_rows_end);
}
#endif
diff --git a/sql/mem_root_array.h b/sql/mem_root_array.h
index 9dc9638c13f..2dcc475cd7b 100644
--- a/sql/mem_root_array.h
+++ b/sql/mem_root_array.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index e561d180d12..fa85b41d70c 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2005, 2011, Oracle and/or its affiliates.
- Copyright (c) 2011 Monty Program Ab
+/* Copyright (c) 2005, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2014, SkySQL 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
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 13b1532f438..d95dc0e0d87 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2012, Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
@@ -5591,7 +5591,7 @@ default_service_handling(char **argv,
/* We have to quote filename if it contains spaces */
pos= add_quoted_string(path_and_service, file_path, end);
- if (*extra_opt)
+ if (extra_opt && *extra_opt)
{
/*
Add option after file_path. There will be zero or one extra option. It's
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 5e5eb16d7c3..75b4c3ba6c4 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index d41d6f7568a..30d796c7688 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3460,6 +3460,11 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item *cond)
table->reginfo.impossible_range= 1;
goto free_alloc;
}
+ else if (tree->type == SEL_TREE::ALWAYS)
+ {
+ rows= table_records;
+ goto free_alloc;
+ }
else if (tree->type == SEL_TREE::MAYBE)
{
rows= table_records;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 4079298f6c0..e00083c4b8b 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5288,6 +5288,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
if (!(*join_where)->fixed)
(*join_where)->fix_fields(join->thd, join_where);
}
+ table->table->maybe_null= MY_TEST(join->mixed_implicit_grouping);
}
if ((nested_join= table->nested_join))
@@ -5318,9 +5319,9 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
through Item::cleanup() calls).
*/
-void cleanup_empty_jtbm_semi_joins(JOIN *join)
+void cleanup_empty_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list)
{
- List_iterator<TABLE_LIST> li(*join->join_list);
+ List_iterator<TABLE_LIST> li(*join_list);
TABLE_LIST *table;
while ((table= li++))
{
@@ -5332,6 +5333,10 @@ void cleanup_empty_jtbm_semi_joins(JOIN *join)
table->table= NULL;
}
}
+ else if (table->nested_join && table->sj_subq_pred)
+ {
+ cleanup_empty_jtbm_semi_joins(join, &table->nested_join->join_list);
+ }
}
}
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index dabf2f95bcc..acfbebed6b3 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -28,7 +28,7 @@ int pull_out_semijoin_tables(JOIN *join);
bool optimize_semijoin_nests(JOIN *join, table_map all_table_map);
bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
Item **join_where);
-void cleanup_empty_jtbm_semi_joins(JOIN *join);
+void cleanup_empty_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list);
// used by Loose_scan_opt
ulonglong get_bound_sj_equalities(TABLE_LIST *sj_nest,
diff --git a/sql/partition_element.h b/sql/partition_element.h
index d0a67c6af3e..308a4d6ddd2 100644
--- a/sql/partition_element.h
+++ b/sql/partition_element.h
@@ -1,7 +1,7 @@
#ifndef PARTITION_ELEMENT_INCLUDED
#define PARTITION_ELEMENT_INCLUDED
-/* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/partition_info.h b/sql/partition_info.h
index e5029c385c1..8ad7b1fd1fd 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -1,7 +1,7 @@
#ifndef PARTITION_INFO_INCLUDED
#define PARTITION_INFO_INCLUDED
-/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 72e7770b6ee..2b4a3093e0f 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index c8c132f9a3b..a6d93d10f11 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2007, 2010, Oracle and/or its affiliates.
- Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
@@ -171,11 +170,15 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
@param row_data
Packed row data
@param cols Pointer to bitset describing columns to fill in
- @param row_end Pointer to variable that will hold the value of the
- one-after-end position for the row
+ @param curr_row_end
+ Pointer to variable that will hold the value of the
+ one-after-end position for the current row
@param master_reclength
Pointer to variable that will be set to the length of the
record on the master side
+ @param row_end
+ Pointer to variable that will hold the value of the
+ end position for the data in the row event
@retval 0 No error
@@ -188,9 +191,9 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
int
unpack_row(rpl_group_info *rgi,
TABLE *table, uint const colcnt,
- uchar const *const row_data, uchar const *const row_buffer_end,
- MY_BITMAP const *cols,
- uchar const **const row_end, ulong *const master_reclength)
+ uchar const *const row_data, MY_BITMAP const *cols,
+ uchar const **const current_row_end, ulong *const master_reclength,
+ uchar const *const row_end)
{
DBUG_ENTER("unpack_row");
DBUG_ASSERT(row_data);
@@ -305,7 +308,7 @@ unpack_row(rpl_group_info *rgi,
#ifndef DBUG_OFF
uchar const *const old_pack_ptr= pack_ptr;
#endif
- pack_ptr= f->unpack(f->ptr, pack_ptr, row_buffer_end, metadata);
+ pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
" pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
f->field_name, metadata,
@@ -392,7 +395,7 @@ unpack_row(rpl_group_info *rgi,
DBUG_DUMP("row_data", row_data, pack_ptr - row_data);
- *row_end = pack_ptr;
+ *current_row_end = pack_ptr;
if (master_reclength)
{
if (*field_ptr)
diff --git a/sql/rpl_record.h b/sql/rpl_record.h
index 7d17d4f7200..c10eb8225b0 100644
--- a/sql/rpl_record.h
+++ b/sql/rpl_record.h
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2007, 2010, Oracle and/or its affiliates.
- Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013, SkySQL 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
@@ -33,9 +32,9 @@ size_t pack_row(TABLE* table, MY_BITMAP const* cols,
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
int unpack_row(rpl_group_info *rgi,
TABLE *table, uint const colcnt,
- uchar const *const row_data, uchar const *row_buffer_end,
- MY_BITMAP const *cols,
- uchar const **const row_end, ulong *const master_reclength);
+ uchar const *const row_data, MY_BITMAP const *cols,
+ uchar const **const curr_row_end, ulong *const master_reclength,
+ uchar const *const row_end);
// Fill table's record[0] with default values.
int prepare_record(TABLE *const table, const uint skip, const bool check);
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index e8bc042e565..fcb6a849fb1 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -208,7 +208,7 @@ int compare_lengths(Field *field, enum_field_types source_type, uint16 metadata)
DBUG_PRINT("result", ("%d", result));
DBUG_RETURN(result);
}
-
+#endif //MYSQL_CLIENT
/*********************************************************************
* table_def member definitions *
*********************************************************************/
@@ -219,7 +219,7 @@ int compare_lengths(Field *field, enum_field_types source_type, uint16 metadata)
*/
uint32 table_def::calc_field_size(uint col, uchar *master_data) const
{
- uint32 length;
+ uint32 length= 0;
switch (type(col)) {
case MYSQL_TYPE_NEWDECIMAL:
@@ -316,7 +316,6 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
case MYSQL_TYPE_VARCHAR:
{
length= m_field_metadata[col] > 255 ? 2 : 1; // c&p of Field_varstring::data_length()
- DBUG_ASSERT(uint2korr(master_data) > 0);
length+= length == 1 ? (uint32) *master_data : uint2korr(master_data);
break;
}
@@ -326,17 +325,6 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
{
-#if 1
- /*
- BUG#29549:
- This is currently broken for NDB, which is using big-endian
- order when packing length of BLOB. Once they have decided how to
- fix the issue, we can enable the code below to make sure to
- always read the length in little-endian order.
- */
- Field_blob fb(m_field_metadata[col]);
- length= fb.get_packed_size(master_data);
-#else
/*
Compute the length of the data. We cannot use get_length() here
since it is dependent on the specific table (and also checks the
@@ -362,7 +350,6 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
}
length+= m_field_metadata[col];
-#endif
break;
}
default:
@@ -371,7 +358,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
return length;
}
-
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
/**
*/
void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_INFO *field_cs)
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 71789b0303b..ecf49e633ab 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -142,7 +142,6 @@ void one_thread_scheduler(scheduler_functions *func)
{
scheduler_init();
func->max_threads= 1;
- //max_connections= 1;
func->max_connections= &max_connections;
func->connection_count= &connection_count;
#ifndef EMBEDDED_LIBRARY
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 1c8a2a4d97c..ea577bbfa74 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2013, Oracle and/or its affiliates.
- Copyright (c) 2008, 2013, Monty Program Ab
+ Copyright (c) 2008, 2014, SkySQL 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
diff --git a/sql/set_var.h b/sql/set_var.h
index 88c5013e28e..28562b72dac 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -1,6 +1,7 @@
#ifndef SET_VAR_INCLUDED
#define SET_VAR_INCLUDED
/* Copyright (c) 2002, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, SkySQL 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
diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml
index e82ffc85ea6..3e402226a34 100644
--- a/sql/share/charsets/Index.xml
+++ b/sql/share/charsets/Index.xml
@@ -3,7 +3,7 @@
<charsets max-id="99">
<copyright>
- Copyright (c) 2003, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2003-2005 MySQL 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
diff --git a/sql/share/charsets/armscii8.xml b/sql/share/charsets/armscii8.xml
index 52382c83af0..c1eb93b1f91 100644
--- a/sql/share/charsets/armscii8.xml
+++ b/sql/share/charsets/armscii8.xml
@@ -3,7 +3,8 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2004 MySQL AB
+ Use is subject to license terms
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
diff --git a/sql/share/charsets/ascii.xml b/sql/share/charsets/ascii.xml
index bec34ad525e..29336b3a665 100644
--- a/sql/share/charsets/ascii.xml
+++ b/sql/share/charsets/ascii.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2007 MySQL 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
diff --git a/sql/share/charsets/cp1250.xml b/sql/share/charsets/cp1250.xml
index 58e55de9bdc..1b4a71ef6d5 100644
--- a/sql/share/charsets/cp1250.xml
+++ b/sql/share/charsets/cp1250.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2005 MySQL 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
diff --git a/sql/share/charsets/cp852.xml b/sql/share/charsets/cp852.xml
index 7608296d5b7..e0c574d2ea1 100644
--- a/sql/share/charsets/cp852.xml
+++ b/sql/share/charsets/cp852.xml
@@ -3,7 +3,8 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2004 MySQL AB
+ Use is subject to license terms
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
diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml
index e7f896a3e12..0544b27ef4f 100644
--- a/sql/share/charsets/hebrew.xml
+++ b/sql/share/charsets/hebrew.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2006 MySQL 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
diff --git a/sql/share/charsets/latin1.xml b/sql/share/charsets/latin1.xml
index 8963c3481d3..4054eea8d33 100644
--- a/sql/share/charsets/latin1.xml
+++ b/sql/share/charsets/latin1.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2005 MySQL 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
diff --git a/sql/share/charsets/latin2.xml b/sql/share/charsets/latin2.xml
index 183da7b6cd3..a44ec7e0ec6 100644
--- a/sql/share/charsets/latin2.xml
+++ b/sql/share/charsets/latin2.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2005 MySQL 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
diff --git a/sql/share/charsets/latin5.xml b/sql/share/charsets/latin5.xml
index 489299564f1..6b60e58cdda 100644
--- a/sql/share/charsets/latin5.xml
+++ b/sql/share/charsets/latin5.xml
@@ -3,7 +3,7 @@
<charsets>
<copyright>
- Copyright (C) 2003 MySQL AB
+ Copyright (c) 2003, 2005 MySQL 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
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index c50072f5159..3fadbcd088f 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates.
- Copyright (c) 2011, Monty Program Ab.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2014, SkySQL 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
diff --git a/sql/slave.cc b/sql/slave.cc
index 0e20609814a..b79e8512f37 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2011, Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
diff --git a/sql/spatial.cc b/sql/spatial.cc
index b82e6977f8a..34d2417f632 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -302,7 +302,8 @@ int Geometry::create_from_opresult(Geometry_buffer *g_buf,
res->q_append((char) wkb_ndr);
res->q_append(geom_type);
- return obj->init_from_opresult(res, rr.result(), rr.length());
+ return obj->init_from_opresult(res, rr.result(), rr.length()) == 0 &&
+ rr.length();
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index f4ddc98521e..fdb32233d92 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, SkySQL 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
diff --git a/sql/sql_admin.h b/sql/sql_admin.h
index fa89fc9063f..77fc41e2ec4 100644
--- a/sql/sql_admin.h
+++ b/sql/sql_admin.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index be35340df27..ac3f7f25518 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2000, 2013, Oracle and/or its affiliates.
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
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index f0e35cb022f..a92f69f3da4 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index bf8d837580a..85e7abb23e9 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -1,7 +1,7 @@
#ifndef SQL_AUDIT_INCLUDED
#define SQL_AUDIT_INCLUDED
-/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 4d91dbab9a6..fef959c37ca 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2005, 2013, Oracle and/or its affiliates.
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
diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h
index 0178844fec4..55b2d7eefd9 100644
--- a/sql/sql_bitmap.h
+++ b/sql/sql_bitmap.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003, 2010, Oracle and/or its affiliates
+/* Copyright (c) 2003, 2013, Oracle and/or its affiliates
Copyright (c) 2009, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index b0327153aa2..c6c5418e0cf 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1333,6 +1333,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
query->unlock_n_destroy();
block= block->next;
} while (block != queries_blocks);
+ queries_blocks= NULL; // avoid second destroying by free_cache
}
free_cache();
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index f14c43d4c54..997fd7923a0 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2013, Monty Program Ab
+ Copyright (c) 2007, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index d3c36e2c5d7..844810af0f4 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -1,5 +1,4 @@
-/*
- Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2002, 2012, Oracle and/or its affiliates.
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
diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h
index 5b7ddf35474..feec4aeb4c2 100644
--- a/sql/sql_lifo_buffer.h
+++ b/sql/sql_lifo_buffer.h
@@ -83,7 +83,8 @@ public:
{
start= start_arg;
end= end_arg;
- TRASH(start, end - start);
+ if (end != start)
+ TRASH(start, end - start);
reset();
}
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 0771f569f35..f13448ca46e 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index b2a8bca72db..8c59febeb77 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index c7b7b7948a0..f4a0b84ff65 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2005, 2012, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013, Monty Program Ab
+ Copyright (c) 2005, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2014, SkySQL 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
@@ -1357,6 +1357,16 @@ static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin,
goto err;
}
+ if (plugin->plugin_dl && global_system_variables.log_warnings >= 9)
+ {
+ void *sym= dlsym(plugin->plugin_dl->handle,
+ plugin->plugin_dl->mariaversion ?
+ maria_plugin_declarations_sym : plugin_declarations_sym);
+ DBUG_ASSERT(sym);
+ sql_print_information("Plugin %s loaded at %p",
+ plugin->name.str, sym);
+ }
+
if (plugin_type_initialize[plugin->plugin->type])
{
if ((*plugin_type_initialize[plugin->plugin->type])(plugin))
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index 5e3b80ab7a9..0676fca8fdc 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -240,6 +240,7 @@ template <class T> bool valid_buffer_range(T jump,
OPTIMIZER_SWITCH_DERIVED_MERGE | \
OPTIMIZER_SWITCH_DERIVED_WITH_KEYS | \
OPTIMIZER_SWITCH_TABLE_ELIMINATION | \
+ OPTIMIZER_SWITCH_EXTENDED_KEYS | \
OPTIMIZER_SWITCH_IN_TO_EXISTS | \
OPTIMIZER_SWITCH_MATERIALIZATION | \
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 418e0a1549f..516e5d7567a 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1960,8 +1960,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
});
if (global_system_variables.log_warnings > 1)
- sql_print_information("Start binlog_dump to slave_server(%d), pos(%s, %lu)",
- (int)thd->variables.server_id, log_ident, (ulong)pos);
+ sql_print_information("Start binlog_dump to slave_server(%lu), pos(%s, %lu)",
+ thd->variables.server_id, log_ident, (ulong)pos);
if (RUN_HOOK(binlog_transmit, transmit_start, (thd, flags, log_ident, pos)))
{
errmsg= "Failed to run hook 'transmit_start'";
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6ed3791b205..37e9c642dbb 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -725,7 +725,7 @@ JOIN::prepare(Item ***rref_pointer_array,
aggregate functions in the SELECT list is a MySQL exptenstion that
is allowed only if the ONLY_FULL_GROUP_BY sql mode is not set.
*/
- bool mixed_implicit_grouping= false;
+ mixed_implicit_grouping= false;
if ((~thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) &&
select_lex->with_sum_func && !group_list)
{
@@ -764,7 +764,7 @@ JOIN::prepare(Item ***rref_pointer_array,
Note: this loop doesn't touch tables inside merged semi-joins, because
subquery-to-semijoin conversion has not been done yet. This is intended.
*/
- if (mixed_implicit_grouping)
+ if (mixed_implicit_grouping && tbl->table)
tbl->table->maybe_null= 1;
}
@@ -3429,13 +3429,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
#endif
DBUG_EXECUTE_IF("bug11747970_raise_error",
- {
- if (!error)
- {
- my_error(ER_UNKNOWN_ERROR, MYF(0));
- goto error;
- }
- });
+ { join->thd->killed= KILL_QUERY_HARD; });
if (error)
{
table->file->print_error(error, MYF(0));
@@ -3824,7 +3818,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
join->impossible_where= false;
if (conds && const_count)
{
+ conds->update_used_tables();
conds= remove_eq_conds(join->thd, conds, &join->cond_value);
+ join->select_lex->where= conds;
if (join->cond_value == Item::COND_FALSE)
{
join->impossible_where= true;
@@ -11484,7 +11480,7 @@ void JOIN::cleanup(bool full)
}
if (full)
{
- cleanup_empty_jtbm_semi_joins(this);
+ cleanup_empty_jtbm_semi_joins(this, join_list);
/*
Ensure that the following delete_elements() would not be called
twice for the same list.
@@ -21007,7 +21003,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
if (!order_item->fixed &&
(order_item->fix_fields(thd, order->item) ||
(order_item= *order->item)->check_cols(1) ||
- thd->is_fatal_error))
+ thd->is_error()))
return TRUE; /* Wrong field. */
uint el= all_fields.elements;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 0262493365b..ea60e815c07 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1147,7 +1147,8 @@ public:
*/
JOIN *tmp_join;
ROLLUP rollup; ///< Used with rollup
-
+
+ bool mixed_implicit_grouping;
bool select_distinct; ///< Set if SELECT DISTINCT
/**
If we have the GROUP BY statement in the query,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 848df7d11f9..a640e44ebe1 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4835,6 +4835,11 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
if (fill_schema_table_names(thd, tables, db_name, table_name))
continue;
}
+ else if (schema_table_idx == SCH_TRIGGERS &&
+ db_name == &INFORMATION_SCHEMA_NAME)
+ {
+ continue;
+ }
else
{
if (!(table_open_method & ~OPEN_FRM_ONLY) &&
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index ddac315f80f..a2d4349f747 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -1,5 +1,4 @@
-/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
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
diff --git a/sql/sql_table.h b/sql/sql_table.h
index fc7eb775bef..7255ce68743 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -19,6 +19,7 @@
#include "my_global.h" /* my_bool */
#include "my_sys.h" // pthread_mutex_t
+#include "m_string.h" // LEX_CUSTRING
class Alter_info;
class Alter_table_ctx;
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index b38670bd03c..395b4ef894b 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2004, 2012, Oracle and/or its affiliates.
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
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index c792dca873c..fdc932957b2 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -352,6 +352,7 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
if (!initialized)
DBUG_RETURN(NULL);
+ DEBUG_SYNC(current_thd, "find_udf_before_lock");
/* TODO: This should be changed to reader locks someday! */
if (mark_used)
mysql_rwlock_wrlock(&THR_LOCK_udf); /* Called during fix_fields */
@@ -458,7 +459,12 @@ int mysql_create_function(THD *thd,udf_func *udf)
DBUG_RETURN(1);
}
+ tables.init_one_table(STRING_WITH_LEN("mysql"), STRING_WITH_LEN("func"),
+ "func", TL_WRITE);
+ table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT);
+
mysql_rwlock_wrlock(&THR_LOCK_udf);
+ DEBUG_SYNC(current_thd, "mysql_create_function_after_lock");
if ((my_hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length)))
{
my_error(ER_UDF_EXISTS, MYF(0), udf->name.str);
@@ -502,9 +508,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
/* create entry in mysql.func table */
- tables.init_one_table("mysql", 5, "func", 4, "func", TL_WRITE);
/* Allow creation of functions even if we can't open func table */
- if (!(table = open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
+ if (!table)
goto err;
table->use_all_columns();
restore_record(table, s->default_values); // Default values for fields
@@ -555,7 +560,12 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
DBUG_RETURN(1);
}
+ tables.init_one_table(STRING_WITH_LEN("mysql"), STRING_WITH_LEN("func"),
+ "func", TL_WRITE);
+ table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT);
+
mysql_rwlock_wrlock(&THR_LOCK_udf);
+ DEBUG_SYNC(current_thd, "mysql_drop_function_after_lock");
if (!(udf=(udf_func*) my_hash_search(&udf_hash,(uchar*) udf_name->str,
(uint) udf_name->length)))
{
@@ -572,9 +582,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
if (udf->dlhandle && !find_udf_dl(udf->dl))
dlclose(udf->dlhandle);
- tables.init_one_table("mysql", 5, "func", 4, "func", TL_WRITE);
-
- if (!(table = open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
+ if (!table)
goto err;
table->use_all_columns();
table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin);
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index e49a8abc95a..9d068e464f5 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -647,6 +647,9 @@ bool st_select_lex_unit::exec()
if (!saved_error && !was_executed)
save_union_explain(thd->lex->explain);
+ if (saved_error)
+ DBUG_RETURN(saved_error);
+
if (uncacheable || !item || !item->assigned() || describe)
{
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 5093398fa40..4ca165a6d19 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
- Copyright (c) 2011, 2013, Monty Program Ab
+/* Copyright (c) 2004, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2014, SkySQL 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
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index a5a64c065ce..b8100e05ce5 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
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
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index a871d398c68..a9684947ba4 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4534,7 +4534,7 @@ static Sys_var_ulong Sys_progress_report_time(
"Seconds between sending progress reports to the client for "
"time-consuming statements. Set to 0 to disable progress reporting.",
SESSION_VAR(progress_report_time), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, UINT_MAX), DEFAULT(56), BLOCK_SIZE(1));
+ VALID_RANGE(0, UINT_MAX), DEFAULT(5), BLOCK_SIZE(1));
const char *use_stat_tables_modes[] =
{"NEVER", "COMPLEMENTARY", "PREFERABLY", 0};
diff --git a/sql/table.cc b/sql/table.cc
index f3f18586fef..f703a302864 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1,6 +1,5 @@
-/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2008, 2013, Monty Program Ab.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2014, SkySQL 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
diff --git a/sql/table.h b/sql/table.h
index 71aaf97f596..e3290410657 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1,7 +1,7 @@
#ifndef TABLE_INCLUDED
#define TABLE_INCLUDED
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2011 Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, SkySQL 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
diff --git a/sql/transaction.h b/sql/transaction.h
index abe7823cf9b..54b25f1de2a 100644
--- a/sql/transaction.h
+++ b/sql/transaction.h
@@ -1,5 +1,4 @@
-/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
+/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
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