From ccf9895159d51100144d2f14f77a3efd65b9f371 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 May 2003 16:36:59 +0500 Subject: [PATCH] A separate, better error message when it's impossible to aggregate strings for some operation --- include/mysqld_error.h | 3 ++- sql/item.h | 13 ++++++++++++- sql/item_cmpfunc.cc | 20 ++++++++++++++++---- sql/item_func.cc | 5 ++++- sql/item_strfunc.cc | 15 ++++++++++++--- sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + 28 files changed, 69 insertions(+), 10 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 224ad3798ef..ae31171553d 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -276,4 +276,5 @@ #define ER_ZLIB_Z_DATA_ERROR 1257 #define ER_CUT_VALUE_GROUP_CONCAT 1258 #define ER_WARN_USING_OTHER_HANDLER 1259 -#define ER_ERROR_MESSAGES 259 +#define ER_CANT_AGGREGATE_COLLATIONS 1260 +#define ER_ERROR_MESSAGES 260 diff --git a/sql/item.h b/sql/item.h index 111892df688..470937f8ee7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -41,7 +41,18 @@ public: enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; enum coercion { COER_COERCIBLE=3, COER_IMPLICIT=2, COER_NOCOLL=1, COER_EXPLICIT=0 }; - + const char *coercion_name(enum coercion coer) const + { + switch(coer) + { + case COER_COERCIBLE: return "COERCIBLE"; + case COER_IMPLICIT: return "IMPLICIT"; + case COER_EXPLICIT: return "EXPLICIT"; + case COER_NOCOLL: return "NO COLLATION"; + default: return "UNKNOWN"; + } + } + String str_value; /* used to store value */ my_string name; /* Name from select */ Item *next; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 7cc07690fcc..e2885c8764a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -170,7 +170,10 @@ void Item_bool_func2::fix_length_and_dec() if (set_cmp_charset(args[0]->charset(), args[0]->coercibility, args[1]->charset(), args[1]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + args[0]->charset()->name,coercion_name(args[0]->coercibility), + args[1]->charset()->name,coercion_name(args[1]->coercibility), + func_name()); return; } set_cmp_func(); @@ -652,7 +655,10 @@ Item_func_ifnull::fix_length_and_dec() decimals= 0; if (set_charset(args[0]->charset(),args[0]->coercibility, args[1]->charset(),args[1]->coercibility)) - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + args[0]->charset()->name,coercion_name(args[0]->coercibility), + args[1]->charset()->name,coercion_name(args[1]->coercibility), + func_name()); } @@ -731,7 +737,10 @@ Item_func_if::fix_length_and_dec() if (set_charset(args[1]->charset(), args[1]->coercibility, args[2]->charset(), args[2]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + args[0]->charset()->name,coercion_name(args[0]->coercibility), + args[1]->charset()->name,coercion_name(args[1]->coercibility), + func_name()); return; } } @@ -1878,7 +1887,10 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) if (set_cmp_charset(args[0]->charset(), args[0]->coercibility, args[1]->charset(), args[1]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + args[0]->charset()->name,coercion_name(args[0]->coercibility), + args[1]->charset()->name,coercion_name(args[1]->coercibility), + func_name()); return 1; } diff --git a/sql/item_func.cc b/sql/item_func.cc index d427e3c5a3a..6af65ece692 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -859,7 +859,10 @@ void Item_func_min_max::fix_length_and_dec() else if (set_charset(charset(), coercibility, args[i]->charset(), args[i]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + charset()->name,coercion_name(coercibility), + args[i]->charset()->name,coercion_name(args[i]->coercibility), + func_name()); break; } } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 6118b25a88c..8aaf9f944e8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -326,7 +326,10 @@ void Item_func_concat::fix_length_and_dec() if (set_charset(charset(), coercibility, args[i]->charset(), args[i]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + charset()->name,coercion_name(coercibility), + args[i]->charset()->name,coercion_name(args[i]->coercibility), + func_name()); break; } } @@ -630,7 +633,10 @@ void Item_func_concat_ws::fix_length_and_dec() if (set_charset(charset(), coercibility, args[i]->charset(), args[i]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + charset()->name,coercion_name(coercibility), + args[i]->charset()->name,coercion_name(args[i]->coercibility), + func_name()); break; } } @@ -1624,7 +1630,10 @@ void Item_func_elt::fix_length_and_dec() if (set_charset(charset(), coercibility, args[i]->charset(), args[i]->coercibility)) { - my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + my_error(ER_CANT_AGGREGATE_COLLATIONS,MYF(0), + charset()->name,coercion_name(coercibility), + args[i]->charset()->name,coercion_name(args[i]->coercibility), + func_name()); break; } } diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 5a9d9f2cf29..e04d4494a93 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -270,3 +270,4 @@ v/* "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 4515f78d8e9..ff89dbb6bcf 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -264,3 +264,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 4b81f94eb83..98ca6a834e4 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -272,3 +272,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 85ab7ac5e9f..cb709c45326 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 20465266d46..f9d5a2b6324 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -266,3 +266,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 4af12b8dbbc..1c4efab7e53 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 525d59164b0..00d6e784dcb 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -270,3 +270,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 26db2a19561..fdeb787859c 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 7ba86704cb1..708bad26391 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -263,3 +263,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 30dc00546cd..23d157ce628 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index eb0d085bd28..82a8c23ab67 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -263,3 +263,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 9747e3cbb3e..a96805c1dc5 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 46eada87157..31e2afa0cc9 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -263,3 +263,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 0f4a0852222..2e1468bc815 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -263,3 +263,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index c95b3a9b482..997ee08e66a 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -265,3 +265,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index af971e6a6ee..284334cbfbd 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 49cdad9adb3..1966b37bc72 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -265,3 +265,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index ef883b38bd3..3935aef82e3 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -263,3 +263,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index c866a54727a..d954e7998a2 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -257,3 +257,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index a6c42c01e1c..db25f12ed13 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -269,3 +269,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 6172524ddc3..44fb0a19640 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -262,3 +262,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index b3cab964fd4..e40a44957f1 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -261,3 +261,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d rad(er) kapades av group_concat()", "Använder handler %s för tabell '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 3c3507c1a2a..968327a1024 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -266,3 +266,4 @@ "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", "Using storage engine %s for table '%s'", +"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'",