Commit graph

185 commits

Author SHA1 Message Date
Dmitry Patsura
6d8aacd85b
feat: Support expression in SET statement (#574)
Co-authored-by: Alex Vasilev <vaspiring@gmail.com>
2022-08-18 13:29:55 -04:00
Alex Qyoun-ae
18881f8fcf
Support SHOW COLLATION (#564) 2022-08-11 09:28:34 -04:00
Dmitry Patsura
54a29e872d
feat: Parse special keywords as functions (current_user, user, etc) (#561)
* feat: Parse special keywors as functions (current_user, user, etc)

* explain special field
2022-08-11 08:30:06 -04:00
Alex Qyoun-ae
b6e36ad760
Support SHOW TABLES (#563) 2022-08-11 08:24:40 -04:00
Dmitry Patsura
221e9c2bab
feat: Support SET NAMES literal [COLLATE literal] (#558)
* feat: Support SET NAMES literal [COLLATE literal]

* feat: Support SET NAMES DEFAULT

* clippy
2022-08-11 06:55:55 -04:00
Alex Qyoun-ae
a9db6ed139
Support USE db (#565) 2022-08-11 06:49:20 -04:00
Alex Qyoun-ae
71c3ec057b
Support SHOW COLUMNS FROM tbl FROM db (#562) 2022-08-11 06:42:08 -04:00
Dmitry Patsura
e2b943799a
feat: Initial support for parsing MySQL show variables (#559)
Co-authored-by: Alex Vasilev <vaspiring@gmail.com>
2022-08-11 06:35:59 -04:00
Mike Roberts
93e16e9864
Add support for mysql 'SHOW CREATE VIEW' statement (#536) 2022-07-18 06:10:09 -04:00
5tan
dea7666086
Boxed Query body to save some stack space (#540) 2022-07-16 07:22:45 -04:00
Yoshiyuki Komazaki
17c238bda7
feat: Support double quoted string (#530) 2022-06-28 16:41:23 -04:00
Andrey Frolov
99697d26e1
add on update for my sql (#522) 2022-06-13 08:33:10 -04:00
Riccardo Azzolini
d19c6c323c
Fix escaping of trailing quote in quoted identifiers (#505)
* Generalize EscapeSingleQuoteString to arbitrary quote character

* Fix escaping of trailing quote in quoted identifiers

* Add new tests instead of modifying existing tests
2022-05-27 06:25:24 -04:00
Riccardo Azzolini
901f5b974f
Distinguish between tables and nullary functions in FROM (#506) 2022-05-25 16:01:13 -04:00
Dmitry Patsura
f5980cd30f
feat: Support KILL statement (#479) 2022-05-02 14:04:33 -04:00
Maciej Obuchowski
525ba527bb
snowflake: add qualify expression (#465)
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2022-04-29 14:11:11 -04:00
slhmy
fd8f2df10d
Support Update Set From statement (#450) 2022-04-02 06:34:59 -04:00
Maciej Obuchowski
d38c30e9ff
add SELECT INTO statement variation (#447)
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2022-03-30 16:01:55 -04:00
Wataru Kurashima
994b86a45c
mysql unsigned datatype (#428)
* support MySQL UNSIGNED

* fix: 🐛 `unsigned` is not column option

* test: 💍 add `unsigned` test

* fix: 🐛 `unsigned` is not column option

* feat: 🎸 declare unsigned data_types

* feat: 🎸 display unsigned

* fix: 🐛 unsigned is not column type option

* feat: 🎸 parse_data_type can parse unsigned

* feat: 🎸 int or decimal or float is unsigned selectable

* fix: 🐛 FLOAT/DOUBLE/DECIMAL + UNSIGNED is not recommended

https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html

* test: 💍 add test

* style: 💄 fmt
2022-03-07 17:01:48 -05:00
Wataru Kurashima
2ebe18a94e
Support COLLATION keywork on CREATE TABLE (#424)
* support table definition's collate

* add table collate test
2022-02-28 14:04:47 -05:00
gamife
0b5178d7e7
feat: add FOR UPDATE/FOR SHARE clause (#418)
* feat: add FOR UPDATE/FOR SHARE clause

* refactor: LockType enum variant name

Co-authored-by: gamife <gamife9886@gmail.com>
2022-02-24 06:39:38 +01:00
Jakob Truelsen
e4959696b5
Support CHARSET and ENGINE clauses on CREATE TABLE for mysql (#392)
* Add support for SET and ENUM types

See https://dev.mysql.com/doc/refman/8.0/en/set.html
and https://dev.mysql.com/doc/refman/8.0/en/enum.html

* Add support for mysql ENGINE and DEFAULT CHARSET in CREATE TABLE

See https://dev.mysql.com/doc/refman/8.0/en/create-table.html

* Add support for COMMENT and CHARACTER SET field attributes

See https://dev.mysql.com/doc/refman/8.0/en/create-table.html
2022-02-08 10:08:56 -05:00
Markus Westerlind
34fedf311d
fix: Handle double quotes inside quoted identifiers correctly (#411)
* fix: Handle double quotes inside quoted identifiers correctly

This fixes #410 for standard SQL, however I don't know enough about other dialects to know if they
handle this differently. May need more extensive testing as well.

* refactor: Make quoted identifier parsing a seperate function

* test: Check that quoted identifier tokenization works

Added `pretty_assertions` so that the `assert_eq!` in the tokenization is readable

* test: Check that quoted identifiers work in mysql

* chore: cargo clippy
2022-02-07 10:05:17 -05:00
Alex Vasilev
ea0eb1be61
fix: mysql backslash escaping (#373)
* fix: mysql backslash escaping

* fixes
2021-12-23 08:50:33 -05:00
Taehoon Moon
823635d2fc
Add FunctionArgExpr and remove Expr::[Qualified]Wildcard, (#378)
* Add FunctionArgExpr and remove Expr::[Qualified]Wildcard,

There is no use case of `Expr::Wildcard` and `Expr::QualifiedWildcard` only except for function argments.
Add `FunctionArgExpr` to have `Wildcard` and `QualifiedWildcard`, and remove wildcards in `Expr`.

* Apply `FunctionArgExpr` to sqlparser_mysql tests
2021-12-15 06:35:37 -05:00
Andrew Lamb
82eaae1522
Implement some MySQL specific syntax and extend the UPDATE statement (#375)
* * implement the ON DUPLICATE KEY syntax for MySQL in an INSERT statement

* * add MySQL to the cli example
* remove the dialect check for the ON DUPLICATE KEY insert to support
  custom dialects and unwrap some missing results

* * use the Assignment DataType for the ON DUPLICATE KEY UPDATE

* * add support for table aliases in an UPDATE statement
* add support for JOINS in an UPDATE statement (for MySQL)

* * implement the MySQL ALTER TABLE CHANGE COLUMN syntax

* * fix the formatting of the else * rename the parse_identifiers_strict
  to parse_identifiers_non_keywords

* Parse SUBSTRING calls that are separated with a comma instead of
keywords

* Fix the linting errors

Co-authored-by: Piotr <piotr.morawski@nc-vision.com>
Co-authored-by: Piotr Morawski <contact@peter-morawski.de>
2021-12-10 14:46:11 -05:00
Alex Vasilev
77d90d3b85
Support minimum display width for integer data types (#337)
* Support minimum display width for integers

* make fmt happy, updated docstrings
2021-08-29 07:13:10 -04:00
Dmitry Patsura
9a5716d94b
feat: Support SHOW CREATE TABLE|EVENT|FUNCTION (MySQL specific) (#338)
* feat: Support SHOW CREATE TABLE|EVENT|FUNCTION (MySQL specific)

* misc: Simplify test with loop over enum values
2021-08-29 07:03:39 -04:00
Nickolay Ponomarev
4128dfe1db Introduce tests/test_utils/mod.rs and use it consistently
To share helper macros between various tests/* we added a new module
(tests/macros/mod.rs). This made the prologue to be used in tests quite
long and a little weird:
```
#[macro_use]
#[path = "macros/mod.rs"]
mod macros;
use sqlparser::test_utils::*;
```

This simplifies it to:
```
#[macro_use]
mod test_utils;
use test_utils::*;
```
- and switches all existing tests to the new prologue simultaneously...

...while fixing a few other inconsistencies and adding a few comments
about the way `test_utils` work.
2020-10-12 06:52:00 +03:00
mz
9e7e30282e
Support identifiers quoted with backticks in the MySQL dialect (#247)
Per https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
MySQL historically supports `identifiers quoted in backticks`
in addition to the ANSI "quoting style" (assuming ANSI_QUOTES mode).
2020-07-30 04:22:29 +03:00
mz
09ca14fe8e
Support dialect-specific auto-increment column options for MySQL and SQLite (#234)
In MySQL it's AUTO_INCREMENT
(see https://dev.mysql.com/doc/refman/8.0/en/create-table.html)
and in SQLite it's AUTOINCREMENT.

We use `ColumnOption::DialectSpecific(Vec<Token>)` to avoid adding a new variant for each vendor-specific column option.
2020-07-28 23:34:21 +03:00
Daniël Heres
15d5f71646
Add CREATE TABLE AS support (#206)
We parse it as a regular `CREATE TABLE` statement
followed by an `AS <query>`, which is how BigQuery works:
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement


ANSI SQL and PostgreSQL only support a plain list of columns
after the table name in a CTAS
    `CREATE TABLE t (a) AS SELECT a FROM foo`

We currently only allow specifying a full schema with data
types, or omitting it altogether.

https://www.postgresql.org/docs/12/sql-createtableas.html
https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#as-subquery-clause


Finally, when no schema is specified, we print empty parens after a
plain `CREATE TABLE t ();` as required by PostgreSQL, but skip them
in a CTAS: `CREATE TABLE t AS ...`. This affects serialization only,
the parser allows omitting the schema in a regular `CREATE TABLE` too
since the first release of the parser:
7d27abdfb4/src/sqlparser.rs (L325-L332)

Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-23 16:30:22 +03:00
Alex Kyllo
172ba42001 Add support for MSSQL's SELECT TOP N syntax (#150)
Add support for MSSQL SELECT TOP (N) [PERCENT] [WITH TIES] syntax.
2020-01-12 23:20:48 -05:00
Robert Grimm
b1cbc55128
Turn type Ident into struct Ident
The Ident type was previously an alias for a String. Turn it into a full
fledged struct, so that the parser can preserve the distinction between
identifier value and quote style already made by the tokenizer's Word
structure.
2019-10-20 00:16:41 -04:00
Brandon W Maister
f64928e994
Support MySQL SHOW COLUMNS statement
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
2019-08-14 15:13:05 -04:00