Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-3396

Valid Multi-byte strings whose total byte size is greater than the max char limit cannot be inserted into VARCHAR fields in the PK

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 4.9.0
    • None
    • None

    Description

      We allow users to insert multi-byte characters into VARCHAR columns that are part of a table or view's PK. We noticed that Strings that had a valid number of characters (i.e. were less than than max char length) were causing upserts to fail with with the following exception:

      Caused by: java.sql.SQLException: ERROR 206 (22003): The data exceeds the max capacity for the data type. MYTABLE may not exceed 100 bytes ('緓嗝加슪䐤㵞靹疸芬꽣汚佃䘯茵䖻埾巆蕤ⱅ澴粖蟤य褻酃岤豦팑薰鄩脼ժ끦碉ķ窯尬룗㚈Ꝝ퍛爃됰灁ᄠࢥ')

      There appears to be an issue in PTableImpl.newKey() where we check the maxLength in chars against the byte length in this check:

      maxLength != null && !type.isArrayType() && byteValue.length > maxLength

      To reproduce you can run the following:

      CREATE TABLE TEXT_FIELD_VALIDATION_PK (TEXT VARCHAR(20), TEXT1 VARCHAR(20) CONSTRAINT PK PRIMARY KEY (TEXT));

      UPSERT INTO TEXT_FIELD_VALIDATION_PK VALUES ('澴粖蟤य褻酃岤豦팑薰鄩脼ժ끦碉碉碉碉碉碉', 'test');

      The string we insert into the column TEXT is 20 chars, but greater than 20 bytes.

      Attachments

        1. PHOENIX-3396.patch
          43 kB
          James R. Taylor
        2. PHOENIX-3396_v2.patch
          44 kB
          James R. Taylor

        Activity

          People

            jamestaylor James R. Taylor
            jfernando_sfdc Jan Fernando
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: