Skip to content

Commit cc3b47a

Browse files
committed
ut
1 parent 0da5b64 commit cc3b47a

File tree

4 files changed

+147
-105
lines changed

4 files changed

+147
-105
lines changed

pkg/sql/compile/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ func (m magicType) String() string {
9090
return "DropDatabase"
9191
case DropTable:
9292
return "DropTable"
93-
case DropPitr:
94-
return "DropPitr"
9593
case DropIndex:
9694
return "DropIndex"
9795
case TruncateTable:

pkg/sql/parsers/dialect/mysql/mysql_sql_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package mysql
1616

1717
import (
1818
"context"
19+
"github.com/stretchr/testify/require"
1920
"testing"
2021

2122
"github.com/matrixorigin/matrixone/pkg/sql/parsers/dialect"
@@ -81,6 +82,39 @@ func TestOriginSQL(t *testing.T) {
8182
}
8283
}
8384

85+
var (
86+
pitrSQLs = []struct {
87+
input string
88+
output string
89+
}{
90+
{
91+
input: "create pitr pitr_d for database db1 range 1 'd' internal",
92+
output: "create pitr pitr_d for database db1 range 1 d internal",
93+
}, {
94+
input: "drop pitr pitr_d internal",
95+
output: "drop pitr pitr_d internal",
96+
},
97+
}
98+
)
99+
100+
func TestPitrInternal(t *testing.T) {
101+
for _, pitrSQL := range pitrSQLs {
102+
if pitrSQL.output == "" {
103+
pitrSQL.output = pitrSQL.input
104+
}
105+
ast, err := ParseOne(context.TODO(), pitrSQL.input, 1)
106+
if err != nil {
107+
t.Errorf("Parse(%q) err: %v", pitrSQL.input, err)
108+
return
109+
}
110+
out := tree.String(ast, dialect.MYSQL)
111+
if pitrSQL.output != out {
112+
t.Errorf("Parsing failed. \nExpected/Got:\n%s\n%s", pitrSQL.output, out)
113+
}
114+
require.Equal(t, ast.StmtKind().ExecLocation(), tree.EXEC_IN_ENGINE)
115+
}
116+
}
117+
84118
var (
85119
validSQL = []struct {
86120
input string

pkg/sql/parsers/tree/pitr.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func (node *DropPitr) Format(ctx *FmtCtx) {
8888
ctx.WriteString("if exists ")
8989
}
9090
node.Name.Format(ctx)
91+
if node.Internal {
92+
ctx.WriteString(" internal")
93+
}
9194
}
9295

9396
func (node *DropPitr) reset() { *node = DropPitr{} }
@@ -151,6 +154,9 @@ func (node *CreatePitr) Format(ctx *FmtCtx) {
151154
ctx.WriteString(fmt.Sprintf("%v ", node.PitrValue))
152155
ctx.WriteString(" ")
153156
ctx.WriteString(node.PitrUnit)
157+
if node.Internal {
158+
ctx.WriteString(" internal")
159+
}
154160
}
155161

156162
func (node *CreatePitr) GetStatementType() string { return "Create PITR" }

0 commit comments

Comments
 (0)