summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-08-05 22:56:11 +0300
committerMichael Widenius <monty@askmonty.org>2010-08-05 22:56:11 +0300
commitd042146e5b41b6222df3e6b4c16a44f3ef2939b7 (patch)
treee40f5b435f7d17ed1c24dfb787ab8cd5f4f7d5d8 /sql/table.cc
parent3e610bc58d0ba325fdca3b06dfa976ecc513dc1e (diff)
parentf0f21036951f6fed2fddeb58375425f957751fd5 (diff)
downloadmariadb-git-d042146e5b41b6222df3e6b4c16a44f3ef2939b7.tar.gz
Merge with MariaDB 5.1.49
Removed references to HA_END_SPACE_KEY (which has been 0 for a long time)
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc175
1 files changed, 85 insertions, 90 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 7db7e510ea0..988e082addf 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -52,6 +52,8 @@ static uint find_field(Field **fields, uchar *record, uint start, uint length);
inline bool is_system_table_name(const char *name, uint length);
+static ulong get_form_pos(File file, uchar *head);
+
/**************************************************************************
Object_creation_ctx implementation.
**************************************************************************/
@@ -304,13 +306,6 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
share->version= refresh_version;
/*
- This constant is used to mark that no table map version has been
- assigned. No arithmetic is done on the value: it will be
- overwritten with a value taken from MYSQL_BIN_LOG.
- */
- share->table_map_version= ~(ulonglong)0;
-
- /*
Since alloc_table_share() can be called without any locking (for
example, ha_create_table... functions), we do not assign a table
map id here. Instead we assign a value that is not used
@@ -373,11 +368,6 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
share->path.length= share->normalized_path.length= strlen(path);
share->frm_version= FRM_VER_TRUE_VARCHAR;
- /*
- Temporary tables are not replicated, but we set up these fields
- anyway to be able to catch errors.
- */
- share->table_map_version= ~(ulonglong)0;
share->cached_row_logging_check= -1;
/*
@@ -706,6 +696,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
const char **interval_array;
enum legacy_db_type legacy_db_type;
my_bitmap_map *bitmaps;
+ bool null_bits_are_used;
DBUG_ENTER("open_binary_frm");
new_field_pack_flag= head[27];
@@ -714,7 +705,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
disk_buff= 0;
error= 3;
- if (!(pos=get_form_pos(file,head,(TYPELIB*) 0)))
+ /* Position of the form in the form file. */
+ if (!(pos= get_form_pos(file, head)))
goto err; /* purecov: inspected */
share->frm_version= head[2];
@@ -1152,6 +1144,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
goto free_and_err;
record= share->default_values-1; /* Fieldstart = 1 */
+ null_bits_are_used= share->null_fields != 0;
if (share->null_field_first)
{
null_flags= null_pos= (uchar*) record+1;
@@ -1370,6 +1363,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
reg_field->stored_in_db= fld_stored_in_db;
if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag))
{
+ null_bits_are_used= 1;
if ((null_bit_pos+= field_length & 7) > 7)
{
null_pos++;
@@ -1503,12 +1497,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
keyinfo->extra_length+=HA_KEY_BLOB_LENGTH;
key_part->store_length+=HA_KEY_BLOB_LENGTH;
keyinfo->key_length+= HA_KEY_BLOB_LENGTH;
- /*
- Mark that there may be many matching values for one key
- combination ('a', 'a ', 'a '...)
- */
- if (!(field->flags & BINARY_FLAG))
- keyinfo->flags|= HA_END_SPACE_KEY;
}
if (field->type() == MYSQL_TYPE_BIT)
key_part->key_part_flag|= HA_BIT_PART;
@@ -1702,6 +1690,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->null_bytes= (null_pos - (uchar*) null_flags +
(null_bit_pos + 7) / 8);
share->last_null_bit_pos= null_bit_pos;
+ share->null_bytes_for_compare= null_bits_are_used ? share->null_bytes : 0;
+ share->can_cmp_whole_record= (share->blob_fields == 0 &&
+ share->varchar_fields == 0);
share->db_low_byte_first= handler_file->low_byte_first();
share->column_bitmap_size= bitmap_buffer_size(share->fields);
@@ -1946,7 +1937,14 @@ bool unpack_vcol_info_from_frm(THD *thd,
LEX_STRING *vcol_expr,
bool *error_reported)
{
- bool rc= FALSE;
+ bool rc;
+ char *vcol_expr_str;
+ int str_len;
+ CHARSET_INFO *old_character_set_client;
+ Query_arena *backup_stmt_arena_ptr;
+ Query_arena backup_arena;
+ Query_arena *vcol_arena;
+ Parser_state parser_state;
DBUG_ENTER("unpack_vcol_info_from_frm");
DBUG_ASSERT(vcol_expr);
@@ -1955,9 +1953,6 @@ bool unpack_vcol_info_from_frm(THD *thd,
The string to be parsed has to be of the following format:
"PARSE_VCOL_EXPR (<expr_string_from_frm>)".
*/
- char *vcol_expr_str;
- int str_len= 0;
- CHARSET_INFO *old_character_set_client;
if (!(vcol_expr_str= (char*) alloc_root(&table->mem_root,
vcol_expr->length +
@@ -1979,14 +1974,15 @@ bool unpack_vcol_info_from_frm(THD *thd,
str_len++;
memcpy(vcol_expr_str + str_len, "\0", 1);
str_len++;
- Parser_state parser_state(thd, vcol_expr_str, str_len);
+
+ if (parser_state.init(thd, vcol_expr_str, str_len))
+ goto err;
/*
Step 2: Setup thd for parsing.
*/
- Query_arena *backup_stmt_arena_ptr= thd->stmt_arena;
- Query_arena backup_arena;
- Query_arena *vcol_arena= table->expr_arena;
+ backup_stmt_arena_ptr= thd->stmt_arena;
+ vcol_arena= table->expr_arena;
if (!vcol_arena)
{
Query_arena expr_arena(&table->mem_root, Query_arena::INITIALIZED);
@@ -2019,6 +2015,7 @@ bool unpack_vcol_info_from_frm(THD *thd,
field->vcol_info= 0;
goto err;
}
+ rc= FALSE;
goto end;
err:
@@ -2517,55 +2514,46 @@ void free_field_buffers_larger_than(TABLE *table, uint32 size)
}
}
- /* Find where a form starts */
- /* if formname is NullS then only formnames is read */
+/**
+ Find where a form starts.
+
+ @param head The start of the form file.
+
+ @remark If formname is NULL then only formnames is read.
+
+ @retval The form position.
+*/
-ulong get_form_pos(File file, uchar *head, TYPELIB *save_names)
+static ulong get_form_pos(File file, uchar *head)
{
- uint a_length,names,length;
- uchar *pos,*buf;
+ uchar *pos, *buf;
+ uint names, length;
ulong ret_value=0;
DBUG_ENTER("get_form_pos");
- LINT_INIT(buf);
+ names= uint2korr(head+8);
- names=uint2korr(head+8);
- a_length=(names+2)*sizeof(char *); /* Room for two extra */
+ if (!(names= uint2korr(head+8)))
+ DBUG_RETURN(0);
- if (!save_names)
- a_length=0;
- else
- save_names->type_names=0; /* Clear if error */
+ length= uint2korr(head+4);
- if (names)
- {
- length=uint2korr(head+4);
- VOID(my_seek(file,64L,MY_SEEK_SET,MYF(0)));
- if (!(buf= (uchar*) my_malloc((size_t) length+a_length+names*4,
- MYF(MY_WME))) ||
- my_read(file, buf+a_length, (size_t) (length+names*4),
- MYF(MY_NABP)))
- { /* purecov: inspected */
- x_free((uchar*) buf); /* purecov: inspected */
- DBUG_RETURN(0L); /* purecov: inspected */
- }
- pos= buf+a_length+length;
- ret_value=uint4korr(pos);
- }
- if (! save_names)
- {
- if (names)
- my_free((uchar*) buf,MYF(0));
- }
- else if (!names)
- bzero((char*) save_names,sizeof(save_names));
- else
+ my_seek(file, 64L, MY_SEEK_SET, MYF(0));
+
+ if (!(buf= (uchar*) my_malloc(length+names*4, MYF(MY_WME))))
+ DBUG_RETURN(0);
+
+ if (my_read(file, buf, length+names*4, MYF(MY_NABP)))
{
- char *str;
- const char **tmp = (const char**) buf;
- str=(char *) (buf+a_length);
- fix_type_pointers(&tmp, save_names, 1, &str);
+ x_free(buf);
+ DBUG_RETURN(0);
}
+
+ pos= buf+length;
+ ret_value= uint4korr(pos);
+
+ my_free(buf, MYF(0));
+
DBUG_RETURN(ret_value);
}
@@ -3163,44 +3151,30 @@ bool check_db_name(LEX_STRING *org_name)
{
char *name= org_name->str;
uint name_length= org_name->length;
+ bool check_for_path_chars;
if (!name_length || name_length > NAME_LEN)
return 1;
+ if ((check_for_path_chars= check_mysql50_prefix(name)))
+ {
+ name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH;
+ name_length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH;
+ }
+
if (lower_case_table_names && name != any_db)
my_casedn_str(files_charset_info, name);
-#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(system_charset_info))
- {
- name_length= 0;
- bool last_char_is_space= TRUE;
- char *end= name + org_name->length;
- while (name < end)
- {
- int len;
- last_char_is_space= my_isspace(system_charset_info, *name);
- len= my_ismbchar(system_charset_info, name, end);
- if (!len)
- len= 1;
- name+= len;
- name_length++;
- }
- return (last_char_is_space || name_length > NAME_CHAR_LEN);
- }
- else
-#endif
- return ((org_name->str[org_name->length - 1] != ' ') ||
- (name_length > NAME_CHAR_LEN)); /* purecov: inspected */
+ return check_table_name(name, name_length, check_for_path_chars);
}
+
/*
Allow anything as a table name, as long as it doesn't contain an
' ' at the end
returns 1 on error
*/
-
bool check_table_name(const char *name, uint length, bool check_for_path_chars)
{
uint name_length= 0; // name length in symbols
@@ -3228,10 +3202,10 @@ bool check_table_name(const char *name, uint length, bool check_for_path_chars)
continue;
}
}
+#endif
if (check_for_path_chars &&
(*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR))
return 1;
-#endif
name++;
name_length++;
}
@@ -4864,6 +4838,27 @@ void st_table::mark_columns_used_by_index(uint index)
/*
+ Add fields used by a specified index to the table's read_set.
+
+ NOTE:
+ The original state can be restored with
+ restore_column_maps_after_mark_index().
+*/
+
+void st_table::add_read_columns_used_by_index(uint index)
+{
+ MY_BITMAP *bitmap= &tmp_set;
+ DBUG_ENTER("st_table::add_read_columns_used_by_index");
+
+ enable_keyread();
+ bitmap_copy(bitmap, read_set);
+ mark_columns_used_by_index_no_reset(index, bitmap);
+ column_bitmaps_set(bitmap, write_set);
+ DBUG_VOID_RETURN;
+}
+
+
+/*
Restore to use normal column maps after key read
NOTES