You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "ilyasahsan123 (via GitHub)" <gi...@apache.org> on 2023/12/31 22:56:10 UTC

[PR] Support Create Trigger with Body [shardingsphere]

ilyasahsan123 opened a new pull request, #29610:
URL: https://github.com/apache/shardingsphere/pull/29610

   Fixes #27119.
   
   Changes proposed in this pull request:
     - Support Create Trigger with Body
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#issuecomment-1873158743

   @ilyasahsan123 Hi, if #27119 The issue is still ongoing, please Fixes #27119 Change to Ref #27119. Thank you


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1438974232


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -280,9 +284,37 @@ autonomousTransPragma
     ;
 
 dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+    : (dmlEventElement (OR dmlEventElement)* ON viewName)
+    | (nonDmlEventElement (OR nonDmlEventElement)* ON (DATABASE | (schemaName DOT_)? SCHEMA))
     ;
 
 dmlEventElement
     : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
     ;
+
+nonDmlEventElement
+    : ALTER

Review Comment:
   ```
   CREATE TRIGGER log_errors
     AFTER SERVERERROR ON DATABASE
     BEGIN
       IF (IS_SERVERERROR (1017)) THEN
         NULL;  -- (substitute code that processes logon error)
       ELSE
         NULL;  -- (substitute code that logs error code)
       END IF;
     END;
   ```
   
   Thank you for providing the document reference. It seems that some parts of SQL should be handled by the `system_trigger` syntax parse.
   ![2024-01-01_14-29](https://github.com/apache/shardingsphere/assets/106047330/a8653025-47f6-4386-ac28-a8fb67a2bf87)
   Ref: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/CREATE-TRIGGER-statement.html#GUID-AF9E33F1-64D1-4382-A6A4-EC33C36F237B__BABHEFGE
   



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#issuecomment-1874046438

   > > > @ilyasahsan123 Hi, if #27119 The issue is still ongoing, please Fixes #27119 Change to Ref #27119. Thank you
   > > 
   > > 
   > > hi @zihaoAK47, I apologize, but I'm a bit lost. Could you please clarify what you mean?
   > 
   > Fixes will close Issues. If there are still tasks to be processed inside, we need to use Ref to reference this issue
   
   I apologize, still didn't get it. Do you mean this one?
   
   <img width="865" alt="Screenshot 2024-01-02 at 20 45 12" src="https://github.com/apache/shardingsphere/assets/14249648/69f7a292-2626-44c9-80dd-974b15d00272">
   


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1438962250


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -280,9 +284,37 @@ autonomousTransPragma
     ;
 
 dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+    : (dmlEventElement (OR dmlEventElement)* ON viewName)
+    | (nonDmlEventElement (OR nonDmlEventElement)* ON (DATABASE | (schemaName DOT_)? SCHEMA))
     ;
 
 dmlEventElement
     : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
     ;
+
+nonDmlEventElement
+    : ALTER

Review Comment:
   Can you provide a grammar diagram reference here?



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with System Trigger in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1440029677


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -279,10 +283,51 @@ autonomousTransPragma
     : PRAGMA AUTONOMOUS_TRANSACTION SEMI_
     ;
 
-dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+plsqlTriggerSource
+    : (schemaName DOT_)? triggerName sharingClause? defaultCollationClause? (simpleDmlTrigger | systemTrigger)
     ;
 
-dmlEventElement
-    : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
+simpleDmlTrigger
+    : (BEFORE | AFTER) dmlEventClause
+    ;
+
+dmlEventClause
+    : dmlEventTrigger (OR dmlEventTrigger)* ON viewName
+    ;
+
+dmlEventTrigger
+    : DELETE

Review Comment:
   Please keep these branches in one line.
   Refer code conduct - https://shardingsphere.apache.org/community/en/involved/conduct/code/.
   > If a rule’s branch is over than 5, every branch take a new line.



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#issuecomment-1873179842

   > @ilyasahsan123 Hi, if #27119 The issue is still ongoing, please Fixes #27119 Change to Ref #27119. Thank you
   
   hi @zihaoAK47, I apologize, but I'm a bit lost. Could you please clarify what you mean?


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#issuecomment-1873199118

   > > @ilyasahsan123 Hi, if #27119 The issue is still ongoing, please Fixes #27119 Change to Ref #27119. Thank you
   > 
   > hi @zihaoAK47, I apologize, but I'm a bit lost. Could you please clarify what you mean?
   
   Fixes will close Issues. If there are still tasks to be processed inside, we need to use Ref to reference this issue


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with System Trigger in Oracle [shardingsphere]

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 merged PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with System Trigger in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1440041282


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -279,10 +283,51 @@ autonomousTransPragma
     : PRAGMA AUTONOMOUS_TRANSACTION SEMI_
     ;
 
-dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+plsqlTriggerSource
+    : (schemaName DOT_)? triggerName sharingClause? defaultCollationClause? (simpleDmlTrigger | systemTrigger)
     ;
 
-dmlEventElement
-    : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
+simpleDmlTrigger
+    : (BEFORE | AFTER) dmlEventClause
+    ;
+
+dmlEventClause
+    : dmlEventTrigger (OR dmlEventTrigger)* ON viewName
+    ;
+
+dmlEventTrigger
+    : DELETE

Review Comment:
   Done. Thanks



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#issuecomment-1873050999

   hi @zihaoAK47, when you get a change, could you please check this out? thanks a bunch!


-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1439461614


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -280,9 +284,37 @@ autonomousTransPragma
     ;
 
 dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+    : (dmlEventElement (OR dmlEventElement)* ON viewName)
+    | (nonDmlEventElement (OR nonDmlEventElement)* ON (DATABASE | (schemaName DOT_)? SCHEMA))
     ;
 
 dmlEventElement
     : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
     ;
+
+nonDmlEventElement
+    : ALTER

Review Comment:
   Thanks for your suggestion, @zihaoAK47, i have updated the changes, could you please take a look? 



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support Create Trigger with Body in Oracle [shardingsphere]

Posted by "ilyasahsan123 (via GitHub)" <gi...@apache.org>.
ilyasahsan123 commented on code in PR #29610:
URL: https://github.com/apache/shardingsphere/pull/29610#discussion_r1438968177


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/PLSQL.g4:
##########
@@ -280,9 +284,37 @@ autonomousTransPragma
     ;
 
 dmlEventClause
-    : dmlEventElement (OR dmlEventElement)* ON viewName
+    : (dmlEventElement (OR dmlEventElement)* ON viewName)
+    | (nonDmlEventElement (OR nonDmlEventElement)* ON (DATABASE | (schemaName DOT_)? SCHEMA))
     ;
 
 dmlEventElement
     : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?
     ;
+
+nonDmlEventElement
+    : ALTER

Review Comment:
   here is the reference:
   https://docs.oracle.com/cd/B13789_01/server.101/b10759/statements_7004.htm
   
   <img width="1726" alt="Screenshot 2024-01-01 at 13 12 59" src="https://github.com/apache/shardingsphere/assets/14249648/53d88b82-1085-46b9-8acd-130696a0da2f">
   
   Please let me know, if you have any concern.



-- 
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@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org