Skip to content

fix: walk the LIKE and WHERE filters of SHOW in StatementFeatureVisitor - #2947

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:show-filter-features
Nov 21, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:show-filter-features

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

StatementFeatureVisitor sends SHOW TABLES, SHOW TABLE STATUS, SHOW COLUMNS, SHOW INDEX and the MySQL SHOW statements (DATABASES, VARIABLES, STATUS, PROCEDURE STATUS, TRIGGERS, COLLATION, ...) straight to metadataOnly(), which never looks at their LIKE / WHERE filter. MySQL evaluates that filter like a SELECT condition, stored functions that write and subqueries included, so SHOW TABLES WHERE purge_audit() = 0 came back as certain=[RETURNS_RESULT_SET] with mayModifyData() == false and no unresolved reference and passed the read-only guard in usage.rst, while SELECT purge_audit() leaves MODIFIES_DATA possible with unresolved=[purge_audit]. A subquery there (SHOW TABLES WHERE Tables_in_db IN (SELECT a FROM t)) was not reported as READS_DATA either. I found it while checking which expression positions keep a function out of the purity check, next to the SET / DECLARE cases from #2935; the filters are reachable since the ShowFilter model of #2916. The five visit methods now walk the filter (getFilter(), or getWhereCondition() for ShowIndexStatement) with the expression visitor after metadataOnly() has claimed the top level, so a subquery there adds no second result set. The new functionIsChecked and showFilterSubqueryIsRead cases fail before (7 failures) and pass after; spotlessCheck, Checkstyle, PMD, SpotBugs and checkGrammarAmbiguity pass, and the only other ./gradlew check failures locally are 33 Mockito inline-mock-maker init errors in the mock-based tests and 2 AccessDeniedExceptions from ParserKeywordsUtilsTest writing its grammar temp file, both environment problems on this machine that do not touch the visitor.

@manticore-projects
manticore-projects merged commit 702e79b into JSQLParser:master Nov 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants