[ https://issues.apache.org/jira/browse/PHOENIX-3396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15602805#comment-15602805 ]
Jan Fernando commented on PHOENIX-3396: --------------------------------------- [~giacomotaylor] Was there a reason this works differently with non-PK and PK fields. I only see this issue if a fields is part of the PK. I think the behavior should be consistent in all cases. > Valid Multi-byte strings whose total byte size is greater than the max char > limit cannot be inserted into VARCHAR fields in the PK > ----------------------------------------------------------------------------------------------------------------------------------- > > Key: PHOENIX-3396 > URL: https://issues.apache.org/jira/browse/PHOENIX-3396 > Project: Phoenix > Issue Type: Bug > Reporter: Jan Fernando > > 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. > -- This message was sent by Atlassian JIRA (v6.3.4#6332)