You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2021/02/23 05:40:13 UTC
[phoenix] branch 5.1 updated: PHOENIX-6396 PChar illegal data
exception should not contain value
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.1 by this push:
new e6878a2 PHOENIX-6396 PChar illegal data exception should not contain value
e6878a2 is described below
commit e6878a2f5b6c7f4e1e27ea896ac55bcc1226f4e9
Author: Xinyi Yan <ya...@apache.org>
AuthorDate: Mon Feb 22 17:02:53 2021 -0800
PHOENIX-6396 PChar illegal data exception should not contain value
---
.../src/main/java/org/apache/phoenix/schema/types/PChar.java | 10 +++++-----
.../java/org/apache/phoenix/compile/QueryCompilerTest.java | 4 +++-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
index 560d8f8..4f63003 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
@@ -85,7 +85,7 @@ public class PChar extends PDataType<String> {
}
byte[] b = PVarchar.INSTANCE.toBytes(object);
if (b.length != ((String) object).length()) {
- throw newIllegalDataException("CHAR types may only contain single byte characters (" + object + ")");
+ throw newIllegalDataException("CHAR types may only contain single byte characters.");
}
return b;
}
@@ -97,7 +97,7 @@ public class PChar extends PDataType<String> {
}
int len = PVarchar.INSTANCE.toBytes(object, bytes, offset);
if (len != ((String) object).length()) {
- throw newIllegalDataException("CHAR types may only contain single byte characters (" + object + ")");
+ throw newIllegalDataException("CHAR types may only contain single byte characters.");
}
return len;
}
@@ -118,7 +118,7 @@ public class PChar extends PDataType<String> {
// TODO: UTF-8 decoder that will invert as it decodes
String s = Bytes.toString(bytes, offset, length);
if (length != s.length()) {
- throw newIllegalDataException("CHAR types may only contain single byte characters (" + s + ")");
+ throw newIllegalDataException("CHAR types may only contain single byte characters.");
}
return s;
}
@@ -142,7 +142,7 @@ public class PChar extends PDataType<String> {
Integer actualMaxLength, Integer actualScale, SortOrder actualModifier,
Integer desiredMaxLength, Integer desiredScale, SortOrder expectedModifier) {
if (o != null && actualType.equals(PVarchar.INSTANCE) && ((String)o).length() != ptr.getLength()) {
- throw newIllegalDataException("CHAR types may only contain single byte characters (" + o + ")");
+ throw newIllegalDataException("CHAR types may only contain single byte characters.");
}
super.coerceBytes(ptr, o, actualType, actualMaxLength, actualScale, actualModifier, desiredMaxLength, desiredScale, expectedModifier);
if (ptr.getLength() > 0 && desiredMaxLength != null &&
@@ -201,7 +201,7 @@ public class PChar extends PDataType<String> {
@Override
public Object toObject(String value) {
if (StringUtil.hasMultiByteChars(value)) {
- throw newIllegalDataException("CHAR types may only contain single byte characters (" + value + ")");
+ throw newIllegalDataException("CHAR types may only contain single byte characters.");
}
return value;
}
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
index 5f0f546..16f9489 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
@@ -631,6 +631,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
@Test
public void testUpsertMultiByteIntoChar() throws Exception {
+ String value = "繰り返し曜日マスク";
try {
// Select non agg column in aggregate query
String query = "upsert into ATABLE VALUES (?, ?, ?)";
@@ -639,7 +640,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
try {
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, "00D300000000XHP");
- statement.setString(2, "繰り返し曜日マスク");
+ statement.setString(2, value);
statement.setInt(3, 1);
statement.executeUpdate();
fail();
@@ -649,6 +650,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
} catch (SQLException e) {
assertTrue(e.getMessage(), e.getMessage().contains("ERROR 201 (22000): Illegal data."));
assertTrue(e.getMessage().contains("CHAR types may only contain single byte characters"));
+ assertFalse(e.getMessage().contains(value));
}
}