-
Knut Anders Hatlen authored
The Protocol class has functions for sending values of different types to the client, one function per type. When sending values that come from an Item, the function for the corresponding type is called. When sending a value from a Field, different Protocol functions are called depending on which protocol is used. If the text protocol is used, Field::send_text() converts the value to string and calls the Protocol function that sends a string value to the client. If the binary protocol is used, Field::send_binary() calls the Protocol function for the actual type of the value, without converting it to string first. This causes inconsistencies between the text protocol and the binary protocol, and also inconsistencies within the text protocol between values that come from Items and values from Fields. This patch merges Field::send_text() and Field::send_binary() into a single function, Field::send_to_protocol(). This function behaves as the old Field::send_binary() and calls the Protocol function that corresponds to the value that is to be sent, without converting it to string first. When the text protocol is used, the value is still converted to a string, but the conversion happens in the Protocol_text class. The Protocol_text class is already capable of converting values to strings, but it is not aware of the ZEROFILL option of numeric types. A new zerofill argument was therefore added to the functions for sending numeric values. The argument is ignored by other protocols than Protocol_text, as they leave it to the clients to format the values. Protocol_text::store(float, ...) used to promote the float argument to double before converting it to string, which could make the returned value presented in higher precision than warranted (like 2.299999952316284 instead of 2.3). It is changed to format the float argument as a float, to be consistent with how it was previously handled for Fields, and with how the binary protocol handles it. Field_time_common::send_binary() has code that normalizes hours and days in the MYSQL_TIME struct. This normalization is only needed by the binary protocol (in fact, the text protocol does not expect it), and it is done redundantly in Protocol_binary::store_time(). The code is removed from Field_time_common, so that it is only performed by Protocol_binary. The Protocol_callback class has a flag which controls whether fields are sent as strings or as native types. This flag is kept, but the conversion from native types to string is moved into Protocol_callback::store_field(). Some tests results were changed, mainly because the formatting of floats resulting from Items changed in the text protocol to match floats from Fields and floats in general in the binary protocol. Some test cases which were previously disabled for the binary protocol because they gave different results on text and binary, have been enabled, as they now produce the same result with both protocols. Change-Id: I788a10eb8eb7ec2fe3d4866d0a50dd08c0ac3255
Knut Anders Hatlen authoredThe Protocol class has functions for sending values of different types to the client, one function per type. When sending values that come from an Item, the function for the corresponding type is called. When sending a value from a Field, different Protocol functions are called depending on which protocol is used. If the text protocol is used, Field::send_text() converts the value to string and calls the Protocol function that sends a string value to the client. If the binary protocol is used, Field::send_binary() calls the Protocol function for the actual type of the value, without converting it to string first. This causes inconsistencies between the text protocol and the binary protocol, and also inconsistencies within the text protocol between values that come from Items and values from Fields. This patch merges Field::send_text() and Field::send_binary() into a single function, Field::send_to_protocol(). This function behaves as the old Field::send_binary() and calls the Protocol function that corresponds to the value that is to be sent, without converting it to string first. When the text protocol is used, the value is still converted to a string, but the conversion happens in the Protocol_text class. The Protocol_text class is already capable of converting values to strings, but it is not aware of the ZEROFILL option of numeric types. A new zerofill argument was therefore added to the functions for sending numeric values. The argument is ignored by other protocols than Protocol_text, as they leave it to the clients to format the values. Protocol_text::store(float, ...) used to promote the float argument to double before converting it to string, which could make the returned value presented in higher precision than warranted (like 2.299999952316284 instead of 2.3). It is changed to format the float argument as a float, to be consistent with how it was previously handled for Fields, and with how the binary protocol handles it. Field_time_common::send_binary() has code that normalizes hours and days in the MYSQL_TIME struct. This normalization is only needed by the binary protocol (in fact, the text protocol does not expect it), and it is done redundantly in Protocol_binary::store_time(). The code is removed from Field_time_common, so that it is only performed by Protocol_binary. The Protocol_callback class has a flag which controls whether fields are sent as strings or as native types. This flag is kept, but the conversion from native types to string is moved into Protocol_callback::store_field(). Some tests results were changed, mainly because the formatting of floats resulting from Items changed in the text protocol to match floats from Fields and floats in general in the binary protocol. Some test cases which were previously disabled for the binary protocol because they gave different results on text and binary, have been enabled, as they now produce the same result with both protocols. Change-Id: I788a10eb8eb7ec2fe3d4866d0a50dd08c0ac3255
Loading