forked from arana-db/arana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE arana-db#93] Feat show var (arana-db#154)
* feat: none * feat: support show var * feat: support show variables * style: 移除无效代码 * feat: 逻辑修改 * fix: 修复PR中的comment
- Loading branch information
1 parent
a24aedb
commit 5935d1c
Showing
9 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,7 @@ vendor/ | |
/docker/data/ | ||
/docker/mysqld/ | ||
/dist | ||
/default.etcd | ||
/default.etcd | ||
|
||
.codecc | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ package ast | |
import ( | ||
"strings" | ||
) | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 plan | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
) | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
import ( | ||
"github.com/arana-db/arana/pkg/proto" | ||
"github.com/arana-db/arana/pkg/runtime/ast" | ||
) | ||
|
||
var _ proto.Plan = (*ShowVariablesPlan)(nil) | ||
|
||
type ShowVariablesPlan struct { | ||
basePlan | ||
stmt *ast.ShowVariables | ||
} | ||
|
||
func NewShowVariablesPlan(stmt *ast.ShowVariables) *ShowVariablesPlan { | ||
return &ShowVariablesPlan{stmt: stmt} | ||
} | ||
|
||
func (s *ShowVariablesPlan) Type() proto.PlanType { | ||
return proto.PlanTypeQuery | ||
} | ||
|
||
func (s *ShowVariablesPlan) ExecIn(ctx context.Context, vConn proto.VConn) (proto.Result, error) { | ||
|
||
var ( | ||
sb strings.Builder | ||
args []int | ||
) | ||
|
||
if err := s.stmt.Restore(ast.RestoreDefault, &sb, &args); err != nil { | ||
return nil, errors.Wrap(err, "failed to execute DELETE statement") | ||
} | ||
|
||
ret, err := vConn.Query(ctx, "", sb.String(), s.toArgs(args)...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ret, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters