#At file:///home/malff/BZR-TREE/mysql-6.0-wl2110-review-part2/
2677 Marc Alff 2008-08-07
WL#2110 (SIGNAL)
Implemented code review comments from the review of patch 2/10
Implemented changes to comply with the decisions documented on 2008-08-06 in
the RESIGNAL work log (2265).
(initialisation of condition items in RESIGNAL)
modified:
sql/mysqld.cc
sql/share/errmsg.txt
sql/sql_class.cc
sql/sql_class.h
sql/sql_signal.cc
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2008-07-23 00:25:11 +0000
+++ b/sql/mysqld.cc 2008-08-07 13:46:39 +0000
@@ -2970,14 +2970,6 @@ void my_message_sql(uint error, const ch
and the storage engine should call that interface (see ma_message_end_user)
*/
- /*
- Flags for printing to the logs are mutually exclusive
- */
- DBUG_ASSERT(!(MyFlags & ME_JUST_INFO) ||
- !(MyFlags & ME_JUST_WARNING) ||
- !(MyFlags & ME_NOREFRESH));
-
-
if (MyFlags & ME_JUST_INFO)
{
sql_print_information("%s: %s", my_progname, str);
=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt 2008-07-23 00:25:11 +0000
+++ b/sql/share/errmsg.txt 2008-08-07 13:46:39 +0000
@@ -6374,7 +6374,7 @@ ER_BACKUP_RELEASE_NAME_LOCK_FAILED
eng "Restore failed to release the name locks on the tables."
ER_DUP_SIGNAL_SET 42000
- eng "Duplicate condition information item: %s"
+ eng "Duplicate condition information item '%s'"
ER_SIGNAL_WARN 01000
eng "Unhandled user-defined warning"
@@ -6392,8 +6392,8 @@ ER_SIGNAL_BAD_CONDITION_TYPE
eng "SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE"
WARN_COND_ITEM_TRUNCATED
- eng "Data truncated for condition item %s"
+ eng "Data truncated for condition item '%s'"
ER_COND_ITEM_TOO_LONG
- eng "Data too long for condition item %s"
+ eng "Data too long for condition item '%s'"
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2008-07-23 00:25:11 +0000
+++ b/sql/sql_class.cc 2008-08-07 13:46:39 +0000
@@ -373,12 +373,8 @@ char *thd_security_context(THD *thd, cha
void Diagnostics_stmt_area::clear()
{
- m_number= 0;
- m_more= FALSE;
- m_rowcount= 0;
-
warn_list.empty();
- bzero((char*) warn_count, sizeof(warn_count));
+ memset((char*) warn_count, 0, sizeof(warn_count));
}
/**
@@ -437,11 +433,6 @@ Diagnostics_area::set_ok_status(THD *thd
m_message[0]= '\0';
m_status= DA_OK;
- if (! m_stmt_area.is_read_only())
- {
- m_stmt_area.m_number++;
- m_stmt_area.m_rowcount= m_affected_rows;
- }
DBUG_VOID_RETURN;
}
@@ -716,7 +707,6 @@ void THD::raise_error(uint code, const c
{
SQL_condition cond(this->mem_root);
cond.set(this, code, str, MYSQL_ERROR::WARN_LEVEL_ERROR, MyFlags);
-
raise_condition(& cond);
}
@@ -724,19 +714,14 @@ void THD::raise_error_printf(uint code,
{
va_list args;
char ebuff[ERRMSGSIZE+20];
-
-
DBUG_ENTER("THD::raise_error_printf");
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d Format: %s",
code, MyFlags, errno, format));
-
va_start(args, MyFlags);
- (void) my_vsnprintf (ebuff, sizeof(ebuff), format, args);
+ my_vsnprintf(ebuff, sizeof(ebuff), format, args);
va_end(args);
-
SQL_condition cond(this->mem_root);
cond.set(this, code, ebuff, MYSQL_ERROR::WARN_LEVEL_ERROR, MyFlags);
-
raise_condition(& cond);
DBUG_VOID_RETURN;
}
@@ -745,7 +730,6 @@ void THD::raise_warning(uint code, const
{
SQL_condition cond(this->mem_root);
cond.set(this, code, msg, MYSQL_ERROR::WARN_LEVEL_WARN, MYF(0));
-
raise_condition(& cond);
}
@@ -753,18 +737,13 @@ void THD::raise_warning_printf(uint code
{
va_list args;
char ebuff[ERRMSGSIZE+20];
-
-
DBUG_ENTER("THD::raise_warning_printf");
DBUG_PRINT("enter", ("warning: %u", code));
-
va_start(args, format);
my_vsnprintf(ebuff, sizeof(ebuff), format, args);
va_end(args);
-
SQL_condition cond(this->mem_root);
cond.set(this, code, ebuff, MYSQL_ERROR::WARN_LEVEL_WARN, MYF(0));
-
raise_condition(& cond);
DBUG_VOID_RETURN;
}
@@ -773,13 +752,10 @@ void THD::raise_note(uint code, const ch
{
DBUG_ENTER("THD::raise_note");
DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg));
-
if (!(this->options & OPTION_SQL_NOTES))
DBUG_VOID_RETURN;
-
SQL_condition cond(this->mem_root);
cond.set(this, code, msg, MYSQL_ERROR::WARN_LEVEL_NOTE, MYF(0));
-
raise_condition(& cond);
DBUG_VOID_RETURN;
}
@@ -788,21 +764,15 @@ void THD::raise_note_printf(uint code, c
{
va_list args;
char ebuff[ERRMSGSIZE+20];
-
-
DBUG_ENTER("THD::raise_note_printf");
DBUG_PRINT("enter",("code: %u", code));
-
if (!(this->options & OPTION_SQL_NOTES))
DBUG_VOID_RETURN;
-
va_start(args, format);
my_vsnprintf(ebuff, sizeof(ebuff), format, args);
va_end(args);
-
SQL_condition cond(this->mem_root);
cond.set(this, code, ebuff, MYSQL_ERROR::WARN_LEVEL_NOTE, MYF(0));
-
raise_condition(& cond);
DBUG_VOID_RETURN;
}
@@ -890,14 +860,6 @@ void THD::raise_condition_no_handler(con
if (no_warnings_for_error && (cond->m_level == MYSQL_ERROR::WARN_LEVEL_ERROR))
DBUG_VOID_RETURN;
-#ifdef BUG_36098_FIXED
- mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_ERROR, error, my_time(0),
- 0, 0, msg, msg ? strlen(msg) : 0,
- query, query_length,
- variables.character_set_client,
- row_count);
-#endif
-
if (! main_da.m_stmt_area.is_read_only())
{
MYSQL_ERROR::enum_warning_level level;
@@ -915,11 +877,8 @@ void THD::raise_condition_no_handler(con
{
stored_cond->m_level= level;
main_da.m_stmt_area.warn_list.push_back(stored_cond, & warn_root);
- main_da.m_stmt_area.m_number++;
}
}
- else
- main_da.m_stmt_area.m_more= TRUE;
main_da.m_stmt_area.warn_count[(uint) level]++;
}
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2008-08-05 18:24:28 +0000
+++ b/sql/sql_class.h 2008-08-07 13:46:39 +0000
@@ -306,12 +306,6 @@ struct Query_cache_tls
/* SIGNAL / RESIGNAL / GET DIAGNOSTICS */
-#define FIRST_DIAG_SET_PROPERTY 0
-#define LAST_DIAG_SET_PROPERTY 11
-
-#define FIRST_DIAG_PROPERTY 0
-#define LAST_DIAG_PROPERTY 28
-
/**
This enumeration list all the condition item names of a condition in the
SQL condition area.
@@ -324,6 +318,7 @@ typedef enum enum_diag_condition_item_na
*/
DIAG_CLASS_ORIGIN= 0,
+ FIRST_DIAG_SET_PROPERTY= DIAG_CLASS_ORIGIN,
DIAG_SUBCLASS_ORIGIN= 1,
DIAG_CONSTRAINT_CATALOG= 2,
DIAG_CONSTRAINT_SCHEMA= 3,
@@ -335,29 +330,7 @@ typedef enum enum_diag_condition_item_na
DIAG_CURSOR_NAME= 9,
DIAG_MESSAGE_TEXT= 10,
DIAG_MYSQL_ERRNO= 11,
-
- /*
- Conditions that can be set only by the server implementation
- (THD::raise_ER_XXX).
- */
-
- DIAG_CONDITION_IDENTIFIER= 12,
- DIAG_CONDITION_NUMBER= 13,
- DIAG_CONNECTION_NAME= 14,
- DIAG_MESSAGE_LENGTH= 15,
- DIAG_MESSAGE_OCTET_LENGTH= 16,
- DIAG_PARAMETER_MODE= 17,
- DIAG_PARAMETER_NAME= 18,
- DIAG_PARAMETER_ORDINAL_POSITION= 19,
- DIAG_RETURNED_SQLSTATE= 20,
- DIAG_ROUTINE_CATALOG= 21,
- DIAG_ROUTINE_NAME= 22,
- DIAG_ROUTINE_SCHEMA= 23,
- DIAG_SERVER_NAME= 24,
- DIAG_SPECIFIC_NAME= 25,
- DIAG_TRIGGER_CATALOG= 26,
- DIAG_TRIGGER_NAME= 27,
- DIAG_TRIGGER_SCHEMA= 28,
+ LAST_DIAG_SET_PROPERTY= DIAG_MYSQL_ERRNO
} Diag_condition_item_name;
/**
@@ -1280,6 +1253,9 @@ public:
const char* get_sqlstate() const
{ return m_returned_sqlstate; }
+ bool is_message_text_set() const
+ { return m_message_text_set; }
+
public:
/** SQL CLASS_ORIGIN condition item. */
UTF8String64 m_class_origin;
@@ -1315,25 +1291,21 @@ private:
/** Message text, expressed in the character set implied by --language. */
String m_message_text;
+ /**
+ True if m_message_text was explicitely set.
+ This member is needed to differentiate:
+ - SIGNAL ... without a SET MESSAGE_TEXT clause, in which case the message
+ text should have a default value,
+ - SIGNAL ... SET MESSAGE_TEXT='', in which case the message text should
+ be '' and not replaced by a default value.
+ */
+
+ bool m_message_text_set;
+
public:
/** MySQL extension, MYSQL_ERRNO condition item. */
int m_sql_errno;
- /** SQL CONDITION_IDENTIFIER condition item. */
- UTF8String64 m_condition_identifier;
-
- /** SQL CONNECTION_NAME condition item. */
- UTF8String64 m_connection_name;
-
- /** SQL PARAMETER_MODE condition item. */
- UTF8String64 m_parameter_mode;
-
- /** SQL PARAMETER_NAME condition item. */
- UTF8String64 m_parameter_name;
-
- /** SQL PARAMETER_ORDINAL_POSITION condition item. */
- int m_parameter_ordinal_position;
-
private:
/**
SQL RETURNED_SQLSTATE condition item.
@@ -1342,30 +1314,6 @@ private:
char m_returned_sqlstate[SQLSTATE_LENGTH+1];
public:
- /** SQL ROUTINE_CATALOG condition item. */
- UTF8String64 m_routine_catalog;
-
- /** SQL ROUTINE_NAME condition item. */
- UTF8String64 m_routine_name;
-
- /** SQL ROUTINE_SCHEMA condition item. */
- UTF8String64 m_routine_schema;
-
- /** SQL SERVER_NAME condition item. */
- UTF8String64 m_server_name;
-
- /** SQL SPECIFIC_NAME condition item. */
- UTF8String64 m_specific_name;
-
- /** SQL TRIGGER_CATALOG condition item. */
- UTF8String64 m_trigger_catalog;
-
- /** SQL TRIGGER_NAME condition item. */
- UTF8String64 m_trigger_name;
-
- /** SQL TRIGGER_SCHEMA condition item. */
- UTF8String64 m_trigger_schema;
-
/** Severity (error, warning, note) of this condition. */
MYSQL_ERROR::enum_warning_level m_level;
@@ -1430,12 +1378,7 @@ class Diagnostics_stmt_area
public:
/** Constructor. */
Diagnostics_stmt_area()
- : m_number(0),
- m_more(FALSE),
- m_command_function_cmd(SQLCOM_END),
- m_dynamic_function_cmd(SQLCOM_END),
- m_rowcount(0),
- warn_list(),
+ : warn_list(),
m_read_only(FALSE)
{
bzero((char*) warn_count, sizeof(warn_count));
@@ -1469,34 +1412,6 @@ public:
bool is_read_only() const
{ return m_read_only; }
- /** SQL 'NUMBER' statement information item. */
- uint m_number;
-
- /** SQL 'MORE' statement information item. */
- bool m_more;
-
- /**
- Internal command of a statement.
- The following statement information items:
- - SQL 'COMMAND_FUNCTION'
- - SQL 'COMMAND_FUNCTION_CODE'
- derive from this attribute.
- */
- enum_sql_command m_command_function_cmd;
-
- /**
- Internal command of a statement,
- for dynamic statements.
- The following statement information items:
- - SQL 'DYNAMIC_FUNCTION'
- - SQL 'DYNAMIC_FUNCTION_CODE'
- derive from this attribute.
- */
- enum_sql_command m_dynamic_function_cmd;
-
- /** SQL 'ROWCOUNT' statement information item. */
- ha_rows m_rowcount;
-
/**
Condition area.
*/
=== modified file 'sql/sql_signal.cc'
--- a/sql/sql_signal.cc 2008-07-23 00:25:11 +0000
+++ b/sql/sql_signal.cc 2008-08-07 13:46:39 +0000
@@ -89,20 +89,8 @@ SQL_condition::SQL_condition(MEM_ROOT *m
m_column_name(mem_root),
m_cursor_name(mem_root),
m_message_text(),
+ m_message_text_set(FALSE),
m_sql_errno(0),
- m_condition_identifier(mem_root),
- m_connection_name(mem_root),
- m_parameter_mode(mem_root),
- m_parameter_name(mem_root),
- m_parameter_ordinal_position(0),
- m_routine_catalog(mem_root),
- m_routine_name(mem_root),
- m_routine_schema(mem_root),
- m_server_name(mem_root),
- m_specific_name(mem_root),
- m_trigger_catalog(mem_root),
- m_trigger_name(mem_root),
- m_trigger_schema(mem_root),
m_level(MYSQL_ERROR::WARN_LEVEL_ERROR),
m_flags(0),
m_mem_root(mem_root),
@@ -140,6 +128,7 @@ SQL_condition::deep_copy(const SQL_condi
DBUG_ASSERT(! m_message_text.is_alloced());
+ m_message_text_set= cond->m_message_text_set;
m_class_origin.copy(& cond->m_class_origin);
m_subclass_origin.copy(& cond->m_subclass_origin);
m_constraint_catalog.copy(& cond->m_constraint_catalog);
@@ -151,19 +140,6 @@ SQL_condition::deep_copy(const SQL_condi
m_column_name.copy(& cond->m_column_name);
m_cursor_name.copy(& cond->m_cursor_name);
m_sql_errno= cond->m_sql_errno;
- m_condition_identifier.copy(& cond->m_condition_identifier);
- m_connection_name.copy(& cond->m_connection_name);
- m_parameter_mode.copy(& cond->m_parameter_mode);
- m_parameter_name.copy(& cond->m_parameter_name);
- m_parameter_ordinal_position= cond->m_parameter_ordinal_position;
- m_routine_catalog.copy(& cond->m_routine_catalog);
- m_routine_name.copy(& cond->m_routine_name);
- m_routine_schema.copy(& cond->m_routine_schema);
- m_server_name.copy(& cond->m_server_name);
- m_specific_name.copy(& cond->m_specific_name);
- m_trigger_catalog.copy(& cond->m_trigger_catalog);
- m_trigger_name.copy(& cond->m_trigger_name);
- m_trigger_schema.copy(& cond->m_trigger_schema);
m_level= cond->m_level;
m_flags= cond->m_flags;
m_broken_caller= cond->m_broken_caller;
@@ -229,6 +205,7 @@ SQL_condition::set_builtin_message_text(
copy= strdup_root(m_mem_root, str);
m_message_text.set(copy, strlen(copy), error_message_charset_info);
DBUG_ASSERT(! m_message_text.is_alloced());
+ m_message_text_set= TRUE;
}
const char*
@@ -252,13 +229,7 @@ SQL_condition::set_sqlstate(const char*
Set_signal_information::Set_signal_information()
{
- int i;
- for (i= FIRST_DIAG_SET_PROPERTY;
- i <= LAST_DIAG_SET_PROPERTY;
- i++)
- {
- m_item[i]= NULL;
- }
+ clear();
}
Set_signal_information::Set_signal_information(
@@ -293,41 +264,55 @@ int Abstract_signal::eval_sqlcode_sqlsta
SIGNAL is restricted in sql_yacc.yy to only signal SQLSTATE conditions
*/
DBUG_ASSERT(m_cond->type == sp_cond_type::state);
-
- cond->m_sql_errno= 0;
- cond->set_sqlstate(m_cond->sqlstate);
-
- return 0;
-}
-
-int Abstract_signal::eval_defaults(THD *thd, SQL_condition *cond)
-{
- const char* sqlstate= cond->get_sqlstate();
+ const char* sqlstate= m_cond->sqlstate;
DBUG_ASSERT((sqlstate[0] != '0') || (sqlstate[1] != '0'));
+ cond->set_sqlstate(sqlstate);
+
if ((sqlstate[0] == '0') && (sqlstate[1] == '1'))
{
/* SQLSTATE class "01": warning */
- cond->set_builtin_message_text(ER(ER_SIGNAL_WARN));
cond->m_level= MYSQL_ERROR::WARN_LEVEL_WARN;
- if (cond->m_sql_errno == 0)
- cond->m_sql_errno= ER_SIGNAL_WARN;
+ cond->m_sql_errno= ER_SIGNAL_WARN;
}
else if ((sqlstate[0] == '0') && (sqlstate[1] == '2'))
{
/* SQLSTATE class "02": not found */
- cond->set_builtin_message_text(ER(ER_SIGNAL_NOT_FOUND));
cond->m_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
- if (cond->m_sql_errno == 0)
- cond->m_sql_errno= ER_SIGNAL_NOT_FOUND;
+ cond->m_sql_errno= ER_SIGNAL_NOT_FOUND;
}
else
{
- cond->set_builtin_message_text(ER(ER_SIGNAL_EXCEPTION));
cond->m_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
- if (cond->m_sql_errno == 0)
- cond->m_sql_errno= ER_SIGNAL_EXCEPTION;
+ cond->m_sql_errno= ER_SIGNAL_EXCEPTION;
+ }
+
+ return 0;
+}
+
+int Abstract_signal::eval_default_message_text(THD *thd, SQL_condition *cond)
+{
+ const char* sqlstate= cond->get_sqlstate();
+
+ DBUG_ASSERT((sqlstate[0] != '0') || (sqlstate[1] != '0'));
+
+ if (! cond->is_message_text_set())
+ {
+ if ((sqlstate[0] == '0') && (sqlstate[1] == '1'))
+ {
+ /* SQLSTATE class "01": warning */
+ cond->set_builtin_message_text(ER(ER_SIGNAL_WARN));
+ }
+ else if ((sqlstate[0] == '0') && (sqlstate[1] == '2'))
+ {
+ /* SQLSTATE class "02": not found */
+ cond->set_builtin_message_text(ER(ER_SIGNAL_NOT_FOUND));
+ }
+ else
+ {
+ cond->set_builtin_message_text(ER(ER_SIGNAL_EXCEPTION));
+ }
}
return 0;
@@ -570,14 +555,14 @@ int Abstract_signal::raise_condition(THD
{
if (eval_sqlcode_sqlstate(thd, cond))
DBUG_RETURN(result);
-
- if (eval_defaults(thd, cond))
- DBUG_RETURN(result);
}
if (eval_signal_informations(thd, cond))
DBUG_RETURN(result);
+ if (eval_default_message_text(thd, cond))
+ DBUG_RETURN(result);
+
/* SIGNAL should not signal WARN_LEVEL_NOTE */
DBUG_ASSERT((cond->m_level == MYSQL_ERROR::WARN_LEVEL_WARN) ||
(cond->m_level == MYSQL_ERROR::WARN_LEVEL_ERROR));
@@ -638,7 +623,6 @@ int SQLCOM_resignal::execute(THD *thd)
> thd->variables.max_error_count))
{
thd->main_da.m_stmt_area.warn_list.pop();
- thd->main_da.m_stmt_area.m_more= TRUE;
}
thd->raise_condition_no_handler(signaled);
| Thread |
|---|
| • bzr commit into mysql-6.0-wl2110-review branch (marc.alff:2677) WL#2110 | Marc Alff | 7 Aug |