Commit a295acf5 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Imported Upstream version 5.5.47

parent a90934f3
/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2015, 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
......@@ -26,6 +26,7 @@
#include "sql_repl.h" // reset_master, reset_slave
#include "rpl_mi.h" // Master_info::data_lock
#include "debug_sync.h"
#include "des_key_file.h"
static void disable_checkpoints(THD *thd);
......@@ -301,7 +302,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long options,
}
}
#endif
#ifdef OPENSSL
#ifdef HAVE_OPENSSL
if (options & REFRESH_DES_KEY_FILE)
{
if (des_key_file && load_des_key_file(des_key_file))
......
......@@ -427,6 +427,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
if (ref_pointer_array && !ref->found_in_select_list)
{
int el= all_fields.elements;
DBUG_ASSERT(all_fields.elements <= select->ref_pointer_array_size);
ref_pointer_array[el]= item;
/* Add the field item to the select list of the current select. */
all_fields.push_front(item);
......@@ -832,6 +833,7 @@ JOIN::prepare(Item ***rref_pointer_array,
{
Item_field *field= new Item_field(thd, *(Item_field**)ord->item);
int el= all_fields.elements;
DBUG_ASSERT(all_fields.elements <= select_lex->ref_pointer_array_size);
ref_pointer_array[el]= field;
all_fields.push_front(field);
ord->item= ref_pointer_array + el;
......@@ -4112,6 +4114,17 @@ add_key_field(JOIN *join,
Field *field, bool eq_func, Item **value, uint num_values,
table_map usable_tables, SARGABLE_PARAM **sargables)
{
if (field->table->reginfo.join_tab == NULL)
{
/*
Due to a bug in IN-to-EXISTS (grep for real_item() in item_subselect.cc
for more info), an index over a field from an outer query might be
considered here, which is incorrect. Their query has been fully
optimized already so their reginfo.join_tab is NULL and we reject them.
*/
return;
}
uint optimize= 0;
if (eq_func &&
((join->is_allowed_hash_join_access() &&
......@@ -14902,8 +14915,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
uint temp_pool_slot=MY_BIT_NONE;
uint fieldnr= 0;
ulong reclength, string_total_length;
bool using_unique_constraint= 0;
bool use_packed_rows= 0;
bool using_unique_constraint= false;
bool use_packed_rows= false;
bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
char *tmpname,path[FN_REFLEN];
uchar *pos, *group_buff, *bitmaps;
......@@ -14977,10 +14990,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
*/
(*tmp->item)->marker=4; // Store null in key
if ((*tmp->item)->too_big_for_varchar())
using_unique_constraint=1;
using_unique_constraint= true;
}
if (param->group_length >= MAX_BLOB_WIDTH)
using_unique_constraint=1;
using_unique_constraint= true;
if (group)
distinct=0; // Can't use distinct
}
......@@ -15234,12 +15247,14 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
*blob_field++= fieldnr;
blob_count++;
}
if (new_field->real_type() == MYSQL_TYPE_STRING ||
new_field->real_type() == MYSQL_TYPE_VARCHAR)
{
string_count++;
string_total_length+= new_field->pack_length();
}
if (item->marker == 4 && item->maybe_null)
{
group_null_items++;
......@@ -15292,7 +15307,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
if (group &&
(param->group_parts > table->file->max_key_parts() ||
param->group_length > table->file->max_key_length()))
using_unique_constraint=1;
using_unique_constraint= true;
}
else
{
......@@ -15429,7 +15444,9 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
field->real_type() == MYSQL_TYPE_STRING &&
length >= MIN_STRING_LENGTH_TO_PACK_ROWS)
recinfo->type= FIELD_SKIP_ENDSPACE;
else if (field->real_type() == MYSQL_TYPE_VARCHAR)
else if (use_packed_rows &&
field->real_type() == MYSQL_TYPE_VARCHAR &&
length >= MIN_STRING_LENGTH_TO_PACK_ROWS)
recinfo->type= FIELD_VARCHAR;
else
recinfo->type= FIELD_NORMAL;
......@@ -16200,7 +16217,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
start_recinfo,
share->uniques, &uniquedef,
&create_info,
HA_CREATE_TMP_TABLE)))
HA_CREATE_TMP_TABLE |
((share->db_create_options & HA_OPTION_PACK_RECORD) ?
HA_PACK_RECORD : 0)
)))
{
table->file->print_error(error,MYF(0)); /* purecov: inspected */
table->db_stat=0;
......@@ -20596,6 +20616,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
return TRUE; /* Wrong field. */
 
uint el= all_fields.elements;
DBUG_ASSERT(all_fields.elements <=
thd->lex->current_select->ref_pointer_array_size);
all_fields.push_front(order_item); /* Add new field to field list. */
ref_pointer_array[el]= order_item;
/*
......@@ -20855,6 +20877,8 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
*/
Item_field *new_item= new Item_field(thd, (Item_field*)item);
int el= all_fields.elements;
DBUG_ASSERT(all_fields.elements <=
thd->lex->current_select->ref_pointer_array_size);
orig_ref_pointer_array[el]= new_item;
all_fields.push_front(new_item);
ord->item= orig_ref_pointer_array + el;
......
......@@ -7371,11 +7371,12 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
tmp_table_param->field_count= field_count;
tmp_table_param->schema_table= 1;
SELECT_LEX *select_lex= thd->lex->current_select;
bool keep_row_order= sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND;
if (!(table= create_tmp_table(thd, tmp_table_param,
field_list, (ORDER*) 0, 0, 0,
(select_lex->options | thd->variables.option_bits |
TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR, table_list->alias)))
TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR,
table_list->alias, false, keep_row_order)))
DBUG_RETURN(0);
my_bitmap_map* bitmaps=
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
......
......@@ -2986,9 +2986,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->interval_list);
List_iterator<String> int_it(sql_field->interval_list);
String conv, *tmp;
char comma_buf[4]; /* 4 bytes for utf32 */
char comma_buf[5]; /* 5 bytes for 'filename' charset */
DBUG_ASSERT(sizeof(comma_buf) >= cs->mbmaxlen);
int comma_length= cs->cset->wc_mb(cs, ',', (uchar*) comma_buf,
(uchar*) comma_buf +
(uchar*) comma_buf +
sizeof(comma_buf));
DBUG_ASSERT(comma_length > 0);
for (uint i= 0; (tmp= int_it++); i++)
......
......@@ -142,7 +142,7 @@ void udf_init()
DBUG_ENTER("ufd_init");
char db[]= "mysql"; /* A subject to casednstr, can't be constant */
if (initialized)
if (initialized || opt_noacl)
DBUG_VOID_RETURN;
#ifdef HAVE_PSI_INTERFACE
......@@ -267,6 +267,8 @@ void udf_free()
{
/* close all shared libraries */
DBUG_ENTER("udf_free");
if (opt_noacl)
DBUG_VOID_RETURN;
for (uint idx=0 ; idx < udf_hash.records ; idx++)
{
udf_func *udf=(udf_func*) my_hash_element(&udf_hash,idx);
......
......@@ -143,5 +143,8 @@ udf_func *find_udf(const char *name, uint len=0,bool mark_used=0);
void free_udf(udf_func *udf);
int mysql_create_function(THD *thd,udf_func *udf);
int mysql_drop_function(THD *thd,const LEX_STRING *name);
#else
static inline void udf_init(void) { }
static inline void udf_free(void) { }
#endif
#endif /* SQL_UDF_INCLUDED */
......@@ -367,6 +367,9 @@ int mysql_update(THD *thd,
DBUG_RETURN(1); /* purecov: inspected */
}
if (check_unique_table(thd, table_list))
DBUG_RETURN(TRUE);
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
if (select_lex->optimize_unflattened_subqueries(false))
DBUG_RETURN(TRUE);
......@@ -1036,19 +1039,30 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
setup_ftfuncs(select_lex))
DBUG_RETURN(TRUE);
/* Check that we are not using table that we are updating in a sub select */
{
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
update_non_unique_table_error(table_list, "UPDATE", duplicate);
DBUG_RETURN(TRUE);
}
}
select_lex->fix_prepare_information(thd, conds, &fake_conds);
DBUG_RETURN(FALSE);
}
/**
Check that we are not using table that we are updating in a sub select
@param thd Thread handle
@param table_list List of table with first to check
@retval TRUE Error
@retval FALSE OK
*/
bool check_unique_table(THD *thd, TABLE_LIST *table_list)
{
TABLE_LIST *duplicate;
DBUG_ENTER("check_unique_table");
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
update_non_unique_table_error(table_list, "UPDATE", duplicate);
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
/***************************************************************************
Update multiple tables from join
......
......@@ -27,6 +27,7 @@ typedef class st_select_lex_unit SELECT_LEX_UNIT;
bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
Item **conds, uint order_num, ORDER *order);
bool check_unique_table(THD *thd, TABLE_LIST *table_list);
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
List<Item> &values,COND *conds,
uint order_num, ORDER *order, ha_rows limit,
......
......@@ -1520,6 +1520,11 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
*/
lex->sql_command= old_lex->sql_command;
lex->duplicates= old_lex->duplicates;
/* Fields in this view can be used in upper select in case of merge. */
if (table->select_lex)
table->select_lex->select_n_where_fields+=
lex->select_lex.select_n_where_fields;
}
/*
This method has a dependency on the proper lock type being set,
......
This diff is collapsed.
......@@ -9872,6 +9872,15 @@ table_factor:
sel->add_joined_table($$);
lex->pop_context();
lex->nest_level--;
/*
Fields in derived table can be used in upper select in
case of merge. We do not add HAVING fields because we do
not merge such derived. We do not add union because
also do not merge them
*/
if (!sel->next_select())
$2->select_n_where_fields+=
sel->select_n_where_fields;
}
/*else if (($3->select_lex &&
$3->select_lex->master_unit()->is_union() &&
......
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2008, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
......@@ -2445,21 +2445,6 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
outparam->record[1]= outparam->record[0]; // Safety
}
#ifdef HAVE_valgrind
/*
We need this because when we read var-length rows, we are not updating
bytes after end of varchar
*/
if (records > 1)
{
memcpy(outparam->record[0], share->default_values, share->rec_buff_length);
memcpy(outparam->record[1], share->default_values, share->null_bytes);
if (records > 2)
memcpy(outparam->record[1], share->default_values,
share->rec_buff_length);
}
#endif
if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
(uint) ((share->fields+1)*
sizeof(Field*)))))
......
......@@ -1662,6 +1662,20 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
DBUG_RETURN(0);
}
class Net_error_handler : public Internal_error_handler
{
public:
Net_error_handler() {}
public:
bool handle_condition(THD *thd, uint sql_errno, const char* sqlstate,
MYSQL_ERROR::enum_warning_level level,
const char* msg, MYSQL_ERROR ** cond_hdl)
{
return sql_errno >= ER_ABORTING_CONNECTION &&
sql_errno <= ER_NET_WRITE_INTERRUPTED;
}
};
/*
Closes a table. We call the free_share() function to free any resources
......@@ -1683,18 +1697,15 @@ int ha_federated::close(void)
delete_dynamic(&results);
/* Disconnect from mysql */
THD *thd= ha_thd();
Net_error_handler err_handler;
if (thd)
thd->push_internal_handler(&err_handler);
mysql_close(mysql);
mysql= NULL;
if (thd)
thd->pop_internal_handler();
/*
mysql_close() might return an error if a remote server's gone
for some reason. If that happens while removing a table from
the table cache, the error will be propagated to a client even
if the original query was not issued against the FEDERATED table.
So, don't propagate errors from mysql_close().
*/
if (table->in_use)
table->in_use->clear_error();
mysql= NULL;
DBUG_RETURN(free_share(share));
}
......
......@@ -1639,6 +1639,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table)
}
static federatedx_txn zero_txn;
static int free_server(federatedx_txn *txn, FEDERATEDX_SERVER *server)
{
bool destroy;
......@@ -1654,12 +1655,9 @@ static int free_server(federatedx_txn *txn, FEDERATEDX_SERVER *server)
MEM_ROOT mem_root;
if (!txn)
{
federatedx_txn tmp_txn;
tmp_txn.close(server);
}
else
txn->close(server);
txn= &zero_txn;
txn->close(server);
DBUG_ASSERT(server->io_count == 0);
......@@ -1678,7 +1676,7 @@ static int free_server(federatedx_txn *txn, FEDERATEDX_SERVER *server)
free memory associated with it.
*/
static int free_share(federatedx_txn *txn, FEDERATEDX_SHARE *share)
static void free_share(federatedx_txn *txn, FEDERATEDX_SHARE *share)
{
bool destroy;
DBUG_ENTER("free_share");
......@@ -1701,7 +1699,7 @@ static int free_share(federatedx_txn *txn, FEDERATEDX_SHARE *share)
free_server(txn, server);
}
DBUG_RETURN(0);
DBUG_VOID_RETURN;
}
......@@ -1767,7 +1765,7 @@ int ha_federatedx::disconnect(handlerton *hton, MYSQL_THD thd)
int ha_federatedx::open(const char *name, int mode, uint test_if_locked)
{
int error;
THD *thd= current_thd;
THD *thd= ha_thd();
DBUG_ENTER("ha_federatedx::open");
if (!(share= get_share(name, table)))
......@@ -1797,6 +1795,20 @@ int ha_federatedx::open(const char *name, int mode, uint test_if_locked)
DBUG_RETURN(0);
}
class Net_error_handler : public Internal_error_handler
{
public:
Net_error_handler() {}
public:
bool handle_condition(THD *thd, uint sql_errno, const char* sqlstate,
MYSQL_ERROR::enum_warning_level level,
const char* msg, MYSQL_ERROR ** cond_hdl)
{
return sql_errno >= ER_ABORTING_CONNECTION &&
sql_errno <= ER_NET_WRITE_INTERRUPTED;
}
};
/*
Closes a table. We call the free_share() function to free any resources
......@@ -1811,8 +1823,8 @@ int ha_federatedx::open(const char *name, int mode, uint test_if_locked)
int ha_federatedx::close(void)
{
int retval= 0, error;
THD *thd= current_thd;
int retval= 0;
THD *thd= ha_thd();
DBUG_ENTER("ha_federatedx::close");
/* free the result set */
......@@ -1822,24 +1834,18 @@ int ha_federatedx::close(void)
/* Disconnect from mysql */
if (!thd || !(txn= get_txn(thd, true)))
{
federatedx_txn tmp_txn;
tmp_txn.release(&io);
txn= &zero_txn;
DBUG_ASSERT(io == NULL);
txn->release(&io);
DBUG_ASSERT(io == NULL);
if ((error= free_share(&tmp_txn, share)))
retval= error;
}
else
{
txn->release(&io);
DBUG_ASSERT(io == NULL);
Net_error_handler err_handler;
if (thd)
thd->push_internal_handler(&err_handler);
free_share(txn, share);
if (thd)
thd->pop_internal_handler();
if ((error= free_share(txn, share)))
retval= error;
}
DBUG_RETURN(retval);
}
......@@ -1862,9 +1868,8 @@ int ha_federatedx::close(void)
0 otherwise
*/
static inline uint field_in_record_is_null(TABLE *table,
Field *field,
char *record)
static inline uint field_in_record_is_null(TABLE *table, Field *field,
char *record)
{
int null_offset;
DBUG_ENTER("ha_federatedx::field_in_record_is_null");
......@@ -2203,7 +2208,7 @@ int ha_federatedx::end_bulk_insert()
*/
void ha_federatedx::update_auto_increment(void)
{
THD *thd= current_thd;
THD *thd= ha_thd();
DBUG_ENTER("ha_federatedx::update_auto_increment");
ha_federatedx::info(HA_STATUS_AUTO);
......@@ -3058,7 +3063,7 @@ int ha_federatedx::rnd_pos(uchar *buf, uchar *pos)
int ha_federatedx::info(uint flag)
{
uint error_code;
THD *thd= current_thd;
THD *thd= ha_thd();
federatedx_txn *tmp_txn;
federatedx_io *tmp_io= 0, **iop= 0;
DBUG_ENTER("ha_federatedx::info");
......@@ -3189,7 +3194,7 @@ int ha_federatedx::reset(void)
federatedx_io *tmp_io= 0, **iop;
// external_lock may not have been called so txn may not be set
tmp_txn= get_txn(current_thd);
tmp_txn= get_txn(ha_thd());
if (!*(iop= &io) && (error= tmp_txn->acquire(share, TRUE, (iop= &tmp_io))))
{
......@@ -3364,7 +3369,7 @@ int ha_federatedx::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info)
{
int retval;
THD *thd= current_thd;
THD *thd= ha_thd();
FEDERATEDX_SHARE tmp_share; // Only a temporary share, to test the url
federatedx_txn *tmp_txn;
federatedx_io *tmp_io= NULL;
......
......@@ -1140,7 +1140,7 @@ dict_create_index_step(
>= DICT_TF_FORMAT_ZIP);
node->index = dict_index_get_if_in_cache_low(index_id);
ut_a(!node->index == (err != DB_SUCCESS));
ut_a(err == DB_SUCCESS ? node->index != NULL : node->index == NULL);
if (err != DB_SUCCESS) {
......
......@@ -3628,13 +3628,13 @@ dict_foreign_push_index_error(
"%s table '%s' with foreign key constraint"
" failed. There is no index in the referenced"
" table where the referenced columns appear"
" as the first columns. Error close to %s.\n",
" as the first columns near '%s'.\n",
operation, create_name, latest_foreign);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table '%s' with foreign key constraint"
" failed. There is no index in the referenced"
" table where the referenced columns appear"
" as the first columns. Error close to %s.",
" as the first columns near '%s'.",
operation, create_name, latest_foreign);
break;
}
......@@ -3643,13 +3643,13 @@ dict_foreign_push_index_error(
"%s table '%s' with foreign key constraint"
" failed. There is only prefix index in the referenced"
" table where the referenced columns appear"
" as the first columns. Error close to %s.\n",
" as the first columns near '%s'.\n",
operation, create_name, latest_foreign);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table '%s' with foreign key constraint"
" failed. There is only prefix index in the referenced"
" table where the referenced columns appear"
" as the first columns. Error close to %s.",
" as the first columns near '%s'.",
operation, create_name, latest_foreign);
break;
}
......@@ -3657,12 +3657,12 @@ dict_foreign_push_index_error(
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. You have defined a SET NULL condition but "
"field %s on index is defined as NOT NULL close to %s\n",
"column '%s' on index is defined as NOT NULL near '%s'.\n",
operation, create_name, columns[err_col], latest_foreign);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. You have defined a SET NULL condition but "
"field %s on index is defined as NOT NULL close to %s",
"column '%s' on index is defined as NOT NULL near '%s'.",
operation, create_name, columns[err_col], latest_foreign);
break;
}
......@@ -3675,13 +3675,13 @@ dict_foreign_push_index_error(
table, dict_col_get_no(field->col));
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. Field type or character set for column %s "
"does not mach referenced column %s close to %s\n",
" failed. Field type or character set for column '%s' "
"does not mach referenced column '%s' near '%s'.\n",
operation, create_name, columns[err_col], col_name, latest_foreign);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Field type or character set for column %s "
"does not mach referenced column %s close to %s",
" failed. Field type or character set for column '%s' "
"does not mach referenced column '%s' near '%s'.",
operation, create_name, columns[err_col], col_name, latest_foreign);
break;
}
......@@ -3973,14 +3973,14 @@ dict_create_foreign_constraints_low(
if (!success) {
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4009,16 +4009,16 @@ dict_create_foreign_constraints_low(
dict_foreign_error_report_low(ef, create_name);
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
mutex_exit(&dict_foreign_err_mutex);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4038,14 +4038,14 @@ dict_create_foreign_constraints_low(
if (!success) {
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4081,14 +4081,14 @@ dict_create_foreign_constraints_low(
if (!success || !my_isspace(cs, *ptr)) {
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
}
......@@ -4148,7 +4148,7 @@ dict_create_foreign_constraints_low(
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
"close to %s.",
"near '%s'.",
operation, create_name, buf, start_of_latest_foreign);
dict_foreign_free(foreign);
......@@ -4157,7 +4157,7 @@ dict_create_foreign_constraints_low(
dict_foreign_error_report_low(ef, create_name);
fprintf(ef,
"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
"close to %s.\n",
"near '%s'.\n",
operation, create_name, buf, start_of_latest_foreign);
mutex_exit(&dict_foreign_err_mutex);
......@@ -4172,14 +4172,14 @@ dict_create_foreign_constraints_low(
dict_foreign_free(foreign);
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4201,16 +4201,16 @@ dict_create_foreign_constraints_low(
dict_foreign_error_report_low(ef, create_name);
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, orig);
mutex_exit(&dict_foreign_err_mutex);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, orig);
return(DB_CANNOT_ADD_CONSTRAINT);
}
......@@ -4228,14 +4228,12 @@ dict_create_foreign_constraints_low(
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s. Too few referenced columns.\n",
" failed. Parse error in '%s' near '%s'. Referencing column count does not match referenced column count.\n",
operation, create_name, start_of_latest_foreign, orig);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s. Too few referenced columns, you have %d when you should have %d.",
" failed. Parse error in '%s' near '%s'. Referencing column count %d does not match referenced column count %d.\n",
operation, create_name, start_of_latest_foreign, orig, i, foreign->n_fields);
dict_foreign_free(foreign);
......@@ -4268,14 +4266,14 @@ dict_create_foreign_constraints_low(
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4316,14 +4314,14 @@ dict_create_foreign_constraints_low(
dict_foreign_free(foreign);
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4345,14 +4343,14 @@ dict_create_foreign_constraints_low(
dict_foreign_free(foreign);
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
return(DB_CANNOT_ADD_CONSTRAINT);
......@@ -4365,14 +4363,14 @@ dict_create_foreign_constraints_low(
dict_foreign_free(foreign);
dict_foreign_report_syntax_err(
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.\n",
" failed. Parse error in '%s'"
" near '%s'.\n",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. Foreign key constraint parse error in %s"
" close to %s.",
" failed. Parse error in '%s'"
" near '%s'.",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
return(DB_CANNOT_ADD_CONSTRAINT);
}
......@@ -4392,16 +4390,16 @@ dict_create_foreign_constraints_low(
dict_foreign_error_report_low(ef, create_name);
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
" in %s close to %s.\n",
" failed. You have defined a SET NULL condition but column '%s' is defined as NOT NULL"
" in '%s' near '%s'.\n",
operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
mutex_exit(&dict_foreign_err_mutex);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
" in %s close to %s.",
" failed. You have defined a SET NULL condition but column '%s' is defined as NOT NULL"
" in '%s' near '%s'.",
operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
dict_foreign_free(foreign);
......@@ -4427,14 +4425,14 @@ dict_create_foreign_constraints_low(
fprintf(ef,
"%s table %s with foreign key constraint"
" failed. You have more than one on delete or on update clause"
" in %s close to %s.\n",
" in '%s' near '%s'.\n",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
mutex_exit(&dict_foreign_err_mutex);
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
"%s table %s with foreign key constraint"
" failed. You have more than one on delete or on update clause"
" in %s close to %s.",
" in '%s' near '%s'.",
operation, create_name, start_of_latest_foreign, start_of_latest_set);
dict_foreign_free(foreign);
return(DB_CANNOT_ADD_CONSTRAINT);
......
......@@ -1504,10 +1504,11 @@ innobase_next_autoinc(
if (next_value == 0) {
ulonglong next;
if (current > offset) {
if (current >= offset) {
next = (current - offset) / step;
} else {
next = (offset - current) / step;
next = 0;
block -= step;
}
ut_a(max_value > next);
......@@ -4053,7 +4054,7 @@ ha_innobase::open(
}
ib_table = dict_table_get(
par_case_name, FALSE, ignore_err);
par_case_name, TRUE, ignore_err);
}
if (ib_table) {
#ifndef __WIN__
......@@ -5214,9 +5215,9 @@ ha_innobase::write_row(
DBUG_ENTER("ha_innobase::write_row");
if (prebuilt->trx != trx) {
sql_print_error("The transaction object for the table handle is at "
"%p, but for the current thread it is at %p",
(const void*) prebuilt->trx, (const void*) trx);
sql_print_error("The transaction object for the table handle is at "
"%p, but for the current thread it is at %p",
(const void*) prebuilt->trx, (const void*) trx);
fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
......@@ -6648,7 +6649,8 @@ create_table_def(
/* MySQL does the name length check. But we do additional check
on the name length here */
if (strlen(table_name) > MAX_FULL_NAME_LEN) {
const size_t table_name_len = strlen(table_name);
if (table_name_len > MAX_FULL_NAME_LEN) {
push_warning_printf(
(THD*) trx->mysql_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_NAME,
......@@ -6657,6 +6659,15 @@ create_table_def(
DBUG_RETURN(ER_TABLE_NAME);
}
if (table_name[table_name_len - 1] == '/') {
push_warning_printf(
(THD*) trx->mysql_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_NAME,
"InnoDB: Table name is empty");
DBUG_RETURN(ER_WRONG_TABLE_NAME);
}
n_cols = form->s->fields;
/* We pass 0 as the space id, and determine at a lower level the space
......@@ -10445,15 +10456,12 @@ ha_innobase::get_auto_increment(
current = *first_value;
/* If the increment step of the auto increment column
decreases then it is not affecting the immediate
next value in the series. */
if (prebuilt->autoinc_increment > increment) {
if (prebuilt->autoinc_increment != increment) {
current = autoinc - prebuilt->autoinc_increment;
current = innobase_next_autoinc(
current, 1, increment, 1, col_max_value);
current, 1, increment, offset, col_max_value);
dict_table_autoinc_initialize(prebuilt->table, current);
......
/*****************************************************************************
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
Copyright (c) 1997, 2015, 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 the Free Software
......@@ -736,6 +736,10 @@ recv_find_max_checkpoint(
fprintf(stderr,
"InnoDB: No valid checkpoint found.\n"
"InnoDB: If you are attempting downgrade"
" from MySQL 5.7.9 or later,\n"
"InnoDB: please refer to " REFMAN
"upgrading-downgrading.html\n"
"InnoDB: If this error appears when you are"
" creating an InnoDB database,\n"
"InnoDB: the problem may be that during"
......@@ -1763,7 +1767,7 @@ recv_apply_hashed_log_recs(
goto loop;
}
ut_ad(!allow_ibuf == mutex_own(&log_sys->mutex));
ut_ad(allow_ibuf == FALSE ? mutex_own(&log_sys->mutex) : !mutex_own(&log_sys->mutex));
if (!allow_ibuf) {
recv_no_ibuf_operations = TRUE;
......
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates
Copyright (c) 2010, 2015, MariaDB
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
......@@ -473,7 +474,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_del[i]=HA_OFFSET_ERROR;
unique_key_parts=0;
offset=reclength-uniques*MI_UNIQUE_HASH_LENGTH;
for (i=0, uniquedef=uniquedefs ; i < uniques ; i++ , uniquedef++)
{
uniquedef->key=keys+i;
......@@ -739,7 +739,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
#endif
}
/* Create extra keys for unique definitions */
offset=reclength-uniques*MI_UNIQUE_HASH_LENGTH;
offset=real_reclength - uniques * MI_UNIQUE_HASH_LENGTH;
bzero((char*) &tmp_keydef,sizeof(tmp_keydef));
bzero((char*) &tmp_keyseg,sizeof(tmp_keyseg));
for (i=0; i < uniques ; i++)
......
......@@ -3140,189 +3140,3 @@ static uint32_t pack_key_from_desc(
return (uint32_t)(packed_key_pos - buf); //
}
static bool fields_have_same_name(Field* a, Field* b) {
return strcmp(a->field_name, b->field_name) == 0;
}
static bool fields_are_same_type(Field* a, Field* b) {
bool retval = true;
enum_field_types a_mysql_type = a->real_type();
enum_field_types b_mysql_type = b->real_type();
TOKU_TYPE a_toku_type = mysql_to_toku_type(a);
TOKU_TYPE b_toku_type = mysql_to_toku_type(b);
// make sure have same names
// make sure have same types
if (a_mysql_type != b_mysql_type) {
retval = false;
goto cleanup;
}
// Thanks to MariaDB 5.5, we can have two fields
// be the same MySQL type but not the same toku type,
// This is an issue introduced with MariaDB's fractional time
// implementation
if (a_toku_type != b_toku_type) {
retval = false;
goto cleanup;
}
// make sure that either both are nullable, or both not nullable
if ((a->null_bit && !b->null_bit) || (!a->null_bit && b->null_bit)) {
retval = false;
goto cleanup;
}
switch (a_mysql_type) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:
// length, unsigned, auto increment
if (a->pack_length() != b->pack_length() ||
(a->flags & UNSIGNED_FLAG) != (b->flags & UNSIGNED_FLAG) ||
(a->flags & AUTO_INCREMENT_FLAG) != (b->flags & AUTO_INCREMENT_FLAG)) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_FLOAT:
// length, unsigned, auto increment
if (a->pack_length() != b->pack_length() ||
(a->flags & UNSIGNED_FLAG) != (b->flags & UNSIGNED_FLAG) ||
(a->flags & AUTO_INCREMENT_FLAG) != (b->flags & AUTO_INCREMENT_FLAG)) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_NEWDECIMAL:
// length, unsigned
if (a->pack_length() != b->pack_length() ||
(a->flags & UNSIGNED_FLAG) != (b->flags & UNSIGNED_FLAG)) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_ENUM: {
Field_enum *a_enum = static_cast<Field_enum *>(a);
if (!a_enum->eq_def(b)) {
retval = false;
goto cleanup;
}
break;
}
case MYSQL_TYPE_SET: {
Field_set *a_set = static_cast<Field_set *>(a);
if (!a_set->eq_def(b)) {
retval = false;
goto cleanup;
}
break;
}
case MYSQL_TYPE_BIT:
// length
if (a->pack_length() != b->pack_length()) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_TIMESTAMP:
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799) || \
(100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100099)
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_TIME2:
#endif
// length
if (a->pack_length() != b->pack_length()) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_LONG_BLOB:
// test the charset
if (a->charset()->number != b->charset()->number) {
retval = false;
goto cleanup;
}
if (a->row_pack_length() != b->row_pack_length()) {
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_STRING:
if (a->pack_length() != b->pack_length()) {
retval = false;
goto cleanup;
}
// if both are binary, we know have same pack lengths,
// so we can goto end
if (a->binary() && b->binary()) {
// nothing to do, we are good
}
else if (!a->binary() && !b->binary()) {
// test the charset
if (a->charset()->number != b->charset()->number) {
retval = false;
goto cleanup;
}
}
else {
// one is binary and the other is not, so not the same
retval = false;
goto cleanup;
}
break;
case MYSQL_TYPE_VARCHAR:
if (a->field_length != b->field_length) {
retval = false;
goto cleanup;
}
// if both are binary, we know have same pack lengths,
// so we can goto end
if (a->binary() && b->binary()) {
// nothing to do, we are good
}
else if (!a->binary() && !b->binary()) {
// test the charset
if (a->charset()->number != b->charset()->number) {
retval = false;
goto cleanup;
}
}
else {
// one is binary and the other is not, so not the same
retval = false;
goto cleanup;
}
break;
//
// I believe these are old types that are no longer
// in any 5.1 tables, so tokudb does not need
// to worry about them
// Putting in this assert in case I am wrong.
// Do not support geometry yet.
//
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_NULL:
assert(false);
}
cleanup:
return retval;
}
static bool are_two_fields_same(Field* a, Field* b) {
return fields_have_same_name(a, b) && fields_are_same_type(a, b);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment