2015-10-08 22:54:24 +02:00
|
|
|
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
|
2018-02-19 10:37:29 +01:00
|
|
|
Copyright (c) 2010, 2018, MariaDB Corporation.
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
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
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
/* Some general useful functions */
|
|
|
|
|
2006-02-28 22:07:14 +01:00
|
|
|
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2017-06-18 05:42:16 +02:00
|
|
|
#include "mariadb.h"
|
2014-09-30 19:31:14 +02:00
|
|
|
#include <my_global.h>
|
2016-12-31 16:33:26 +01:00
|
|
|
#include <tztime.h>
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_priv.h"
|
|
|
|
// Required to get server definitions for mysql/plugin.h right
|
|
|
|
#include "sql_plugin.h"
|
2013-06-15 17:32:08 +02:00
|
|
|
#include "sql_partition.h" // partition_info.h: LIST_PART_ENTRY
|
|
|
|
// NOT_A_PARTITION_ID
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "partition_info.h"
|
2017-03-03 00:37:54 +01:00
|
|
|
#include "sql_parse.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_acl.h" // *_ACL
|
2013-06-15 17:32:08 +02:00
|
|
|
#include "sql_base.h" // fill_record
|
2016-12-11 18:04:11 +01:00
|
|
|
#include "sql_statistics.h" // vers_stat_end
|
2017-12-20 19:04:22 +01:00
|
|
|
#include "vers_utils.h"
|
2017-12-21 16:24:58 +01:00
|
|
|
#include "lock.h"
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
2006-04-13 22:49:29 +02:00
|
|
|
#include "ha_partition.h"
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
partition_info *partition_info::get_clone(THD *thd)
|
2006-03-18 15:48:21 +01:00
|
|
|
{
|
2015-08-24 13:42:07 +02:00
|
|
|
MEM_ROOT *mem_root= thd->mem_root;
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_ENTER("partition_info::get_clone");
|
2015-08-24 13:42:07 +02:00
|
|
|
|
2006-03-18 15:48:21 +01:00
|
|
|
List_iterator<partition_element> part_it(partitions);
|
|
|
|
partition_element *part;
|
2017-09-07 14:49:11 +02:00
|
|
|
partition_info *clone= new (mem_root) partition_info(*this);
|
2018-04-12 01:57:19 +02:00
|
|
|
if (unlikely(!clone))
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(NULL);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions));
|
|
|
|
memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions));
|
|
|
|
clone->bitmaps_are_initialized= FALSE;
|
2006-03-18 15:48:21 +01:00
|
|
|
clone->partitions.empty();
|
|
|
|
|
|
|
|
while ((part= (part_it++)))
|
|
|
|
{
|
|
|
|
List_iterator<partition_element> subpart_it(part->subpartitions);
|
|
|
|
partition_element *subpart;
|
2015-08-24 13:42:07 +02:00
|
|
|
partition_element *part_clone= new (mem_root) partition_element();
|
2006-03-18 15:48:21 +01:00
|
|
|
if (!part_clone)
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(NULL);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2019-03-12 16:27:19 +01:00
|
|
|
*part_clone= *part;
|
2006-03-18 15:48:21 +01:00
|
|
|
part_clone->subpartitions.empty();
|
|
|
|
while ((subpart= (subpart_it++)))
|
|
|
|
{
|
2015-10-12 00:37:58 +02:00
|
|
|
partition_element *subpart_clone= new (mem_root) partition_element();
|
2006-03-18 15:48:21 +01:00
|
|
|
if (!subpart_clone)
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(NULL);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2019-03-12 16:27:19 +01:00
|
|
|
*subpart_clone= *subpart;
|
2015-08-24 13:42:07 +02:00
|
|
|
part_clone->subpartitions.push_back(subpart_clone, mem_root);
|
2006-03-18 15:48:21 +01:00
|
|
|
}
|
2015-08-24 13:42:07 +02:00
|
|
|
clone->partitions.push_back(part_clone, mem_root);
|
2015-05-06 13:19:22 +02:00
|
|
|
part_clone->list_val_list.empty();
|
|
|
|
List_iterator<part_elem_value> list_val_it(part->list_val_list);
|
|
|
|
part_elem_value *new_val_arr=
|
2015-10-12 00:37:58 +02:00
|
|
|
(part_elem_value *)alloc_root(mem_root, sizeof(part_elem_value) *
|
|
|
|
part->list_val_list.elements);
|
2015-05-06 13:19:22 +02:00
|
|
|
if (!new_val_arr)
|
|
|
|
DBUG_RETURN(NULL);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2015-05-06 13:19:22 +02:00
|
|
|
p_column_list_val *new_colval_arr=
|
2015-10-12 00:37:58 +02:00
|
|
|
(p_column_list_val*)alloc_root(mem_root, sizeof(p_column_list_val) *
|
|
|
|
num_columns *
|
|
|
|
part->list_val_list.elements);
|
2015-05-06 13:19:22 +02:00
|
|
|
if (!new_colval_arr)
|
|
|
|
DBUG_RETURN(NULL);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2015-05-06 13:19:22 +02:00
|
|
|
part_elem_value *val;
|
|
|
|
while ((val= list_val_it++))
|
|
|
|
{
|
|
|
|
part_elem_value *new_val= new_val_arr++;
|
|
|
|
memcpy(new_val, val, sizeof(part_elem_value));
|
|
|
|
if (!val->null_value)
|
|
|
|
{
|
|
|
|
p_column_list_val *new_colval= new_colval_arr;
|
|
|
|
new_colval_arr+= num_columns;
|
|
|
|
memcpy(new_colval, val->col_val_array,
|
|
|
|
sizeof(p_column_list_val) * num_columns);
|
|
|
|
new_val->col_val_array= new_colval;
|
|
|
|
}
|
2015-10-12 00:37:58 +02:00
|
|
|
part_clone->list_val_list.push_back(new_val, mem_root);
|
2015-05-06 13:19:22 +02:00
|
|
|
}
|
2006-03-18 15:48:21 +01:00
|
|
|
}
|
2016-12-11 18:04:11 +01:00
|
|
|
if (part_type == VERSIONING_PARTITION && vers_info)
|
|
|
|
{
|
|
|
|
// clone Vers_part_info; set now_part, hist_part
|
|
|
|
clone->vers_info= new (mem_root) Vers_part_info(*vers_info);
|
|
|
|
List_iterator<partition_element> it(clone->partitions);
|
|
|
|
while ((part= it++))
|
|
|
|
{
|
|
|
|
if (vers_info->now_part && part->id == vers_info->now_part->id)
|
|
|
|
clone->vers_info->now_part= part;
|
|
|
|
else if (vers_info->hist_part && part->id == vers_info->hist_part->id)
|
|
|
|
clone->vers_info->hist_part= part;
|
|
|
|
} // while ((part= it++))
|
|
|
|
} // if (part_type == VERSIONING_PARTITION ...
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(clone);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Mark named [sub]partition to be used/locked.
|
|
|
|
|
|
|
|
@param part_name Partition name to match.
|
|
|
|
@param length Partition name length.
|
|
|
|
|
|
|
|
@return Success if partition found
|
|
|
|
@retval true Partition found
|
|
|
|
@retval false Partition not found
|
|
|
|
*/
|
|
|
|
|
2018-02-06 13:55:58 +01:00
|
|
|
bool partition_info::add_named_partition(const char *part_name, size_t length)
|
2013-06-15 17:32:08 +02:00
|
|
|
{
|
|
|
|
HASH *part_name_hash;
|
|
|
|
PART_NAME_DEF *part_def;
|
|
|
|
Partition_share *part_share;
|
|
|
|
DBUG_ENTER("partition_info::add_named_partition");
|
|
|
|
DBUG_ASSERT(table && table->s && table->s->ha_share);
|
|
|
|
part_share= static_cast<Partition_share*>((table->s->ha_share));
|
|
|
|
DBUG_ASSERT(part_share->partition_name_hash_initialized);
|
|
|
|
part_name_hash= &part_share->partition_name_hash;
|
|
|
|
DBUG_ASSERT(part_name_hash->records);
|
|
|
|
|
|
|
|
part_def= (PART_NAME_DEF*) my_hash_search(part_name_hash,
|
|
|
|
(const uchar*) part_name,
|
|
|
|
length);
|
|
|
|
if (!part_def)
|
|
|
|
{
|
2013-07-08 21:55:11 +02:00
|
|
|
my_error(ER_UNKNOWN_PARTITION, MYF(0), part_name, table->alias.c_ptr());
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (part_def->is_subpart)
|
|
|
|
{
|
|
|
|
bitmap_set_bit(&read_partitions, part_def->part_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (is_sub_partitioned())
|
|
|
|
{
|
|
|
|
/* Mark all subpartitions in the partition */
|
|
|
|
uint j, start= part_def->part_id;
|
|
|
|
uint end= start + num_subparts;
|
|
|
|
for (j= start; j < end; j++)
|
|
|
|
bitmap_set_bit(&read_partitions, j);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bitmap_set_bit(&read_partitions, part_def->part_id);
|
|
|
|
}
|
|
|
|
DBUG_PRINT("info", ("Found partition %u is_subpart %d for name %s",
|
|
|
|
part_def->part_id, part_def->is_subpart,
|
|
|
|
part_name));
|
|
|
|
DBUG_RETURN(false);
|
2006-03-18 15:48:21 +01:00
|
|
|
}
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Mark named [sub]partition to be used/locked.
|
|
|
|
|
|
|
|
@param part_elem Partition element that matched.
|
|
|
|
*/
|
|
|
|
|
2018-02-06 13:55:58 +01:00
|
|
|
bool partition_info::set_named_partition_bitmap(const char *part_name, size_t length)
|
2013-06-15 17:32:08 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::set_named_partition_bitmap");
|
|
|
|
bitmap_clear_all(&read_partitions);
|
|
|
|
if (add_named_partition(part_name, length))
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
bitmap_copy(&lock_partitions, &read_partitions);
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-20 08:06:58 +01:00
|
|
|
/**
|
|
|
|
Prune away partitions not mentioned in the PARTITION () clause,
|
|
|
|
if used.
|
|
|
|
|
|
|
|
@param table_list Table list pointing to table to prune.
|
|
|
|
|
|
|
|
@return Operation status
|
|
|
|
@retval false Success
|
|
|
|
@retval true Failure
|
|
|
|
*/
|
|
|
|
bool partition_info::set_read_partitions(List<char> *partition_names)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::set_read_partitions");
|
|
|
|
if (!partition_names || !partition_names->elements)
|
|
|
|
{
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint num_names= partition_names->elements;
|
|
|
|
List_iterator<char> partition_names_it(*partition_names);
|
|
|
|
uint i= 0;
|
|
|
|
/*
|
|
|
|
TODO: When adding support for FK in partitioned tables, the referenced
|
|
|
|
table must probably lock all partitions for read, and also write depending
|
|
|
|
of ON DELETE/UPDATE.
|
|
|
|
*/
|
|
|
|
bitmap_clear_all(&read_partitions);
|
|
|
|
|
|
|
|
/* No check for duplicate names or overlapping partitions/subpartitions. */
|
|
|
|
|
|
|
|
DBUG_PRINT("info", ("Searching through partition_name_hash"));
|
|
|
|
do
|
|
|
|
{
|
|
|
|
char *part_name= partition_names_it++;
|
|
|
|
if (add_named_partition(part_name, strlen(part_name)))
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
} while (++i < num_names);
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
/**
|
|
|
|
Prune away partitions not mentioned in the PARTITION () clause,
|
|
|
|
if used.
|
|
|
|
|
2018-01-29 08:01:14 +01:00
|
|
|
@param partition_names list of names of partitions.
|
2013-06-15 17:32:08 +02:00
|
|
|
|
|
|
|
@return Operation status
|
|
|
|
@retval true Failure
|
|
|
|
@retval false Success
|
|
|
|
*/
|
2018-01-29 08:01:14 +01:00
|
|
|
bool partition_info::prune_partition_bitmaps(List<String> *partition_names)
|
2013-06-15 17:32:08 +02:00
|
|
|
{
|
2018-01-29 08:01:14 +01:00
|
|
|
List_iterator<String> partition_names_it(*(partition_names));
|
|
|
|
uint num_names= partition_names->elements;
|
2013-06-15 17:32:08 +02:00
|
|
|
uint i= 0;
|
|
|
|
DBUG_ENTER("partition_info::prune_partition_bitmaps");
|
|
|
|
|
|
|
|
if (num_names < 1)
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO: When adding support for FK in partitioned tables, the referenced
|
|
|
|
table must probably lock all partitions for read, and also write depending
|
|
|
|
of ON DELETE/UPDATE.
|
|
|
|
*/
|
|
|
|
bitmap_clear_all(&read_partitions);
|
|
|
|
|
|
|
|
/* No check for duplicate names or overlapping partitions/subpartitions. */
|
|
|
|
|
|
|
|
DBUG_PRINT("info", ("Searching through partition_name_hash"));
|
|
|
|
do
|
|
|
|
{
|
|
|
|
String *part_name_str= partition_names_it++;
|
|
|
|
if (add_named_partition(part_name_str->c_ptr(), part_name_str->length()))
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
} while (++i < num_names);
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set read/lock_partitions bitmap over non pruned partitions
|
|
|
|
|
2018-01-29 08:01:14 +01:00
|
|
|
@param partition_names list of partition names to query
|
2013-06-15 17:32:08 +02:00
|
|
|
|
|
|
|
@return Operation status
|
|
|
|
@retval FALSE OK
|
|
|
|
@retval TRUE Failed to allocate memory for bitmap or list of partitions
|
|
|
|
did not match
|
|
|
|
|
|
|
|
@note OK to call multiple times without the need for free_bitmaps.
|
|
|
|
*/
|
|
|
|
|
2018-01-29 08:01:14 +01:00
|
|
|
bool partition_info::set_partition_bitmaps(List<String> *partition_names)
|
2013-06-15 17:32:08 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::set_partition_bitmaps");
|
|
|
|
|
|
|
|
DBUG_ASSERT(bitmaps_are_initialized);
|
|
|
|
DBUG_ASSERT(table);
|
|
|
|
if (!bitmaps_are_initialized)
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
|
2018-01-29 08:01:14 +01:00
|
|
|
if (partition_names &&
|
|
|
|
partition_names->elements)
|
2013-06-15 17:32:08 +02:00
|
|
|
{
|
|
|
|
if (table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION)
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_CLAUSE_ON_NONPARTITIONED, MYF(0));
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
2018-01-29 08:01:14 +01:00
|
|
|
if (prune_partition_bitmaps(partition_names))
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bitmap_set_all(&read_partitions);
|
|
|
|
DBUG_PRINT("info", ("Set all partitions"));
|
|
|
|
}
|
|
|
|
bitmap_copy(&lock_partitions, &read_partitions);
|
|
|
|
DBUG_ASSERT(bitmap_get_first_set(&lock_partitions) != MY_BIT_NONE);
|
|
|
|
DBUG_RETURN(FALSE);
|
2006-03-18 15:48:21 +01:00
|
|
|
}
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
|
2018-01-29 08:01:14 +01:00
|
|
|
/**
|
|
|
|
Set read/lock_partitions bitmap over non pruned partitions
|
|
|
|
|
|
|
|
@param table_list Possible TABLE_LIST which can contain
|
|
|
|
list of partition names to query
|
|
|
|
|
|
|
|
@return Operation status
|
|
|
|
@retval FALSE OK
|
|
|
|
@retval TRUE Failed to allocate memory for bitmap or list of partitions
|
|
|
|
did not match
|
|
|
|
|
|
|
|
@note OK to call multiple times without the need for free_bitmaps.
|
|
|
|
*/
|
|
|
|
bool partition_info::set_partition_bitmaps_from_table(TABLE_LIST *table_list)
|
|
|
|
{
|
|
|
|
List<String> *partition_names= table_list ?
|
|
|
|
NULL : table_list->partition_names;
|
|
|
|
return set_partition_bitmaps(partition_names);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
/*
|
|
|
|
Create a memory area where default partition names are stored and fill it
|
|
|
|
up with the names.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
create_default_partition_names()
|
|
|
|
part_no Partition number for subparts
|
2009-10-01 15:04:42 +02:00
|
|
|
num_parts Number of partitions
|
2006-02-16 17:38:33 +01:00
|
|
|
start_no Starting partition number
|
|
|
|
subpart Is it subpartitions
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
A pointer to the memory area of the default partition names
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
A support routine for the partition code where default values are
|
|
|
|
generated.
|
|
|
|
The external routine needing this code is check_partition_info
|
|
|
|
*/
|
|
|
|
|
2006-04-21 14:37:09 +02:00
|
|
|
#define MAX_PART_NAME_SIZE 8
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2015-11-18 20:54:01 +01:00
|
|
|
char *partition_info::create_default_partition_names(THD *thd, uint part_no,
|
2009-10-01 15:04:42 +02:00
|
|
|
uint num_parts_arg,
|
2006-04-12 05:35:48 +02:00
|
|
|
uint start_no)
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2015-11-18 20:54:01 +01:00
|
|
|
char *ptr= (char*) thd->calloc(num_parts_arg * MAX_PART_NAME_SIZE);
|
2006-02-16 17:38:33 +01:00
|
|
|
char *move_ptr= ptr;
|
|
|
|
uint i= 0;
|
|
|
|
DBUG_ENTER("create_default_partition_names");
|
|
|
|
|
|
|
|
if (likely(ptr != 0))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2010-07-09 14:00:17 +02:00
|
|
|
sprintf(move_ptr, "p%u", (start_no + i));
|
|
|
|
move_ptr+= MAX_PART_NAME_SIZE;
|
2009-10-01 15:04:42 +02:00
|
|
|
} while (++i < num_parts_arg);
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
DBUG_RETURN(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-12 05:35:48 +02:00
|
|
|
/*
|
|
|
|
Create a unique name for the subpartition as part_name'sp''subpart_no'
|
2013-06-15 17:32:08 +02:00
|
|
|
|
2006-04-12 05:35:48 +02:00
|
|
|
SYNOPSIS
|
2013-06-15 17:32:08 +02:00
|
|
|
create_default_subpartition_name()
|
2006-04-12 05:35:48 +02:00
|
|
|
subpart_no Number of subpartition
|
|
|
|
part_name Name of partition
|
|
|
|
RETURN VALUES
|
|
|
|
>0 A reference to the created name string
|
|
|
|
0 Memory allocation error
|
|
|
|
*/
|
|
|
|
|
2015-11-18 20:54:01 +01:00
|
|
|
char *partition_info::create_default_subpartition_name(THD *thd, uint subpart_no,
|
2006-04-21 14:37:09 +02:00
|
|
|
const char *part_name)
|
2006-04-12 05:35:48 +02:00
|
|
|
{
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t size_alloc= strlen(part_name) + MAX_PART_NAME_SIZE;
|
2015-11-18 20:54:01 +01:00
|
|
|
char *ptr= (char*) thd->calloc(size_alloc);
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_ENTER("create_default_subpartition_name");
|
2006-04-12 05:35:48 +02:00
|
|
|
|
|
|
|
if (likely(ptr != NULL))
|
2010-07-09 14:00:17 +02:00
|
|
|
my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2006-04-12 05:35:48 +02:00
|
|
|
DBUG_RETURN(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
/*
|
|
|
|
Set up all the default partitions not set-up by the user in the SQL
|
|
|
|
statement. Also perform a number of checks that the user hasn't tried
|
|
|
|
to use default values where no defaults exists.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
set_up_default_partitions()
|
|
|
|
file A reference to a handler of the table
|
2006-06-27 22:19:27 +02:00
|
|
|
info Create info
|
2006-02-16 17:38:33 +01:00
|
|
|
start_no Starting partition number
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE Error, attempted default values not possible
|
|
|
|
FALSE Ok, default partitions set-up
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
The routine uses the underlying handler of the partitioning to define
|
|
|
|
the default number of partitions. For some handlers this requires
|
|
|
|
knowledge of the maximum number of rows to be stored in the table.
|
|
|
|
This routine only accepts HASH and KEY partitioning and thus there is
|
|
|
|
no subpartitioning if this routine is successful.
|
|
|
|
The external routine needing this code is check_partition_info
|
|
|
|
*/
|
|
|
|
|
2015-11-18 20:54:01 +01:00
|
|
|
bool partition_info::set_up_default_partitions(THD *thd, handler *file,
|
2006-06-27 22:19:27 +02:00
|
|
|
HA_CREATE_INFO *info,
|
2006-02-16 17:38:33 +01:00
|
|
|
uint start_no)
|
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
char *default_name;
|
|
|
|
bool result= TRUE;
|
|
|
|
DBUG_ENTER("partition_info::set_up_default_partitions");
|
|
|
|
|
|
|
|
if (part_type != HASH_PARTITION)
|
|
|
|
{
|
|
|
|
const char *error_string;
|
|
|
|
if (part_type == RANGE_PARTITION)
|
2017-06-28 12:50:18 +02:00
|
|
|
error_string= "RANGE";
|
2006-02-16 17:38:33 +01:00
|
|
|
else
|
2017-06-28 12:50:18 +02:00
|
|
|
error_string= "LIST";
|
2006-02-16 17:38:33 +01:00
|
|
|
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), error_string);
|
|
|
|
goto end;
|
|
|
|
}
|
2007-04-05 10:25:39 +02:00
|
|
|
|
2009-10-01 15:04:42 +02:00
|
|
|
if ((num_parts == 0) &&
|
|
|
|
((num_parts= file->get_default_no_partitions(info)) == 0))
|
2007-04-05 10:25:39 +02:00
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_NOT_DEFINED_ERROR, MYF(0), "partitions");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2009-10-01 15:04:42 +02:00
|
|
|
if (unlikely(num_parts > MAX_PARTITIONS))
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
|
|
|
my_error(ER_TOO_MANY_PARTITIONS_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2015-11-18 20:54:01 +01:00
|
|
|
if (unlikely((!(default_name= create_default_partition_names(thd, 0,
|
|
|
|
num_parts,
|
2006-04-12 05:35:48 +02:00
|
|
|
start_no)))))
|
2006-02-16 17:38:33 +01:00
|
|
|
goto end;
|
|
|
|
i= 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
partition_element *part_elem= new partition_element();
|
|
|
|
if (likely(part_elem != 0 &&
|
|
|
|
(!partitions.push_back(part_elem))))
|
|
|
|
{
|
|
|
|
part_elem->engine_type= default_engine_type;
|
|
|
|
part_elem->partition_name= default_name;
|
|
|
|
default_name+=MAX_PART_NAME_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto end;
|
2009-10-01 15:04:42 +02:00
|
|
|
} while (++i < num_parts);
|
2006-02-16 17:38:33 +01:00
|
|
|
result= FALSE;
|
|
|
|
end:
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
/*
|
|
|
|
Set up all the default subpartitions not set-up by the user in the SQL
|
|
|
|
statement. Also perform a number of checks that the default partitioning
|
|
|
|
becomes an allowed partitioning scheme.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
set_up_default_subpartitions()
|
|
|
|
file A reference to a handler of the table
|
2006-06-27 22:19:27 +02:00
|
|
|
info Create info
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE Error, attempted default values not possible
|
|
|
|
FALSE Ok, default partitions set-up
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
The routine uses the underlying handler of the partitioning to define
|
|
|
|
the default number of partitions. For some handlers this requires
|
|
|
|
knowledge of the maximum number of rows to be stored in the table.
|
|
|
|
This routine is only called for RANGE or LIST partitioning and those
|
|
|
|
need to be specified so only subpartitions are specified.
|
|
|
|
The external routine needing this code is check_partition_info
|
|
|
|
*/
|
|
|
|
|
2015-11-18 20:54:01 +01:00
|
|
|
bool partition_info::set_up_default_subpartitions(THD *thd, handler *file,
|
2006-06-27 22:19:27 +02:00
|
|
|
HA_CREATE_INFO *info)
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2006-02-16 19:01:14 +01:00
|
|
|
uint i, j;
|
2006-02-16 17:38:33 +01:00
|
|
|
bool result= TRUE;
|
|
|
|
partition_element *part_elem;
|
|
|
|
List_iterator<partition_element> part_it(partitions);
|
|
|
|
DBUG_ENTER("partition_info::set_up_default_subpartitions");
|
|
|
|
|
2009-10-01 15:04:42 +02:00
|
|
|
if (num_subparts == 0)
|
|
|
|
num_subparts= file->get_default_no_partitions(info);
|
|
|
|
if (unlikely((num_parts * num_subparts) > MAX_PARTITIONS))
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
|
|
|
my_error(ER_TOO_MANY_PARTITIONS_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
i= 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
part_elem= part_it++;
|
|
|
|
j= 0;
|
|
|
|
do
|
|
|
|
{
|
2006-04-21 14:43:07 +02:00
|
|
|
partition_element *subpart_elem= new partition_element(part_elem);
|
2006-02-16 17:38:33 +01:00
|
|
|
if (likely(subpart_elem != 0 &&
|
|
|
|
(!part_elem->subpartitions.push_back(subpart_elem))))
|
|
|
|
{
|
2015-11-18 20:54:01 +01:00
|
|
|
char *ptr= create_default_subpartition_name(thd, j,
|
2013-06-15 17:32:08 +02:00
|
|
|
part_elem->partition_name);
|
2006-04-12 05:35:48 +02:00
|
|
|
if (!ptr)
|
|
|
|
goto end;
|
2006-02-16 17:38:33 +01:00
|
|
|
subpart_elem->engine_type= default_engine_type;
|
2006-04-12 05:35:48 +02:00
|
|
|
subpart_elem->partition_name= ptr;
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goto end;
|
2009-10-01 15:04:42 +02:00
|
|
|
} while (++j < num_subparts);
|
|
|
|
} while (++i < num_parts);
|
2006-02-16 17:38:33 +01:00
|
|
|
result= FALSE;
|
|
|
|
end:
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
/*
|
|
|
|
Support routine for check_partition_info
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
set_up_defaults_for_partitioning()
|
|
|
|
file A reference to a handler of the table
|
2006-06-27 22:19:27 +02:00
|
|
|
info Create info
|
2006-02-16 17:38:33 +01:00
|
|
|
start_no Starting partition number
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE Error, attempted default values not possible
|
|
|
|
FALSE Ok, default partitions set-up
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Set up defaults for partition or subpartition (cannot set-up for both,
|
|
|
|
this will return an error.
|
|
|
|
*/
|
|
|
|
|
2015-11-18 20:54:01 +01:00
|
|
|
bool partition_info::set_up_defaults_for_partitioning(THD *thd, handler *file,
|
2006-06-27 22:19:27 +02:00
|
|
|
HA_CREATE_INFO *info,
|
2006-02-16 17:38:33 +01:00
|
|
|
uint start_no)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::set_up_defaults_for_partitioning");
|
|
|
|
|
|
|
|
if (!default_partitions_setup)
|
|
|
|
{
|
|
|
|
default_partitions_setup= TRUE;
|
|
|
|
if (use_default_partitions)
|
2015-11-18 20:54:01 +01:00
|
|
|
DBUG_RETURN(set_up_default_partitions(thd, file, info, start_no));
|
2006-02-16 17:38:33 +01:00
|
|
|
if (is_sub_partitioned() &&
|
|
|
|
use_default_subpartitions)
|
2015-11-18 20:54:01 +01:00
|
|
|
DBUG_RETURN(set_up_default_subpartitions(thd, file, info));
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2009-10-06 17:01:59 +02:00
|
|
|
/*
|
|
|
|
Support routine for check_partition_info
|
|
|
|
|
|
|
|
SYNOPSIS
|
2013-06-15 17:32:08 +02:00
|
|
|
find_duplicate_field
|
2009-10-06 17:01:59 +02:00
|
|
|
no parameters
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
Erroneus field name Error, there are two fields with same name
|
|
|
|
NULL Ok, no field defined twice
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Check that the user haven't defined the same field twice in
|
|
|
|
key or column list partitioning.
|
|
|
|
*/
|
2017-04-23 18:39:57 +02:00
|
|
|
|
|
|
|
const char* partition_info::find_duplicate_field()
|
2009-10-06 17:01:59 +02:00
|
|
|
{
|
2017-04-23 18:39:57 +02:00
|
|
|
const char *field_name_outer, *field_name_inner;
|
|
|
|
List_iterator<const char> it_outer(part_field_list);
|
2009-10-06 17:01:59 +02:00
|
|
|
uint num_fields= part_field_list.elements;
|
|
|
|
uint i,j;
|
2013-06-15 17:32:08 +02:00
|
|
|
DBUG_ENTER("partition_info::find_duplicate_field");
|
2009-10-06 17:01:59 +02:00
|
|
|
|
|
|
|
for (i= 0; i < num_fields; i++)
|
|
|
|
{
|
|
|
|
field_name_outer= it_outer++;
|
2017-04-23 18:39:57 +02:00
|
|
|
List_iterator<const char> it_inner(part_field_list);
|
2009-10-06 17:01:59 +02:00
|
|
|
for (j= 0; j < num_fields; j++)
|
|
|
|
{
|
|
|
|
field_name_inner= it_inner++;
|
2009-10-16 17:08:34 +02:00
|
|
|
if (i >= j)
|
2009-10-06 17:01:59 +02:00
|
|
|
continue;
|
|
|
|
if (!(my_strcasecmp(system_charset_info,
|
|
|
|
field_name_outer,
|
|
|
|
field_name_inner)))
|
|
|
|
{
|
|
|
|
DBUG_RETURN(field_name_outer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
2006-02-16 19:01:14 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
/**
|
|
|
|
@brief Get part_elem and part_id from partition name
|
|
|
|
|
|
|
|
@param partition_name Name of partition to search for.
|
|
|
|
@param file_name[out] Partition file name (part after table name,
|
|
|
|
#P#<part>[#SP#<subpart>]), skipped if NULL.
|
|
|
|
@param part_id[out] Id of found partition or NOT_A_PARTITION_ID.
|
|
|
|
|
|
|
|
@retval Pointer to part_elem of [sub]partition, if not found NULL
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
@note Since names of partitions AND subpartitions must be unique,
|
|
|
|
this function searches both partitions and subpartitions and if name of
|
|
|
|
a partition is given for a subpartitioned table, part_elem will be
|
|
|
|
the partition, but part_id will be NOT_A_PARTITION_ID and file_name not set.
|
|
|
|
*/
|
|
|
|
partition_element *partition_info::get_part_elem(const char *partition_name,
|
|
|
|
char *file_name,
|
2017-07-06 23:47:33 +02:00
|
|
|
size_t file_name_size,
|
2013-06-15 17:32:08 +02:00
|
|
|
uint32 *part_id)
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
List_iterator<partition_element> part_it(partitions);
|
|
|
|
uint i= 0;
|
|
|
|
DBUG_ENTER("partition_info::get_part_elem");
|
|
|
|
DBUG_ASSERT(part_id);
|
|
|
|
*part_id= NOT_A_PARTITION_ID;
|
|
|
|
do
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
partition_element *part_elem= part_it++;
|
|
|
|
if (is_sub_partitioned())
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
List_iterator<partition_element> sub_part_it(part_elem->subpartitions);
|
|
|
|
uint j= 0;
|
|
|
|
do
|
2006-02-22 00:40:07 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
partition_element *sub_part_elem= sub_part_it++;
|
|
|
|
if (!my_strcasecmp(system_charset_info,
|
|
|
|
sub_part_elem->partition_name, partition_name))
|
|
|
|
{
|
|
|
|
if (file_name)
|
2017-07-06 23:47:33 +02:00
|
|
|
if (create_subpartition_name(file_name, file_name_size, "",
|
|
|
|
part_elem->partition_name,
|
|
|
|
partition_name, NORMAL_PART_NAME))
|
|
|
|
DBUG_RETURN(NULL);
|
2013-06-15 17:32:08 +02:00
|
|
|
*part_id= j + (i * num_subparts);
|
|
|
|
DBUG_RETURN(sub_part_elem);
|
|
|
|
}
|
|
|
|
} while (++j < num_subparts);
|
|
|
|
|
|
|
|
/* Naming a partition (first level) on a subpartitioned table. */
|
|
|
|
if (!my_strcasecmp(system_charset_info,
|
|
|
|
part_elem->partition_name, partition_name))
|
|
|
|
DBUG_RETURN(part_elem);
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
2013-06-15 17:32:08 +02:00
|
|
|
else if (!my_strcasecmp(system_charset_info,
|
|
|
|
part_elem->partition_name, partition_name))
|
|
|
|
{
|
|
|
|
if (file_name)
|
2017-07-06 23:47:33 +02:00
|
|
|
if (create_partition_name(file_name, file_name_size, "",
|
|
|
|
partition_name, NORMAL_PART_NAME, TRUE))
|
|
|
|
DBUG_RETURN(NULL);
|
2013-06-15 17:32:08 +02:00
|
|
|
*part_id= i;
|
|
|
|
DBUG_RETURN(part_elem);
|
|
|
|
}
|
|
|
|
} while (++i < num_parts);
|
|
|
|
DBUG_RETURN(NULL);
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
/**
|
|
|
|
Helper function to find_duplicate_name.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const char *get_part_name_from_elem(const char *name, size_t *length,
|
|
|
|
my_bool not_used __attribute__((unused)))
|
|
|
|
{
|
|
|
|
*length= strlen(name);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
/*
|
|
|
|
A support function to check partition names for duplication in a
|
|
|
|
partitioned table
|
|
|
|
|
|
|
|
SYNOPSIS
|
2013-06-15 17:32:08 +02:00
|
|
|
find_duplicate_name()
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
RETURN VALUES
|
2013-06-15 17:32:08 +02:00
|
|
|
NULL Has unique part and subpart names
|
|
|
|
!NULL Pointer to duplicated name
|
2006-02-16 17:38:33 +01:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Checks that the list of names in the partitions doesn't contain any
|
|
|
|
duplicated names.
|
|
|
|
*/
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
char *partition_info::find_duplicate_name()
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
HASH partition_names;
|
|
|
|
uint max_names;
|
|
|
|
const uchar *curr_name= NULL;
|
2006-02-16 17:38:33 +01:00
|
|
|
List_iterator<partition_element> parts_it(partitions);
|
2013-06-15 17:32:08 +02:00
|
|
|
partition_element *p_elem;
|
|
|
|
|
|
|
|
DBUG_ENTER("partition_info::find_duplicate_name");
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
/*
|
|
|
|
TODO: If table->s->ha_part_data->partition_name_hash.elements is > 0,
|
|
|
|
then we could just return NULL, but that has not been verified.
|
|
|
|
And this only happens when in ALTER TABLE with full table copy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
max_names= num_parts;
|
|
|
|
if (is_sub_partitioned())
|
|
|
|
max_names+= num_parts * num_subparts;
|
|
|
|
if (my_hash_init(&partition_names, system_charset_info, max_names, 0, 0,
|
|
|
|
(my_hash_get_key) get_part_name_from_elem, 0, HASH_UNIQUE))
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
curr_name= (const uchar*) "Internal failure";
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
while ((p_elem= (parts_it++)))
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
curr_name= (const uchar*) p_elem->partition_name;
|
|
|
|
if (my_hash_insert(&partition_names, curr_name))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!p_elem->subpartitions.is_empty())
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
List_iterator<partition_element> subparts_it(p_elem->subpartitions);
|
|
|
|
partition_element *subp_elem;
|
|
|
|
while ((subp_elem= (subparts_it++)))
|
2006-02-22 00:40:07 +01:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
curr_name= (const uchar*) subp_elem->partition_name;
|
|
|
|
if (my_hash_insert(&partition_names, curr_name))
|
|
|
|
goto error;
|
2006-02-22 00:40:07 +01:00
|
|
|
}
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
2013-06-15 17:32:08 +02:00
|
|
|
}
|
|
|
|
my_hash_free(&partition_names);
|
2006-02-16 17:38:33 +01:00
|
|
|
DBUG_RETURN(NULL);
|
2013-06-15 17:32:08 +02:00
|
|
|
error:
|
|
|
|
my_hash_free(&partition_names);
|
|
|
|
DBUG_RETURN((char*) curr_name);
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
|
2006-02-16 19:01:14 +01:00
|
|
|
/*
|
|
|
|
A support function to check if a partition element's name is unique
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
has_unique_name()
|
|
|
|
partition_element element to check
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Has unique name
|
|
|
|
FALSE Doesn't
|
|
|
|
*/
|
2006-02-22 00:40:07 +01:00
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
bool partition_info::has_unique_name(partition_element *element)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::has_unique_name");
|
|
|
|
|
|
|
|
const char *name_to_check= element->partition_name;
|
|
|
|
List_iterator<partition_element> parts_it(partitions);
|
|
|
|
|
|
|
|
partition_element *el;
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
mysql-test/r/rpl_row_4_bytes.result:
update
mysql-test/t/rpl_row_4_bytes.test:
don't influence next tests
sql/ha_archive.cc:
please pay attention to this structure when you change it...
sql/ha_berkeley.cc:
please pay attention to this structure when you change it...
sql/ha_blackhole.cc:
please pay attention to this structure when you change it...
sql/ha_federated.cc:
please pay attention to this structure when you change it...
sql/ha_heap.cc:
please pay attention to this structure when you change it...
sql/ha_innodb.cc:
please pay attention to this structure when you change it...
sql/ha_myisam.cc:
please pay attention to this structure when you change it...
sql/ha_myisammrg.cc:
please pay attention to this structure when you change it...
sql/ha_ndbcluster_binlog.cc:
no more global 'binlog_row_based'
sql/ha_partition.cc:
please pay attention to this structure when you change it...
sql/handler.cc:
please pay attention to this structure when you change it...
sql/handler.h:
it's good to initialize statically (to get no compiler warning) even if to a null value.
sql/item_func.cc:
UDFs require row-based if this is the "mixed" binlog format.
sql/item_strfunc.cc:
UUID() requires row-based binlogging if this is the "mixed" binlog format
sql/log.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log.h:
the enum enum_binlog_format moves to log.h from mysqld.cc as we need it in several places.
sql/log_event.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log_event.h:
this global variable not used anymore
sql/mysql_priv.h:
these global variables not used anymore
sql/mysqld.cc:
simplification in the handling of --binlog-format (but with no user-visible change), thanks to
the new global system variable.
RBR does not anymore turn on --log-bin-trust-function-creators and --innodb-locks-unsafe-for-binlog
as these are global options and RBR is now settable per session.
sql/partition_info.cc:
compiler warnings
sql/set_var.cc:
new class of thread's variable, to handle the binlog_format (like sys_var_thd_enum except
that is_readonly() is overriden for more checks before update).
compiler warnings (ok'd by Serg)
sql/set_var.h:
new class for the thread's binlog_format (see set_var.cc)
sql/share/errmsg.txt:
some messages for when one can't toggle from one binlog format to another
sql/sp_head.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_base.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_class.cc:
When a THD is initialized, we set its current_stmt_binlog_row_based
sql/sql_class.h:
new THD::variables.binlog_format (the value of the session variable set by SET
or inherited from the global value), and THD::current_stmt_binlog_row_based which tells if the
current statement does row-based or statement-based binlogging. Both members are needed
as the 2nd one cannot be derived only from the first one (the statement's type plays a role too),
and the 1st one is needed to reset the 2nd one.
sql/sql_delete.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_insert.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_load.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based.
sql/sql_parse.cc:
when we are done with a statement, we reset the current_stmt_binlog_row_based to the value
derived from THD::variables.binlog_format.
sql/sql_partition.cc:
compiler warning
sql/sql_show.cc:
compiler warning
sql/sql_table.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
tests/mysql_client_test.c:
compiler warning
mysql-test/r/ndb_binlog_basic2.result:
new result
mysql-test/r/rpl_switch_stm_row_mixed.result:
new result
mysql-test/t/ndb_binlog_basic2.test:
new test to verify that if cluster is enabled, can't change binlog format on the fly.
mysql-test/t/rpl_switch_stm_row_mixed.test:
test to see if one can switch between SBR, RBR, and "mixed" mode, and when one cannot,
and test to see if the switching, and the mixed mode, work properly (using UUID() to test,
as using UDFs is not possible in the testsuite for portability reasons).
2006-02-25 22:21:03 +01:00
|
|
|
while ((el= (parts_it++)))
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
|
|
|
if (!(my_strcasecmp(system_charset_info, el->partition_name,
|
|
|
|
name_to_check)) && el != element)
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
|
2006-02-22 00:40:07 +01:00
|
|
|
if (!el->subpartitions.is_empty())
|
2006-02-16 17:38:33 +01:00
|
|
|
{
|
2006-02-22 00:40:07 +01:00
|
|
|
partition_element *sub_el;
|
|
|
|
List_iterator<partition_element> subparts_it(el->subpartitions);
|
WL#2977 and WL#2712 global and session-level variable to set the binlog format (row/statement),
and new binlog format called "mixed" (which is statement-based except if only row-based is correct,
in this cset it means if UDF or UUID is used; more cases could be added in later 5.1 release):
SET GLOBAL|SESSION BINLOG_FORMAT=row|statement|mixed|default;
the global default is statement unless cluster is enabled (then it's row) as in 5.1-alpha.
It's not possible to use SET on this variable if a session is currently in row-based mode and has open temporary tables (because CREATE
TEMPORARY TABLE was not binlogged so temp table is not known on slave), or if NDB is enabled (because
NDB does not support such change on-the-fly, though it will later), of if in a stored function (see below).
The added tests test the possibility or impossibility to SET, their effects, and the mixed mode,
including in prepared statements and in stored procedures and functions.
Caveats:
a) The mixed mode will not work for stored functions: in mixed mode, a stored function will
always be binlogged as one call and in a statement-based way (e.g. INSERT VALUES(myfunc()) or SELECT myfunc()).
b) for the same reason, changing the thread's binlog format inside a stored function is
refused with an error message.
c) the same problems apply to triggers; implementing b) for triggers will be done later (will ask
Dmitri).
Additionally, as the binlog format is now changeable by each user for his session, I remove the implication
which was done at startup, where row-based automatically set log-bin-trust-routine-creators to 1
(not possible anymore as a user can now switch to stmt-based and do nasty things again), and automatically
set --innodb-locks-unsafe-for-binlog to 1 (was anyway theoretically incorrect as it disabled
phantom protection).
Plus fixes for compiler warnings.
mysql-test/r/rpl_row_4_bytes.result:
update
mysql-test/t/rpl_row_4_bytes.test:
don't influence next tests
sql/ha_archive.cc:
please pay attention to this structure when you change it...
sql/ha_berkeley.cc:
please pay attention to this structure when you change it...
sql/ha_blackhole.cc:
please pay attention to this structure when you change it...
sql/ha_federated.cc:
please pay attention to this structure when you change it...
sql/ha_heap.cc:
please pay attention to this structure when you change it...
sql/ha_innodb.cc:
please pay attention to this structure when you change it...
sql/ha_myisam.cc:
please pay attention to this structure when you change it...
sql/ha_myisammrg.cc:
please pay attention to this structure when you change it...
sql/ha_ndbcluster_binlog.cc:
no more global 'binlog_row_based'
sql/ha_partition.cc:
please pay attention to this structure when you change it...
sql/handler.cc:
please pay attention to this structure when you change it...
sql/handler.h:
it's good to initialize statically (to get no compiler warning) even if to a null value.
sql/item_func.cc:
UDFs require row-based if this is the "mixed" binlog format.
sql/item_strfunc.cc:
UUID() requires row-based binlogging if this is the "mixed" binlog format
sql/log.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log.h:
the enum enum_binlog_format moves to log.h from mysqld.cc as we need it in several places.
sql/log_event.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/log_event.h:
this global variable not used anymore
sql/mysql_priv.h:
these global variables not used anymore
sql/mysqld.cc:
simplification in the handling of --binlog-format (but with no user-visible change), thanks to
the new global system variable.
RBR does not anymore turn on --log-bin-trust-function-creators and --innodb-locks-unsafe-for-binlog
as these are global options and RBR is now settable per session.
sql/partition_info.cc:
compiler warnings
sql/set_var.cc:
new class of thread's variable, to handle the binlog_format (like sys_var_thd_enum except
that is_readonly() is overriden for more checks before update).
compiler warnings (ok'd by Serg)
sql/set_var.h:
new class for the thread's binlog_format (see set_var.cc)
sql/share/errmsg.txt:
some messages for when one can't toggle from one binlog format to another
sql/sp_head.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_base.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_class.cc:
When a THD is initialized, we set its current_stmt_binlog_row_based
sql/sql_class.h:
new THD::variables.binlog_format (the value of the session variable set by SET
or inherited from the global value), and THD::current_stmt_binlog_row_based which tells if the
current statement does row-based or statement-based binlogging. Both members are needed
as the 2nd one cannot be derived only from the first one (the statement's type plays a role too),
and the 1st one is needed to reset the 2nd one.
sql/sql_delete.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_insert.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
sql/sql_load.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based.
sql/sql_parse.cc:
when we are done with a statement, we reset the current_stmt_binlog_row_based to the value
derived from THD::variables.binlog_format.
sql/sql_partition.cc:
compiler warning
sql/sql_show.cc:
compiler warning
sql/sql_table.cc:
binlog_row_based -> thd->current_stmt_binlog_row_based
tests/mysql_client_test.c:
compiler warning
mysql-test/r/ndb_binlog_basic2.result:
new result
mysql-test/r/rpl_switch_stm_row_mixed.result:
new result
mysql-test/t/ndb_binlog_basic2.test:
new test to verify that if cluster is enabled, can't change binlog format on the fly.
mysql-test/t/rpl_switch_stm_row_mixed.test:
test to see if one can switch between SBR, RBR, and "mixed" mode, and when one cannot,
and test to see if the switching, and the mixed mode, work properly (using UUID() to test,
as using UDFs is not possible in the testsuite for portability reasons).
2006-02-25 22:21:03 +01:00
|
|
|
while ((sub_el= (subparts_it++)))
|
2006-02-22 00:40:07 +01:00
|
|
|
{
|
|
|
|
if (!(my_strcasecmp(system_charset_info, sub_el->partition_name,
|
|
|
|
name_to_check)) && sub_el != element)
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2006-02-16 17:38:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
void partition_info::vers_set_hist_part(THD *thd)
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
if (vers_info->limit)
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
ha_partition *hp= (ha_partition*)(table->file);
|
|
|
|
partition_element *next= NULL;
|
|
|
|
List_iterator<partition_element> it(partitions);
|
|
|
|
while (next != vers_info->hist_part)
|
|
|
|
next= it++;
|
|
|
|
ha_rows records= hp->part_records(next);
|
|
|
|
while ((next= it++) != vers_info->now_part)
|
|
|
|
{
|
|
|
|
ha_rows next_records= hp->part_records(next);
|
|
|
|
if (next_records == 0)
|
|
|
|
break;
|
|
|
|
vers_info->hist_part= next;
|
|
|
|
records= next_records;
|
|
|
|
}
|
|
|
|
if (records > vers_info->limit)
|
|
|
|
{
|
|
|
|
if (next == vers_info->now_part)
|
|
|
|
goto warn;
|
|
|
|
vers_info->hist_part= next;
|
|
|
|
}
|
|
|
|
return;
|
2016-12-11 18:04:11 +01:00
|
|
|
}
|
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
if (vers_info->interval.is_set())
|
|
|
|
{
|
2018-05-02 21:53:12 +02:00
|
|
|
if (vers_info->hist_part->range_value > thd->query_start())
|
2018-02-21 15:16:19 +01:00
|
|
|
return;
|
2016-12-11 18:04:11 +01:00
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
partition_element *next= NULL;
|
|
|
|
List_iterator<partition_element> it(partitions);
|
|
|
|
while (next != vers_info->hist_part)
|
|
|
|
next= it++;
|
2016-12-11 18:04:11 +01:00
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
while ((next= it++) != vers_info->now_part)
|
2017-09-07 14:49:11 +02:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
vers_info->hist_part= next;
|
2018-05-02 21:53:12 +02:00
|
|
|
if (next->range_value > thd->query_start())
|
2018-02-21 15:16:19 +01:00
|
|
|
return;
|
2017-09-07 14:49:11 +02:00
|
|
|
}
|
2018-02-21 15:16:19 +01:00
|
|
|
goto warn;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
warn:
|
|
|
|
my_error(WARN_VERS_PART_FULL, MYF(ME_WARNING|ME_ERROR_LOG),
|
2019-02-07 16:12:49 +01:00
|
|
|
table->s->db.str, table->s->table_name.str,
|
2018-02-21 15:16:19 +01:00
|
|
|
vers_info->hist_part->partition_name);
|
2017-09-07 14:49:11 +02:00
|
|
|
}
|
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
|
2017-09-07 14:49:11 +02:00
|
|
|
bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
if (!table->versioned())
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
2018-02-21 18:14:04 +01:00
|
|
|
// frm must be corrupted, normally CREATE/ALTER TABLE checks for that
|
|
|
|
my_error(ER_FILE_CORRUPT, MYF(0), table->s->path.str);
|
2016-12-11 18:04:11 +01:00
|
|
|
return true;
|
|
|
|
}
|
2016-12-31 16:33:26 +01:00
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
DBUG_ASSERT(part_type == VERSIONING_PARTITION);
|
|
|
|
DBUG_ASSERT(table->versioned(VERS_TIMESTAMP));
|
|
|
|
|
|
|
|
if (!alter_add)
|
2016-12-31 16:33:26 +01:00
|
|
|
{
|
2018-01-08 18:03:55 +01:00
|
|
|
Field *row_end= table->vers_end_field();
|
2016-12-31 16:33:26 +01:00
|
|
|
// needed in handle_list_of_fields()
|
2018-01-08 18:03:55 +01:00
|
|
|
row_end->flags|= GET_FIXED_FIELDS_FLAG;
|
2019-08-28 10:57:16 +02:00
|
|
|
Name_resolution_context *context= &thd->lex->current_select->context;
|
|
|
|
Item *row_end_item= new (thd->mem_root) Item_field(thd, context, row_end);
|
|
|
|
Item *row_end_ts= new (thd->mem_root) Item_func_unix_timestamp(thd, row_end_item);
|
|
|
|
set_part_expr(thd, row_end_ts, false);
|
2016-12-31 16:33:26 +01:00
|
|
|
}
|
|
|
|
|
2018-02-21 15:16:19 +01:00
|
|
|
if (alter_add)
|
2016-12-31 16:33:26 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
List_iterator<partition_element> it(partitions);
|
|
|
|
partition_element *el;
|
|
|
|
for(uint32 id= 0; ((el= it++)); id++)
|
2016-12-31 16:33:26 +01:00
|
|
|
{
|
2019-08-28 10:57:16 +02:00
|
|
|
DBUG_ASSERT(el->type != partition_element::CONVENTIONAL);
|
2017-09-07 14:49:11 +02:00
|
|
|
/* Newly added element is inserted before AS_OF_NOW. */
|
2019-08-28 10:57:16 +02:00
|
|
|
if (el->id == UINT_MAX32 || el->type == partition_element::CURRENT)
|
2016-12-31 16:33:26 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
el->id= id;
|
2019-08-28 10:57:16 +02:00
|
|
|
if (el->type == partition_element::CURRENT)
|
2016-12-31 16:33:26 +01:00
|
|
|
break;
|
2016-12-11 18:04:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
/*
|
2008-01-09 13:15:50 +01:00
|
|
|
Check that the partition/subpartition is setup to use the correct
|
|
|
|
storage engine
|
|
|
|
SYNOPSIS
|
|
|
|
check_engine_condition()
|
|
|
|
p_elem Partition element
|
|
|
|
table_engine_set Have user specified engine on table level
|
|
|
|
inout::engine_type Current engine used
|
|
|
|
inout::first Is it first partition
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE Failed check
|
|
|
|
FALSE Ok
|
|
|
|
DESCRIPTION
|
|
|
|
Specified engine for table and partitions p0 and pn
|
|
|
|
Must be correct both on CREATE and ALTER commands
|
|
|
|
table p0 pn res (0 - OK, 1 - FAIL)
|
|
|
|
- - - 0
|
|
|
|
- - x 1
|
|
|
|
- x - 1
|
|
|
|
- x x 0
|
|
|
|
x - - 0
|
|
|
|
x - x 0
|
|
|
|
x x - 0
|
|
|
|
x x x 0
|
|
|
|
i.e:
|
|
|
|
- All subpartitions must use the same engine
|
|
|
|
AND it must be the same as the partition.
|
|
|
|
- All partitions must use the same engine
|
|
|
|
AND it must be the same as the table.
|
|
|
|
- if one does NOT specify an engine on the table level
|
|
|
|
then one must either NOT specify any engine on any
|
|
|
|
partition/subpartition OR for ALL partitions/subpartitions
|
|
|
|
Note:
|
|
|
|
When ALTER a table, the engines are already set for all levels
|
|
|
|
(table, all partitions and subpartitions). So if one want to
|
|
|
|
change the storage engine, one must specify it on the table level
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool check_engine_condition(partition_element *p_elem,
|
|
|
|
bool table_engine_set,
|
|
|
|
handlerton **engine_type,
|
|
|
|
bool *first)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("check_engine_condition");
|
|
|
|
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("enter", ("p_eng %s t_eng %s t_eng_set %u first %u state %u",
|
|
|
|
ha_resolve_storage_engine_name(p_elem->engine_type),
|
|
|
|
ha_resolve_storage_engine_name(*engine_type),
|
2008-01-09 13:15:50 +01:00
|
|
|
table_engine_set, *first, p_elem->part_state));
|
|
|
|
if (*first && !table_engine_set)
|
|
|
|
{
|
|
|
|
*engine_type= p_elem->engine_type;
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("setting table_engine = %s",
|
|
|
|
ha_resolve_storage_engine_name(*engine_type)));
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
|
|
|
*first= FALSE;
|
|
|
|
if ((table_engine_set &&
|
|
|
|
(p_elem->engine_type != (*engine_type) &&
|
|
|
|
p_elem->engine_type)) ||
|
|
|
|
(!table_engine_set &&
|
|
|
|
p_elem->engine_type != (*engine_type)))
|
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2009-09-23 15:21:29 +02:00
|
|
|
|
|
|
|
DBUG_RETURN(FALSE);
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
|
2008-01-09 13:15:50 +01:00
|
|
|
/*
|
|
|
|
Check engine mix that it is correct
|
|
|
|
Current limitation is that all partitions and subpartitions
|
|
|
|
must use the same storage engine.
|
2006-03-31 19:39:44 +02:00
|
|
|
SYNOPSIS
|
|
|
|
check_engine_mix()
|
2008-01-09 13:15:50 +01:00
|
|
|
inout::engine_type Current engine used
|
|
|
|
table_engine_set Have user specified engine on table level
|
2006-03-31 19:39:44 +02:00
|
|
|
RETURN VALUE
|
2008-01-09 13:15:50 +01:00
|
|
|
TRUE Error, mixed engines
|
|
|
|
FALSE Ok, no mixed engines
|
2006-03-31 19:39:44 +02:00
|
|
|
DESCRIPTION
|
|
|
|
Current check verifies only that all handlers are the same.
|
|
|
|
Later this check will be more sophisticated.
|
2008-01-09 13:15:50 +01:00
|
|
|
(specified partition handler ) specified table handler
|
|
|
|
(MYISAM, MYISAM) - OK
|
|
|
|
(MYISAM, -) - NOT OK
|
|
|
|
(MYISAM, -) MYISAM OK
|
|
|
|
(- , MYISAM) - NOT OK
|
|
|
|
(- , -) MYISAM OK
|
|
|
|
(-,-) - OK
|
2006-03-31 19:39:44 +02:00
|
|
|
*/
|
|
|
|
|
2008-01-09 13:15:50 +01:00
|
|
|
bool partition_info::check_engine_mix(handlerton *engine_type,
|
|
|
|
bool table_engine_set)
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
2008-01-09 13:15:50 +01:00
|
|
|
handlerton *old_engine_type= engine_type;
|
|
|
|
bool first= TRUE;
|
2010-05-31 12:59:58 +02:00
|
|
|
uint n_parts= partitions.elements;
|
2006-03-31 19:39:44 +02:00
|
|
|
DBUG_ENTER("partition_info::check_engine_mix");
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("in: engine_type = %s, table_engine_set = %u",
|
|
|
|
ha_resolve_storage_engine_name(engine_type),
|
2008-01-09 13:15:50 +01:00
|
|
|
table_engine_set));
|
2010-05-31 12:59:58 +02:00
|
|
|
if (n_parts)
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
2008-01-09 13:15:50 +01:00
|
|
|
List_iterator<partition_element> part_it(partitions);
|
|
|
|
uint i= 0;
|
|
|
|
do
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
2008-01-09 13:15:50 +01:00
|
|
|
partition_element *part_elem= part_it++;
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("part = %d engine = %s table_engine_set %u",
|
|
|
|
i, ha_resolve_storage_engine_name(part_elem->engine_type),
|
2008-01-09 13:15:50 +01:00
|
|
|
table_engine_set));
|
|
|
|
if (is_sub_partitioned() &&
|
|
|
|
part_elem->subpartitions.elements)
|
|
|
|
{
|
2010-05-31 12:59:58 +02:00
|
|
|
uint n_subparts= part_elem->subpartitions.elements;
|
2008-01-09 13:15:50 +01:00
|
|
|
uint j= 0;
|
|
|
|
List_iterator<partition_element> sub_it(part_elem->subpartitions);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
partition_element *sub_elem= sub_it++;
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("sub = %d engine = %s table_engie_set %u",
|
|
|
|
j, ha_resolve_storage_engine_name(sub_elem->engine_type),
|
2008-01-09 13:15:50 +01:00
|
|
|
table_engine_set));
|
|
|
|
if (check_engine_condition(sub_elem, table_engine_set,
|
|
|
|
&engine_type, &first))
|
|
|
|
goto error;
|
2010-05-31 12:59:58 +02:00
|
|
|
} while (++j < n_subparts);
|
2008-01-09 13:15:50 +01:00
|
|
|
/* ensure that the partition also has correct engine */
|
|
|
|
if (check_engine_condition(part_elem, table_engine_set,
|
|
|
|
&engine_type, &first))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
else if (check_engine_condition(part_elem, table_engine_set,
|
|
|
|
&engine_type, &first))
|
|
|
|
goto error;
|
2010-05-31 12:59:58 +02:00
|
|
|
} while (++i < n_parts);
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("engine_type = %s",
|
|
|
|
ha_resolve_storage_engine_name(engine_type)));
|
2008-01-09 13:15:50 +01:00
|
|
|
if (!engine_type)
|
|
|
|
engine_type= old_engine_type;
|
|
|
|
if (engine_type->flags & HTON_NO_PARTITION)
|
2006-05-23 13:37:03 +02:00
|
|
|
{
|
2006-10-01 03:31:13 +02:00
|
|
|
my_error(ER_PARTITION_MERGE_ERROR, MYF(0));
|
2006-05-23 13:37:03 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("out: engine_type = %s",
|
|
|
|
ha_resolve_storage_engine_name(engine_type)));
|
2008-01-09 13:15:50 +01:00
|
|
|
DBUG_ASSERT(engine_type != partition_hton);
|
2006-05-23 13:37:03 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
2008-01-09 13:15:50 +01:00
|
|
|
error:
|
|
|
|
/*
|
|
|
|
Mixed engines not yet supported but when supported it will need
|
|
|
|
the partition handler
|
|
|
|
*/
|
|
|
|
DBUG_RETURN(TRUE);
|
2006-03-31 19:39:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-11 14:00:36 +01:00
|
|
|
/**
|
|
|
|
Check if we allow DATA/INDEX DIRECTORY, if not warn and set them to NULL.
|
|
|
|
|
|
|
|
@param thd THD also containing sql_mode (looks from MODE_NO_DIR_IN_CREATE).
|
|
|
|
@param part_elem partition_element to check.
|
|
|
|
*/
|
|
|
|
static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem)
|
|
|
|
{
|
2014-03-23 16:00:29 +01:00
|
|
|
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
|
2010-03-11 14:00:36 +01:00
|
|
|
{
|
|
|
|
if (part_elem->data_file_name)
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2015-07-06 19:24:14 +02:00
|
|
|
WARN_OPTION_IGNORED,
|
|
|
|
ER_THD(thd, WARN_OPTION_IGNORED),
|
2010-03-11 14:00:36 +01:00
|
|
|
"DATA DIRECTORY");
|
|
|
|
if (part_elem->index_file_name)
|
2013-06-15 17:32:08 +02:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2015-07-06 19:24:14 +02:00
|
|
|
WARN_OPTION_IGNORED,
|
|
|
|
ER_THD(thd, WARN_OPTION_IGNORED),
|
2010-03-11 14:00:36 +01:00
|
|
|
"INDEX DIRECTORY");
|
|
|
|
part_elem->data_file_name= part_elem->index_file_name= NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
This code is used early in the CREATE TABLE and ALTER TABLE process.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
check_partition_info()
|
2009-09-15 17:07:52 +02:00
|
|
|
thd Thread object
|
|
|
|
eng_type Return value for used engine in partitions
|
2006-03-31 19:39:44 +02:00
|
|
|
file A reference to a handler of the table
|
2006-06-27 22:19:27 +02:00
|
|
|
info Create info
|
2009-09-15 17:07:52 +02:00
|
|
|
add_or_reorg_part Is it ALTER TABLE ADD/REORGANIZE command
|
2006-03-31 19:39:44 +02:00
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE Error, something went wrong
|
|
|
|
FALSE Ok, full partition data structures are now generated
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
We will check that the partition info requested is possible to set-up in
|
|
|
|
this version. This routine is an extension of the parser one could say.
|
|
|
|
If defaults were used we will generate default data structures for all
|
|
|
|
partitions.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-04-18 04:51:34 +02:00
|
|
|
bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
2006-07-12 17:33:22 +02:00
|
|
|
handler *file, HA_CREATE_INFO *info,
|
2018-01-12 10:54:07 +01:00
|
|
|
partition_info *add_or_reorg_part)
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
2008-01-09 13:15:50 +01:00
|
|
|
handlerton *table_engine= default_engine_type;
|
2006-03-31 19:39:44 +02:00
|
|
|
uint i, tot_partitions;
|
2008-01-09 13:15:50 +01:00
|
|
|
bool result= TRUE, table_engine_set;
|
2017-04-23 18:39:57 +02:00
|
|
|
const char *same_name;
|
2016-12-11 18:04:11 +01:00
|
|
|
uint32 hist_parts= 0;
|
|
|
|
uint32 now_parts= 0;
|
2006-03-31 19:39:44 +02:00
|
|
|
DBUG_ENTER("partition_info::check_partition_info");
|
2008-01-09 13:15:50 +01:00
|
|
|
DBUG_ASSERT(default_engine_type != partition_hton);
|
2006-03-31 19:39:44 +02:00
|
|
|
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("default table_engine = %s",
|
|
|
|
ha_resolve_storage_engine_name(table_engine)));
|
2009-09-15 17:07:52 +02:00
|
|
|
if (!add_or_reorg_part)
|
2006-04-05 12:39:06 +02:00
|
|
|
{
|
2006-09-26 08:30:40 +02:00
|
|
|
int err= 0;
|
2006-07-21 16:23:32 +02:00
|
|
|
|
2015-06-24 06:57:12 +02:00
|
|
|
/* Check for partition expression. */
|
2009-09-15 17:07:52 +02:00
|
|
|
if (!list_of_part_fields)
|
2006-06-23 07:21:26 +02:00
|
|
|
{
|
2008-12-02 11:18:01 +01:00
|
|
|
DBUG_ASSERT(part_expr);
|
2016-06-26 22:42:48 +02:00
|
|
|
err= part_expr->walk(&Item::check_partition_func_processor, 0, NULL);
|
2006-06-23 07:21:26 +02:00
|
|
|
}
|
2015-06-24 06:57:12 +02:00
|
|
|
|
|
|
|
/* Check for sub partition expression. */
|
|
|
|
if (!err && is_sub_partitioned() && !list_of_subpart_fields)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(subpart_expr);
|
|
|
|
err= subpart_expr->walk(&Item::check_partition_func_processor, 0,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2006-09-26 08:30:40 +02:00
|
|
|
if (err)
|
2006-06-23 07:21:26 +02:00
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2009-10-21 17:28:10 +02:00
|
|
|
if (thd->lex->sql_command == SQLCOM_CREATE_TABLE &&
|
|
|
|
fix_parser_data(thd))
|
2009-10-16 16:16:06 +02:00
|
|
|
goto end;
|
2006-04-05 12:39:06 +02:00
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
if (unlikely(!is_sub_partitioned() &&
|
2009-10-01 15:04:42 +02:00
|
|
|
!(use_default_subpartitions && use_default_num_subpartitions)))
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
|
|
|
my_error(ER_SUBPARTITION_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (unlikely(is_sub_partitioned() &&
|
|
|
|
(!(part_type == RANGE_PARTITION ||
|
2016-12-11 18:04:11 +01:00
|
|
|
part_type == LIST_PARTITION ||
|
|
|
|
part_type == VERSIONING_PARTITION))))
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
|
|
|
/* Only RANGE and LIST partitioning can be subpartitioned */
|
|
|
|
my_error(ER_SUBPARTITION_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2015-11-18 20:54:01 +01:00
|
|
|
if (unlikely(set_up_defaults_for_partitioning(thd, file, info, (uint)0)))
|
2006-03-31 19:39:44 +02:00
|
|
|
goto end;
|
2007-03-27 15:39:11 +02:00
|
|
|
if (!(tot_partitions= get_tot_partitions()))
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_NOT_DEFINED_ERROR, MYF(0), "partitions");
|
|
|
|
goto end;
|
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
if (unlikely(tot_partitions > MAX_PARTITIONS))
|
|
|
|
{
|
|
|
|
my_error(ER_TOO_MANY_PARTITIONS_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2008-01-09 13:15:50 +01:00
|
|
|
/*
|
|
|
|
if NOT specified ENGINE = <engine>:
|
|
|
|
If Create, always use create_info->db_type
|
|
|
|
else, use previous tables db_type
|
|
|
|
either ALL or NONE partition should be set to
|
|
|
|
default_engine_type when not table_engine_set
|
|
|
|
Note: after a table is created its storage engines for
|
|
|
|
the table and all partitions/subpartitions are set.
|
|
|
|
So when ALTER it is already set on table level
|
|
|
|
*/
|
2008-02-25 21:18:50 +01:00
|
|
|
if (info && info->used_fields & HA_CREATE_USED_ENGINE)
|
2008-01-09 13:15:50 +01:00
|
|
|
{
|
|
|
|
table_engine_set= TRUE;
|
2008-02-25 21:18:50 +01:00
|
|
|
table_engine= info->db_type;
|
|
|
|
/* if partition_hton, use thd->lex->create_info */
|
|
|
|
if (table_engine == partition_hton)
|
|
|
|
table_engine= thd->lex->create_info.db_type;
|
|
|
|
DBUG_ASSERT(table_engine != partition_hton);
|
|
|
|
DBUG_PRINT("info", ("Using table_engine = %s",
|
|
|
|
ha_resolve_storage_engine_name(table_engine)));
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
table_engine_set= FALSE;
|
|
|
|
if (thd->lex->sql_command != SQLCOM_CREATE_TABLE)
|
|
|
|
{
|
|
|
|
table_engine_set= TRUE;
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("No create, table_engine = %s",
|
|
|
|
ha_resolve_storage_engine_name(table_engine)));
|
2008-01-09 13:15:50 +01:00
|
|
|
DBUG_ASSERT(table_engine && table_engine != partition_hton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-06 17:01:59 +02:00
|
|
|
if (part_field_list.elements > 0 &&
|
2013-06-15 17:32:08 +02:00
|
|
|
(same_name= find_duplicate_field()))
|
2009-10-06 17:01:59 +02:00
|
|
|
{
|
|
|
|
my_error(ER_SAME_NAME_PARTITION_FIELD, MYF(0), same_name);
|
|
|
|
goto end;
|
|
|
|
}
|
2013-06-15 17:32:08 +02:00
|
|
|
if ((same_name= find_duplicate_name()))
|
2006-03-31 19:39:44 +02:00
|
|
|
{
|
|
|
|
my_error(ER_SAME_NAME_PARTITION, MYF(0), same_name);
|
|
|
|
goto end;
|
|
|
|
}
|
2016-12-11 18:04:11 +01:00
|
|
|
|
|
|
|
if (part_type == VERSIONING_PARTITION)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(vers_info);
|
2017-06-29 18:35:08 +02:00
|
|
|
if (num_parts < 2 || !vers_info->now_part)
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
DBUG_ASSERT(info);
|
|
|
|
DBUG_ASSERT(info->alias.str);
|
2018-01-07 17:03:44 +01:00
|
|
|
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias.str);
|
2016-12-11 18:04:11 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(num_parts == partitions.elements);
|
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
i= 0;
|
|
|
|
{
|
|
|
|
List_iterator<partition_element> part_it(partitions);
|
2009-10-01 15:04:42 +02:00
|
|
|
uint num_parts_not_set= 0;
|
|
|
|
uint prev_num_subparts_not_set= num_subparts + 1;
|
2006-03-31 19:39:44 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
partition_element *part_elem= part_it++;
|
2010-03-11 14:00:36 +01:00
|
|
|
warn_if_dir_in_part_elem(thd, part_elem);
|
2006-03-31 19:39:44 +02:00
|
|
|
if (!is_sub_partitioned())
|
|
|
|
{
|
2008-02-25 21:18:50 +01:00
|
|
|
if (part_elem->engine_type == NULL)
|
|
|
|
{
|
2009-10-01 15:04:42 +02:00
|
|
|
num_parts_not_set++;
|
2008-02-25 21:18:50 +01:00
|
|
|
part_elem->engine_type= default_engine_type;
|
|
|
|
}
|
2006-04-10 19:48:58 +02:00
|
|
|
if (check_table_name(part_elem->partition_name,
|
2010-05-04 16:03:28 +02:00
|
|
|
strlen(part_elem->partition_name), FALSE))
|
2006-04-10 19:48:58 +02:00
|
|
|
{
|
|
|
|
my_error(ER_WRONG_PARTITION_NAME, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("part = %d engine = %s",
|
|
|
|
i, ha_resolve_storage_engine_name(part_elem->engine_type)));
|
2006-03-31 19:39:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uint j= 0;
|
2009-10-01 15:04:42 +02:00
|
|
|
uint num_subparts_not_set= 0;
|
2006-03-31 19:39:44 +02:00
|
|
|
List_iterator<partition_element> sub_it(part_elem->subpartitions);
|
2008-02-25 21:18:50 +01:00
|
|
|
partition_element *sub_elem;
|
2006-03-31 19:39:44 +02:00
|
|
|
do
|
|
|
|
{
|
2008-02-25 21:18:50 +01:00
|
|
|
sub_elem= sub_it++;
|
2010-03-11 14:00:36 +01:00
|
|
|
warn_if_dir_in_part_elem(thd, sub_elem);
|
2006-04-20 20:11:54 +02:00
|
|
|
if (check_table_name(sub_elem->partition_name,
|
2010-05-04 16:03:28 +02:00
|
|
|
strlen(sub_elem->partition_name), FALSE))
|
2006-04-10 19:48:58 +02:00
|
|
|
{
|
|
|
|
my_error(ER_WRONG_PARTITION_NAME, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2006-04-20 20:11:54 +02:00
|
|
|
if (sub_elem->engine_type == NULL)
|
2008-01-09 13:15:50 +01:00
|
|
|
{
|
2008-02-25 21:18:50 +01:00
|
|
|
if (part_elem->engine_type != NULL)
|
|
|
|
sub_elem->engine_type= part_elem->engine_type;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_elem->engine_type= default_engine_type;
|
2009-10-01 15:04:42 +02:00
|
|
|
num_subparts_not_set++;
|
2008-02-25 21:18:50 +01:00
|
|
|
}
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_PRINT("info", ("part = %d sub = %d engine = %s", i, j,
|
|
|
|
ha_resolve_storage_engine_name(sub_elem->engine_type)));
|
2009-10-01 15:04:42 +02:00
|
|
|
} while (++j < num_subparts);
|
2008-02-25 21:18:50 +01:00
|
|
|
|
2009-10-01 15:04:42 +02:00
|
|
|
if (prev_num_subparts_not_set == (num_subparts + 1) &&
|
|
|
|
(num_subparts_not_set == 0 ||
|
|
|
|
num_subparts_not_set == num_subparts))
|
|
|
|
prev_num_subparts_not_set= num_subparts_not_set;
|
2008-02-25 21:18:50 +01:00
|
|
|
|
2008-01-09 13:15:50 +01:00
|
|
|
if (!table_engine_set &&
|
2009-10-01 15:04:42 +02:00
|
|
|
prev_num_subparts_not_set != num_subparts_not_set)
|
2008-01-09 13:15:50 +01:00
|
|
|
{
|
2009-10-01 15:04:42 +02:00
|
|
|
DBUG_PRINT("info", ("num_subparts_not_set = %u num_subparts = %u",
|
|
|
|
num_subparts_not_set, num_subparts));
|
2008-01-09 13:15:50 +01:00
|
|
|
my_error(ER_MIX_HANDLER_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2008-02-25 21:18:50 +01:00
|
|
|
|
|
|
|
if (part_elem->engine_type == NULL)
|
|
|
|
{
|
2009-10-01 15:04:42 +02:00
|
|
|
if (num_subparts_not_set == 0)
|
2008-02-25 21:18:50 +01:00
|
|
|
part_elem->engine_type= sub_elem->engine_type;
|
|
|
|
else
|
|
|
|
{
|
2009-10-01 15:04:42 +02:00
|
|
|
num_parts_not_set++;
|
2008-02-25 21:18:50 +01:00
|
|
|
part_elem->engine_type= default_engine_type;
|
|
|
|
}
|
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
}
|
2016-12-11 18:04:11 +01:00
|
|
|
if (part_type == VERSIONING_PARTITION)
|
|
|
|
{
|
2019-08-28 10:57:16 +02:00
|
|
|
if (part_elem->type == partition_element::HISTORY)
|
2016-12-11 18:04:11 +01:00
|
|
|
{
|
|
|
|
hist_parts++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-28 10:57:16 +02:00
|
|
|
DBUG_ASSERT(part_elem->type == partition_element::CURRENT);
|
2016-12-11 18:04:11 +01:00
|
|
|
now_parts++;
|
|
|
|
}
|
|
|
|
}
|
2009-10-01 15:04:42 +02:00
|
|
|
} while (++i < num_parts);
|
2008-01-09 13:15:50 +01:00
|
|
|
if (!table_engine_set &&
|
2009-10-01 15:04:42 +02:00
|
|
|
num_parts_not_set != 0 &&
|
|
|
|
num_parts_not_set != num_parts)
|
2008-01-09 13:15:50 +01:00
|
|
|
{
|
2009-10-01 15:04:42 +02:00
|
|
|
DBUG_PRINT("info", ("num_parts_not_set = %u num_parts = %u",
|
|
|
|
num_parts_not_set, num_subparts));
|
2008-01-09 13:15:50 +01:00
|
|
|
my_error(ER_MIX_HANDLER_ERROR, MYF(0));
|
|
|
|
goto end;
|
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
}
|
2008-01-09 13:15:50 +01:00
|
|
|
if (unlikely(check_engine_mix(table_engine, table_engine_set)))
|
|
|
|
{
|
|
|
|
my_error(ER_MIX_HANDLER_ERROR, MYF(0));
|
2006-03-31 19:39:44 +02:00
|
|
|
goto end;
|
2008-01-09 13:15:50 +01:00
|
|
|
}
|
2006-03-31 19:39:44 +02:00
|
|
|
|
2018-01-12 10:54:07 +01:00
|
|
|
if (hist_parts > 1)
|
|
|
|
{
|
2018-02-21 15:16:19 +01:00
|
|
|
if (vers_info->limit == 0 && !vers_info->interval.is_set())
|
2018-01-12 10:54:07 +01:00
|
|
|
{
|
|
|
|
push_warning_printf(thd,
|
|
|
|
Sql_condition::WARN_LEVEL_WARN,
|
|
|
|
WARN_VERS_PARAMETERS,
|
|
|
|
ER_THD(thd, WARN_VERS_PARAMETERS),
|
|
|
|
"no rotation condition for multiple HISTORY partitions.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (unlikely(now_parts > 1))
|
|
|
|
{
|
2018-01-07 17:03:44 +01:00
|
|
|
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias.str);
|
2018-01-12 10:54:07 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-25 21:18:50 +01:00
|
|
|
DBUG_ASSERT(table_engine != partition_hton &&
|
|
|
|
default_engine_type == table_engine);
|
2006-03-31 19:39:44 +02:00
|
|
|
if (eng_type)
|
2008-01-09 13:15:50 +01:00
|
|
|
*eng_type= table_engine;
|
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
We need to check all constant expressions that they are of the correct
|
|
|
|
type and that they are increasing for ranges and not overlapping for
|
|
|
|
list constants.
|
|
|
|
*/
|
|
|
|
|
2009-09-15 17:07:52 +02:00
|
|
|
if (add_or_reorg_part)
|
2006-04-18 04:51:34 +02:00
|
|
|
{
|
2018-01-12 10:54:07 +01:00
|
|
|
if (unlikely(part_type == VERSIONING_PARTITION &&
|
|
|
|
vers_setup_expression(thd, add_or_reorg_part->partitions.elements)))
|
|
|
|
goto end;
|
2018-02-18 12:24:51 +01:00
|
|
|
if (check_constants(thd, this))
|
2006-04-18 04:51:34 +02:00
|
|
|
goto end;
|
|
|
|
}
|
2016-12-11 18:04:11 +01:00
|
|
|
|
2006-03-31 19:39:44 +02:00
|
|
|
result= FALSE;
|
|
|
|
end:
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-15 01:40:06 +02:00
|
|
|
/*
|
|
|
|
Print error for no partition found
|
2006-09-30 23:38:15 +02:00
|
|
|
|
2006-06-15 01:40:06 +02:00
|
|
|
SYNOPSIS
|
|
|
|
print_no_partition_found()
|
|
|
|
table Table object
|
2006-09-30 23:38:15 +02:00
|
|
|
|
2006-06-15 01:40:06 +02:00
|
|
|
RETURN VALUES
|
|
|
|
*/
|
|
|
|
|
2014-01-23 00:03:05 +01:00
|
|
|
void partition_info::print_no_partition_found(TABLE *table_arg, myf errflag)
|
2006-06-15 01:40:06 +02:00
|
|
|
{
|
|
|
|
char buf[100];
|
|
|
|
char *buf_ptr= (char*)&buf;
|
2007-04-04 11:01:47 +02:00
|
|
|
TABLE_LIST table_list;
|
2015-07-06 19:24:14 +02:00
|
|
|
THD *thd= current_thd;
|
2006-06-15 01:40:06 +02:00
|
|
|
|
2019-03-12 16:27:19 +01:00
|
|
|
table_list.reset();
|
2018-01-07 17:03:44 +01:00
|
|
|
table_list.db= table_arg->s->db;
|
|
|
|
table_list.table_name= table_arg->s->table_name;
|
2007-04-04 11:01:47 +02:00
|
|
|
|
2019-03-12 16:27:19 +01:00
|
|
|
if (check_single_table_access(thd, SELECT_ACL, &table_list, TRUE))
|
2009-09-15 17:07:52 +02:00
|
|
|
{
|
2007-04-04 11:01:47 +02:00
|
|
|
my_message(ER_NO_PARTITION_FOR_GIVEN_VALUE,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_THD(thd, ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT), errflag);
|
2009-09-15 17:07:52 +02:00
|
|
|
}
|
2006-06-15 01:40:06 +02:00
|
|
|
else
|
2007-04-04 11:01:47 +02:00
|
|
|
{
|
2009-09-15 17:07:52 +02:00
|
|
|
if (column_list)
|
|
|
|
buf_ptr= (char*)"from column_list";
|
2007-04-04 11:01:47 +02:00
|
|
|
else
|
2009-09-15 17:07:52 +02:00
|
|
|
{
|
2010-05-31 12:59:58 +02:00
|
|
|
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table_arg, table_arg->read_set);
|
2009-09-15 17:07:52 +02:00
|
|
|
if (part_expr->null_value)
|
|
|
|
buf_ptr= (char*)"NULL";
|
|
|
|
else
|
2010-11-25 18:17:28 +01:00
|
|
|
longlong10_to_str(err_value, buf,
|
2009-09-15 17:07:52 +02:00
|
|
|
part_expr->unsigned_flag ? 10 : -10);
|
2010-05-31 12:59:58 +02:00
|
|
|
dbug_tmp_restore_column_map(table_arg->read_set, old_map);
|
2009-09-15 17:07:52 +02:00
|
|
|
}
|
2014-01-23 00:03:05 +01:00
|
|
|
my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, errflag, buf_ptr);
|
2007-04-04 11:01:47 +02:00
|
|
|
}
|
2006-06-15 01:40:06 +02:00
|
|
|
}
|
2009-09-15 17:07:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Set fields related to partition expression
|
|
|
|
SYNOPSIS
|
|
|
|
set_part_expr()
|
|
|
|
start_token Start of partition function string
|
|
|
|
item_ptr Pointer to item tree
|
|
|
|
end_token End of partition function string
|
|
|
|
is_subpart Subpartition indicator
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Memory allocation error
|
|
|
|
FALSE Success
|
|
|
|
*/
|
|
|
|
|
2019-08-27 22:01:12 +02:00
|
|
|
bool partition_info::set_part_expr(THD *thd, Item *item_ptr, bool is_subpart)
|
2009-09-15 17:07:52 +02:00
|
|
|
{
|
|
|
|
if (is_subpart)
|
|
|
|
{
|
|
|
|
list_of_subpart_fields= FALSE;
|
|
|
|
subpart_expr= item_ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list_of_part_fields= FALSE;
|
|
|
|
part_expr= item_ptr;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-28 01:11:17 +01:00
|
|
|
/*
|
|
|
|
Check that partition fields and subpartition fields are not too long
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
check_partition_field_length()
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Total length was too big
|
|
|
|
FALSE Length is ok
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool partition_info::check_partition_field_length()
|
|
|
|
{
|
|
|
|
uint store_length= 0;
|
|
|
|
uint i;
|
|
|
|
DBUG_ENTER("partition_info::check_partition_field_length");
|
|
|
|
|
|
|
|
for (i= 0; i < num_part_fields; i++)
|
|
|
|
store_length+= get_partition_field_store_length(part_field_array[i]);
|
2018-12-19 06:04:30 +01:00
|
|
|
if (store_length > MAX_DATA_LENGTH_FOR_KEY)
|
2009-10-28 01:11:17 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
store_length= 0;
|
|
|
|
for (i= 0; i < num_subpart_fields; i++)
|
|
|
|
store_length+= get_partition_field_store_length(subpart_field_array[i]);
|
2018-12-19 06:04:30 +01:00
|
|
|
if (store_length > MAX_DATA_LENGTH_FOR_KEY)
|
2009-10-28 01:11:17 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-26 22:30:39 +02:00
|
|
|
/*
|
|
|
|
Set up buffers and arrays for fields requiring preparation
|
|
|
|
SYNOPSIS
|
|
|
|
set_up_charset_field_preps()
|
2006-09-30 23:38:15 +02:00
|
|
|
|
2006-09-26 22:30:39 +02:00
|
|
|
RETURN VALUES
|
|
|
|
TRUE Memory Allocation error
|
|
|
|
FALSE Success
|
2006-06-15 01:40:06 +02:00
|
|
|
|
2006-09-26 22:30:39 +02:00
|
|
|
DESCRIPTION
|
|
|
|
Set up arrays and buffers for fields that require special care for
|
|
|
|
calculation of partition id. This is used for string fields with
|
|
|
|
variable length or string fields with fixed length that isn't using
|
|
|
|
the binary collation.
|
|
|
|
*/
|
2006-06-15 01:40:06 +02:00
|
|
|
|
2015-08-27 09:07:32 +02:00
|
|
|
bool partition_info::set_up_charset_field_preps(THD *thd)
|
2006-09-26 22:30:39 +02:00
|
|
|
{
|
|
|
|
Field *field, **ptr;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
uchar **char_ptrs;
|
2006-09-26 22:30:39 +02:00
|
|
|
unsigned i;
|
|
|
|
size_t size;
|
|
|
|
uint tot_fields= 0;
|
|
|
|
uint tot_part_fields= 0;
|
|
|
|
uint tot_subpart_fields= 0;
|
|
|
|
DBUG_ENTER("set_up_charset_field_preps");
|
|
|
|
|
|
|
|
if (!(part_type == HASH_PARTITION &&
|
|
|
|
list_of_part_fields) &&
|
|
|
|
check_part_func_fields(part_field_array, FALSE))
|
|
|
|
{
|
|
|
|
ptr= part_field_array;
|
|
|
|
/* Set up arrays and buffers for those fields */
|
|
|
|
while ((field= *(ptr++)))
|
|
|
|
{
|
|
|
|
if (field_is_partition_charset(field))
|
|
|
|
{
|
|
|
|
tot_part_fields++;
|
|
|
|
tot_fields++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size= tot_part_fields * sizeof(char*);
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**)thd->calloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
part_field_buffers= char_ptrs;
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**)thd->calloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
restore_part_field_ptrs= char_ptrs;
|
|
|
|
size= (tot_part_fields + 1) * sizeof(Field*);
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**)thd->alloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
part_charset_field_array= (Field**)char_ptrs;
|
|
|
|
ptr= part_field_array;
|
|
|
|
i= 0;
|
|
|
|
while ((field= *(ptr++)))
|
|
|
|
{
|
|
|
|
if (field_is_partition_charset(field))
|
|
|
|
{
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
uchar *field_buf;
|
2006-09-26 22:30:39 +02:00
|
|
|
size= field->pack_length();
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(field_buf= (uchar*) thd->calloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
part_charset_field_array[i]= field;
|
|
|
|
part_field_buffers[i++]= field_buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
part_charset_field_array[i]= NULL;
|
|
|
|
}
|
2007-04-04 16:26:32 +02:00
|
|
|
if (is_sub_partitioned() && !list_of_subpart_fields &&
|
2006-09-26 22:30:39 +02:00
|
|
|
check_part_func_fields(subpart_field_array, FALSE))
|
|
|
|
{
|
|
|
|
/* Set up arrays and buffers for those fields */
|
|
|
|
ptr= subpart_field_array;
|
|
|
|
while ((field= *(ptr++)))
|
|
|
|
{
|
|
|
|
if (field_is_partition_charset(field))
|
2007-04-04 16:26:32 +02:00
|
|
|
{
|
2006-09-26 22:30:39 +02:00
|
|
|
tot_subpart_fields++;
|
2007-04-04 16:26:32 +02:00
|
|
|
tot_fields++;
|
|
|
|
}
|
2006-09-26 22:30:39 +02:00
|
|
|
}
|
|
|
|
size= tot_subpart_fields * sizeof(char*);
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**) thd->calloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
subpart_field_buffers= char_ptrs;
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**) thd->calloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
restore_subpart_field_ptrs= char_ptrs;
|
|
|
|
size= (tot_subpart_fields + 1) * sizeof(Field*);
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(char_ptrs= (uchar**) thd->alloc(size)))
|
2006-09-26 22:30:39 +02:00
|
|
|
goto error;
|
|
|
|
subpart_charset_field_array= (Field**)char_ptrs;
|
2007-04-20 18:35:16 +02:00
|
|
|
ptr= subpart_field_array;
|
2006-09-26 22:30:39 +02:00
|
|
|
i= 0;
|
|
|
|
while ((field= *(ptr++)))
|
|
|
|
{
|
2015-02-10 11:05:49 +01:00
|
|
|
uchar *UNINIT_VAR(field_buf);
|
2006-09-26 22:30:39 +02:00
|
|
|
|
|
|
|
if (!field_is_partition_charset(field))
|
|
|
|
continue;
|
|
|
|
size= field->pack_length();
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(field_buf= (uchar*) thd->calloc(size)))
|
2007-04-04 16:26:32 +02:00
|
|
|
goto error;
|
|
|
|
subpart_charset_field_array[i]= field;
|
2006-09-26 22:30:39 +02:00
|
|
|
subpart_field_buffers[i++]= field_buf;
|
|
|
|
}
|
2007-04-04 16:26:32 +02:00
|
|
|
subpart_charset_field_array[i]= NULL;
|
2006-09-26 22:30:39 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
error:
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2008-02-28 13:46:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check if path does not contain mysql data home directory
|
|
|
|
for partition elements with data directory and index directory
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
check_partition_dirs()
|
|
|
|
part_info partition_info struct
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 ok
|
|
|
|
1 error
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool check_partition_dirs(partition_info *part_info)
|
|
|
|
{
|
|
|
|
if (!part_info)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
partition_element *part_elem;
|
|
|
|
List_iterator<partition_element> part_it(part_info->partitions);
|
|
|
|
while ((part_elem= part_it++))
|
|
|
|
{
|
|
|
|
if (part_elem->subpartitions.elements)
|
|
|
|
{
|
|
|
|
List_iterator<partition_element> sub_it(part_elem->subpartitions);
|
|
|
|
partition_element *subpart_elem;
|
|
|
|
while ((subpart_elem= sub_it++))
|
|
|
|
{
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error_if_data_home_dir(subpart_elem->data_file_name,
|
|
|
|
"DATA DIRECTORY")) ||
|
|
|
|
unlikely(error_if_data_home_dir(subpart_elem->index_file_name,
|
|
|
|
"INDEX DIRECTORY")))
|
2013-04-09 16:18:37 +02:00
|
|
|
return 1;
|
2008-02-28 13:46:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error_if_data_home_dir(part_elem->data_file_name,
|
|
|
|
"DATA DIRECTORY")) ||
|
|
|
|
unlikely(error_if_data_home_dir(part_elem->index_file_name,
|
|
|
|
"INDEX DIRECTORY")))
|
2013-04-09 16:18:37 +02:00
|
|
|
return 1;
|
2008-02-28 13:46:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-30 17:33:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Check what kind of error to report
|
|
|
|
|
|
|
|
@param use_subpart_expr Use the subpart_expr instead of part_expr
|
|
|
|
@param part_str Name of partition to report error (or NULL)
|
|
|
|
*/
|
|
|
|
void partition_info::report_part_expr_error(bool use_subpart_expr)
|
|
|
|
{
|
|
|
|
Item *expr= part_expr;
|
|
|
|
DBUG_ENTER("partition_info::report_part_expr_error");
|
|
|
|
if (use_subpart_expr)
|
|
|
|
expr= subpart_expr;
|
|
|
|
|
|
|
|
if (expr->type() == Item::FIELD_ITEM)
|
|
|
|
{
|
|
|
|
partition_type type= part_type;
|
|
|
|
bool list_of_fields= list_of_part_fields;
|
|
|
|
Item_field *item_field= (Item_field*) expr;
|
|
|
|
/*
|
|
|
|
The expression consists of a single field.
|
|
|
|
It must be of integer type unless KEY or COLUMNS partitioning.
|
|
|
|
*/
|
|
|
|
if (use_subpart_expr)
|
|
|
|
{
|
|
|
|
type= subpart_type;
|
|
|
|
list_of_fields= list_of_subpart_fields;
|
|
|
|
}
|
|
|
|
if (!column_list &&
|
|
|
|
item_field->field &&
|
|
|
|
item_field->field->result_type() != INT_RESULT &&
|
|
|
|
!(type == HASH_PARTITION && list_of_fields))
|
|
|
|
{
|
|
|
|
my_error(ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD, MYF(0),
|
2017-05-02 11:51:35 +02:00
|
|
|
item_field->name.str);
|
2010-08-30 17:33:55 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (use_subpart_expr)
|
|
|
|
my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), "SUBPARTITION");
|
|
|
|
else
|
|
|
|
my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), "PARTITION");
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-16 16:16:06 +02:00
|
|
|
/*
|
|
|
|
Create a new column value in current list with maxvalue
|
|
|
|
Called from parser
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
add_max_value()
|
|
|
|
RETURN
|
|
|
|
TRUE Error
|
|
|
|
FALSE Success
|
|
|
|
*/
|
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
int partition_info::add_max_value(THD *thd)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::add_max_value");
|
|
|
|
|
|
|
|
part_column_list_val *col_val;
|
2016-08-29 22:29:12 +02:00
|
|
|
/*
|
|
|
|
Makes for LIST COLUMNS 'num_columns' DEFAULT tuples, 1 tuple for RANGEs
|
|
|
|
*/
|
|
|
|
uint max_val= (num_columns && part_type == LIST_PARTITION) ?
|
|
|
|
num_columns : 1;
|
|
|
|
for (uint i= 0; i < max_val; i++)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
if (!(col_val= add_column_value(thd)))
|
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
col_val->max_value= TRUE;
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Create a new column value in current list
|
|
|
|
Called from parser
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
add_column_value()
|
|
|
|
RETURN
|
|
|
|
>0 A part_column_list_val object which have been
|
|
|
|
inserted into its list
|
|
|
|
0 Memory allocation failure
|
|
|
|
*/
|
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
part_column_list_val *partition_info::add_column_value(THD *thd)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
uint max_val= num_columns ? num_columns : MAX_REF_PARTS;
|
|
|
|
DBUG_ENTER("add_column_value");
|
|
|
|
DBUG_PRINT("enter", ("num_columns = %u, curr_list_object %u, max_val = %u",
|
|
|
|
num_columns, curr_list_object, max_val));
|
|
|
|
if (curr_list_object < max_val)
|
|
|
|
{
|
|
|
|
curr_list_val->added_items++;
|
|
|
|
DBUG_RETURN(&curr_list_val->col_val_array[curr_list_object++]);
|
|
|
|
}
|
|
|
|
if (!num_columns && part_type == LIST_PARTITION)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We're trying to add more than MAX_REF_PARTS, this can happen
|
|
|
|
in ALTER TABLE using List partitions where the first partition
|
|
|
|
uses VALUES IN (1,2,3...,17) where the number of fields in
|
|
|
|
the list is more than MAX_REF_PARTS, in this case we know
|
|
|
|
that the number of columns must be 1 and we thus reorganize
|
|
|
|
into the structure used for 1 column. After this we call
|
|
|
|
ourselves recursively which should always succeed.
|
|
|
|
*/
|
2018-05-11 23:45:09 +02:00
|
|
|
num_columns= curr_list_object;
|
2015-08-24 13:42:07 +02:00
|
|
|
if (!reorganize_into_single_field_col_val(thd))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2018-05-11 23:45:09 +02:00
|
|
|
if (!init_column_part(thd))
|
|
|
|
DBUG_RETURN(add_column_value(thd));
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
2009-10-21 12:40:21 +02:00
|
|
|
if (column_list)
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (part_type == RANGE_PARTITION)
|
|
|
|
my_error(ER_TOO_MANY_VALUES_ERROR, MYF(0), "RANGE");
|
|
|
|
else
|
|
|
|
my_error(ER_TOO_MANY_VALUES_ERROR, MYF(0), "LIST");
|
|
|
|
}
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-21 12:40:21 +02:00
|
|
|
/*
|
|
|
|
Initialise part_elem_value object at setting of a new object
|
|
|
|
(Helper functions to functions called by parser)
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
init_col_val
|
|
|
|
col_val Column value object to be initialised
|
|
|
|
item Item object representing column value
|
2008-02-28 13:46:52 +01:00
|
|
|
|
2009-10-21 12:40:21 +02:00
|
|
|
RETURN VALUES
|
|
|
|
TRUE Failure
|
|
|
|
FALSE Success
|
|
|
|
*/
|
|
|
|
void partition_info::init_col_val(part_column_list_val *col_val, Item *item)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::init_col_val");
|
|
|
|
|
|
|
|
col_val->item_expression= item;
|
|
|
|
col_val->null_value= item->null_value;
|
|
|
|
if (item->result_type() == INT_RESULT)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This could be both column_list partitioning and function
|
|
|
|
partitioning, but it doesn't hurt to set the function
|
|
|
|
partitioning flags about unsignedness.
|
|
|
|
*/
|
|
|
|
curr_list_val->value= item->val_int();
|
|
|
|
curr_list_val->unsigned_flag= TRUE;
|
|
|
|
if (!item->unsigned_flag &&
|
|
|
|
curr_list_val->value < 0)
|
|
|
|
curr_list_val->unsigned_flag= FALSE;
|
|
|
|
if (!curr_list_val->unsigned_flag)
|
|
|
|
curr_part_elem->signed_flag= TRUE;
|
|
|
|
}
|
|
|
|
col_val->part_info= NULL;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2009-10-16 16:16:06 +02:00
|
|
|
/*
|
|
|
|
Add a column value in VALUES LESS THAN or VALUES IN
|
|
|
|
(Called from parser)
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
add_column_list_value()
|
|
|
|
lex Parser's lex object
|
2009-10-21 12:40:21 +02:00
|
|
|
thd Thread object
|
2009-10-16 16:16:06 +02:00
|
|
|
item Item object representing column value
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Failure
|
|
|
|
FALSE Success
|
|
|
|
*/
|
2009-10-21 12:40:21 +02:00
|
|
|
bool partition_info::add_column_list_value(THD *thd, Item *item)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
part_column_list_val *col_val;
|
2009-10-21 12:40:21 +02:00
|
|
|
Name_resolution_context *context= &thd->lex->current_select->context;
|
|
|
|
TABLE_LIST *save_list= context->table_list;
|
|
|
|
const char *save_where= thd->where;
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_ENTER("partition_info::add_column_list_value");
|
|
|
|
|
|
|
|
if (part_type == LIST_PARTITION &&
|
|
|
|
num_columns == 1U)
|
|
|
|
{
|
2015-08-24 13:42:07 +02:00
|
|
|
if (init_column_part(thd))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
}
|
2009-10-21 12:40:21 +02:00
|
|
|
|
|
|
|
context->table_list= 0;
|
|
|
|
if (column_list)
|
|
|
|
thd->where= "field list";
|
|
|
|
else
|
|
|
|
thd->where= "partition function";
|
|
|
|
|
2016-06-26 22:42:48 +02:00
|
|
|
if (item->walk(&Item::check_partition_func_processor, 0, NULL))
|
2009-10-21 12:40:21 +02:00
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
if (item->fix_fields(thd, (Item**)0) ||
|
|
|
|
((context->table_list= save_list), FALSE) ||
|
|
|
|
(!item->const_item()))
|
|
|
|
{
|
|
|
|
context->table_list= save_list;
|
|
|
|
thd->where= save_where;
|
2009-10-21 18:27:34 +02:00
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
2009-10-21 12:40:21 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
thd->where= save_where;
|
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
if (!(col_val= add_column_value(thd)))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2009-10-21 12:40:21 +02:00
|
|
|
init_col_val(col_val, item);
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initialise part_info object for receiving a set of column values
|
|
|
|
for a partition, called when parser reaches VALUES LESS THAN or
|
|
|
|
VALUES IN.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
init_column_part()
|
|
|
|
lex Parser's lex object
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Failure
|
|
|
|
FALSE Success
|
|
|
|
*/
|
2015-08-24 13:42:07 +02:00
|
|
|
bool partition_info::init_column_part(THD *thd)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
partition_element *p_elem= curr_part_elem;
|
|
|
|
part_column_list_val *col_val_array;
|
|
|
|
part_elem_value *list_val;
|
|
|
|
uint loc_num_columns;
|
|
|
|
DBUG_ENTER("partition_info::init_column_part");
|
|
|
|
|
|
|
|
if (!(list_val=
|
2015-08-24 13:42:07 +02:00
|
|
|
(part_elem_value*) thd->calloc(sizeof(part_elem_value))) ||
|
|
|
|
p_elem->list_val_list.push_back(list_val, thd->mem_root))
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2009-10-16 16:16:06 +02:00
|
|
|
if (num_columns)
|
|
|
|
loc_num_columns= num_columns;
|
|
|
|
else
|
|
|
|
loc_num_columns= MAX_REF_PARTS;
|
|
|
|
if (!(col_val_array=
|
2015-08-24 13:42:07 +02:00
|
|
|
(part_column_list_val*) thd->calloc(loc_num_columns *
|
|
|
|
sizeof(part_column_list_val))))
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2009-10-16 16:16:06 +02:00
|
|
|
list_val->col_val_array= col_val_array;
|
|
|
|
list_val->added_items= 0;
|
|
|
|
curr_list_val= list_val;
|
|
|
|
curr_list_object= 0;
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
In the case of ALTER TABLE ADD/REORGANIZE PARTITION for LIST
|
|
|
|
partitions we can specify list values as:
|
|
|
|
VALUES IN (v1, v2,,,, v17) if we're using the first partitioning
|
|
|
|
variant with a function or a column list partitioned table with
|
|
|
|
one partition field. In this case the parser knows not the
|
|
|
|
number of columns start with and allocates MAX_REF_PARTS in the
|
|
|
|
array. If we try to allocate something beyond MAX_REF_PARTS we
|
|
|
|
will call this function to reorganize into a structure with
|
|
|
|
num_columns = 1. Also when the parser knows that we used LIST
|
|
|
|
partitioning and we used a VALUES IN like above where number of
|
|
|
|
values was smaller than MAX_REF_PARTS or equal, then we will
|
|
|
|
reorganize after discovering this in the parser.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
reorganize_into_single_field_col_val()
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Failure
|
|
|
|
FALSE Success
|
|
|
|
*/
|
2015-08-24 13:42:07 +02:00
|
|
|
|
|
|
|
int partition_info::reorganize_into_single_field_col_val(THD *thd)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2009-10-21 12:40:21 +02:00
|
|
|
part_column_list_val *col_val, *new_col_val;
|
|
|
|
part_elem_value *val= curr_list_val;
|
2009-10-16 16:16:06 +02:00
|
|
|
uint loc_num_columns= num_columns;
|
|
|
|
uint i;
|
|
|
|
DBUG_ENTER("partition_info::reorganize_into_single_field_col_val");
|
|
|
|
|
|
|
|
num_columns= 1;
|
2009-10-21 12:40:21 +02:00
|
|
|
val->added_items= 1U;
|
|
|
|
col_val= &val->col_val_array[0];
|
|
|
|
init_col_val(col_val, col_val->item_expression);
|
2009-10-16 16:16:06 +02:00
|
|
|
for (i= 1; i < loc_num_columns; i++)
|
|
|
|
{
|
2009-10-21 12:40:21 +02:00
|
|
|
col_val= &val->col_val_array[i];
|
|
|
|
DBUG_ASSERT(part_type == LIST_PARTITION);
|
2015-08-24 13:42:07 +02:00
|
|
|
if (init_column_part(thd))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2015-08-24 13:42:07 +02:00
|
|
|
if (!(new_col_val= add_column_value(thd)))
|
2009-10-21 12:40:21 +02:00
|
|
|
{
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
memcpy(new_col_val, col_val, sizeof(*col_val));
|
|
|
|
init_col_val(new_col_val, col_val->item_expression);
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
2009-10-21 12:40:21 +02:00
|
|
|
curr_list_val= val;
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function handles the case of function-based partitioning.
|
|
|
|
It fixes some data structures created in the parser and puts
|
|
|
|
them in the format required by the rest of the partitioning
|
|
|
|
code.
|
|
|
|
|
|
|
|
SYNOPSIS
|
2010-08-30 17:33:55 +02:00
|
|
|
fix_partition_values()
|
2009-10-16 16:16:06 +02:00
|
|
|
thd Thread object
|
|
|
|
col_val Array of one value
|
|
|
|
part_elem The partition instance
|
2009-10-21 12:40:21 +02:00
|
|
|
part_id Id of partition instance
|
2009-10-16 16:16:06 +02:00
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Failure
|
|
|
|
FALSE Success
|
|
|
|
*/
|
2010-08-30 17:33:55 +02:00
|
|
|
int partition_info::fix_partition_values(THD *thd,
|
|
|
|
part_elem_value *val,
|
2016-08-29 22:29:12 +02:00
|
|
|
partition_element *part_elem)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
part_column_list_val *col_val= val->col_val_array;
|
2010-08-30 17:33:55 +02:00
|
|
|
DBUG_ENTER("partition_info::fix_partition_values");
|
2009-10-16 16:16:06 +02:00
|
|
|
|
|
|
|
if (col_val->fixed)
|
|
|
|
{
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
|
|
|
|
Item *item_expr= col_val->item_expression;
|
|
|
|
if ((val->null_value= item_expr->null_value))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
if (part_elem->has_null_value)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0));
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
part_elem->has_null_value= TRUE;
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
else if (item_expr->result_type() != INT_RESULT)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
my_error(ER_VALUES_IS_NOT_INT_TYPE_ERROR, MYF(0),
|
|
|
|
part_elem->partition_name);
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
if (part_type == RANGE_PARTITION)
|
|
|
|
{
|
|
|
|
if (part_elem->has_null_value)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
my_error(ER_NULL_IN_VALUES_LESS_THAN, MYF(0));
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
part_elem->range_value= val->value;
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
|
|
|
col_val->fixed= 2;
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
2009-10-22 16:15:06 +02:00
|
|
|
/*
|
|
|
|
Get column item with a proper character set according to the field
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
get_column_item()
|
|
|
|
item Item object to start with
|
|
|
|
field Field for which the item will be compared to
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
NULL Error
|
|
|
|
item Returned item
|
|
|
|
*/
|
|
|
|
|
|
|
|
Item* partition_info::get_column_item(Item *item, Field *field)
|
|
|
|
{
|
|
|
|
if (field->result_type() == STRING_RESULT &&
|
|
|
|
item->collation.collation != field->charset())
|
|
|
|
{
|
|
|
|
if (!(item= convert_charset_partition_constant(item,
|
|
|
|
field->charset())))
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2009-10-16 16:16:06 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Evaluate VALUES functions for column list values
|
|
|
|
SYNOPSIS
|
|
|
|
fix_column_value_functions()
|
|
|
|
thd Thread object
|
|
|
|
col_val List of column values
|
|
|
|
part_id Partition id we are fixing
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
TRUE Error
|
|
|
|
FALSE Success
|
|
|
|
DESCRIPTION
|
|
|
|
Fix column VALUES and store in memory array adapted to the data type
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool partition_info::fix_column_value_functions(THD *thd,
|
|
|
|
part_elem_value *val,
|
|
|
|
uint part_id)
|
|
|
|
{
|
2010-05-31 12:59:58 +02:00
|
|
|
uint n_columns= part_field_list.elements;
|
2009-10-16 16:16:06 +02:00
|
|
|
bool result= FALSE;
|
|
|
|
uint i;
|
|
|
|
part_column_list_val *col_val= val->col_val_array;
|
|
|
|
DBUG_ENTER("partition_info::fix_column_value_functions");
|
|
|
|
|
|
|
|
if (col_val->fixed > 1)
|
|
|
|
{
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2010-05-31 12:59:58 +02:00
|
|
|
for (i= 0; i < n_columns; col_val++, i++)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
Item *column_item= col_val->item_expression;
|
|
|
|
Field *field= part_field_array[i];
|
|
|
|
col_val->part_info= this;
|
|
|
|
col_val->partition_id= part_id;
|
|
|
|
if (col_val->max_value)
|
|
|
|
col_val->column_value= NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
col_val->column_value= NULL;
|
|
|
|
if (!col_val->null_value)
|
|
|
|
{
|
|
|
|
uchar *val_ptr;
|
|
|
|
uint len= field->pack_length();
|
2017-10-13 15:55:42 +02:00
|
|
|
sql_mode_t save_sql_mode;
|
2009-10-28 00:06:11 +01:00
|
|
|
bool save_got_warning;
|
|
|
|
|
2018-02-18 12:24:51 +01:00
|
|
|
if (!(column_item= get_column_item(column_item, field)))
|
2009-10-22 16:15:06 +02:00
|
|
|
{
|
|
|
|
result= TRUE;
|
|
|
|
goto end;
|
|
|
|
}
|
2009-10-28 00:06:11 +01:00
|
|
|
save_sql_mode= thd->variables.sql_mode;
|
|
|
|
thd->variables.sql_mode= 0;
|
|
|
|
save_got_warning= thd->got_warning;
|
|
|
|
thd->got_warning= 0;
|
|
|
|
if (column_item->save_in_field(field, TRUE) ||
|
|
|
|
thd->got_warning)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
my_error(ER_WRONG_TYPE_COLUMN_VALUE_ERROR, MYF(0));
|
2018-02-18 12:24:51 +01:00
|
|
|
thd->variables.sql_mode= save_sql_mode;
|
2009-10-16 16:16:06 +02:00
|
|
|
result= TRUE;
|
|
|
|
goto end;
|
|
|
|
}
|
2009-10-28 00:06:11 +01:00
|
|
|
thd->got_warning= save_got_warning;
|
|
|
|
thd->variables.sql_mode= save_sql_mode;
|
2015-08-27 09:07:32 +02:00
|
|
|
if (!(val_ptr= (uchar*) thd->memdup(field->ptr, len)))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
result= TRUE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
col_val->column_value= val_ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
col_val->fixed= 2;
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
2017-11-20 06:33:19 +01:00
|
|
|
|
2013-11-28 12:10:44 +01:00
|
|
|
/**
|
|
|
|
Fix partition data from parser.
|
|
|
|
|
|
|
|
@details The parser generates generic data structures, we need to set them
|
|
|
|
up as the rest of the code expects to find them. This is in reality part
|
2009-10-16 16:16:06 +02:00
|
|
|
of the syntax check of the parser code.
|
|
|
|
|
|
|
|
It is necessary to call this function in the case of a CREATE TABLE
|
|
|
|
statement, in this case we do it early in the check_partition_info
|
|
|
|
function.
|
|
|
|
|
|
|
|
It is necessary to call this function for ALTER TABLE where we
|
|
|
|
assign a completely new partition structure, in this case we do it
|
|
|
|
in prep_alter_part_table after discovering that the partition
|
|
|
|
structure is entirely redefined.
|
|
|
|
|
|
|
|
It's necessary to call this method also for ALTER TABLE ADD/REORGANIZE
|
|
|
|
of partitions, in this we call it in prep_alter_part_table after
|
|
|
|
making some initial checks but before going deep to check the partition
|
|
|
|
info, we also assign the column_list variable before calling this function
|
|
|
|
here.
|
|
|
|
|
|
|
|
Finally we also call it immediately after returning from parsing the
|
|
|
|
partitioning text found in the frm file.
|
|
|
|
|
|
|
|
This function mainly fixes the VALUES parts, these are handled differently
|
|
|
|
whether or not we use column list partitioning. Since the parser doesn't
|
|
|
|
know which we are using we need to set-up the old data structures after
|
|
|
|
the parser is complete when we know if what type of partitioning the
|
|
|
|
base table is using.
|
|
|
|
|
|
|
|
For column lists we will handle this in the fix_column_value_function.
|
|
|
|
For column lists it is sufficient to verify that the number of columns
|
|
|
|
and number of elements are in synch with each other. So only partitioning
|
|
|
|
using functions need to be set-up to their data structures.
|
|
|
|
|
2013-11-28 12:10:44 +01:00
|
|
|
@param thd Thread object
|
2009-10-16 16:16:06 +02:00
|
|
|
|
2013-11-28 12:10:44 +01:00
|
|
|
@return Operation status
|
|
|
|
@retval TRUE Failure
|
|
|
|
@retval FALSE Success
|
2009-10-16 16:16:06 +02:00
|
|
|
*/
|
|
|
|
|
2013-11-28 12:10:44 +01:00
|
|
|
bool partition_info::fix_parser_data(THD *thd)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
List_iterator<partition_element> it(partitions);
|
|
|
|
partition_element *part_elem;
|
|
|
|
uint num_elements;
|
2009-10-21 20:53:44 +02:00
|
|
|
uint i= 0, j, k;
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_ENTER("partition_info::fix_parser_data");
|
|
|
|
|
|
|
|
if (!(part_type == RANGE_PARTITION ||
|
|
|
|
part_type == LIST_PARTITION))
|
|
|
|
{
|
2013-11-28 12:10:44 +01:00
|
|
|
if (part_type == HASH_PARTITION && list_of_part_fields)
|
|
|
|
{
|
|
|
|
/* KEY partitioning, check ALGORITHM = N. Should not pass the parser! */
|
|
|
|
if (key_algorithm > KEY_ALGORITHM_55)
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
/* If not set, use DEFAULT = 2 for CREATE and ALTER! */
|
|
|
|
if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
|
|
|
|
thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
|
|
|
|
key_algorithm == KEY_ALGORITHM_NONE)
|
|
|
|
key_algorithm= KEY_ALGORITHM_55;
|
|
|
|
}
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2013-11-28 12:10:44 +01:00
|
|
|
if (is_sub_partitioned() && list_of_subpart_fields)
|
|
|
|
{
|
|
|
|
/* KEY subpartitioning, check ALGORITHM = N. Should not pass the parser! */
|
|
|
|
if (key_algorithm > KEY_ALGORITHM_55)
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
/* If not set, use DEFAULT = 2 for CREATE and ALTER! */
|
|
|
|
if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
|
|
|
|
thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
|
|
|
|
key_algorithm == KEY_ALGORITHM_NONE)
|
|
|
|
key_algorithm= KEY_ALGORITHM_55;
|
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
defined_max_value= FALSE; // in case it already set (CREATE TABLE LIKE)
|
2009-10-16 16:16:06 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
part_elem= it++;
|
2009-10-21 12:40:21 +02:00
|
|
|
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
|
2009-10-16 16:16:06 +02:00
|
|
|
num_elements= part_elem->list_val_list.elements;
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(!num_elements && error_if_requires_values()))
|
2017-11-20 06:33:19 +01:00
|
|
|
DBUG_RETURN(true);
|
2009-10-16 16:16:06 +02:00
|
|
|
DBUG_ASSERT(part_type == RANGE_PARTITION ?
|
|
|
|
num_elements == 1U : TRUE);
|
2016-08-29 22:29:12 +02:00
|
|
|
|
2013-08-12 11:09:33 +02:00
|
|
|
for (j= 0; j < num_elements; j++)
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
|
|
|
part_elem_value *val= list_val_it++;
|
2016-08-29 22:29:12 +02:00
|
|
|
|
|
|
|
if (val->added_items != (column_list ? num_columns : 1))
|
|
|
|
{
|
|
|
|
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check the last MAX_VALUE for range partitions and DEFAULT value
|
|
|
|
for LIST partitions.
|
|
|
|
Both values are marked with defined_max_value and
|
|
|
|
default_partition_id.
|
|
|
|
|
|
|
|
This is a max_value/default is max_value is set and this is
|
|
|
|
a normal RANGE (no column list) or if it's a LIST partition:
|
|
|
|
|
|
|
|
PARTITION p3 VALUES LESS THAN MAXVALUE
|
|
|
|
or
|
|
|
|
PARTITION p3 VALUES DEFAULT
|
|
|
|
*/
|
|
|
|
if (val->added_items && val->col_val_array[0].max_value &&
|
|
|
|
(!column_list || part_type == LIST_PARTITION))
|
2009-10-16 16:16:06 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
DBUG_ASSERT(part_type == RANGE_PARTITION ||
|
|
|
|
part_type == LIST_PARTITION);
|
|
|
|
if (defined_max_value)
|
|
|
|
{
|
|
|
|
my_error((part_type == RANGE_PARTITION) ?
|
|
|
|
ER_PARTITION_MAXVALUE_ERROR :
|
|
|
|
ER_PARTITION_DEFAULT_ERROR, MYF(0));
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For RANGE PARTITION MAX_VALUE must be last */
|
|
|
|
if (i != (num_parts - 1) &&
|
|
|
|
part_type != LIST_PARTITION)
|
2009-10-21 12:40:21 +02:00
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
my_error(ER_PARTITION_MAXVALUE_ERROR, MYF(0));
|
2009-10-21 12:40:21 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2016-08-29 22:29:12 +02:00
|
|
|
|
|
|
|
defined_max_value= TRUE;
|
|
|
|
default_partition_id= i;
|
|
|
|
part_elem->max_value= TRUE;
|
|
|
|
part_elem->range_value= LONGLONG_MAX;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column_list)
|
|
|
|
{
|
2009-10-21 20:53:44 +02:00
|
|
|
for (k= 0; k < num_columns; k++)
|
|
|
|
{
|
|
|
|
part_column_list_val *col_val= &val->col_val_array[k];
|
|
|
|
if (col_val->null_value && part_type == RANGE_PARTITION)
|
|
|
|
{
|
|
|
|
my_error(ER_NULL_IN_VALUES_LESS_THAN, MYF(0));
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
}
|
2009-10-21 12:40:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-29 22:29:12 +02:00
|
|
|
if (fix_partition_values(thd, val, part_elem))
|
2009-10-21 12:40:21 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
if (val->null_value)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Null values aren't required in the value part, they are kept per
|
|
|
|
partition instance, only LIST partitions have NULL values.
|
|
|
|
*/
|
|
|
|
list_val_it.remove();
|
|
|
|
}
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
2013-08-12 11:09:33 +02:00
|
|
|
}
|
2009-10-16 16:16:06 +02:00
|
|
|
} while (++i < num_parts);
|
2009-10-21 12:40:21 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
2009-10-16 16:16:06 +02:00
|
|
|
}
|
|
|
|
|
Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING
Due to an internal change in the server code in between 5.1 and 5.5
(wl#2649) the hash function used in KEY partitioning changed
for numeric and date/time columns (from binary hash calculation
to character based hash calculation).
Also enum/set changed from latin1 ci based hash calculation to
binary hash between 5.1 and 5.5. (bug#11759782).
These changes makes KEY [sub]partitioned tables on any of
the affected column types incompatible with 5.5 and above,
since the calculation of partition id differs.
Also since InnoDB asserts that a deleted row was previously
read (positioned), the server asserts on delete of a row that
is in the wrong partition.
The solution for this situation is:
1) The partitioning engine will check that delete/update will go to the
partition the row was read from and give an error otherwise, consisting
of the rows partitioning fields. This will avoid asserts in InnoDB and
also alert the user that there is a misplaced row. A detailed error
message will be given, including an entry to the error log consisting
of both table name, partition and row content (PK if exists, otherwise
all partitioning columns).
2) A new optional syntax for KEY () partitioning in 5.5 is allowed:
[SUB]PARTITION BY KEY [ALGORITHM = N] (list_of_cols)
Where N = 1 uses the same hashing as 5.1 (Numeric/date/time fields uses
binary hashing, ENUM/SET uses charset hashing) N = 2 uses the same
hashing as 5.5 (Numeric/date/time fields uses charset hashing,
ENUM/SET uses binary hashing). If not set on CREATE/ALTER it will
default to 2.
This new syntax should probably be ignored by NDB.
3) Since there is a demand for avoiding scanning through the full
table, during upgrade the ALTER TABLE t PARTITION BY ... command is
considered a no-op (only .frm change) if everything except ALGORITHM
is the same and ALGORITHM was not set before, which allows manually
upgrading such table by something like:
ALTER TABLE t PARTITION BY KEY ALGORITHM = 1 () or
ALTER TABLE t PARTITION BY KEY ALGORITHM = 2 ()
4) Enhanced partitioning with CHECK/REPAIR to also check for/repair
misplaced rows. (Also works for ALTER TABLE t CHECK/REPAIR PARTITION)
CHECK FOR UPGRADE:
If the .frm version is < 5.5.3
and uses KEY [sub]partitioning
and an affected column type
then it will fail with an message:
KEY () partitioning changed, please run:
ALTER TABLE `test`.`t1` PARTITION BY KEY ALGORITHM = 1 (a)
PARTITIONS 12
(i.e. current partitioning clause, with the addition of
ALGORITHM = 1)
CHECK without FOR UPGRADE:
if MEDIUM (default) or EXTENDED options are given:
Scan all rows and verify that it is in the correct partition.
Fail for the first misplaced row.
REPAIR:
if default or EXTENDED (i.e. not QUICK/USE_FRM):
Scan all rows and every misplaced row is moved into its correct
partitions.
5) Updated mysqlcheck (called by mysql_upgrade) to handle the
new output from CHECK FOR UPGRADE, to run the ALTER statement
instead of running REPAIR.
This will allow mysql_upgrade (or CHECK TABLE t FOR UPGRADE) to upgrade
a KEY [sub]partitioned table that has any affected field type
and a .frm version < 5.5.3 to ALGORITHM = 1 without rebuild.
Also notice that if the .frm has a version of >= 5.5.3 and ALGORITHM
is not set, it is not possible to know if it consists of rows from
5.1 or 5.5! In these cases I suggest that the user does:
(optional)
LOCK TABLE t WRITE;
SHOW CREATE TABLE t;
(verify that it has no ALGORITHM = N, and to be safe, I would suggest
backing up the .frm file, to be used if one need to change to another
ALGORITHM = N, without needing to rebuild/repair)
ALTER TABLE t <old partitioning clause, but with ALGORITHM = N>;
which should set the ALGORITHM to N (if the table has rows from
5.1 I would suggest N = 1, otherwise N = 2)
CHECK TABLE t;
(here one could use the backed up .frm instead and change to a new N
and run CHECK again and see if it passes)
and if there are misplaced rows:
REPAIR TABLE t;
(optional)
UNLOCK TABLES;
2013-01-30 17:51:52 +01:00
|
|
|
|
2013-11-28 12:10:44 +01:00
|
|
|
/**
|
|
|
|
helper function to compare strings that can also be
|
|
|
|
a NULL pointer.
|
|
|
|
|
|
|
|
@param a char pointer (can be NULL).
|
|
|
|
@param b char pointer (can be NULL).
|
|
|
|
|
|
|
|
@return false if equal
|
|
|
|
@retval true strings differs
|
|
|
|
@retval false strings is equal
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool strcmp_null(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (!a && !b)
|
|
|
|
return false;
|
|
|
|
if (a && b && !strcmp(a, b))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check if the new part_info has the same partitioning.
|
|
|
|
|
|
|
|
@param new_part_info New partition definition to compare with.
|
|
|
|
|
|
|
|
@return True if not considered to have changed the partitioning.
|
|
|
|
@retval true Allowed change (only .frm change, compatible distribution).
|
|
|
|
@retval false Different partitioning, will need redistribution of rows.
|
|
|
|
|
|
|
|
@note Currently only used to allow changing from non-set key_algorithm
|
|
|
|
to a specified key_algorithm, to avoid rebuild when upgrading from 5.1 of
|
|
|
|
such partitioned tables using numeric colums in the partitioning expression.
|
|
|
|
For more info see bug#14521864.
|
|
|
|
Does not check if columns etc has changed, i.e. only for
|
2018-02-19 10:23:20 +01:00
|
|
|
alter_info->partition_flags == ALTER_PARTITION_INFO.
|
2013-11-28 12:10:44 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool partition_info::has_same_partitioning(partition_info *new_part_info)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("partition_info::has_same_partitioning");
|
|
|
|
|
|
|
|
DBUG_ASSERT(part_field_array && part_field_array[0]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Only consider pre 5.5.3 .frm's to have same partitioning as
|
|
|
|
a new one with KEY ALGORITHM = 1 ().
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (part_field_array[0]->table->s->mysql_version >= 50503)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (!new_part_info ||
|
|
|
|
part_type != new_part_info->part_type ||
|
|
|
|
num_parts != new_part_info->num_parts ||
|
|
|
|
use_default_partitions != new_part_info->use_default_partitions ||
|
|
|
|
new_part_info->is_sub_partitioned() != is_sub_partitioned())
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (part_type != HASH_PARTITION)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
RANGE or LIST partitioning, check if KEY subpartitioned.
|
|
|
|
Also COLUMNS partitioning was added in 5.5, so treat that as different.
|
|
|
|
*/
|
|
|
|
if (!is_sub_partitioned() ||
|
|
|
|
!new_part_info->is_sub_partitioned() ||
|
|
|
|
column_list ||
|
|
|
|
new_part_info->column_list ||
|
|
|
|
!list_of_subpart_fields ||
|
|
|
|
!new_part_info->list_of_subpart_fields ||
|
|
|
|
new_part_info->num_subparts != num_subparts ||
|
|
|
|
new_part_info->subpart_field_list.elements !=
|
|
|
|
subpart_field_list.elements ||
|
|
|
|
new_part_info->use_default_subpartitions !=
|
|
|
|
use_default_subpartitions)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check if KEY partitioned. */
|
|
|
|
if (!new_part_info->list_of_part_fields ||
|
|
|
|
!list_of_part_fields ||
|
|
|
|
new_part_info->part_field_list.elements != part_field_list.elements)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that it will use the same fields in KEY (fields) list. */
|
2017-04-23 18:39:57 +02:00
|
|
|
List_iterator<const char> old_field_name_it(part_field_list);
|
|
|
|
List_iterator<const char> new_field_name_it(new_part_info->part_field_list);
|
|
|
|
const char *old_name, *new_name;
|
2013-11-28 12:10:44 +01:00
|
|
|
while ((old_name= old_field_name_it++))
|
|
|
|
{
|
|
|
|
new_name= new_field_name_it++;
|
|
|
|
if (!new_name || my_strcasecmp(system_charset_info,
|
|
|
|
new_name,
|
|
|
|
old_name))
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_sub_partitioned())
|
|
|
|
{
|
|
|
|
/* Check that it will use the same fields in KEY subpart fields list. */
|
2017-04-23 18:39:57 +02:00
|
|
|
List_iterator<const char> old_field_name_it(subpart_field_list);
|
|
|
|
List_iterator<const char> new_field_name_it(new_part_info->subpart_field_list);
|
|
|
|
const char *old_name, *new_name;
|
2013-11-28 12:10:44 +01:00
|
|
|
while ((old_name= old_field_name_it++))
|
|
|
|
{
|
|
|
|
new_name= new_field_name_it++;
|
|
|
|
if (!new_name || my_strcasecmp(system_charset_info,
|
|
|
|
new_name,
|
|
|
|
old_name))
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!use_default_partitions)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Loop over partitions/subpartition to verify that they are
|
|
|
|
the same, including state and name.
|
|
|
|
*/
|
|
|
|
List_iterator<partition_element> part_it(partitions);
|
|
|
|
List_iterator<partition_element> new_part_it(new_part_info->partitions);
|
|
|
|
uint i= 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
partition_element *part_elem= part_it++;
|
|
|
|
partition_element *new_part_elem= new_part_it++;
|
|
|
|
/*
|
|
|
|
The following must match:
|
|
|
|
partition_name, tablespace_name, data_file_name, index_file_name,
|
|
|
|
engine_type, part_max_rows, part_min_rows, nodegroup_id.
|
|
|
|
(max_value, signed_flag, has_null_value only on partition level,
|
|
|
|
RANGE/LIST)
|
|
|
|
The following can differ:
|
|
|
|
- part_comment
|
|
|
|
part_state must be PART_NORMAL!
|
|
|
|
*/
|
|
|
|
if (!part_elem || !new_part_elem ||
|
|
|
|
strcmp(part_elem->partition_name,
|
|
|
|
new_part_elem->partition_name) ||
|
|
|
|
part_elem->part_state != PART_NORMAL ||
|
|
|
|
new_part_elem->part_state != PART_NORMAL ||
|
|
|
|
part_elem->max_value != new_part_elem->max_value ||
|
|
|
|
part_elem->signed_flag != new_part_elem->signed_flag ||
|
|
|
|
part_elem->has_null_value != new_part_elem->has_null_value)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
/* new_part_elem may not have engine_type set! */
|
|
|
|
if (new_part_elem->engine_type &&
|
|
|
|
part_elem->engine_type != new_part_elem->engine_type)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (is_sub_partitioned())
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Check that both old and new partition has the same definition
|
|
|
|
(VALUES IN/VALUES LESS THAN) (No COLUMNS partitioning, see above)
|
|
|
|
*/
|
|
|
|
if (part_type == LIST_PARTITION)
|
|
|
|
{
|
|
|
|
List_iterator<part_elem_value> list_vals(part_elem->list_val_list);
|
|
|
|
List_iterator<part_elem_value>
|
|
|
|
new_list_vals(new_part_elem->list_val_list);
|
|
|
|
part_elem_value *val;
|
|
|
|
part_elem_value *new_val;
|
|
|
|
while ((val= list_vals++))
|
|
|
|
{
|
|
|
|
new_val= new_list_vals++;
|
|
|
|
if (!new_val)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
if ((!val->null_value && !new_val->null_value) &&
|
|
|
|
val->value != new_val->value)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
if (new_list_vals++)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(part_type == RANGE_PARTITION);
|
|
|
|
if (new_part_elem->range_value != part_elem->range_value)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!use_default_subpartitions)
|
|
|
|
{
|
|
|
|
List_iterator<partition_element>
|
|
|
|
sub_part_it(part_elem->subpartitions);
|
|
|
|
List_iterator<partition_element>
|
|
|
|
new_sub_part_it(new_part_elem->subpartitions);
|
|
|
|
uint j= 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
partition_element *sub_part_elem= sub_part_it++;
|
|
|
|
partition_element *new_sub_part_elem= new_sub_part_it++;
|
|
|
|
/* new_part_elem may not have engine_type set! */
|
|
|
|
if (new_sub_part_elem->engine_type &&
|
|
|
|
sub_part_elem->engine_type != new_sub_part_elem->engine_type)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (strcmp(sub_part_elem->partition_name,
|
|
|
|
new_sub_part_elem->partition_name) ||
|
|
|
|
sub_part_elem->part_state != PART_NORMAL ||
|
|
|
|
new_sub_part_elem->part_state != PART_NORMAL ||
|
|
|
|
sub_part_elem->part_min_rows !=
|
|
|
|
new_sub_part_elem->part_min_rows ||
|
|
|
|
sub_part_elem->part_max_rows !=
|
|
|
|
new_sub_part_elem->part_max_rows ||
|
|
|
|
sub_part_elem->nodegroup_id !=
|
|
|
|
new_sub_part_elem->nodegroup_id)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (strcmp_null(sub_part_elem->data_file_name,
|
|
|
|
new_sub_part_elem->data_file_name) ||
|
|
|
|
strcmp_null(sub_part_elem->index_file_name,
|
|
|
|
new_sub_part_elem->index_file_name) ||
|
|
|
|
strcmp_null(sub_part_elem->tablespace_name,
|
|
|
|
new_sub_part_elem->tablespace_name))
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
} while (++j < num_subparts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (part_elem->part_min_rows != new_part_elem->part_min_rows ||
|
|
|
|
part_elem->part_max_rows != new_part_elem->part_max_rows ||
|
|
|
|
part_elem->nodegroup_id != new_part_elem->nodegroup_id)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
if (strcmp_null(part_elem->data_file_name,
|
|
|
|
new_part_elem->data_file_name) ||
|
|
|
|
strcmp_null(part_elem->index_file_name,
|
|
|
|
new_part_elem->index_file_name) ||
|
|
|
|
strcmp_null(part_elem->tablespace_name,
|
|
|
|
new_part_elem->tablespace_name))
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
}
|
|
|
|
} while (++i < num_parts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Only if key_algorithm was not specified before and it is now set,
|
|
|
|
consider this as nothing was changed, and allow change without rebuild!
|
|
|
|
*/
|
|
|
|
if (key_algorithm != partition_info::KEY_ALGORITHM_NONE ||
|
|
|
|
new_part_info->key_algorithm == partition_info::KEY_ALGORITHM_NONE)
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-16 16:16:06 +02:00
|
|
|
void partition_info::print_debug(const char *str, uint *value)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("print_debug");
|
|
|
|
if (value)
|
|
|
|
DBUG_PRINT("info", ("parser: %s, val = %u", str, *value));
|
|
|
|
else
|
|
|
|
DBUG_PRINT("info", ("parser: %s", str));
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2018-12-06 21:42:22 +01:00
|
|
|
|
|
|
|
bool partition_info::field_in_partition_expr(Field *field) const
|
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
for (i= 0; i < num_part_fields; i++)
|
|
|
|
{
|
|
|
|
if (field->eq(part_field_array[i]))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
for (i= 0; i < num_subpart_fields; i++)
|
|
|
|
{
|
|
|
|
if (field->eq(subpart_field_array[i]))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-10-19 09:10:25 +02:00
|
|
|
#else /* WITH_PARTITION_STORAGE_ENGINE */
|
|
|
|
/*
|
|
|
|
For builds without partitioning we need to define these functions
|
|
|
|
since we they are called from the parser. The parser cannot
|
|
|
|
remove code parts using ifdef, but the code parts cannot be called
|
|
|
|
so we simply need to add empty functions to make the linker happy.
|
|
|
|
*/
|
2015-08-24 13:42:07 +02:00
|
|
|
part_column_list_val *partition_info::add_column_value(THD *thd)
|
2009-10-19 09:10:25 +02:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-28 13:46:52 +01:00
|
|
|
|
2019-09-01 16:56:47 +02:00
|
|
|
bool partition_info::set_part_expr(THD *thd, Item *item_ptr, bool is_subpart)
|
2009-10-19 09:10:25 +02:00
|
|
|
{
|
|
|
|
(void)item_ptr;
|
|
|
|
(void)is_subpart;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-19 13:06:21 +02:00
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
int partition_info::reorganize_into_single_field_col_val(THD *thd)
|
2009-10-19 13:06:21 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-24 13:42:07 +02:00
|
|
|
bool partition_info::init_column_part(THD *thd)
|
2009-10-19 13:06:21 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-11-10 10:32:29 +01:00
|
|
|
bool partition_info::add_column_list_value(THD *thd, Item *item)
|
2009-10-19 13:06:21 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-08-24 13:42:07 +02:00
|
|
|
int partition_info::add_max_value(THD *thd)
|
2009-10-19 13:06:21 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-10 10:32:29 +01:00
|
|
|
|
|
|
|
void partition_info::print_debug(const char *str, uint *value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-09 16:18:37 +02:00
|
|
|
bool check_partition_dirs(partition_info *part_info)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-16 17:38:33 +01:00
|
|
|
#endif /* WITH_PARTITION_STORAGE_ENGINE */
|
2018-02-14 12:35:12 +01:00
|
|
|
|
2018-03-28 19:19:17 +02:00
|
|
|
bool partition_info::vers_init_info(THD * thd)
|
|
|
|
{
|
|
|
|
part_type= VERSIONING_PARTITION;
|
2019-08-28 10:57:16 +02:00
|
|
|
list_of_part_fields= true;
|
|
|
|
column_list= false;
|
2018-03-28 19:19:17 +02:00
|
|
|
vers_info= new (thd->mem_root) Vers_part_info;
|
2018-04-12 01:57:19 +02:00
|
|
|
if (unlikely(!vers_info))
|
2018-03-28 19:19:17 +02:00
|
|
|
return true;
|
2018-04-12 01:57:19 +02:00
|
|
|
|
2018-03-28 19:19:17 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-14 12:35:12 +01:00
|
|
|
bool partition_info::error_if_requires_values() const
|
|
|
|
{
|
|
|
|
switch (part_type) {
|
|
|
|
case NOT_A_PARTITION:
|
|
|
|
case HASH_PARTITION:
|
2018-02-23 08:43:34 +01:00
|
|
|
case VERSIONING_PARTITION:
|
2018-02-14 12:35:12 +01:00
|
|
|
break;
|
|
|
|
case RANGE_PARTITION:
|
|
|
|
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN");
|
|
|
|
return true;
|
|
|
|
case LIST_PARTITION:
|
|
|
|
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|