Below is the list of changes that have just been committed into a local
6.0 repository of kostja. When kostja does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-04-25 22:45:33+04:00, kostja@bodhi.(none) +5 -0
Fix failure of error_simulation test in 'pst' build (prepared
statements protocol + pool-of-threads).
dbug/dbug.c@stripped, 2008-04-25 22:45:30+04:00, kostja@bodhi.(none) +12 -0
Implement _db_is_pushed_() - a helper function that checks
if session-specific settings have been set.
include/my_dbug.h@stripped, 2008-04-25 22:45:30+04:00, kostja@bodhi.(none) +1 -0
Declare _db_is_pushed_()
sql/scheduler.cc@stripped, 2008-04-25 22:45:30+04:00, kostja@bodhi.(none) +23 -23
Re-implement reset/restore of session-specific dbug settings in
pool-of-thread scheduler. The old implementation would wrongly
set empty settings in some cases.
The new approach is to remember the current session-specific
settings, if any, at thread detach, and restore at attach.
The thread is always returned to the pool without session-specific
settings.
sql/scheduler.h@stripped, 2008-04-25 22:45:30+04:00, kostja@bodhi.(none) +2 -2
Update declarations.
sql/set_var.h@stripped, 2008-04-25 22:45:30+04:00, kostja@bodhi.(none) +11 -0
Add a comment clarifying semantics of @@session.dbug.
diff -Nrup a/dbug/dbug.c b/dbug/dbug.c
--- a/dbug/dbug.c 2008-04-25 22:38:06 +04:00
+++ b/dbug/dbug.c 2008-04-25 22:45:30 +04:00
@@ -723,6 +723,18 @@ void _db_push_(const char *control)
DbugParse(cs, control);
}
+
+/**
+ Returns TRUE if session-local settings have been set.
+*/
+
+int _db_is_pushed_()
+{
+ CODE_STATE *cs= NULL;
+ get_code_state_or_return FALSE;
+ return (cs->stack != &init_settings);
+}
+
/*
* FUNCTION
*
diff -Nrup a/include/my_dbug.h b/include/my_dbug.h
--- a/include/my_dbug.h 2008-03-31 11:40:35 +04:00
+++ b/include/my_dbug.h 2008-04-25 22:45:30 +04:00
@@ -25,6 +25,7 @@ extern int _db_keyword_(struct _db_code_
extern int _db_strict_keyword_(const char *keyword);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
extern int _db_explain_init_(char *buf, size_t len);
+extern int _db_is_pushed_(void);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern void _db_process_(const char *name);
diff -Nrup a/sql/scheduler.cc b/sql/scheduler.cc
--- a/sql/scheduler.cc 2008-04-24 07:31:56 +04:00
+++ b/sql/scheduler.cc 2008-04-25 22:45:30 +04:00
@@ -152,7 +152,8 @@ thd_scheduler::thd_scheduler()
: logged_in(FALSE), io_event(NULL), thread_attached(FALSE)
{
#ifndef DBUG_OFF
- dbug_explain_buf[0]= 0;
+ dbug_explain[0]= '\0';
+ set_explain= FALSE;
#endif
}
@@ -200,7 +201,13 @@ bool thd_scheduler::thread_attach()
thd->mysys_var->abort= 0;
thread_attached= TRUE;
#ifndef DBUG_OFF
- swap_dbug_explain();
+ /*
+ When we attach the thread for a connection for the first time,
+ we know that there is no session value set yet. Thus
+ the initial setting of set_explain to FALSE is OK.
+ */
+ if (set_explain)
+ DBUG_SET(dbug_explain);
#endif
return FALSE;
}
@@ -218,30 +225,23 @@ void thd_scheduler::thread_detach()
thd->mysys_var= NULL;
thread_attached= FALSE;
#ifndef DBUG_OFF
- swap_dbug_explain();
+ /*
+ If during the session @@session.dbug was assigned, the
+ dbug options/state has been pushed. Check if this is the
+ case, to be able to restore the state when we attach this
+ logical connection to a physical thread.
+ */
+ if (_db_is_pushed_())
+ {
+ set_explain= TRUE;
+ if (DBUG_EXPLAIN(dbug_explain, sizeof(dbug_explain)))
+ sql_print_error("thd_scheduler: DBUG_EXPLAIN buffer is too small");
+ }
+ /* DBUG_POP() is a no-op in case there is no session state */
+ DBUG_POP();
#endif
}
}
-
-
-/*
- Swap the THD's dbug explain_buffer with the OS thread's dbug explain buffer.
-
- This is used to preserve the SESSION DEBUG variable, which is mapped to the OS
- thread during a command, but each command is handled by a different thread.
-*/
-
-#ifndef DBUG_OFF
-void thd_scheduler::swap_dbug_explain()
-{
- char buffer[sizeof(dbug_explain_buf)];
- if (DBUG_EXPLAIN(buffer, sizeof(buffer)))
- sql_print_error("DBUG_EXPLAIN buffer too small.\n");
- DBUG_POP();
- DBUG_PUSH(dbug_explain_buf);
- memcpy(dbug_explain_buf, buffer, sizeof(buffer));
-}
-#endif
/**
Create all threads for the thread pool
diff -Nrup a/sql/scheduler.h b/sql/scheduler.h
--- a/sql/scheduler.h 2007-11-21 00:09:55 +03:00
+++ b/sql/scheduler.h 2008-04-25 22:45:30 +04:00
@@ -63,8 +63,8 @@ public:
bool thread_attached; /* Indicates if THD is attached to the OS thread */
#ifndef DBUG_OFF
- char dbug_explain_buf[256];
- void swap_dbug_explain();
+ char dbug_explain[256];
+ bool set_explain;
#endif
thd_scheduler();
diff -Nrup a/sql/set_var.h b/sql/set_var.h
--- a/sql/set_var.h 2008-03-31 14:53:25 +04:00
+++ b/sql/set_var.h 2008-04-25 22:45:30 +04:00
@@ -581,6 +581,17 @@ public:
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
+/**
+ @@session.dbug and @@global.dbug variables.
+
+ @@dbug variable differs from other variables in one aspect:
+ if its value is not assigned in the session, it "points" to the global
+ value, and so when the global value is changed, the change
+ immediately takes effect in the session.
+
+ This semantics is intentional, to be able to debug one session from
+ another.
+*/
class sys_var_thd_dbug :public sys_var_thd
{
public:
| Thread |
|---|
| • bk commit into 6.0 tree (kostja:1.2630) | konstantin | 25 Apr |