Skip to content

fix: walk the expressions of ALTER TABLE and ALTER DOMAIN actions - #2950

Open
tanjiroK-coder wants to merge 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:alter-expression-features
Open

tanjiroK-coder wants to merge 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:alter-expression-features

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

StatementFeatureVisitor.visit(Alter) classifies each AlterExpression by its AlterOperation (the #2894 cases) and then returns without calling super, so the DEFAULT, CHECK, USING, generated-column and partition expressions that StatementVisitorAdapter.visit(Alter) walks through TableDefinitionTraversal never reach the pure-function check; visit(AlterDomain) returns before the adapter walks the domain constraint in the same way. PostgreSQL evaluates ALTER COLUMN .. TYPE .. USING, a volatile ADD COLUMN .. DEFAULT, ADD CONSTRAINT .. CHECK and ALTER DOMAIN .. ADD CONSTRAINT .. CHECK against every row already stored while the statement runs, so ALTER TABLE t ALTER COLUMN a TYPE int USING purge_audit(a) came back as certain=[MODIFIES_SCHEMA] with mayModifyData() == false and no unresolved reference and passed the read-only guard in usage.rst, while the same call in CREATE TABLE x (a INT DEFAULT purge_audit()) or SELECT purge_audit() leaves MODIFIES_DATA possible with unresolved=[purge_audit]. I found it while probing which statement positions keep a function out of the purity check, after the SET / DECLARE (#2935) and SHOW filter (#2947) cases. Both overrides now end with super.visit(..) after their classification, the way visit(CreateTable) already does; a plain ALTER TABLE t ADD COLUMN c INT or RENAME still reports certain=[MODIFIES_SCHEMA] only, and a SET DEFAULT call is reported as possible like a CREATE TABLE default, an over-report on a statement that already modifies the schema. The new alterExpressionIsChecked cases fail before (4 failures) and pass after; spotlessCheck, Checkstyle, PMD and SpotBugs pass, and the only ./gradlew test failures locally (16672 tests) are the same 33 Mockito inline-mock-maker init errors and 2 ParserKeywordsUtilsTest AccessDeniedExceptions as on master, both environment problems on this machine.

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