Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] complete insert/replace statement #708

Closed
hustjieke opened this issue Dec 7, 2020 · 0 comments
Closed

[feature] complete insert/replace statement #708

hustjieke opened this issue Dec 7, 2020 · 0 comments
Assignees
Labels
P0 High priority type: feature

Comments

@hustjieke
Copy link
Contributor

MySQL 8.0 insert syntax:

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    { {VALUES | VALUE} (value_list) [, (value_list)] ...
      |
      VALUES row_constructor_list
    }
    [AS row_alias[(col_alias [, col_alias] ...)]]
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [AS row_alias[(col_alias [, col_alias] ...)]]
    SET assignment_list
    [ON DUPLICATE KEY UPDATE assignment_list]

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    [AS row_alias[(col_alias [, col_alias] ...)]]
    {SELECT ... | TABLE table_name}
    [ON DUPLICATE KEY UPDATE assignment_list]

value:
    {expr | DEFAULT}

value_list:
    value [, value] ...

row_constructor_list:
    ROW(value_list)[, ROW(value_list)][, ...]

assignment:
    col_name = [row_alias.]value

assignment_list:
    assignment [, assignment] ...

For repalce syntax:

REPLACE [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    { {VALUES | VALUE} (value_list) [, (value_list)] ...
      |
      VALUES row_constructor_list
    }

REPLACE [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    SET assignment_list

REPLACE [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name
    [PARTITION (partition_name [, partition_name] ...)]
    [(col_name [, col_name] ...)]
    {SELECT ... | TABLE table_name}

value:
    {expr | DEFAULT}

value_list:
    value [, value] ...

row_constructor_list:
    ROW(value_list)[, ROW(value_list)][, ...]

assignment:
    col_name = value

assignment_list:
    assignment [, assignment] ...

For radon, we should do some more work:
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function can be implemented later.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

But next list still not support, maybe we can complete next in the future.
1. INSERT ... SELECT Statement
2. 8.0 new features:[AS row_alias[(col_alias [, col_alias] ...)]]
VALUES row_constructor_list

@hustjieke hustjieke added type: feature P0 High priority labels Dec 7, 2020
@hustjieke hustjieke self-assigned this Dec 7, 2020
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 7, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 87.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 21, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 87.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 21, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 87.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 21, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 87.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 21, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 92.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 21, 2020
[summary]
compute insert/replace statement.
1. add [HIGH_PRIORITY | LOW_PRIORITY | DELAYED] options for Insert, add
[LOW_PRIORITY | DELAYED] options for Replace Statement.
2. remove "on duplicate key update" for Replace Statement, this is a bug.
3. add support for "PARTITION" to parse, but the function hasn't
implement yet.
4. add support for writing data without columns, like: "insert into t values ...."
5. refactor some code on insert plan.

[test case]
src/planner/insert_plan_test.go
src/proxy/insert_test.go
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/parse_test.go

[patch codecov]
src/planner/insert_plan.go  93.7%
src/proxy/insert.go 92.0%
src/vendor/github.com/xelabs/go-mysqlstack/sqlparser/ast.go 96.6%
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 30, 2020
[summary]
fix wrong word  'globle' --> 'global'

[test case]
N/A

[patch codecov]
N/A
hustjieke added a commit to hustjieke/radon that referenced this issue Dec 30, 2020
…sn't match value count' radondb#708

[summary]
add fail test cases about insert stmt 'Column count doesn't match value count',e.g.:
create table t(a int key);
insert /*success test*/ into t values(1);
insert /*fail test*/ into t values(2, 3);

[test case]
N/A

[patch codecov]
N/A
BohuTANG added a commit that referenced this issue Dec 30, 2020
…t_stmt

.*: complete insert/replace statement #708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 High priority type: feature
Projects
None yet
Development

No branches or pull requests

1 participant