You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1811 lines
51 KiB

26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
22 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY <any non-const-function> Several problems fixed : 1. Non constant expressions in UNION ... ORDER BY were not correctly cleaned up in st_select_lex_unit::cleanup() causing crashes in EXPLAIN EXTENDED because of fields quoted by these expressions pointing to the already freed temporary table used to calculate the UNION. Fixed by correctly cleaning up expressions of any depth. 2. Subqueries in the order by part of UNION ... ORDER BY ... caused a crash in EXPLAIN EXTENDED because of a transformation attempt made during EXPLAIN EXTENDED execution. Fixed by not doing the transformation when in EXPLAIN. 3. Fulltext functions caused crash when in the ORDER BY part of an un-parenthesized UNION that gets "promoted" to be valid for the whole union, e.g. SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY MATCHES (a) AGAINST ('abc' IN BOOLEAN MODE). This is a case that demonstrates a more general problem of parts of the query being moved to another level. When doing such transformation late in the optimization run when most of the flags about the contents of the query are already aggregated it's possible to "split" the flags so that they correctly reflect the new queries after the transformation. In specific the ST_SELECT_LEX::ftfunc_list is holding all the free text function for all the parts of the second SELECT in the UNION and we don't know what part of that is in the ORDER BY that we're to move to the UNION level and what part is about the other parts of the second SELECT. Fixed by throwing and error when such statements are about to be processed by adding a check for the presence of MATCH() inside the ORDER BY clause that's going to get promoted to UNION. To workaround this new limitation one must parenthesize the UNION SELECTs and provide a real global ORDER BY for the UNION outside of the parenthesis.
16 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
26 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
26 years ago
26 years ago
WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data.
16 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
19 years ago
19 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
19 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
21 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
WL#3817: Simplify string / memory area types and make things more consistent (first part) The following type conversions was done: - Changed byte to uchar - Changed gptr to uchar* - Change my_string to char * - Change my_size_t to size_t - Change size_s to size_t Removed declaration of byte, gptr, my_string, my_size_t and size_s. Following function parameter changes was done: - All string functions in mysys/strings was changed to use size_t instead of uint for string lengths. - All read()/write() functions changed to use size_t (including vio). - All protocoll functions changed to use size_t instead of uint - Functions that used a pointer to a string length was changed to use size_t* - Changed malloc(), free() and related functions from using gptr to use void * as this requires fewer casts in the code and is more in line with how the standard functions work. - Added extra length argument to dirname_part() to return the length of the created string. - Changed (at least) following functions to take uchar* as argument: - db_dump() - my_net_write() - net_write_command() - net_store_data() - DBUG_DUMP() - decimal2bin() & bin2decimal() - Changed my_compress() and my_uncompress() to use size_t. Changed one argument to my_uncompress() from a pointer to a value as we only return one value (makes function easier to use). - Changed type of 'pack_data' argument to packfrm() to avoid casts. - Changed in readfrm() and writefrom(), ha_discover and handler::discover() the type for argument 'frmdata' to uchar** to avoid casts. - Changed most Field functions to use uchar* instead of char* (reduced a lot of casts). - Changed field->val_xxx(xxx, new_ptr) to take const pointers. Other changes: - Removed a lot of not needed casts - Added a few new cast required by other changes - Added some cast to my_multi_malloc() arguments for safety (as string lengths needs to be uint, not size_t). - Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done explicitely as this conflict was often hided by casting the function to hash_get_key). - Changed some buffers to memory regions to uchar* to avoid casts. - Changed some string lengths from uint to size_t. - Changed field->ptr to be uchar* instead of char*. This allowed us to get rid of a lot of casts. - Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar - Include zlib.h in some files as we needed declaration of crc32() - Changed MY_FILE_ERROR to be (size_t) -1. - Changed many variables to hold the result of my_read() / my_write() to be size_t. This was needed to properly detect errors (which are returned as (size_t) -1). - Removed some very old VMS code - Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix) - Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe. Updated function comment to reflect this. Changed function that depended on original behavior of my_pwrite() to itself restore the cursor position (one such case). - Added some missing checking of return value of malloc(). - Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow. - Changed type of table_def::m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length. - Moved THD::max_row_length() to table.cc (as it's not depending on THD). Inlined max_row_length_blob() into this function. - More function comments - Fixed some compiler warnings when compiled without partitions. - Removed setting of LEX_STRING() arguments in declaration (portability fix). - Some trivial indentation/variable name changes. - Some trivial code simplifications: - Replaced some calls to alloc_root + memcpy to use strmake_root()/strdup_root(). - Changed some calls from memdup() to strmake() (Safety fix) - Simpler loops in client-simple.c
19 years ago
  1. #ifndef ITEM_FUNC_INCLUDED
  2. #define ITEM_FUNC_INCLUDED
  3. /* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  14. /* Function items used by mysql */
  15. #ifdef USE_PRAGMA_INTERFACE
  16. #pragma interface /* gcc class implementation */
  17. #endif
  18. #ifdef HAVE_IEEEFP_H
  19. extern "C" /* Bug in BSDI include file */
  20. {
  21. #include <ieeefp.h>
  22. }
  23. #endif
  24. class Item_func :public Item_result_field
  25. {
  26. protected:
  27. Item **args, *tmp_arg[2];
  28. /*
  29. Allowed numbers of columns in result (usually 1, which means scalar value)
  30. 0 means get this number from first argument
  31. */
  32. uint allowed_arg_cols;
  33. public:
  34. uint arg_count;
  35. table_map used_tables_cache, not_null_tables_cache;
  36. bool const_item_cache;
  37. enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
  38. GE_FUNC,GT_FUNC,FT_FUNC,
  39. LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
  40. COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
  41. BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
  42. INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
  43. SP_EQUALS_FUNC, SP_DISJOINT_FUNC,SP_INTERSECTS_FUNC,
  44. SP_TOUCHES_FUNC,SP_CROSSES_FUNC,SP_WITHIN_FUNC,
  45. SP_CONTAINS_FUNC,SP_OVERLAPS_FUNC,
  46. SP_STARTPOINT,SP_ENDPOINT,SP_EXTERIORRING,
  47. SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
  48. NOT_FUNC, NOT_ALL_FUNC,
  49. NOW_FUNC, TRIG_COND_FUNC,
  50. SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
  51. EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
  52. NEG_FUNC, GSYSVAR_FUNC };
  53. enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
  54. OPTIMIZE_EQUAL };
  55. enum Type type() const { return FUNC_ITEM; }
  56. virtual enum Functype functype() const { return UNKNOWN_FUNC; }
  57. Item_func(void):
  58. allowed_arg_cols(1), arg_count(0)
  59. {
  60. with_sum_func= 0;
  61. }
  62. Item_func(Item *a):
  63. allowed_arg_cols(1), arg_count(1)
  64. {
  65. args= tmp_arg;
  66. args[0]= a;
  67. with_sum_func= a->with_sum_func;
  68. }
  69. Item_func(Item *a,Item *b):
  70. allowed_arg_cols(1), arg_count(2)
  71. {
  72. args= tmp_arg;
  73. args[0]= a; args[1]= b;
  74. with_sum_func= a->with_sum_func || b->with_sum_func;
  75. }
  76. Item_func(Item *a,Item *b,Item *c):
  77. allowed_arg_cols(1)
  78. {
  79. arg_count= 0;
  80. if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
  81. {
  82. arg_count= 3;
  83. args[0]= a; args[1]= b; args[2]= c;
  84. with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
  85. }
  86. }
  87. Item_func(Item *a,Item *b,Item *c,Item *d):
  88. allowed_arg_cols(1)
  89. {
  90. arg_count= 0;
  91. if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
  92. {
  93. arg_count= 4;
  94. args[0]= a; args[1]= b; args[2]= c; args[3]= d;
  95. with_sum_func= a->with_sum_func || b->with_sum_func ||
  96. c->with_sum_func || d->with_sum_func;
  97. }
  98. }
  99. Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
  100. allowed_arg_cols(1)
  101. {
  102. arg_count= 5;
  103. if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
  104. {
  105. args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
  106. with_sum_func= a->with_sum_func || b->with_sum_func ||
  107. c->with_sum_func || d->with_sum_func || e->with_sum_func ;
  108. }
  109. }
  110. Item_func(List<Item> &list);
  111. // Constructor used for Item_cond_and/or (see Item comment)
  112. Item_func(THD *thd, Item_func *item);
  113. bool fix_fields(THD *, Item **ref);
  114. table_map used_tables() const;
  115. table_map not_null_tables() const;
  116. void update_used_tables();
  117. bool eq(const Item *item, bool binary_cmp) const;
  118. virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
  119. virtual bool have_rev_func() const { return 0; }
  120. virtual Item *key_item() const { return args[0]; }
  121. virtual bool const_item() const { return const_item_cache; }
  122. inline Item **arguments() const { return args; }
  123. void set_arguments(List<Item> &list);
  124. inline uint argument_count() const { return arg_count; }
  125. inline void remove_arguments() { arg_count=0; }
  126. void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
  127. virtual void print(String *str, enum_query_type query_type);
  128. void print_op(String *str, enum_query_type query_type);
  129. void print_args(String *str, uint from, enum_query_type query_type);
  130. virtual void fix_num_length_and_dec();
  131. void count_only_length();
  132. void count_real_length();
  133. void count_decimal_length();
  134. inline bool get_arg0_date(MYSQL_TIME *ltime, uint fuzzy_date)
  135. {
  136. return (null_value=args[0]->get_date(ltime, fuzzy_date));
  137. }
  138. inline bool get_arg0_time(MYSQL_TIME *ltime)
  139. {
  140. return (null_value=args[0]->get_time(ltime));
  141. }
  142. bool is_null() {
  143. update_null_value();
  144. return null_value;
  145. }
  146. void signal_divide_by_null();
  147. friend class udf_handler;
  148. Field *tmp_table_field() { return result_field; }
  149. Field *tmp_table_field(TABLE *t_arg);
  150. Item *get_tmp_table_item(THD *thd);
  151. my_decimal *val_decimal(my_decimal *);
  152. bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems,
  153. uint flags, int item_sep)
  154. {
  155. return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep);
  156. }
  157. bool agg_arg_charsets_for_string_result(DTCollation &c,
  158. Item **items, uint nitems,
  159. int item_sep= 1)
  160. {
  161. return agg_item_charsets_for_string_result(c, func_name(),
  162. items, nitems, item_sep);
  163. }
  164. bool agg_arg_charsets_for_comparison(DTCollation &c,
  165. Item **items, uint nitems,
  166. int item_sep= 1)
  167. {
  168. return agg_item_charsets_for_comparison(c, func_name(),
  169. items, nitems, item_sep);
  170. }
  171. bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
  172. Item *transform(Item_transformer transformer, uchar *arg);
  173. Item* compile(Item_analyzer analyzer, uchar **arg_p,
  174. Item_transformer transformer, uchar *arg_t);
  175. void traverse_cond(Cond_traverser traverser,
  176. void * arg, traverse_order order);
  177. bool is_expensive_processor(uchar *arg);
  178. virtual bool is_expensive() { return 0; }
  179. inline void raise_numeric_overflow(const char *type_name)
  180. {
  181. char buf[256];
  182. String str(buf, sizeof(buf), system_charset_info);
  183. str.length(0);
  184. print(&str, QT_ORDINARY);
  185. my_error(ER_DATA_OUT_OF_RANGE, MYF(0), type_name, str.c_ptr_safe());
  186. }
  187. inline double raise_float_overflow()
  188. {
  189. raise_numeric_overflow("DOUBLE");
  190. return 0.0;
  191. }
  192. inline longlong raise_integer_overflow()
  193. {
  194. raise_numeric_overflow(unsigned_flag ? "BIGINT UNSIGNED": "BIGINT");
  195. return 0;
  196. }
  197. inline int raise_decimal_overflow()
  198. {
  199. raise_numeric_overflow("DECIMAL");
  200. return E_DEC_OVERFLOW;
  201. }
  202. /**
  203. Throw an error if the input double number is not finite, i.e. is either
  204. +/-INF or NAN.
  205. */
  206. inline double check_float_overflow(double value)
  207. {
  208. return isfinite(value) ? value : raise_float_overflow();
  209. }
  210. /**
  211. Throw an error if the input BIGINT value represented by the
  212. (longlong value, bool unsigned flag) pair cannot be returned by the
  213. function, i.e. is not compatible with this Item's unsigned_flag.
  214. */
  215. inline longlong check_integer_overflow(longlong value, bool val_unsigned)
  216. {
  217. if ((unsigned_flag && !val_unsigned && value < 0) ||
  218. (!unsigned_flag && val_unsigned && (ulonglong) value > LONGLONG_MAX))
  219. return raise_integer_overflow();
  220. return value;
  221. }
  222. /**
  223. Throw an error if the error code of a DECIMAL operation is E_DEC_OVERFLOW.
  224. */
  225. inline int check_decimal_overflow(int error)
  226. {
  227. return (error == E_DEC_OVERFLOW) ? raise_decimal_overflow() : error;
  228. }
  229. bool has_timestamp_args()
  230. {
  231. DBUG_ASSERT(fixed == TRUE);
  232. for (uint i= 0; i < arg_count; i++)
  233. {
  234. if (args[i]->type() == Item::FIELD_ITEM &&
  235. args[i]->field_type() == MYSQL_TYPE_TIMESTAMP)
  236. return TRUE;
  237. }
  238. return FALSE;
  239. }
  240. /*
  241. We assume the result of any function that has a TIMESTAMP argument to be
  242. timezone-dependent, since a TIMESTAMP value in both numeric and string
  243. contexts is interpreted according to the current timezone.
  244. The only exception is UNIX_TIMESTAMP() which returns the internal
  245. representation of a TIMESTAMP argument verbatim, and thus does not depend on
  246. the timezone.
  247. */
  248. virtual bool is_timezone_dependent_processor(uchar *bool_arg)
  249. {
  250. return has_timestamp_args();
  251. }
  252. virtual bool find_function_processor (uchar *arg)
  253. {
  254. return functype() == *(Functype *) arg;
  255. }
  256. };
  257. class Item_real_func :public Item_func
  258. {
  259. public:
  260. Item_real_func() :Item_func() { collation.set_numeric(); }
  261. Item_real_func(Item *a) :Item_func(a) { collation.set_numeric(); }
  262. Item_real_func(Item *a,Item *b) :Item_func(a,b) { collation.set_numeric(); }
  263. Item_real_func(List<Item> &list) :Item_func(list) { collation.set_numeric(); }
  264. String *val_str(String*str);
  265. my_decimal *val_decimal(my_decimal *decimal_value);
  266. longlong val_int()
  267. { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
  268. enum Item_result result_type () const { return REAL_RESULT; }
  269. void fix_length_and_dec()
  270. { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
  271. };
  272. class Item_func_numhybrid: public Item_func
  273. {
  274. protected:
  275. Item_result hybrid_type;
  276. public:
  277. Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
  278. { collation.set_numeric(); }
  279. Item_func_numhybrid(Item *a,Item *b)
  280. :Item_func(a,b), hybrid_type(REAL_RESULT)
  281. { collation.set_numeric(); }
  282. Item_func_numhybrid(List<Item> &list)
  283. :Item_func(list), hybrid_type(REAL_RESULT)
  284. { collation.set_numeric(); }
  285. enum Item_result result_type () const { return hybrid_type; }
  286. void fix_length_and_dec();
  287. void fix_num_length_and_dec();
  288. virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
  289. double val_real();
  290. longlong val_int();
  291. my_decimal *val_decimal(my_decimal *);
  292. String *val_str(String*str);
  293. /**
  294. @brief Performs the operation that this functions implements when the
  295. result type is INT.
  296. @return The result of the operation.
  297. */
  298. virtual longlong int_op()= 0;
  299. /**
  300. @brief Performs the operation that this functions implements when the
  301. result type is REAL.
  302. @return The result of the operation.
  303. */
  304. virtual double real_op()= 0;
  305. /**
  306. @brief Performs the operation that this functions implements when the
  307. result type is DECIMAL.
  308. @param A pointer where the DECIMAL value will be allocated.
  309. @return
  310. - 0 If the result is NULL
  311. - The same pointer it was given, with the area initialized to the
  312. result of the operation.
  313. */
  314. virtual my_decimal *decimal_op(my_decimal *)= 0;
  315. /**
  316. @brief Performs the operation that this functions implements when the
  317. result type is a string type.
  318. @return The result of the operation.
  319. */
  320. virtual String *str_op(String *)= 0;
  321. bool is_null() { update_null_value(); return null_value; }
  322. };
  323. /* function where type of result detected by first argument */
  324. class Item_func_num1: public Item_func_numhybrid
  325. {
  326. public:
  327. Item_func_num1(Item *a) :Item_func_numhybrid(a) {}
  328. Item_func_num1(Item *a, Item *b) :Item_func_numhybrid(a, b) {}
  329. void fix_num_length_and_dec();
  330. void find_num_type();
  331. String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
  332. };
  333. /* Base class for operations like '+', '-', '*' */
  334. class Item_num_op :public Item_func_numhybrid
  335. {
  336. public:
  337. Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {}
  338. virtual void result_precision()= 0;
  339. virtual inline void print(String *str, enum_query_type query_type)
  340. {
  341. print_op(str, query_type);
  342. }
  343. void find_num_type();
  344. String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
  345. };
  346. class Item_int_func :public Item_func
  347. {
  348. public:
  349. Item_int_func() :Item_func()
  350. { collation.set_numeric(); fix_char_length(21); }
  351. Item_int_func(Item *a) :Item_func(a)
  352. { collation.set_numeric(); fix_char_length(21); }
  353. Item_int_func(Item *a,Item *b) :Item_func(a,b)
  354. { collation.set_numeric(); fix_char_length(21); }
  355. Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c)
  356. { collation.set_numeric(); fix_char_length(21); }
  357. Item_int_func(List<Item> &list) :Item_func(list)
  358. { collation.set_numeric(); fix_char_length(21); }
  359. Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item)
  360. { collation.set_numeric(); }
  361. double val_real();
  362. String *val_str(String*str);
  363. enum Item_result result_type () const { return INT_RESULT; }
  364. void fix_length_and_dec() {}
  365. };
  366. class Item_func_connection_id :public Item_int_func
  367. {
  368. longlong value;
  369. public:
  370. Item_func_connection_id() {}
  371. const char *func_name() const { return "connection_id"; }
  372. void fix_length_and_dec();
  373. bool fix_fields(THD *thd, Item **ref);
  374. longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
  375. };
  376. class Item_func_signed :public Item_int_func
  377. {
  378. public:
  379. Item_func_signed(Item *a) :Item_int_func(a) {}
  380. const char *func_name() const { return "cast_as_signed"; }
  381. longlong val_int();
  382. longlong val_int_from_str(int *error);
  383. void fix_length_and_dec()
  384. { fix_char_length(args[0]->max_char_length()); unsigned_flag=0; }
  385. virtual void print(String *str, enum_query_type query_type);
  386. uint decimal_precision() const { return args[0]->decimal_precision(); }
  387. };
  388. class Item_func_unsigned :public Item_func_signed
  389. {
  390. public:
  391. Item_func_unsigned(Item *a) :Item_func_signed(a) {}
  392. const char *func_name() const { return "cast_as_unsigned"; }
  393. void fix_length_and_dec()
  394. {
  395. fix_char_length(min(args[0]->max_char_length(),
  396. DECIMAL_MAX_PRECISION + 2));
  397. unsigned_flag=1;
  398. }
  399. longlong val_int();
  400. virtual void print(String *str, enum_query_type query_type);
  401. };
  402. class Item_decimal_typecast :public Item_func
  403. {
  404. my_decimal decimal_value;
  405. public:
  406. Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a)
  407. {
  408. decimals= dec;
  409. collation.set_numeric();
  410. fix_char_length(my_decimal_precision_to_length_no_truncation(len, dec,
  411. unsigned_flag));
  412. }
  413. String *val_str(String *str);
  414. double val_real();
  415. longlong val_int();
  416. my_decimal *val_decimal(my_decimal*);
  417. enum Item_result result_type () const { return DECIMAL_RESULT; }
  418. enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
  419. void fix_length_and_dec() {};
  420. const char *func_name() const { return "decimal_typecast"; }
  421. virtual void print(String *str, enum_query_type query_type);
  422. };
  423. class Item_func_additive_op :public Item_num_op
  424. {
  425. public:
  426. Item_func_additive_op(Item *a,Item *b) :Item_num_op(a,b) {}
  427. void result_precision();
  428. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  429. };
  430. class Item_func_plus :public Item_func_additive_op
  431. {
  432. public:
  433. Item_func_plus(Item *a,Item *b) :Item_func_additive_op(a,b) {}
  434. const char *func_name() const { return "+"; }
  435. longlong int_op();
  436. double real_op();
  437. my_decimal *decimal_op(my_decimal *);
  438. };
  439. class Item_func_minus :public Item_func_additive_op
  440. {
  441. public:
  442. Item_func_minus(Item *a,Item *b) :Item_func_additive_op(a,b) {}
  443. const char *func_name() const { return "-"; }
  444. longlong int_op();
  445. double real_op();
  446. my_decimal *decimal_op(my_decimal *);
  447. void fix_length_and_dec();
  448. };
  449. class Item_func_mul :public Item_num_op
  450. {
  451. public:
  452. Item_func_mul(Item *a,Item *b) :Item_num_op(a,b) {}
  453. const char *func_name() const { return "*"; }
  454. longlong int_op();
  455. double real_op();
  456. my_decimal *decimal_op(my_decimal *);
  457. void result_precision();
  458. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  459. };
  460. class Item_func_div :public Item_num_op
  461. {
  462. public:
  463. uint prec_increment;
  464. Item_func_div(Item *a,Item *b) :Item_num_op(a,b) {}
  465. longlong int_op() { DBUG_ASSERT(0); return 0; }
  466. double real_op();
  467. my_decimal *decimal_op(my_decimal *);
  468. const char *func_name() const { return "/"; }
  469. void fix_length_and_dec();
  470. void result_precision();
  471. };
  472. class Item_func_int_div :public Item_int_func
  473. {
  474. public:
  475. Item_func_int_div(Item *a,Item *b) :Item_int_func(a,b)
  476. {}
  477. longlong val_int();
  478. const char *func_name() const { return "DIV"; }
  479. void fix_length_and_dec();
  480. virtual inline void print(String *str, enum_query_type query_type)
  481. {
  482. print_op(str, query_type);
  483. }
  484. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  485. };
  486. class Item_func_mod :public Item_num_op
  487. {
  488. public:
  489. Item_func_mod(Item *a,Item *b) :Item_num_op(a,b) {}
  490. longlong int_op();
  491. double real_op();
  492. my_decimal *decimal_op(my_decimal *);
  493. const char *func_name() const { return "%"; }
  494. void result_precision();
  495. void fix_length_and_dec();
  496. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  497. };
  498. class Item_func_neg :public Item_func_num1
  499. {
  500. public:
  501. Item_func_neg(Item *a) :Item_func_num1(a) {}
  502. double real_op();
  503. longlong int_op();
  504. my_decimal *decimal_op(my_decimal *);
  505. const char *func_name() const { return "-"; }
  506. enum Functype functype() const { return NEG_FUNC; }
  507. void fix_length_and_dec();
  508. void fix_num_length_and_dec();
  509. uint decimal_precision() const { return args[0]->decimal_precision(); }
  510. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  511. };
  512. class Item_func_abs :public Item_func_num1
  513. {
  514. public:
  515. Item_func_abs(Item *a) :Item_func_num1(a) {}
  516. double real_op();
  517. longlong int_op();
  518. my_decimal *decimal_op(my_decimal *);
  519. const char *func_name() const { return "abs"; }
  520. void fix_length_and_dec();
  521. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  522. };
  523. // A class to handle logarithmic and trigonometric functions
  524. class Item_dec_func :public Item_real_func
  525. {
  526. public:
  527. Item_dec_func(Item *a) :Item_real_func(a) {}
  528. Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {}
  529. void fix_length_and_dec()
  530. {
  531. decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
  532. maybe_null=1;
  533. }
  534. };
  535. class Item_func_exp :public Item_dec_func
  536. {
  537. public:
  538. Item_func_exp(Item *a) :Item_dec_func(a) {}
  539. double val_real();
  540. const char *func_name() const { return "exp"; }
  541. };
  542. class Item_func_ln :public Item_dec_func
  543. {
  544. public:
  545. Item_func_ln(Item *a) :Item_dec_func(a) {}
  546. double val_real();
  547. const char *func_name() const { return "ln"; }
  548. };
  549. class Item_func_log :public Item_dec_func
  550. {
  551. public:
  552. Item_func_log(Item *a) :Item_dec_func(a) {}
  553. Item_func_log(Item *a,Item *b) :Item_dec_func(a,b) {}
  554. double val_real();
  555. const char *func_name() const { return "log"; }
  556. };
  557. class Item_func_log2 :public Item_dec_func
  558. {
  559. public:
  560. Item_func_log2(Item *a) :Item_dec_func(a) {}
  561. double val_real();
  562. const char *func_name() const { return "log2"; }
  563. };
  564. class Item_func_log10 :public Item_dec_func
  565. {
  566. public:
  567. Item_func_log10(Item *a) :Item_dec_func(a) {}
  568. double val_real();
  569. const char *func_name() const { return "log10"; }
  570. };
  571. class Item_func_sqrt :public Item_dec_func
  572. {
  573. public:
  574. Item_func_sqrt(Item *a) :Item_dec_func(a) {}
  575. double val_real();
  576. const char *func_name() const { return "sqrt"; }
  577. };
  578. class Item_func_pow :public Item_dec_func
  579. {
  580. public:
  581. Item_func_pow(Item *a,Item *b) :Item_dec_func(a,b) {}
  582. double val_real();
  583. const char *func_name() const { return "pow"; }
  584. };
  585. class Item_func_acos :public Item_dec_func
  586. {
  587. public:
  588. Item_func_acos(Item *a) :Item_dec_func(a) {}
  589. double val_real();
  590. const char *func_name() const { return "acos"; }
  591. };
  592. class Item_func_asin :public Item_dec_func
  593. {
  594. public:
  595. Item_func_asin(Item *a) :Item_dec_func(a) {}
  596. double val_real();
  597. const char *func_name() const { return "asin"; }
  598. };
  599. class Item_func_atan :public Item_dec_func
  600. {
  601. public:
  602. Item_func_atan(Item *a) :Item_dec_func(a) {}
  603. Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {}
  604. double val_real();
  605. const char *func_name() const { return "atan"; }
  606. };
  607. class Item_func_cos :public Item_dec_func
  608. {
  609. public:
  610. Item_func_cos(Item *a) :Item_dec_func(a) {}
  611. double val_real();
  612. const char *func_name() const { return "cos"; }
  613. };
  614. class Item_func_sin :public Item_dec_func
  615. {
  616. public:
  617. Item_func_sin(Item *a) :Item_dec_func(a) {}
  618. double val_real();
  619. const char *func_name() const { return "sin"; }
  620. };
  621. class Item_func_tan :public Item_dec_func
  622. {
  623. public:
  624. Item_func_tan(Item *a) :Item_dec_func(a) {}
  625. double val_real();
  626. const char *func_name() const { return "tan"; }
  627. };
  628. class Item_func_cot :public Item_dec_func
  629. {
  630. public:
  631. Item_func_cot(Item *a) :Item_dec_func(a) {}
  632. double val_real();
  633. const char *func_name() const { return "cot"; }
  634. };
  635. class Item_func_integer :public Item_int_func
  636. {
  637. public:
  638. inline Item_func_integer(Item *a) :Item_int_func(a) {}
  639. void fix_length_and_dec();
  640. };
  641. class Item_func_int_val :public Item_func_num1
  642. {
  643. public:
  644. Item_func_int_val(Item *a) :Item_func_num1(a) {}
  645. void fix_num_length_and_dec();
  646. void find_num_type();
  647. };
  648. class Item_func_ceiling :public Item_func_int_val
  649. {
  650. public:
  651. Item_func_ceiling(Item *a) :Item_func_int_val(a) {}
  652. const char *func_name() const { return "ceiling"; }
  653. longlong int_op();
  654. double real_op();
  655. my_decimal *decimal_op(my_decimal *);
  656. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  657. };
  658. class Item_func_floor :public Item_func_int_val
  659. {
  660. public:
  661. Item_func_floor(Item *a) :Item_func_int_val(a) {}
  662. const char *func_name() const { return "floor"; }
  663. longlong int_op();
  664. double real_op();
  665. my_decimal *decimal_op(my_decimal *);
  666. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  667. };
  668. /* This handles round and truncate */
  669. class Item_func_round :public Item_func_num1
  670. {
  671. bool truncate;
  672. public:
  673. Item_func_round(Item *a, Item *b, bool trunc_arg)
  674. :Item_func_num1(a,b), truncate(trunc_arg) {}
  675. const char *func_name() const { return truncate ? "truncate" : "round"; }
  676. double real_op();
  677. longlong int_op();
  678. my_decimal *decimal_op(my_decimal *);
  679. void fix_length_and_dec();
  680. };
  681. class Item_func_rand :public Item_real_func
  682. {
  683. struct rand_struct *rand;
  684. bool first_eval; // TRUE if val_real() is called 1st time
  685. public:
  686. Item_func_rand(Item *a) :Item_real_func(a), rand(0), first_eval(TRUE) {}
  687. Item_func_rand() :Item_real_func() {}
  688. double val_real();
  689. const char *func_name() const { return "rand"; }
  690. bool const_item() const { return 0; }
  691. void update_used_tables();
  692. bool fix_fields(THD *thd, Item **ref);
  693. void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
  694. private:
  695. void seed_random (Item * val);
  696. };
  697. class Item_func_sign :public Item_int_func
  698. {
  699. public:
  700. Item_func_sign(Item *a) :Item_int_func(a) {}
  701. const char *func_name() const { return "sign"; }
  702. longlong val_int();
  703. };
  704. class Item_func_units :public Item_real_func
  705. {
  706. char *name;
  707. double mul,add;
  708. public:
  709. Item_func_units(char *name_arg,Item *a,double mul_arg,double add_arg)
  710. :Item_real_func(a),name(name_arg),mul(mul_arg),add(add_arg) {}
  711. double val_real();
  712. const char *func_name() const { return name; }
  713. void fix_length_and_dec()
  714. { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
  715. };
  716. class Item_func_min_max :public Item_func
  717. {
  718. Item_result cmp_type;
  719. String tmp_value;
  720. int cmp_sign;
  721. /* TRUE <=> arguments should be compared in the DATETIME context. */
  722. bool compare_as_dates;
  723. /* An item used for issuing warnings while string to DATETIME conversion. */
  724. Item *datetime_item;
  725. THD *thd;
  726. protected:
  727. enum_field_types cached_field_type;
  728. public:
  729. Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
  730. cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE),
  731. datetime_item(0) {}
  732. double val_real();
  733. longlong val_int();
  734. String *val_str(String *);
  735. my_decimal *val_decimal(my_decimal *);
  736. void fix_length_and_dec();
  737. enum Item_result result_type () const { return cmp_type; }
  738. bool result_as_longlong() { return compare_as_dates; };
  739. uint cmp_datetimes(ulonglong *value);
  740. enum_field_types field_type() const { return cached_field_type; }
  741. };
  742. class Item_func_min :public Item_func_min_max
  743. {
  744. public:
  745. Item_func_min(List<Item> &list) :Item_func_min_max(list,1) {}
  746. const char *func_name() const { return "least"; }
  747. };
  748. class Item_func_max :public Item_func_min_max
  749. {
  750. public:
  751. Item_func_max(List<Item> &list) :Item_func_min_max(list,-1) {}
  752. const char *func_name() const { return "greatest"; }
  753. };
  754. /*
  755. Objects of this class are used for ROLLUP queries to wrap up
  756. each constant item referred to in GROUP BY list.
  757. */
  758. class Item_func_rollup_const :public Item_func
  759. {
  760. public:
  761. Item_func_rollup_const(Item *a) :Item_func(a)
  762. {
  763. name= a->name;
  764. name_length= a->name_length;
  765. }
  766. double val_real() { return args[0]->val_real(); }
  767. longlong val_int() { return args[0]->val_int(); }
  768. String *val_str(String *str) { return args[0]->val_str(str); }
  769. my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); }
  770. const char *func_name() const { return "rollup_const"; }
  771. bool const_item() const { return 0; }
  772. Item_result result_type() const { return args[0]->result_type(); }
  773. void fix_length_and_dec()
  774. {
  775. collation= args[0]->collation;
  776. max_length= args[0]->max_length;
  777. decimals=args[0]->decimals;
  778. /* The item could be a NULL constant. */
  779. null_value= args[0]->is_null();
  780. }
  781. };
  782. class Item_func_length :public Item_int_func
  783. {
  784. String value;
  785. public:
  786. Item_func_length(Item *a) :Item_int_func(a) {}
  787. longlong val_int();
  788. const char *func_name() const { return "length"; }
  789. void fix_length_and_dec() { max_length=10; }
  790. };
  791. class Item_func_bit_length :public Item_func_length
  792. {
  793. public:
  794. Item_func_bit_length(Item *a) :Item_func_length(a) {}
  795. longlong val_int()
  796. { DBUG_ASSERT(fixed == 1); return Item_func_length::val_int()*8; }
  797. const char *func_name() const { return "bit_length"; }
  798. };
  799. class Item_func_char_length :public Item_int_func
  800. {
  801. String value;
  802. public:
  803. Item_func_char_length(Item *a) :Item_int_func(a) {}
  804. longlong val_int();
  805. const char *func_name() const { return "char_length"; }
  806. void fix_length_and_dec() { max_length=10; }
  807. };
  808. class Item_func_coercibility :public Item_int_func
  809. {
  810. public:
  811. Item_func_coercibility(Item *a) :Item_int_func(a) {}
  812. longlong val_int();
  813. const char *func_name() const { return "coercibility"; }
  814. void fix_length_and_dec() { max_length=10; maybe_null= 0; }
  815. table_map not_null_tables() const { return 0; }
  816. };
  817. class Item_func_locate :public Item_int_func
  818. {
  819. String value1,value2;
  820. DTCollation cmp_collation;
  821. public:
  822. Item_func_locate(Item *a,Item *b) :Item_int_func(a,b) {}
  823. Item_func_locate(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
  824. const char *func_name() const { return "locate"; }
  825. longlong val_int();
  826. void fix_length_and_dec();
  827. virtual void print(String *str, enum_query_type query_type);
  828. };
  829. class Item_func_field :public Item_int_func
  830. {
  831. String value,tmp;
  832. Item_result cmp_type;
  833. DTCollation cmp_collation;
  834. public:
  835. Item_func_field(List<Item> &list) :Item_int_func(list) {}
  836. longlong val_int();
  837. const char *func_name() const { return "field"; }
  838. void fix_length_and_dec();
  839. };
  840. class Item_func_ascii :public Item_int_func
  841. {
  842. String value;
  843. public:
  844. Item_func_ascii(Item *a) :Item_int_func(a) {}
  845. longlong val_int();
  846. const char *func_name() const { return "ascii"; }
  847. void fix_length_and_dec() { max_length=3; }
  848. };
  849. class Item_func_ord :public Item_int_func
  850. {
  851. String value;
  852. public:
  853. Item_func_ord(Item *a) :Item_int_func(a) {}
  854. longlong val_int();
  855. const char *func_name() const { return "ord"; }
  856. };
  857. class Item_func_find_in_set :public Item_int_func
  858. {
  859. String value,value2;
  860. uint enum_value;
  861. ulonglong enum_bit;
  862. DTCollation cmp_collation;
  863. public:
  864. Item_func_find_in_set(Item *a,Item *b) :Item_int_func(a,b),enum_value(0) {}
  865. longlong val_int();
  866. const char *func_name() const { return "find_in_set"; }
  867. void fix_length_and_dec();
  868. };
  869. /* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
  870. class Item_func_bit: public Item_int_func
  871. {
  872. public:
  873. Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
  874. Item_func_bit(Item *a) :Item_int_func(a) {}
  875. void fix_length_and_dec() { unsigned_flag= 1; }
  876. virtual inline void print(String *str, enum_query_type query_type)
  877. {
  878. print_op(str, query_type);
  879. }
  880. };
  881. class Item_func_bit_or :public Item_func_bit
  882. {
  883. public:
  884. Item_func_bit_or(Item *a, Item *b) :Item_func_bit(a, b) {}
  885. longlong val_int();
  886. const char *func_name() const { return "|"; }
  887. };
  888. class Item_func_bit_and :public Item_func_bit
  889. {
  890. public:
  891. Item_func_bit_and(Item *a, Item *b) :Item_func_bit(a, b) {}
  892. longlong val_int();
  893. const char *func_name() const { return "&"; }
  894. };
  895. class Item_func_bit_count :public Item_int_func
  896. {
  897. public:
  898. Item_func_bit_count(Item *a) :Item_int_func(a) {}
  899. longlong val_int();
  900. const char *func_name() const { return "bit_count"; }
  901. void fix_length_and_dec() { max_length=2; }
  902. };
  903. class Item_func_shift_left :public Item_func_bit
  904. {
  905. public:
  906. Item_func_shift_left(Item *a, Item *b) :Item_func_bit(a, b) {}
  907. longlong val_int();
  908. const char *func_name() const { return "<<"; }
  909. };
  910. class Item_func_shift_right :public Item_func_bit
  911. {
  912. public:
  913. Item_func_shift_right(Item *a, Item *b) :Item_func_bit(a, b) {}
  914. longlong val_int();
  915. const char *func_name() const { return ">>"; }
  916. };
  917. class Item_func_bit_neg :public Item_func_bit
  918. {
  919. public:
  920. Item_func_bit_neg(Item *a) :Item_func_bit(a) {}
  921. longlong val_int();
  922. const char *func_name() const { return "~"; }
  923. virtual inline void print(String *str, enum_query_type query_type)
  924. {
  925. Item_func::print(str, query_type);
  926. }
  927. };
  928. class Item_func_last_insert_id :public Item_int_func
  929. {
  930. public:
  931. Item_func_last_insert_id() :Item_int_func() {}
  932. Item_func_last_insert_id(Item *a) :Item_int_func(a) {}
  933. longlong val_int();
  934. const char *func_name() const { return "last_insert_id"; }
  935. void fix_length_and_dec()
  936. {
  937. if (arg_count)
  938. max_length= args[0]->max_length;
  939. }
  940. bool fix_fields(THD *thd, Item **ref);
  941. };
  942. class Item_func_benchmark :public Item_int_func
  943. {
  944. public:
  945. Item_func_benchmark(Item *count_expr, Item *expr)
  946. :Item_int_func(count_expr, expr)
  947. {}
  948. longlong val_int();
  949. const char *func_name() const { return "benchmark"; }
  950. void fix_length_and_dec() { max_length=1; maybe_null=0; }
  951. virtual void print(String *str, enum_query_type query_type);
  952. };
  953. class Item_func_sleep :public Item_int_func
  954. {
  955. public:
  956. Item_func_sleep(Item *a) :Item_int_func(a) {}
  957. bool const_item() const { return 0; }
  958. const char *func_name() const { return "sleep"; }
  959. void update_used_tables()
  960. {
  961. Item_int_func::update_used_tables();
  962. used_tables_cache|= RAND_TABLE_BIT;
  963. }
  964. longlong val_int();
  965. };
  966. #ifdef HAVE_DLOPEN
  967. class Item_udf_func :public Item_func
  968. {
  969. protected:
  970. udf_handler udf;
  971. public:
  972. Item_udf_func(udf_func *udf_arg)
  973. :Item_func(), udf(udf_arg) {}
  974. Item_udf_func(udf_func *udf_arg, List<Item> &list)
  975. :Item_func(list), udf(udf_arg) {}
  976. const char *func_name() const { return udf.name(); }
  977. enum Functype functype() const { return UDF_FUNC; }
  978. bool fix_fields(THD *thd, Item **ref)
  979. {
  980. DBUG_ASSERT(fixed == 0);
  981. bool res= udf.fix_fields(thd, this, arg_count, args);
  982. used_tables_cache= udf.used_tables_cache;
  983. const_item_cache= udf.const_item_cache;
  984. fixed= 1;
  985. return res;
  986. }
  987. void update_used_tables()
  988. {
  989. /*
  990. TODO: Make a member in UDF_INIT and return if a UDF is deterministic or
  991. not.
  992. Currently UDF_INIT has a member (const_item) that is an in/out
  993. parameter to the init() call.
  994. The code in udf_handler::fix_fields also duplicates the arguments
  995. handling code in Item_func::fix_fields().
  996. The lack of information if a UDF is deterministic makes writing
  997. a correct update_used_tables() for UDFs impossible.
  998. One solution to this would be :
  999. - Add a is_deterministic member of UDF_INIT
  1000. - (optionally) deprecate the const_item member of UDF_INIT
  1001. - Take away the duplicate code from udf_handler::fix_fields() and
  1002. make Item_udf_func call Item_func::fix_fields() to process its
  1003. arguments as for any other function.
  1004. - Store the deterministic flag returned by <udf>_init into the
  1005. udf_handler.
  1006. - Don't implement Item_udf_func::fix_fields, implement
  1007. Item_udf_func::fix_length_and_dec() instead (similar to non-UDF
  1008. functions).
  1009. - Override Item_func::update_used_tables to call
  1010. Item_func::update_used_tables() and add a RAND_TABLE_BIT to the
  1011. result of Item_func::update_used_tables() if the UDF is
  1012. non-deterministic.
  1013. - (optionally) rename RAND_TABLE_BIT to NONDETERMINISTIC_BIT to
  1014. better describe its usage.
  1015. The above would require a change of the UDF API.
  1016. Until that change is done here's how the current code works:
  1017. We call Item_func::update_used_tables() only when we know that
  1018. the function depends on real non-const tables and is deterministic.
  1019. This can be done only because we know that the optimizer will
  1020. call update_used_tables() only when there's possibly a new const
  1021. table. So update_used_tables() can only make a Item_func more
  1022. constant than it is currently.
  1023. That's why we don't need to do anything if a function is guaranteed
  1024. to return non-constant (it's non-deterministic) or is already a
  1025. const.
  1026. */
  1027. if ((used_tables_cache & ~PSEUDO_TABLE_BITS) &&
  1028. !(used_tables_cache & RAND_TABLE_BIT))
  1029. {
  1030. Item_func::update_used_tables();
  1031. if (!const_item_cache && !used_tables_cache)
  1032. used_tables_cache= RAND_TABLE_BIT;
  1033. }
  1034. }
  1035. void cleanup();
  1036. Item_result result_type () const { return udf.result_type(); }
  1037. table_map not_null_tables() const { return 0; }
  1038. bool is_expensive() { return 1; }
  1039. virtual void print(String *str, enum_query_type query_type);
  1040. };
  1041. class Item_func_udf_float :public Item_udf_func
  1042. {
  1043. public:
  1044. Item_func_udf_float(udf_func *udf_arg)
  1045. :Item_udf_func(udf_arg) {}
  1046. Item_func_udf_float(udf_func *udf_arg,
  1047. List<Item> &list)
  1048. :Item_udf_func(udf_arg, list) {}
  1049. longlong val_int()
  1050. {
  1051. DBUG_ASSERT(fixed == 1);
  1052. return (longlong) rint(Item_func_udf_float::val_real());
  1053. }
  1054. my_decimal *val_decimal(my_decimal *dec_buf)
  1055. {
  1056. double res=val_real();
  1057. if (null_value)
  1058. return NULL;
  1059. double2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
  1060. return dec_buf;
  1061. }
  1062. double val_real();
  1063. String *val_str(String *str);
  1064. void fix_length_and_dec() { fix_num_length_and_dec(); }
  1065. };
  1066. class Item_func_udf_int :public Item_udf_func
  1067. {
  1068. public:
  1069. Item_func_udf_int(udf_func *udf_arg)
  1070. :Item_udf_func(udf_arg) {}
  1071. Item_func_udf_int(udf_func *udf_arg,
  1072. List<Item> &list)
  1073. :Item_udf_func(udf_arg, list) {}
  1074. longlong val_int();
  1075. double val_real() { return (double) Item_func_udf_int::val_int(); }
  1076. String *val_str(String *str);
  1077. enum Item_result result_type () const { return INT_RESULT; }
  1078. void fix_length_and_dec() { decimals= 0; max_length= 21; }
  1079. };
  1080. class Item_func_udf_decimal :public Item_udf_func
  1081. {
  1082. public:
  1083. Item_func_udf_decimal(udf_func *udf_arg)
  1084. :Item_udf_func(udf_arg) {}
  1085. Item_func_udf_decimal(udf_func *udf_arg, List<Item> &list)
  1086. :Item_udf_func(udf_arg, list) {}
  1087. longlong val_int();
  1088. double val_real();
  1089. my_decimal *val_decimal(my_decimal *);
  1090. String *val_str(String *str);
  1091. enum Item_result result_type () const { return DECIMAL_RESULT; }
  1092. void fix_length_and_dec();
  1093. };
  1094. class Item_func_udf_str :public Item_udf_func
  1095. {
  1096. public:
  1097. Item_func_udf_str(udf_func *udf_arg)
  1098. :Item_udf_func(udf_arg) {}
  1099. Item_func_udf_str(udf_func *udf_arg, List<Item> &list)
  1100. :Item_udf_func(udf_arg, list) {}
  1101. String *val_str(String *);
  1102. double val_real()
  1103. {
  1104. int err_not_used;
  1105. char *end_not_used;
  1106. String *res;
  1107. res= val_str(&str_value);
  1108. return res ? my_strntod(res->charset(),(char*) res->ptr(),
  1109. res->length(), &end_not_used, &err_not_used) : 0.0;
  1110. }
  1111. longlong val_int()
  1112. {
  1113. int err_not_used;
  1114. String *res; res=val_str(&str_value);
  1115. return res ? my_strntoll(res->charset(),res->ptr(),res->length(),10,
  1116. (char**) 0, &err_not_used) : (longlong) 0;
  1117. }
  1118. my_decimal *val_decimal(my_decimal *dec_buf)
  1119. {
  1120. String *res=val_str(&str_value);
  1121. if (!res)
  1122. return NULL;
  1123. string2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
  1124. return dec_buf;
  1125. }
  1126. enum Item_result result_type () const { return STRING_RESULT; }
  1127. void fix_length_and_dec();
  1128. };
  1129. #else /* Dummy functions to get sql_yacc.cc compiled */
  1130. class Item_func_udf_float :public Item_real_func
  1131. {
  1132. public:
  1133. Item_func_udf_float(udf_func *udf_arg)
  1134. :Item_real_func() {}
  1135. Item_func_udf_float(udf_func *udf_arg, List<Item> &list)
  1136. :Item_real_func(list) {}
  1137. double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
  1138. };
  1139. class Item_func_udf_int :public Item_int_func
  1140. {
  1141. public:
  1142. Item_func_udf_int(udf_func *udf_arg)
  1143. :Item_int_func() {}
  1144. Item_func_udf_int(udf_func *udf_arg, List<Item> &list)
  1145. :Item_int_func(list) {}
  1146. longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; }
  1147. };
  1148. class Item_func_udf_decimal :public Item_int_func
  1149. {
  1150. public:
  1151. Item_func_udf_decimal(udf_func *udf_arg)
  1152. :Item_int_func() {}
  1153. Item_func_udf_decimal(udf_func *udf_arg, List<Item> &list)
  1154. :Item_int_func(list) {}
  1155. my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; }
  1156. };
  1157. class Item_func_udf_str :public Item_func
  1158. {
  1159. public:
  1160. Item_func_udf_str(udf_func *udf_arg)
  1161. :Item_func() {}
  1162. Item_func_udf_str(udf_func *udf_arg, List<Item> &list)
  1163. :Item_func(list) {}
  1164. String *val_str(String *)
  1165. { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
  1166. double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; }
  1167. longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
  1168. enum Item_result result_type () const { return STRING_RESULT; }
  1169. void fix_length_and_dec() { maybe_null=1; max_length=0; }
  1170. };
  1171. #endif /* HAVE_DLOPEN */
  1172. /*
  1173. ** User level locks
  1174. */
  1175. class User_level_lock;
  1176. void item_user_lock_init(void);
  1177. void item_user_lock_release(User_level_lock *ull);
  1178. void item_user_lock_free(void);
  1179. class Item_func_get_lock :public Item_int_func
  1180. {
  1181. String value;
  1182. public:
  1183. Item_func_get_lock(Item *a,Item *b) :Item_int_func(a,b) {}
  1184. longlong val_int();
  1185. const char *func_name() const { return "get_lock"; }
  1186. void fix_length_and_dec() { max_length=1; maybe_null=1;}
  1187. };
  1188. class Item_func_release_lock :public Item_int_func
  1189. {
  1190. String value;
  1191. public:
  1192. Item_func_release_lock(Item *a) :Item_int_func(a) {}
  1193. longlong val_int();
  1194. const char *func_name() const { return "release_lock"; }
  1195. void fix_length_and_dec() { max_length=1; maybe_null=1;}
  1196. };
  1197. /* replication functions */
  1198. class Item_master_pos_wait :public Item_int_func
  1199. {
  1200. String value;
  1201. public:
  1202. Item_master_pos_wait(Item *a,Item *b) :Item_int_func(a,b) {}
  1203. Item_master_pos_wait(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
  1204. longlong val_int();
  1205. const char *func_name() const { return "master_pos_wait"; }
  1206. void fix_length_and_dec() { max_length=21; maybe_null=1;}
  1207. };
  1208. /* Handling of user definable variables */
  1209. class user_var_entry;
  1210. class Item_func_set_user_var :public Item_func
  1211. {
  1212. enum Item_result cached_result_type;
  1213. user_var_entry *entry;
  1214. /*
  1215. The entry_thread_id variable is used:
  1216. 1) to skip unnecessary updates of the entry field (see above);
  1217. 2) to reset the entry field that was initialized in the other thread
  1218. (for example, an item tree of a trigger that updates user variables
  1219. may be shared between several connections, and the entry_thread_id field
  1220. prevents updates of one connection user variables from a concurrent
  1221. connection calling the same trigger that initially updated some
  1222. user variable it the first connection context).
  1223. */
  1224. my_thread_id entry_thread_id;
  1225. char buffer[MAX_FIELD_WIDTH];
  1226. String value;
  1227. my_decimal decimal_buff;
  1228. bool null_item;
  1229. union
  1230. {
  1231. longlong vint;
  1232. double vreal;
  1233. String *vstr;
  1234. my_decimal *vdec;
  1235. } save_result;
  1236. public:
  1237. LEX_STRING name; // keep it public
  1238. Item_func_set_user_var(LEX_STRING a,Item *b)
  1239. :Item_func(b), cached_result_type(INT_RESULT),
  1240. entry(NULL), entry_thread_id(0), name(a)
  1241. {}
  1242. enum Functype functype() const { return SUSERVAR_FUNC; }
  1243. double val_real();
  1244. longlong val_int();
  1245. String *val_str(String *str);
  1246. my_decimal *val_decimal(my_decimal *);
  1247. double val_result();
  1248. longlong val_int_result();
  1249. String *str_result(String *str);
  1250. my_decimal *val_decimal_result(my_decimal *);
  1251. bool is_null_result();
  1252. bool update_hash(void *ptr, uint length, enum Item_result type,
  1253. CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
  1254. bool send(Protocol *protocol, String *str_arg);
  1255. void make_field(Send_field *tmp_field);
  1256. bool check(bool use_result_field);
  1257. void save_item_result(Item *item);
  1258. bool update();
  1259. enum Item_result result_type () const { return cached_result_type; }
  1260. bool fix_fields(THD *thd, Item **ref);
  1261. void fix_length_and_dec();
  1262. virtual void print(String *str, enum_query_type query_type);
  1263. void print_as_stmt(String *str, enum_query_type query_type);
  1264. const char *func_name() const { return "set_user_var"; }
  1265. int save_in_field(Field *field, bool no_conversions,
  1266. bool can_use_result_field);
  1267. int save_in_field(Field *field, bool no_conversions)
  1268. {
  1269. return save_in_field(field, no_conversions, 1);
  1270. }
  1271. void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
  1272. bool register_field_in_read_map(uchar *arg);
  1273. bool set_entry(THD *thd, bool create_if_not_exists);
  1274. void cleanup();
  1275. };
  1276. class Item_func_get_user_var :public Item_func,
  1277. private Settable_routine_parameter
  1278. {
  1279. user_var_entry *var_entry;
  1280. Item_result m_cached_result_type;
  1281. public:
  1282. LEX_STRING name; // keep it public
  1283. Item_func_get_user_var(LEX_STRING a):
  1284. Item_func(), m_cached_result_type(STRING_RESULT), name(a) {}
  1285. enum Functype functype() const { return GUSERVAR_FUNC; }
  1286. LEX_STRING get_name() { return name; }
  1287. double val_real();
  1288. longlong val_int();
  1289. my_decimal *val_decimal(my_decimal*);
  1290. String *val_str(String* str);
  1291. void fix_length_and_dec();
  1292. virtual void print(String *str, enum_query_type query_type);
  1293. enum Item_result result_type() const;
  1294. /*
  1295. We must always return variables as strings to guard against selects of type
  1296. select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
  1297. */
  1298. const char *func_name() const { return "get_user_var"; }
  1299. bool const_item() const;
  1300. table_map used_tables() const
  1301. { return const_item() ? 0 : RAND_TABLE_BIT; }
  1302. bool eq(const Item *item, bool binary_cmp) const;
  1303. private:
  1304. bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
  1305. public:
  1306. Settable_routine_parameter *get_settable_routine_parameter()
  1307. {
  1308. return this;
  1309. }
  1310. };
  1311. /*
  1312. This item represents user variable used as out parameter (e.g in LOAD DATA),
  1313. and it is supposed to be used only for this purprose. So it is simplified
  1314. a lot. Actually you should never obtain its value.
  1315. The only two reasons for this thing being an Item is possibility to store it
  1316. in List<Item> and desire to place this code somewhere near other functions
  1317. working with user variables.
  1318. */
  1319. class Item_user_var_as_out_param :public Item
  1320. {
  1321. LEX_STRING name;
  1322. user_var_entry *entry;
  1323. public:
  1324. Item_user_var_as_out_param(LEX_STRING a) : name(a)
  1325. { set_name(a.str, 0, system_charset_info); }
  1326. /* We should return something different from FIELD_ITEM here */
  1327. enum Type type() const { return STRING_ITEM;}
  1328. double val_real();
  1329. longlong val_int();
  1330. String *val_str(String *str);
  1331. my_decimal *val_decimal(my_decimal *decimal_buffer);
  1332. /* fix_fields() binds variable name with its entry structure */
  1333. bool fix_fields(THD *thd, Item **ref);
  1334. virtual void print(String *str, enum_query_type query_type);
  1335. void set_null_value(CHARSET_INFO* cs);
  1336. void set_value(const char *str, uint length, CHARSET_INFO* cs);
  1337. };
  1338. /* A system variable */
  1339. #define GET_SYS_VAR_CACHE_LONG 1
  1340. #define GET_SYS_VAR_CACHE_DOUBLE 2
  1341. #define GET_SYS_VAR_CACHE_STRING 4
  1342. class Item_func_get_system_var :public Item_func
  1343. {
  1344. sys_var *var;
  1345. enum_var_type var_type, orig_var_type;
  1346. LEX_STRING component;
  1347. longlong cached_llval;
  1348. double cached_dval;
  1349. String cached_strval;
  1350. my_bool cached_null_value;
  1351. query_id_t used_query_id;
  1352. uchar cache_present;
  1353. public:
  1354. Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
  1355. LEX_STRING *component_arg, const char *name_arg,
  1356. size_t name_len_arg);
  1357. enum Functype functype() const { return GSYSVAR_FUNC; }
  1358. void update_null_value();
  1359. void fix_length_and_dec();
  1360. void print(String *str, enum_query_type query_type);
  1361. bool const_item() const { return true; }
  1362. table_map used_tables() const { return 0; }
  1363. enum Item_result result_type() const;
  1364. enum_field_types field_type() const;
  1365. double val_real();
  1366. longlong val_int();
  1367. String* val_str(String*);
  1368. /* TODO: fix to support views */
  1369. const char *func_name() const { return "get_system_var"; }
  1370. /**
  1371. Indicates whether this system variable is written to the binlog or not.
  1372. Variables are written to the binlog as part of "status_vars" in
  1373. Query_log_event, as an Intvar_log_event, or a Rand_log_event.
  1374. @return true if the variable is written to the binlog, false otherwise.
  1375. */
  1376. bool is_written_to_binlog();
  1377. bool eq(const Item *item, bool binary_cmp) const;
  1378. void cleanup();
  1379. };
  1380. class Item_func_inet_aton : public Item_int_func
  1381. {
  1382. public:
  1383. Item_func_inet_aton(Item *a) :Item_int_func(a) {}
  1384. longlong val_int();
  1385. const char *func_name() const { return "inet_aton"; }
  1386. void fix_length_and_dec() { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
  1387. };
  1388. /* for fulltext search */
  1389. #include <ft_global.h>
  1390. class Item_func_match :public Item_real_func
  1391. {
  1392. public:
  1393. uint key, flags;
  1394. bool join_key;
  1395. DTCollation cmp_collation;
  1396. FT_INFO *ft_handler;
  1397. TABLE *table;
  1398. Item_func_match *master; // for master-slave optimization
  1399. Item *concat_ws; // Item_func_concat_ws
  1400. String value; // value of concat_ws
  1401. String search_value; // key_item()'s value converted to cmp_collation
  1402. Item_func_match(List<Item> &a, uint b): Item_real_func(a), key(0), flags(b),
  1403. join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { }
  1404. void cleanup()
  1405. {
  1406. DBUG_ENTER("Item_func_match");
  1407. Item_real_func::cleanup();
  1408. if (!master && ft_handler)
  1409. ft_handler->please->close_search(ft_handler);
  1410. ft_handler= 0;
  1411. concat_ws= 0;
  1412. table= 0; // required by Item_func_match::eq()
  1413. DBUG_VOID_RETURN;
  1414. }
  1415. enum Functype functype() const { return FT_FUNC; }
  1416. const char *func_name() const { return "match"; }
  1417. void update_used_tables() {}
  1418. table_map not_null_tables() const { return 0; }
  1419. bool fix_fields(THD *thd, Item **ref);
  1420. bool eq(const Item *, bool binary_cmp) const;
  1421. /* The following should be safe, even if we compare doubles */
  1422. longlong val_int() { DBUG_ASSERT(fixed == 1); return val_real() != 0.0; }
  1423. double val_real();
  1424. virtual void print(String *str, enum_query_type query_type);
  1425. bool fix_index();
  1426. void init_search(bool no_order);
  1427. };
  1428. class Item_func_bit_xor : public Item_func_bit
  1429. {
  1430. public:
  1431. Item_func_bit_xor(Item *a, Item *b) :Item_func_bit(a, b) {}
  1432. longlong val_int();
  1433. const char *func_name() const { return "^"; }
  1434. };
  1435. class Item_func_is_free_lock :public Item_int_func
  1436. {
  1437. String value;
  1438. public:
  1439. Item_func_is_free_lock(Item *a) :Item_int_func(a) {}
  1440. longlong val_int();
  1441. const char *func_name() const { return "is_free_lock"; }
  1442. void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
  1443. };
  1444. class Item_func_is_used_lock :public Item_int_func
  1445. {
  1446. String value;
  1447. public:
  1448. Item_func_is_used_lock(Item *a) :Item_int_func(a) {}
  1449. longlong val_int();
  1450. const char *func_name() const { return "is_used_lock"; }
  1451. void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
  1452. };
  1453. /* For type casts */
  1454. enum Cast_target
  1455. {
  1456. ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
  1457. ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR,
  1458. ITEM_CAST_DECIMAL
  1459. };
  1460. class Item_func_row_count :public Item_int_func
  1461. {
  1462. public:
  1463. Item_func_row_count() :Item_int_func() {}
  1464. longlong val_int();
  1465. const char *func_name() const { return "row_count"; }
  1466. void fix_length_and_dec() { decimals= 0; maybe_null=0; }
  1467. };
  1468. /*
  1469. *
  1470. * Stored FUNCTIONs
  1471. *
  1472. */
  1473. class sp_head;
  1474. class sp_name;
  1475. struct st_sp_security_context;
  1476. class Item_func_sp :public Item_func
  1477. {
  1478. private:
  1479. Name_resolution_context *context;
  1480. sp_name *m_name;
  1481. mutable sp_head *m_sp;
  1482. TABLE *dummy_table;
  1483. uchar result_buf[64];
  1484. /*
  1485. The result field of the concrete stored function.
  1486. */
  1487. Field *sp_result_field;
  1488. bool execute();
  1489. bool execute_impl(THD *thd);
  1490. bool init_result_field(THD *thd);
  1491. public:
  1492. Item_func_sp(Name_resolution_context *context_arg, sp_name *name);
  1493. Item_func_sp(Name_resolution_context *context_arg,
  1494. sp_name *name, List<Item> &list);
  1495. virtual ~Item_func_sp()
  1496. {}
  1497. void update_used_tables();
  1498. void cleanup();
  1499. const char *func_name() const;
  1500. enum enum_field_types field_type() const;
  1501. Field *tmp_table_field(TABLE *t_arg);
  1502. void make_field(Send_field *tmp_field);
  1503. Item_result result_type() const;
  1504. longlong val_int()
  1505. {
  1506. if (execute())
  1507. return (longlong) 0;
  1508. return sp_result_field->val_int();
  1509. }
  1510. double val_real()
  1511. {
  1512. if (execute())
  1513. return 0.0;
  1514. return sp_result_field->val_real();
  1515. }
  1516. my_decimal *val_decimal(my_decimal *dec_buf)
  1517. {
  1518. if (execute())
  1519. return NULL;
  1520. return sp_result_field->val_decimal(dec_buf);
  1521. }
  1522. String *val_str(String *str)
  1523. {
  1524. String buf;
  1525. char buff[20];
  1526. buf.set(buff, 20, str->charset());
  1527. buf.length(0);
  1528. if (execute())
  1529. return NULL;
  1530. /*
  1531. result_field will set buf pointing to internal buffer
  1532. of the resul_field. Due to this it will change any time
  1533. when SP is executed. In order to prevent occasional
  1534. corruption of returned value, we make here a copy.
  1535. */
  1536. sp_result_field->val_str(&buf);
  1537. str->copy(buf);
  1538. return str;
  1539. }
  1540. virtual bool change_context_processor(uchar *cntx)
  1541. { context= (Name_resolution_context *)cntx; return FALSE; }
  1542. bool sp_check_access(THD * thd);
  1543. virtual enum Functype functype() const { return FUNC_SP; }
  1544. bool fix_fields(THD *thd, Item **ref);
  1545. void fix_length_and_dec(void);
  1546. bool is_expensive() { return 1; }
  1547. inline Field *get_sp_result_field()
  1548. {
  1549. return sp_result_field;
  1550. }
  1551. };
  1552. class Item_func_found_rows :public Item_int_func
  1553. {
  1554. public:
  1555. Item_func_found_rows() :Item_int_func() {}
  1556. longlong val_int();
  1557. const char *func_name() const { return "found_rows"; }
  1558. void fix_length_and_dec() { decimals= 0; maybe_null=0; }
  1559. };
  1560. void uuid_short_init();
  1561. class Item_func_uuid_short :public Item_int_func
  1562. {
  1563. public:
  1564. Item_func_uuid_short() :Item_int_func() {}
  1565. const char *func_name() const { return "uuid_short"; }
  1566. longlong val_int();
  1567. void fix_length_and_dec()
  1568. { max_length= 21; unsigned_flag=1; }
  1569. bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
  1570. };
  1571. Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
  1572. LEX_STRING component);
  1573. extern bool check_reserved_words(LEX_STRING *name);
  1574. extern enum_field_types agg_field_type(Item **items, uint nitems);
  1575. double my_double_round(double value, longlong dec, bool dec_unsigned,
  1576. bool truncate);
  1577. bool eval_const_cond(COND *cond);
  1578. extern bool volatile mqh_used;
  1579. #endif /* ITEM_FUNC_INCLUDED */