Skip to content

Commit 2e27916

Browse files
author
Arun Kuruvila
committed
Bug #16204175 COLLATION NAME MISSING FROM LOG MESSAGES
ABOUT LDML DEFINITION PROBLEMS Description: When trying to use an invalid user defined collation error information that can be found in SHOW WARNINGS also gets logged to the error log, e.g. 2013-01-22 16:03:02 9130 [ERROR] Shift expected at '' The error message is missing information about the actual invalid collation Analysis: When a collation is defined with invalid grammar rules, " expected at '' " error is logged to error log. But collation name is missing in this error message. So for a DBA looking at the error log it is impossible to tell where the error actually is . So it is better to add collation name along with the error message which is logged to the error log. Fix: As a fix i added the collation name also to the error message which is logged to the error log.
1 parent a21cb5a commit 2e27916

5 files changed

Lines changed: 74 additions & 8 deletions

File tree

mysql-test/r/ctype_ldml.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ ERROR HY000: Unknown collation: 'utf8_5624_2'
819819
SHOW WARNINGS;
820820
Level Code Message
821821
Error 1273 Unknown collation: 'utf8_5624_2'
822-
Warning 1273 Syntax error at '[strength tertiary]'
822+
Warning 1273 Syntax error at '[strength tertiary]' for COLLATION : utf8_5624_2
823823
#
824824
# WL#5624, reset before primary ignorable
825825
#

mysql-test/r/ctype_uca.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7120,5 +7120,19 @@ F0909080 30D2 𐐀
71207120
F09090A8 30D2 𐐨
71217121
DROP TABLE t1;
71227122
#
7123+
# Bug #16204175 : COLLATION NAME MISSING FROM LOG MESSAGES
7124+
# ABOUT LDML DEFINITION PROBLEMS
7125+
#
7126+
# Check whether the new collation is loaded after restart
7127+
SHOW COLLATION LIKE 'utf8_test';
7128+
Collation Charset Id Default Compiled Sortlen
7129+
utf8_test utf8 248 8
7130+
# Create a table with the unknown collation.
7131+
CREATE TABLE t1(id INT PRIMARY KEY, c CHAR(1) COLLATE utf8_test);
7132+
ERROR HY000: Unknown collation: 'utf8_test'
7133+
# Below error is caused as a result of this test. The error message
7134+
# contains collation name which is added as a part of the fix.
7135+
call mtr.add_suppression("Shift expected at '' for COLLATION : utf8_test");
7136+
#
71237137
# End of 5.6 tests
71247138
#

mysql-test/suite/innodb/r/innodb_ctype_ldml.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ ERROR HY000: Unknown collation: 'utf8_5624_2'
805805
SHOW WARNINGS;
806806
Level Code Message
807807
Error 1273 Unknown collation: 'utf8_5624_2'
808-
Warning 1273 Syntax error at '[strength tertiary]'
808+
Warning 1273 Syntax error at '[strength tertiary]' for COLLATION : utf8_5624_2
809809
#
810810
# WL#5624, reset before primary ignorable
811811
#

mysql-test/t/ctype_uca.test

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,54 @@ SET collation_connection=utf8_german2_ci;
542542
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_ci;
543543
--source include/ctype_unicode520.inc
544544

545+
--echo #
546+
--echo # Bug #16204175 : COLLATION NAME MISSING FROM LOG MESSAGES
547+
--echo # ABOUT LDML DEFINITION PROBLEMS
548+
--echo #
549+
550+
-- source include/not_embedded.inc
551+
552+
# Creating a temporary file for Index.xml
553+
--copy_file $MYSQL_CHARSETSDIR/Index.xml $MYSQLTEST_VARDIR/temp.xml
554+
--remove_file $MYSQL_CHARSETSDIR/Index.xml
555+
556+
# Adding an unknown collation with invalid grammer rules.
557+
--write_file $MYSQL_CHARSETSDIR/Index.xml
558+
<?xml version='1.0' encoding="utf-8"?>
559+
<charsets max-id="99">
560+
<charset name="utf8">
561+
<family>Unicode</family>
562+
<description>UTF-8 Unicode</description>
563+
<alias>utf-8</alias>
564+
<collation name="utf8_test" id="248">
565+
<rules>
566+
<reset>A</reset>
567+
</rules>
568+
</collation>
569+
</charset>
570+
</charsets>
571+
EOF
572+
573+
# Restart the server
574+
-- source include/restart_mysqld.inc
575+
576+
--echo # Check whether the new collation is loaded after restart
577+
SHOW COLLATION LIKE 'utf8_test';
578+
579+
--echo # Create a table with the unknown collation.
580+
--error ER_UNKNOWN_COLLATION
581+
CREATE TABLE t1(id INT PRIMARY KEY, c CHAR(1) COLLATE utf8_test);
582+
583+
--echo # Below error is caused as a result of this test. The error message
584+
--echo # contains collation name which is added as a part of the fix.
585+
call mtr.add_suppression("Shift expected at '' for COLLATION : utf8_test");
586+
587+
# Cleanup
588+
--remove_file $MYSQL_CHARSETSDIR/Index.xml
589+
--copy_file $MYSQLTEST_VARDIR/temp.xml $MYSQL_CHARSETSDIR/Index.xml
590+
--remove_file $MYSQLTEST_VARDIR/temp.xml
591+
592+
545593
--echo #
546594
--echo # End of 5.6 tests
547595
--echo #

strings/ctype-uca.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
22

33
This library is free software; you can redistribute it and/or
44
modify it under the terms of the GNU Library General Public
@@ -20658,6 +20658,7 @@ lex_cmp(MY_COLL_LEXEM *lexem, const char *pattern, size_t patternlen)
2065820658
errstr sting to write error to
2065920659
errsize errstr size
2066020660
txt error message
20661+
col_name collation name
2066120662
USAGE
2066220663

2066320664
RETURN VALUES
@@ -20666,14 +20667,15 @@ lex_cmp(MY_COLL_LEXEM *lexem, const char *pattern, size_t patternlen)
2066620667

2066720668
static void my_coll_lexem_print_error(MY_COLL_LEXEM *lexem,
2066820669
char *errstr, size_t errsize,
20669-
const char *txt)
20670+
const char *txt, const char *col_name)
2067020671
{
2067120672
char tail[30];
2067220673
size_t len= lexem->end - lexem->prev;
2067320674
strmake (tail, lexem->prev, (size_t) MY_MIN(len, sizeof(tail)-1));
2067420675
errstr[errsize-1]= '\0';
2067520676
my_snprintf(errstr, errsize - 1,
20676-
"%s at '%s'", txt[0] ? txt : "Syntax error", tail);
20677+
"%s at '%s' for COLLATION : %s", txt[0] ? txt : "Syntax error",
20678+
tail, col_name);
2067720679
}
2067820680

2067920681

@@ -21659,6 +21661,7 @@ my_coll_parser_exec(MY_COLL_RULE_PARSER *p)
2165921661
@param rules Collation rule list to load to.
2166021662
@param str A string with collation customization.
2166121663
@param str_end End of the string.
21664+
@param col_name Collation name
2166221665

2166321666
@return
2166421667
@retval 0 on success
@@ -21667,7 +21670,7 @@ my_coll_parser_exec(MY_COLL_RULE_PARSER *p)
2166721670

2166821671
static int
2166921672
my_coll_rule_parse(MY_COLL_RULES *rules,
21670-
const char *str, const char *str_end)
21673+
const char *str, const char *str_end, const char *col_name)
2167121674
{
2167221675
MY_COLL_RULE_PARSER p;
2167321676

@@ -21678,7 +21681,7 @@ my_coll_rule_parse(MY_COLL_RULES *rules,
2167821681
my_coll_lexem_print_error(my_coll_parser_curr(&p),
2167921682
rules->loader->error,
2168021683
sizeof(rules->loader->error) - 1,
21681-
p.errstr);
21684+
p.errstr, col_name);
2168221685
return 1;
2168321686
}
2168421687
return 0;
@@ -22030,7 +22033,8 @@ create_tailoring(CHARSET_INFO *cs, MY_CHARSET_LOADER *loader)
2203022033
/* Parse ICU Collation Customization expression */
2203122034
if ((rc= my_coll_rule_parse(&rules,
2203222035
cs->tailoring,
22033-
cs->tailoring + strlen(cs->tailoring))))
22036+
cs->tailoring + strlen(cs->tailoring),
22037+
cs->name)))
2203422038
goto ex;
2203522039

2203622040
if (rules.version == 520) /* Unicode-5.2.0 requested */

0 commit comments

Comments
 (0)