summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-02-25 16:04:35 +0100
committerSergei Golubchik <sergii@pisem.net>2014-02-25 16:04:35 +0100
commit0b9a0a3517ca2b75655f3af5c372cf333d3d5fe2 (patch)
tree5c67457ff8abbb89b203a7f55cda776b738c385b /sql
parent6324c36bd703a0f55dcd49dd721af262f73cf7aa (diff)
parentff2e82f4a175b7b023cd167b2fa6e6fcd1bd192e (diff)
downloadmariadb-git-0b9a0a3517ca2b75655f3af5c372cf333d3d5fe2.tar.gz
5.5 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.cc75
-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_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_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
87 files changed, 505 insertions, 255 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 0d8e7f3ff42..cacc87356d4 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 07f5a520e64..f005f8787ed 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2010, 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/event_scheduler.h b/sql/event_scheduler.h
index 9435ee548d9..538514b8b12 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 c449b9009f2..b0d7c00478c 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 d6fc4b5ea67..223f68c8370 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 d8630e181fb..8aa02440e22 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
@@ -2051,18 +2051,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 7bc8c1d972e..be84dd0736c 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)
@@ -732,12 +824,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)
{
@@ -880,8 +977,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;
@@ -909,25 +1004,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;
@@ -938,6 +1021,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 f8b2ed8429a..e1bd6271866 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 27675588ed7..2387dcaf5ba 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 67406627e20..248b95751af 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -80,18 +80,18 @@ 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
};
-
static int partition_initialize(void *p)
{
@@ -4527,8 +4527,8 @@ bool ha_partition::init_record_priority_queue()
} while (++i < m_tot_parts);
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;
@@ -4724,6 +4724,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
@@ -5551,7 +5597,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");
@@ -5586,9 +5632,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);
}
@@ -7619,6 +7668,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 3540dd8c8ab..f9a6f4b3fcf 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 9d2d4a6dbfd..6542888d511 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1682,17 +1682,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");
}
@@ -5235,8 +5246,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)))
@@ -5257,7 +5268,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.
@@ -5270,7 +5286,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
@@ -8246,7 +8262,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,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_VIEW_FIELD,
diff --git a/sql/item.h b/sql/item.h
index 2617e96989e..d73e858d68e 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2104,7 +2104,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);
}
}
@@ -3440,6 +3444,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 a0d9b7c20fa..0a26569aafd 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 2e3f352e377..3c15ca0094d 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 b5289c9b3cc..a38e9d416a7 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 7dcd6f26deb..09a976b5edd 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1084,6 +1084,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;
}
@@ -2013,18 +2014,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))
{
@@ -2037,6 +2055,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 7144289a1de..3986e488dab 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3343,7 +3343,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;
@@ -3357,7 +3357,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;
@@ -3591,9 +3591,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;
@@ -3606,7 +3603,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 e806f45041a..f83f2557e07 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 e539d0b76b4..c824cc70617 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 e238668d6ab..064038a06fe 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 0d3db2d5bf5..110b13000ed 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 0eeda58cd17..f5f9a19178c 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 6fead95a4b1..155b50946a3 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 d0cfa799d3c..0aa53a6f2bd 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -19,6 +19,7 @@
#ifdef MYSQL_CLIENT
#include "sql_priv.h"
+#include "mysqld_error.h"
#else
@@ -2424,6 +2425,14 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
else
{
my_b_printf(file, "### @%d=", 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));
@@ -5440,11 +5449,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 312a9656d01..4dc33f7a747 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -4295,13 +4295,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 ef81739a543..192123e603f 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
@@ -204,11 +204,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 4b1c7f647b1..22ae38bef41 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 d95d856c18f..7066eba00ac 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
@@ -5399,7 +5399,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 4fdd34fd8be..71fdd3ee5bd 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_subselect.cc b/sql/opt_subselect.cc
index 48f58bc0e96..2cc7447202c 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5283,6 +5283,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= test(join->mixed_implicit_grouping);
}
if ((nested_join= table->nested_join))
@@ -5313,9 +5314,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++))
{
@@ -5327,6 +5328,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 d44f193dcf2..07aa3c64633 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 4f03d91035a..75033d3552f 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 a590f8a0b2c..2a7c1bede0e 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 12df72a251b..1d4eedbb017 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 bded28cb542..678a2bf978d 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -186,7 +186,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 *
*********************************************************************/
@@ -197,7 +197,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:
@@ -285,7 +285,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;
}
@@ -295,17 +294,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
@@ -331,7 +319,6 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
}
length+= m_field_metadata[col];
-#endif
break;
}
default:
@@ -340,7 +327,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 e690f06af2e..4b544090dcd 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -129,7 +129,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 fb691a9c095..a266b24165b 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, 2011, 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 229bbb3ff70..e25109385e3 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 33b0fd13267..b0c67fbfe32 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 07209c30ff3..a4c2f470bb1 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 879316f1da3..58bc440174f 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 5398e3019f1..43d8f70c6f4 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 f287bf47e81..36026a39616 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 f71b09f740b..8172610607a 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 9bcfe64cf2d..99ebf59235a 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 7e163b0dbcc..f9ef9b6c63c 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 0a2c0528539..cbb8bbc0fd4 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1326,6 +1326,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 e7bea820c6e..0e078f2aac4 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 9d014790929..778c732d443 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 b9bf3dbc217..a03dcc5c16e 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 f25c424e29a..efc49c6286b 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
@@ -1341,6 +1341,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_repl.cc b/sql/sql_repl.cc
index 7c4e5b1b383..33a0ab5b4f1 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 fb258b1d5aa..93e67c484e3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -730,7 +730,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)
{
@@ -769,7 +769,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;
}
@@ -3433,13 +3433,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));
@@ -3828,7 +3822,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;
@@ -11480,7 +11476,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.
@@ -21029,7 +21025,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 b05bdd68689..5ecc3f0b18e 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1150,7 +1150,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 aac5932c593..27fe535a3ab 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4821,6 +4821,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 4c1e4af5ff5..36415d2cb50 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 02e72fc564c..837bcdcbbfb 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 Create_field;
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index c7d47487c6a..d0c5bcf03c0 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 448e3c88d17..6cfdd9ebee8 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 2554909aea9..0b9dd782956 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 48c77c7c99f..452937024f7 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 69d93968f9f..77ea9e7a994 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4327,7 +4327,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 b9f2731e46e..957e911e462 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 99dda3b6bf1..b4aa0739f74 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