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

sql: add SPLIT AT #8938

Merged
merged 1 commit into from Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/testserver.go
Expand Up @@ -387,8 +387,8 @@ func (ts *TestServer) GetNode() *Node {
return ts.node
}

// GetDistSender exposes the Server's DistSender.
func (ts *TestServer) GetDistSender() *kv.DistSender {
// DistSender exposes the Server's DistSender.
func (ts *TestServer) DistSender() *kv.DistSender {
return ts.distSender
}

Expand Down
1 change: 1 addition & 0 deletions sql/parser/keywords.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sql/parser/parse_test.go
Expand Up @@ -507,6 +507,11 @@ func TestParse(t *testing.T) {

{`COPY t FROM STDIN`},
{`COPY t (a, b, c) FROM STDIN`},

{`ALTER TABLE a SPLIT AT (1)`},
{`ALTER TABLE d.a SPLIT AT ('b', 2)`},
{`ALTER INDEX a@i SPLIT AT (1)`},
{`ALTER INDEX d.a@i SPLIT AT (2)`},
}
for _, d := range testData {
stmts, err := parseTraditional(d.sql)
Expand Down
41 changes: 41 additions & 0 deletions sql/parser/split.go
@@ -0,0 +1,41 @@
// Copyright 2016 The Cockroach Authors.
//
// 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.
//
// Author: Matt Jibson

package parser

import "bytes"

// Split represents a SPLIT statement.
type Split struct {
Table NormalizableTableName
Index *TableNameWithIndex
Exprs Exprs
}

// Format implements the NodeFormatter interface.
func (node *Split) Format(buf *bytes.Buffer, f FmtFlags) {
buf.WriteString("ALTER ")
if node.Index != nil {
buf.WriteString("INDEX ")
FormatNode(buf, f, node.Index)
} else {
buf.WriteString("TABLE ")
FormatNode(buf, f, node.Table)
}
buf.WriteString(" SPLIT AT (")
FormatNode(buf, f, node.Exprs)
buf.WriteString(")")
}