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 2024/05/17 09:47:40 UTC
[PR] [IGNITE-22120] Sql. Possibility set zero length for character string type [ignite-3]
lowka opened a new pull request, #3782:
URL: https://github.com/apache/ignite-3/pull/3782
---
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1608034600
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/ColumnParams.java:
##########
@@ -234,14 +234,14 @@ private void validate() {
boolean validatePrecision = params.type.precisionAllowed();
boolean validateScale = params.type.scaleAllowed();
- boolean validateLenght = params.type.lengthAllowed();
+ boolean validateLength = params.type.lengthAllowed();
- if (validateLenght) {
+ if (validateLength) {
if (params.length() == null) {
throw new CatalogValidationException(format(ERR_COL_PARAM_DEFINITION, "Length", params.name(), params.type()));
}
- if (params.length() < 0) {
+ if (params.length() <= 0) {
Review Comment:
do we need to append additional tests for add column and alter column with "0" precision ?
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1608049048
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -655,6 +656,65 @@ public void charLimitationWithMergeUpdateOp() {
}
}
+ @Test
+ public void zeroStringsAreNotAllowed() {
+ // Char
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS CHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT '1'::CHAR(0)")
+ );
+
+ // Varchar
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS VARCHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT '1'::VARCHAR(0)")
+ );
+
+ // Binary
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type BINARY must be at least 1",
Review Comment:
I mean '.....must be at least 1' and '.....must be positive'
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1609492125
##########
modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test:
##########
@@ -4,35 +4,15 @@
# length shouldn't be negative;
statement error
-SELECT 'c'::CHAR(-1);
-
-# length shouldn't be zero;
-statement error: Length for column 'C1' of type 'STRING' must be at least 1
-CREATE TABLE t_zero(c1 CHAR(0));
-
-statement ok
-CREATE TABLE t_default(c1 CHAR);
+CREATE TABLE t_negative(c1 CHAR(-1));
-# If <length> is omitted, then a <length> of 1 (one) is implicit.
-skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-18492
+# length shouldn't be negative;
statement error
-INSERT INTO t_default VALUES('12');
-
-statement ok
-INSERT INTO t_default VALUES('1');
-
-# possibility to insert empty string
-statement ok
-INSERT INTO t_default VALUES('');
-
-
-statement ok
-CREATE TABLE t_three (c1 CHAR(3), c2 CHARACTER(3));
+SELECT 'c'::CHAR(-1);
-# MUST FAIL due to length
+# length shouldn't be zero;
skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-18492
+# https://issues.apache.org/jira/browse/IGNITE-22120
Review Comment:
Fixed.
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/ColumnParams.java:
##########
@@ -234,14 +234,14 @@ private void validate() {
boolean validatePrecision = params.type.precisionAllowed();
boolean validateScale = params.type.scaleAllowed();
- boolean validateLenght = params.type.lengthAllowed();
+ boolean validateLength = params.type.lengthAllowed();
- if (validateLenght) {
+ if (validateLength) {
if (params.length() == null) {
throw new CatalogValidationException(format(ERR_COL_PARAM_DEFINITION, "Length", params.name(), params.type()));
}
- if (params.length() < 0) {
+ if (params.length() <= 0) {
Review Comment:
Fixed.
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1609311575
##########
modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test:
##########
@@ -4,35 +4,15 @@
# length shouldn't be negative;
statement error
-SELECT 'c'::CHAR(-1);
-
-# length shouldn't be zero;
-statement error: Length for column 'C1' of type 'STRING' must be at least 1
-CREATE TABLE t_zero(c1 CHAR(0));
-
-statement ok
-CREATE TABLE t_default(c1 CHAR);
+CREATE TABLE t_negative(c1 CHAR(-1));
-# If <length> is omitted, then a <length> of 1 (one) is implicit.
-skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-18492
+# length shouldn't be negative;
statement error
-INSERT INTO t_default VALUES('12');
-
-statement ok
-INSERT INTO t_default VALUES('1');
-
-# possibility to insert empty string
-statement ok
-INSERT INTO t_default VALUES('');
-
-
-statement ok
-CREATE TABLE t_three (c1 CHAR(3), c2 CHARACTER(3));
+SELECT 'c'::CHAR(-1);
-# MUST FAIL due to length
+# length shouldn't be zero;
skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-18492
+# https://issues.apache.org/jira/browse/IGNITE-22120
Review Comment:
we cover the case by the ticket. It shouldn't be ignored
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1608034305
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java:
##########
@@ -527,6 +527,33 @@ public void tableStorageProfileWithCustomZoneExplicitProfile() {
sql("DROP ZONE ZONE1");
}
+ @Test
+ public void testStringZeroLength() {
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for column 'ID' of type 'STRING' must be non-negative",
Review Comment:
```suggestion
"Length for column 'ID' of type 'STRING' must be positive",
```
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1608039615
##########
modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test:
##########
@@ -7,9 +7,7 @@ statement error
CREATE TABLE t_negative(c1 CHAR(-1));
# length shouldn't be zero;
-skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-22120
-statement ok
+statement error: Length for column 'C1' of type 'STRING' must be non-negative
Review Comment:
positive
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1608038141
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -655,6 +656,65 @@ public void charLimitationWithMergeUpdateOp() {
}
}
+ @Test
+ public void zeroStringsAreNotAllowed() {
+ // Char
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS CHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT '1'::CHAR(0)")
+ );
+
+ // Varchar
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS VARCHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT '1'::VARCHAR(0)")
+ );
+
+ // Binary
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type BINARY must be at least 1",
Review Comment:
it looks strange that we have different messages for different types. Looks like we should have one template.
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1609996706
##########
modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test:
##########
@@ -7,9 +7,7 @@ statement error
CREATE TABLE t_negative(c1 CHAR(-1));
# length shouldn't be zero;
-skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-22120
-statement ok
+statement error: Length for column 'C1' of type 'STRING' must be non-negative
Review Comment:
Fixed
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan merged PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782
--
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
Re: [PR] IGNITE-22120: Sql. Possibility set zero length for character string type [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3782:
URL: https://github.com/apache/ignite-3/pull/3782#discussion_r1606934988
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -655,6 +656,65 @@ public void charLimitationWithMergeUpdateOp() {
}
}
+ @Test
+ public void zeroStringsAreNotAllowed() {
+ // Char
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS CHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type CHAR must be at least 1",
+ () -> sql("SELECT '1'::CHAR(0)")
+ );
+
+ // Varchar
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT CAST(1 AS VARCHAR(0))")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Length for type VARCHAR must be at least 1",
+ () -> sql("SELECT '1'::VARCHAR(0)")
Review Comment:
Should we check an empty string?
--
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