Skip to content

Commit 42fd0bb

Browse files
authored
Fix nil pointer for replicated database engine (#212)
1 parent c9e8bb4 commit 42fd0bb

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

parser/parser_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (p *Parser) parseCreateDatabase(pos Pos) (*CreateDatabase, error) {
100100
return nil, err
101101
}
102102
if engineExpr != nil {
103-
StatementEnd = onCluster.End()
103+
StatementEnd = engineExpr.End()
104104
}
105105
commentExpr, err := p.tryParseComment()
106106
if err != nil {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE DATABASE IF NOT EXISTS `test` ENGINE=Replicated('/root/test_local', 'shard', 'replica');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Origin SQL:
2+
CREATE DATABASE IF NOT EXISTS `test` ENGINE=Replicated('/root/test_local', 'shard', 'replica');
3+
4+
5+
-- Format SQL:
6+
CREATE DATABASE IF NOT EXISTS `test` ENGINE = Replicated('/root/test_local', 'shard', 'replica');
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
"CreatePos": 0,
4+
"StatementEnd": 54,
5+
"Name": {
6+
"Name": "test",
7+
"QuoteType": 3,
8+
"NamePos": 31,
9+
"NameEnd": 35
10+
},
11+
"IfNotExists": true,
12+
"OnCluster": null,
13+
"Engine": {
14+
"EnginePos": 37,
15+
"EngineEnd": 54,
16+
"Name": "Replicated",
17+
"Params": {
18+
"LeftParenPos": 54,
19+
"RightParenPos": 93,
20+
"Items": {
21+
"ListPos": 56,
22+
"ListEnd": 92,
23+
"HasDistinct": false,
24+
"Items": [
25+
{
26+
"Expr": {
27+
"LiteralPos": 56,
28+
"LiteralEnd": 72,
29+
"Literal": "/root/test_local"
30+
},
31+
"Alias": null
32+
},
33+
{
34+
"Expr": {
35+
"LiteralPos": 76,
36+
"LiteralEnd": 81,
37+
"Literal": "shard"
38+
},
39+
"Alias": null
40+
},
41+
{
42+
"Expr": {
43+
"LiteralPos": 85,
44+
"LiteralEnd": 92,
45+
"Literal": "replica"
46+
},
47+
"Alias": null
48+
}
49+
]
50+
},
51+
"ColumnArgList": null
52+
},
53+
"PrimaryKey": null,
54+
"PartitionBy": null,
55+
"SampleBy": null,
56+
"TTL": null,
57+
"Settings": null,
58+
"OrderBy": null
59+
},
60+
"Comment": null
61+
}
62+
]

0 commit comments

Comments
 (0)