#At file:///home/dlenev/src/bzr/mysql-6.1-fk-mrg/
2675 Dmitry Lenev 2008-06-25 [merge]
Merge of latest changes from mysql-6.0-3726 tree to
mysql-6.1-fk tree.
modified:
include/my_global.h
include/thr_lock.h
mysql-test/r/lock.result
mysql-test/t/lock.test
mysys/thr_lock.c
sql/lock.cc
sql/sql_base.cc
sql/sql_profile.cc
sql/sql_profile.h
=== modified file 'include/my_global.h'
--- a/include/my_global.h 2008-05-22 18:40:15 +0000
+++ b/include/my_global.h 2008-06-25 16:40:20 +0000
@@ -1546,4 +1546,23 @@ inline void operator delete[](void*, vo
#define bool In_C_you_should_use_my_bool_instead()
#endif
+/* Provide __func__ macro definition for platforms that miss it. */
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+# define __func__ __FUNCTION__
+# else
+# define __func__ "<unknown>"
+# endif
+#elif defined(_MSC_VER)
+# if _MSC_VER < 1300
+# define __func__ "<unknown>"
+# else
+# define __func__ __FUNCTION__
+# endif
+#elif defined(__BORLANDC__)
+# define __func__ __FUNC__
+#else
+# define __func__ "<unknown>"
+#endif
+
#endif /* my_global_h */
=== modified file 'include/thr_lock.h'
--- a/include/thr_lock.h 2008-02-18 22:29:39 +0000
+++ b/include/thr_lock.h 2008-06-25 12:44:00 +0000
@@ -148,6 +148,8 @@ void thr_unlock(THR_LOCK_DATA *data);
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
uint count, THR_LOCK_OWNER *owner);
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
+void
+thr_lock_merge_status(THR_LOCK_DATA **data, uint count);
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
void thr_print_locks(void); /* For debugging */
=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result 2008-06-11 11:49:58 +0000
+++ b/mysql-test/r/lock.result 2008-06-25 12:44:00 +0000
@@ -217,5 +217,23 @@ a
unlock tables;
drop table t1, t2;
#
+# Ensure that mi_copy_status is called for two instances
+# of the same table when it is reopened after a flush.
+#
+drop table if exists t1;
+drop view if exists v1;
+create table t1 (c1 int);
+create view v1 as select * from t1;
+lock tables t1 write, v1 write;
+flush table t1;
+insert into t1 values (33);
+flush table t1;
+select * from t1;
+c1
+33
+unlock tables;
+drop table t1;
+drop view v1;
+#
# End of 6.0 tests.
#
=== modified file 'mysql-test/t/lock.test'
--- a/mysql-test/t/lock.test 2008-06-11 11:49:58 +0000
+++ b/mysql-test/t/lock.test 2008-06-25 12:44:00 +0000
@@ -261,6 +261,24 @@ select * from t1;
unlock tables;
drop table t1, t2;
+--echo #
+--echo # Ensure that mi_copy_status is called for two instances
+--echo # of the same table when it is reopened after a flush.
+--echo #
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1;
+--enable_warnings
+create table t1 (c1 int);
+create view v1 as select * from t1;
+lock tables t1 write, v1 write;
+flush table t1;
+insert into t1 values (33);
+flush table t1;
+select * from t1;
+unlock tables;
+drop table t1;
+drop view v1;
--echo #
--echo # End of 6.0 tests.
=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c 2008-04-09 01:07:00 +0000
+++ b/mysys/thr_lock.c 2008-06-25 12:44:00 +0000
@@ -981,12 +981,43 @@ thr_multi_lock(THR_LOCK_DATA **data, uin
(long) pos[0]->lock, pos[0]->type); fflush(stdout);
#endif
}
- /*
- Ensure that all get_locks() have the same status
- If we lock the same table multiple times, we must use the same
- status_param!
- */
+ thr_lock_merge_status(data, count);
+ DBUG_RETURN(THR_LOCK_SUCCESS);
+}
+
+
+/**
+ Ensure that all locks for a given table have the same
+ status_param.
+
+ This is a MyISAM and possibly Maria specific crutch. MyISAM
+ engine stores data file length, record count and other table
+ properties in status_param member of handler. When a table is
+ locked, connection-local copy is made from a global copy
+ (myisam_share) by mi_get_status(). When a table is unlocked,
+ the changed status is transferred back to the global share by
+ mi_update_status().
+
+ One thing MyISAM doesn't do is to ensure that when the same
+ table is opened twice in a connection all instances share the
+ same status_param. This is necessary, however: for one, to keep
+ all instances of a connection "on the same page" with regard to
+ the current state of the table. For other, unless this is done,
+ myisam_share will always get updated from the last unlocked
+ instance (in mi_update_status()), and when this instance was not
+ the one that was used to update data, records may be lost.
+
+ For each table, this function looks up the last lock_data in the
+ list of acquired locks, and makes sure that all other instances
+ share status_param with it.
+*/
+
+void
+thr_lock_merge_status(THR_LOCK_DATA **data, uint count)
+{
#if !defined(DONT_USE_RW_LOCKS)
+ THR_LOCK_DATA **pos= data;
+ THR_LOCK_DATA **end= data + count;
if (count > 1)
{
THR_LOCK_DATA *last_lock= end[-1];
@@ -1028,7 +1059,6 @@ thr_multi_lock(THR_LOCK_DATA **data, uin
} while (pos != data);
}
#endif
- DBUG_RETURN(THR_LOCK_SUCCESS);
}
/* free all locks */
=== modified file 'sql/lock.cc'
--- a/sql/lock.cc 2008-06-19 12:39:58 +0000
+++ b/sql/lock.cc 2008-06-25 12:44:00 +0000
@@ -672,6 +672,8 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK
/* Delete old, not needed locks */
my_free((uchar*) a,MYF(0));
my_free((uchar*) b,MYF(0));
+
+ thr_lock_merge_status(sql_lock->locks, sql_lock->lock_count);
DBUG_RETURN(sql_lock);
}
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2008-06-23 13:26:17 +0000
+++ b/sql/sql_base.cc 2008-06-25 16:40:20 +0000
@@ -1288,7 +1288,6 @@ void close_thread_tables(THD *thd,
bool skip_mdl)
{
TABLE *table;
- bool clear_table_lock_option= FALSE;
DBUG_ENTER("close_thread_tables");
#ifdef EXTRA_DEBUG
@@ -1381,7 +1380,6 @@ void close_thread_tables(THD *thd,
DBUG_VOID_RETURN;
thd->locked_tables_mode= LTM_NONE;
- clear_table_lock_option= TRUE;
/*
Note that we are leaving prelocked mode so we don't need
@@ -1420,10 +1418,6 @@ void close_thread_tables(THD *thd,
{
mdl_remove_all_locks(&thd->mdl_context);
}
-
- if (clear_table_lock_option)
- thd->options&= ~OPTION_TABLE_LOCK;
-
DBUG_VOID_RETURN;
}
@@ -4732,8 +4726,6 @@ int lock_tables(THD *thd, TABLE_LIST *ta
/* We have to emulate LOCK TABLES if we are statement needs prelocking. */
if (thd->lex->requires_prelocking())
{
- thd->in_lock_tables=1;
- thd->options|= OPTION_TABLE_LOCK;
/*
If we have >= 2 different tables to update with auto_inc columns,
statement-based binlogging won't work. We can solve this problem in
@@ -4749,14 +4741,7 @@ int lock_tables(THD *thd, TABLE_LIST *ta
if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
flags, need_reopen)))
- {
- if (thd->lex->requires_prelocking())
- {
- thd->options&= ~(OPTION_TABLE_LOCK);
- thd->in_lock_tables=0;
- }
DBUG_RETURN(-1);
- }
if (thd->lex->requires_prelocking() &&
thd->lex->sql_command != SQLCOM_LOCK_TABLES)
@@ -4766,10 +4751,6 @@ int lock_tables(THD *thd, TABLE_LIST *ta
We just have done implicit LOCK TABLES, and now we have
to emulate first open_and_lock_tables() after it.
- */
- thd->in_lock_tables= 0;
-
- /*
When open_and_lock_tables() is called for a single table out of
a table list, the 'next_global' chain is temporarily broken. We
may not find 'first_not_own' before the end of the "list".
@@ -4792,7 +4773,6 @@ int lock_tables(THD *thd, TABLE_LIST *ta
*/
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
- thd->options&= ~(OPTION_TABLE_LOCK);
DBUG_RETURN(-1);
}
}
=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc 2008-02-19 21:33:56 +0000
+++ b/sql/sql_profile.cc 2008-06-25 16:28:57 +0000
@@ -38,9 +38,6 @@
#define MAX_QUERY_LENGTH 300
-/* Reserved for systems that can't record the function name in source. */
-const char * const _unknown_func_ = "<unknown>";
-
/**
Connects Information_Schema and Profiling.
*/
=== modified file 'sql/sql_profile.h'
--- a/sql/sql_profile.h 2007-12-20 16:29:11 +0000
+++ b/sql/sql_profile.h 2008-06-25 16:28:57 +0000
@@ -16,27 +16,6 @@
#ifndef _SQL_PROFILE_H
#define _SQL_PROFILE_H
-#if __STDC_VERSION__ < 199901L
-# if __GNUC__ >= 2
-# define __func__ __FUNCTION__
-# else
-# define __func__ _unknown_func_
-extern const char * const _unknown_func_;
-# endif
-#elif defined(_MSC_VER)
-# if _MSC_VER < 1300
-# define __func__ _unknown_func_
-extern const char * const _unknown_func_;
-# else
-# define __func__ __FUNCTION__
-# endif
-#elif defined(__BORLANDC__)
-# define __func__ __FUNC__
-#else
-# define __func__ _unknown_func_
-extern const char * const _unknown_func_;
-#endif
-
extern ST_FIELD_INFO query_profile_statistics_info[];
int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
| Thread |
|---|
| • bzr commit into mysql-6.1-fk branch (dlenev:2675) | Dmitry Lenev | 25 Jun |