File tree 4 files changed +33
-2
lines changed
4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 17
17
#define DERROR_INCLUDED
18
18
19
19
#include " my_global.h" /* uint */
20
+ #ifdef EXTRA_CODE_FOR_UNIT_TESTING
21
+ #include " mysqld_error.h"
22
+ #endif
20
23
21
24
class THD ;
22
25
@@ -33,6 +36,25 @@ class MY_LOCALE_ERRMSGS
33
36
/* * Return error message string for a given error number. */
34
37
const char *lookup (int mysql_errno);
35
38
39
+ #ifdef EXTRA_CODE_FOR_UNIT_TESTING
40
+ bool replace_msg (int mysql_errno, const char *new_msg)
41
+ {
42
+ int offset= 0 ; // Position where the current section starts in the array.
43
+ int num_sections= sizeof (errmsg_section_start) /
44
+ sizeof (errmsg_section_start[0 ]);
45
+ for (int i= 0 ; i < num_sections; i++)
46
+ {
47
+ if (mysql_errno < (errmsg_section_start[i] + errmsg_section_size[i]))
48
+ {
49
+ errmsgs[mysql_errno - errmsg_section_start[i] + offset]= new_msg;
50
+ return false ;
51
+ }
52
+ offset+= errmsg_section_size[i];
53
+ }
54
+ return true ;
55
+ }
56
+ #endif
57
+
36
58
/* * Has the error message file been sucessfully loaded? */
37
59
bool is_loaded () const { return errmsgs != NULL ; }
38
60
Original file line number Diff line number Diff line change @@ -237,7 +237,6 @@ MESSAGE(STATUS "GTEST_LIBRARIES:${GTEST_LIBRARIES}")
237
237
238
238
# Add some defines.
239
239
ADD_DEFINITIONS (-DMYSQL_SERVER -DEXTRA_CODE_FOR_UNIT_TESTING)
240
- ADD_DEFINITIONS (-DERRMSG_DIR=\"${CMAKE_BINARY_DIR} /sql/share/\")
241
240
242
241
INCLUDE (${MYSQL_CMAKE_SCRIPT_DIR} /compile_flags .cmake)
243
242
Original file line number Diff line number Diff line change @@ -35,10 +35,21 @@ class PartitionTest : public ::testing::Test
35
35
protected:
36
36
virtual void SetUp ()
37
37
{
38
+ // Save global settings.
38
39
m_charset= system_charset_info;
39
40
m_locale= my_default_lc_messages;
41
+
40
42
system_charset_info = &my_charset_utf8_bin;
41
43
my_default_lc_messages = &my_locale_en_US;
44
+
45
+ /* Populate the necessary error messages */
46
+ MY_LOCALE_ERRMSGS *errmsgs= my_default_lc_messages->errmsgs ;
47
+ EXPECT_FALSE (errmsgs->replace_msg (ER_DATABASE_NAME, " Database" ));
48
+ EXPECT_FALSE (errmsgs->replace_msg (ER_TABLE_NAME, " Table" ));
49
+ EXPECT_FALSE (errmsgs->replace_msg (ER_PARTITION_NAME, " Partition" ));
50
+ EXPECT_FALSE (errmsgs->replace_msg (ER_SUBPARTITION_NAME, " Subpartition" ));
51
+ EXPECT_FALSE (errmsgs->replace_msg (ER_TEMPORARY_NAME, " Temporary" ));
52
+ EXPECT_FALSE (errmsgs->replace_msg (ER_RENAMED_NAME, " Renamed" ));
42
53
}
43
54
44
55
virtual void TearDown ()
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ void setup_server_for_unit_tests()
48
48
mysql_mutex_init (key_LOCK_error_log, &LOCK_error_log, MY_MUTEX_INIT_FAST);
49
49
system_charset_info= &my_charset_utf8_general_ci;
50
50
sys_var_init ();
51
- strcpy (lc_messages_dir, ERRMSG_DIR);
52
51
init_common_variables ();
53
52
my_init_signals ();
54
53
randominit (&sql_rand, 0 , 0 );
You can’t perform that action at this time.
0 commit comments