You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StatementFeatureVisitor purity check misses AnalyticExpression (f(x) OVER ..) and TranscodingFunction (CONVERT .. USING) #2575
Statement.getFeatures(pureFunctions) is meant to report every function the caller cannot prove pure, so a read-only guard can refuse it (usage.rst, "Proven, possible, excluded"). Two expression kinds never reach that check, so a guard built on getUnresolvedReferences() / mayModifyData() lets them through.
Version:com.manticore-projects.jsqlformatter:jsqlparser:5.4.351-SNAPSHOT (build 5.4.351-20260910.100601-1), same on master at b2115ac8.
Reproduce
Predicate<String> nothingIsPure = name -> false;
// window-form call: the name pg_sleep is never testedStatementFeaturesf = CCJSqlParserUtil.parse("SELECT pg_sleep(1) OVER () FROM t").getFeatures(nothingIsPure);
f.getUnresolvedReferences(); // [] expected [pg_sleep]f.mayModifyData(); // false expected true// CONVERT .. USING: samef = CCJSqlParserUtil.parse("SELECT CONVERT(name USING utf8) FROM t").getFeatures(nothingIsPure);
f.getUnresolvedReferences(); // [] expected [convert]// for comparison, the plain call is reportedf = CCJSqlParserUtil.parse("SELECT pg_sleep(1) FROM t").getFeatures(nothingIsPure);
f.getUnresolvedReferences(); // [pg_sleep]
Cause
StatementFeatureVisitor.FeatureExpressionVisitor overrides visit(Function) (StatementFeatureVisitor.java:836-848) and the table-function case, but not visit(AnalyticExpression) (getName()) and visit(TranscodingFunction). An AnalyticExpression wraps the call itself; its getExpression() is the argument, not a Function, so the inherited traversal never produces a Function node for the name.
Suggestion
Treat AnalyticExpression.getName() like a Function name in the purity check, and TranscodingFunction as a function named convert (or its getTranscodingName()), so mayModifyData() and getUnresolvedReferences() cover f(x) OVER (..) and CONVERT(x USING y). A negative test in StatementFeatureVisitorTest next to unprovenFunctionIsPossibleNotCertain would pin it.
Activity