Skip to content

fix: report a feature for every statement in StatementValidator - #2886

Open
tanjiroK-coder wants to merge 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:validate-unchecked-statements
Open

tanjiroK-coder wants to merge 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:validate-unchecked-statements

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

Validation only rejects what a validator reports as a Feature, and 34 statement types in StatementValidator report none, so they pass every FeaturesAllowed and database check. COPY, ATTACH/DETACH, CONNECT/DISCONNECT, PRAGMA, INSTALL/LOAD, CREATE MACRO, CREATE EXTENSION REPOSITORY, EXPORT DATA, LOAD DATA, ASSERT, PREPARE/DEALLOCATE, SAVEPOINT, LOCK, ALTER SESSION, ALTER SYSTEM, PURGE, RENAME TABLE and the Exasol IMPORT/EXPORT are still // TODO: not yet implemented, CREATE USER and SESSION return straight away, CREATE/ALTER POLICY and CREATE STATISTICS only walk their children, ROLLBACK only checks AND CHAIN, ALTER STATISTICS and ALTER ... ALL IN TABLESPACE have no override, CREATE EVENT, ALTER EVENT and body-style CREATE TRIGGER only check their body, and an UnsupportedStatement (which the parser now also returns for unmodelled CREATE forms such as CREATE LANGUAGE plperlu) is accepted as is. With FeaturesAllowed.SELECT used as a read-only gate, ALTER SYSTEM SET archive_command = '...', COPY t TO '/tmp/x', ATTACH DATABASE '/tmp/x.db' AS x, CREATE USER 'app'@'%' REQUIRE SSL and CREATE EVENT e ON SCHEDULE EVERY 1 DAY DO SELECT 1 all validate without errors. I found them by running the SQL literals of the test suite through validation with an empty FeaturesAllowed and listing the statement types that still came back clean; after this change none does. Each statement now reports its own feature: a new constant where none existed, alterTable for RENAME TABLE, alterTablespace for ALTER ... ALL IN TABLESPACE, export for EXPORT DATA, the so far unused imprt and export for Exasol, and allowUnsupportedStatements for an UnsupportedStatement, whose tokens cannot be checked. The new features are added to the database versions whose syntax has the statement, and the policy, statistics and event ones to FeaturesAllowed.CREATE and ALTER, so valid dialect SQL keeps validating (DdlVisitorTraversalTest expects ALTER POLICY and CREATE STATISTICS to pass under DDL); touching H2Version makes the spotless ratchet reformat the rest of that file. The new StatementValidatorTest cases check every statement against FeaturesAllowed.SELECT and against the databases that support it, and ./gradlew check and mvn verify pass.

This branch has not been deployed

No deployments
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.

1 participant