You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "lowka (via GitHub)" <gi...@apache.org> on 2025/02/03 12:38:23 UTC
Re: [PR] IGNITE-24152 Sql. Dml. Varbinary value in dynamic parameter is truncated if its length is larger than 65536 [ignite-3]
lowka commented on code in PR #5145:
URL: https://github.com/apache/ignite-3/pull/5145#discussion_r1939301095
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -735,6 +743,15 @@ public static <RowT> RowT validateCharactersOverflowAndTrimIfPossible(
RelDataType colType = rowType.getFieldList().get(i).getType();
Object data = rowHandler.get(i, row);
+ if (BINARY_TYPES.contains(colType.getSqlTypeName()) && data != null) {
+ assert data instanceof ByteString;
+ assert colType.getPrecision() != RelDataType.PRECISION_NOT_SPECIFIED;
+
+ if (((ByteString) data).length() > colType.getPrecision()) {
+ throw new SqlException(STMT_VALIDATION_ERR, format("Value too long for type binary({})", colType.getPrecision()));
Review Comment:
Perhaps we should use the same error message we use in case of string errors:
> "Value too long for type: " + colType
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -735,6 +743,15 @@ public static <RowT> RowT validateCharactersOverflowAndTrimIfPossible(
RelDataType colType = rowType.getFieldList().get(i).getType();
Object data = rowHandler.get(i, row);
+ if (BINARY_TYPES.contains(colType.getSqlTypeName()) && data != null) {
+ assert data instanceof ByteString;
+ assert colType.getPrecision() != RelDataType.PRECISION_NOT_SPECIFIED;
+
+ if (((ByteString) data).length() > colType.getPrecision()) {
+ throw new SqlException(STMT_VALIDATION_ERR, format("Value too long for type binary({})", colType.getPrecision()));
+ }
+ }
+
// Skip null values and non-character types.
if (!CHAR_TYPES.contains(colType.getSqlTypeName()) || data == null) {
Review Comment:
I think it would be better just to skip null values first, and only it is not null do type checks.
// if data is null -> skip
// if binary types -> ...
// if char types -> ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org