summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-08-02 12:01:24 +0300
committerMichael Widenius <monty@askmonty.org>2010-08-02 12:01:24 +0300
commite0a6b02c5d0a311e7167295494786077009743d1 (patch)
tree72c934fe42261ad5de3139961e092f57e9d147df /sql/table.cc
parentd2f8b7d04503478ab6b6998194a2070891f0c2bb (diff)
parent6ad06b15222300e4eed4fe3972d1ad249c4c42a2 (diff)
downloadmariadb-git-e0a6b02c5d0a311e7167295494786077009743d1.tar.gz
Merge with MySQL 5.1.49
Fixed Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins' in a better way (patch from Sergey Petrunya)
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc141
1 files changed, 65 insertions, 76 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 5d2b72f9316..d77d09b9b6f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -45,6 +45,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.
**************************************************************************/
@@ -297,13 +299,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
@@ -366,11 +361,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;
/*
@@ -705,7 +695,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];
@@ -2065,55 +2056,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.
-ulong get_form_pos(File file, uchar *head, TYPELIB *save_names)
+ @remark If formname is NULL then only formnames is read.
+
+ @retval The form position.
+*/
+
+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);
}
@@ -2709,44 +2691,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
@@ -2774,10 +2742,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++;
}
@@ -4412,6 +4380,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