You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hop.apache.org by "hansva (via GitHub)" <gi...@apache.org> on 2026/09/22 15:04:12 UTC

[PR] clear cache button code hardening, fixes #3312 (hop)

hansva opened a new pull request, #8541:
URL: https://github.com/apache/hop/pull/8541

   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   - [ ] Run `mvn clean install apache-rat:check` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
   - [ ] If you have a group of commits related to the same change, please squash your commits into one and force push your branch using `git rebase -i`.
   - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable.
   
   To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
   - [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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: issues-unsubscribe@hop.apache.org

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


Re: [PR] clear cache button code hardening, fixes #3312 (hop)

Posted by "mattcasters (via GitHub)" <gi...@apache.org>.
mattcasters commented on code in PR #8541:
URL: https://github.com/apache/hop/pull/8541#discussion_r4083711259


##########
core/src/main/java/org/apache/hop/core/database/SqlQueryClassifier.java:
##########
@@ -153,6 +202,36 @@ public static String statementVerb(String sql) {
     return first;
   }
 
+  /**
+   * Whether a statement changes the layout of a table or a view, which makes any row metadata
+   * cached for that connection unreliable.
+   *
+   * @param sql one statement, comments allowed
+   * @return {@code true} for statements such as {@code ALTER TABLE ...}, {@code DROP TABLE IF
+   *     EXISTS ...} or {@code CREATE OR REPLACE VIEW ...}
+   */
+  public static boolean isSchemaChange(String sql) {
+    if (Utils.isEmpty(sql)) {
+      return false;
+    }
+    int i = skipTrivia(sql, 0);
+    String keyword = keywordAt(sql, i);
+    if (keyword == null || !SCHEMA_CHANGE_VERBS.contains(keyword)) {
+      return false;
+    }
+    i = skipKeyword(sql, i);
+    while ((keyword = keywordAt(sql, i)) != null) {
+      if (SCHEMA_CHANGE_OBJECTS.contains(keyword)) {
+        return true;
+      }
+      if (!SCHEMA_CHANGE_MODIFIERS.contains(keyword)) {

Review Comment:
   **[suggestion]** `isSchemaChange` returns false on the first token that is neither an object type nor a listed modifier, so the usual MySQL/MariaDB view statement never clears the cache.
   
   `SHOW CREATE VIEW` / `mysqldump` emit `CREATE ALGORITHM=UNDEFINED DEFINER=\`root\`@\`localhost\` SQL SECURITY DEFINER VIEW v AS SELECT ...`. `ALGORITHM` is not in `SCHEMA_CHANGE_MODIFIERS`, and `keywordAt` stops at `=`, so the next lookup is not a keyword and this returns false at the end of the loop even if `ALGORITHM` were added to the set. The same early return misses bare words in `SQL SECURITY DEFINER` and Oracle forms that are not in the set (`CREATE OR REPLACE NOFORCE EDITIONABLE VIEW`, `CREATE OR REPLACE EDITIONING VIEW`). Plain `CREATE OR REPLACE VIEW` is covered, and this is not a regression against `startsWith("CREATE TABLE")`, but `execStatement` will keep the previous view layout cached after these statements.
   
   **Suggestion:** While scanning the prefix, skip a `keyword = value` clause (value is a keyword, number, or quoted identifier; also accept MySQL `` `user`@`host` ``) instead of aborting, and treat `ALGORITHM`, `DEFINER`, `SQL`, `SECURITY`, `INVOKER`, `UNDEFINED`, `MERGE`, `TEMPTABLE`, `NOFORCE`, and `EDITIONING` as modifiers. Add a test for the `SHOW CREATE VIEW` text, not only `CREATE OR REPLACE VIEW`.
   



-- 
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: issues-unsubscribe@hop.apache.org

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


Re: [PR] clear cache button code hardening, fixes #3312 (hop)

Posted by "hansva (via GitHub)" <gi...@apache.org>.
hansva commented on PR #8541:
URL: https://github.com/apache/hop/pull/8541#issuecomment-5796551674

   Fixed all remarks


-- 
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: issues-unsubscribe@hop.apache.org

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


Re: [PR] clear cache button code hardening, fixes #3312 (hop)

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


-- 
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: issues-unsubscribe@hop.apache.org

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