My initial implementation of mutable visitors closely matched the existing immutable visitor implementations,
and used pre_* visitors (a mutable expression was first passed the visitor, then its children were visited).
After some initial usage, I realize this actually impractical, and can easily lead to infinite recursion when one isn't careful.
For instance a mutable visitor would replace x by f(x),
then would be called again on the nested x and result in f(f(x)),
then again resulting in f(f(f(x))), and so on.
So, this commit changes the behavior of the visit_*_mut functions to call the visitor on an expression only
once all of its children have been visited.
It also makes the documentation more explicit and adds an example.
* Add a mutable visitor
This adds the ability to mutate parsed sql queries.
Previously, only visitors taking an immutable reference to the visited structures were allowed.
* add utility functions for mutable visits
* bump version numbers
* Add derive based AST visitor
* Fix BigDecimal
* Fix no visitor feature
* Add test
* Rename visit_table to visit_relation
* Review feedback
* Add pre and post visit
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
postgres supports a bunch more json operators. See
https://www.postgresql.org/docs/15/functions-json.html
Skipping operators starting with a question mark for now, since those
are hard to distinguish from placeholders without more context.
Postgres supports more generalized locking clauses, for example:
FOR UPDATE OF <table_name> SKIP LOCKED
also, multiple locking clauses. Generalize the parser to support these.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* support basic pg CREATE FUNCTION
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* support function argument
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* fix display and use verify in test
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* support OR REPLACE
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* fix compile error in bigdecimal
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* unify all `CreateFunctionBody` to a structure
Signed-off-by: Runji Wang <wangrunji0408@163.com>
Signed-off-by: Runji Wang <wangrunji0408@163.com>
* first commit
* fix style and edit test
* fix test?
* remove unnecessary logic
* refactor implementation
* codestyle
* add schema support
* codestyle and lint
* Apply suggestions from code review
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* PartialOrd and Ord
* clean up parser logic
* codestyle and lint
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* Adapt VALUES to MySQL dialect
* Update src/ast/query.rs
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* remove *requirement* for ROW
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>