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 2023/10/12 10:53:39 UTC
[PR] IGNITE-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
lowka opened a new pull request, #2683:
URL: https://github.com/apache/ignite-3/pull/2683
Update validation in SqlQueryProcessor to disallow transaction control statements when explicit transaction is present.
https://issues.apache.org/jira/browse/IGNITE-20444
---
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan merged PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358371581
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358261897
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
Review Comment:
Checking for an explicit transaction seems useless, because the user is currently prohibited from executing TX_CONTROL in any way. I suggest to make this check in https://issues.apache.org/jira/browse/IGNITE-20463.
I'm not sure what the Script Processor will look like and I think this part will change somehow in any case.
But instead of the current changes, what do you think about the following?
```
if (!allowedTypes.contains(queryType)) {
if (parsedResult.queryType() == SqlQueryType.TX_CONTROL)
...throw "Transaction control statement can not be executed as an independent statement"
... old code
String message = format("Invalid SQL statement type. Expected {} but got {}", allowedTypes, queryType);
```
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358261897
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
Review Comment:
Checking for an explicit transaction seems useless, because the user is currently prohibited from executing TX_CONTROL in any way. I suggest to make this check in https://issues.apache.org/jira/browse/IGNITE-20463.
I'm not sure what the Script Processor will look like and I think this part will change somehow in any case.
But instead of the current changes, what do you think about something like this?
```
if (!allowedTypes.contains(queryType)) {
String message = parsedResult.queryType() == SqlQueryType.TX_CONTROL
? Transaction control statement can not be executed as an independent statement"
: format("Invalid SQL statement type. Expected {} but got {}", allowedTypes, queryType);
... old code
```
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358069571
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
Sorry, I missed "complementOf" :pensive:
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358315667
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
Review Comment:
>Checking for an explicit transaction seems useless, because the user is currently prohibited from executing TX_CONTROL in any way
Control statement check can be moved to the caller method because `validateParsedStatement` is going to be used by execute script method.
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358055617
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
For me this doesn't match with current PR description "Add restrictions for execution tx related statements with single statement mode" :thinking_face:
I thought that the main goal is to throw exception if SqlQueryProcessor#querySingle processing tx-related statements, but may be I missing something?
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358322878
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
Review Comment:
> I'm not sure what the Script Processor will look like and I think this part will change somehow in any case.
It will. But I think it better to have a messages like that give a descriptive error message. Instead of generic `Expected ... but got ...` which should be clearly improved.
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryProcessor.java:
##########
@@ -559,11 +559,24 @@ public MetricManager metricManager() {
private static void validateParsedStatement(
QueryContext context,
ParsedResult parsedResult,
+ @Nullable InternalTransaction outerTx,
Object[] params
) {
Set<SqlQueryType> allowedTypes = context.allowedQueryTypes();
SqlQueryType queryType = parsedResult.queryType();
+ if (parsedResult.queryType() == SqlQueryType.TX_CONTROL) {
+ if (outerTx != null) {
Review Comment:
> I'm not sure what the Script Processor will look like and I think this part will change somehow in any case.
It will. But I think it better to have a messages like that give a descriptive error message. Instead of generic
`Expected ... but got ...` which should be clearly improved.
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358060801
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
@xtern
I think you missed tests cases in `testTxControlStatementsAreNotAllowdWithExplicitTransactions`
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358059130
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
@zstan
can you clarify what the main goal of the ticket is?
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358055617
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
For me this doesn't match with current PR description "Add restrictions for execution tx related statements with single statement mode" :thinking:
I thought that the main goal is to throw exception if SqlQueryProcessor#querySingle processing tx-related statements, but may be I missing something?
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358059130
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
@zstan
can you clarify what the main goal of the ticket is?
--
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-20444 Sql. Add restrictions for execution tx related statements with single statement mode [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #2683:
URL: https://github.com/apache/ignite-3/pull/2683#discussion_r1358055617
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java:
##########
@@ -33,7 +34,15 @@ public enum SqlQueryType {
DDL,
/** Explain. */
- EXPLAIN;
+ EXPLAIN,
+
+ /** Transaction control statements such as {@code START TRANSACTION}, {@code COMMIT}, etc. */
+ TX_CONTROL,
+
+ ;
+
+ /** A set of statement types that can run only in single statement mode. **/
Review Comment:
For me this doesn't match with current PR description "Add restrictions for execution tx related statements with single statement mode" :thinking:
I thought that the main goal is to throw exception if SqlQueryProcessor#querySingle processing tx-related statements, but may be I'm missing something?
--
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