Skip to content
Snippets Groups Projects
Unverified Commit 574f471e authored by iamlinjunhong's avatar iamlinjunhong Committed by GitHub
Browse files

Create database for plan2 (#2562)

parent ff4cfcf0
No related branches found
No related tags found
No related merge requests found
......@@ -15,8 +15,12 @@
package compile2
import (
"fmt"
"github.com/matrixorigin/matrixone/pkg/common/moerr"
batch "github.com/matrixorigin/matrixone/pkg/container/batch2"
"github.com/matrixorigin/matrixone/pkg/errno"
"github.com/matrixorigin/matrixone/pkg/pb/plan"
"github.com/matrixorigin/matrixone/pkg/sql/errors"
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
)
......@@ -46,10 +50,26 @@ func (e *Exec) Run(ts uint64) (err error) {
switch e.scope.Magic {
case Merge:
return nil
case CreateDatabase:
return e.scope.CreateDatabase(ts, e.c.proc.Snapshot, e.c.e)
}
return nil
}
func (e *Exec) compileScope(pn *plan.Plan) (*Scope, error) {
switch qry := pn.Plan.(type) {
case *plan.Plan_Ddl:
switch qry.Ddl.DdlType {
case plan.DataDefinition_CREATE_DATABASE:
return &Scope{
Magic: CreateDatabase,
Plan: pn,
}, nil
}
}
return nil, errors.New(errno.SyntaxErrororAccessRuleViolation, fmt.Sprintf("query '%s' not support now", pn))
}
func (e *Exec) Statement() tree.Statement {
return e.stmt
}
......
// Copyright 2021 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compile2
import (
"github.com/matrixorigin/matrixone/pkg/vm/engine"
)
func (s *Scope) CreateDatabase(ts uint64, snapshot engine.Snapshot, engine engine.Engine) error {
dbName := s.Plan.GetDdl().GetCreateDatabase().GetDatabase()
return engine.Create(ts, dbName, 0, snapshot)
}
......@@ -25,6 +25,7 @@ import (
const (
Merge = iota
CreateDatabase
)
// Address is the ip:port of local node
......
......@@ -67,7 +67,7 @@ type Process struct {
UnixTime int64
// snapshot is transaction context
snapshot engine.Snapshot
Snapshot engine.Snapshot
Cancel context.CancelFunc
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment