Skip to content
  • Karthik Kamath's avatar
    06add7ef
    BUG#26475237: "INCORRECT STRING VALUE" IS DIPLAYED INSTEAD · 06add7ef
    Karthik Kamath authored
                  OF "DATA TOO LONG" SOMETIMES.
    
    ANALYSIS:
    =========
    Consider a table having a TEXT type field. Inserting a
    valid string consisting of multi-byte characters, the
    length of which exceeds the allowed column size, could
    result in the server reporting an incorrect error.
    
    Before we insert a string into the field, we check if the
    input byte sequence is a valid character string of a given
    charset or not (i.e check if the string is "well formed").
    
    In the current scenario, length of string is 256, which
    exceeds the allowed column size (255 for TINYTEXT). In the
    given example, the last multi-byte character in the string
    occupies the 255th and 256th byte position. Since we are
    restricting the string length to 255, we will truncate only
    255 bytes from the original string, thus breaking the
    sequence of the last character. So the result of
    'well-formed'ness check will imply that only 254 characters
    in the string are well formed. This leads to the server
    incorrectly reporting a "Incorrect string value" error.
    
    FIX:
    ====
    We are introducing an extra check after the initial
    'well-formed'ness check, which will confirm whether the
    string is actually not 'well-formed' or if length of the
    string exceeded the allowed limit. That is, If the initial
    check suggests that the string is not 'well-formed' but the
    original string was truncated in the middle of a character,
    we confirm if the string was actually 'well-formed' in case
    the truncation hadn't taken place. Thus, for the current
    scenario, "Data too long" error is reported.
    
    Change-Id: I0e93f59b762f33ad61d56e36141edcfaebc23bf1
    06add7ef
    BUG#26475237: "INCORRECT STRING VALUE" IS DIPLAYED INSTEAD
    Karthik Kamath authored
                  OF "DATA TOO LONG" SOMETIMES.
    
    ANALYSIS:
    =========
    Consider a table having a TEXT type field. Inserting a
    valid string consisting of multi-byte characters, the
    length of which exceeds the allowed column size, could
    result in the server reporting an incorrect error.
    
    Before we insert a string into the field, we check if the
    input byte sequence is a valid character string of a given
    charset or not (i.e check if the string is "well formed").
    
    In the current scenario, length of string is 256, which
    exceeds the allowed column size (255 for TINYTEXT). In the
    given example, the last multi-byte character in the string
    occupies the 255th and 256th byte position. Since we are
    restricting the string length to 255, we will truncate only
    255 bytes from the original string, thus breaking the
    sequence of the last character. So the result of
    'well-formed'ness check will imply that only 254 characters
    in the string are well formed. This leads to the server
    incorrectly reporting a "Incorrect string value" error.
    
    FIX:
    ====
    We are introducing an extra check after the initial
    'well-formed'ness check, which will confirm whether the
    string is actually not 'well-formed' or if length of the
    string exceeded the allowed limit. That is, If the initial
    check suggests that the string is not 'well-formed' but the
    original string was truncated in the middle of a character,
    we confirm if the string was actually 'well-formed' in case
    the truncation hadn't taken place. Thus, for the current
    scenario, "Data too long" error is reported.
    
    Change-Id: I0e93f59b762f33ad61d56e36141edcfaebc23bf1
Loading