Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/ast/alter_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ func nodeAlterDatabase(ctx *Context, node *tree.AlterDatabase) (vitess.Statement
return nil, nil
}

// We can handle the common ALTER DATABASE .. TO OWNER case since it's a no-op
if node.Owner != "" {
return NewNoOp([]string{"owners are unsupported"}), nil
}

return NotYetSupportedError("ALTER DATABASE is not yet supported")
}
5 changes: 5 additions & 0 deletions server/ast/alter_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ func nodeAlterFunction(ctx *Context, node *tree.AlterFunction) (vitess.Statement
return nil, err
}

// We can handle the common ALTER FUNCTION .. TO OWNER case since it's a no-op
if node.Owner != "" {
return NewNoOp([]string{"owners are unsupported"}), nil
}

return NotYetSupportedError("ALTER FUNCTION statement is not yet supported")
}
5 changes: 5 additions & 0 deletions server/ast/alter_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ func nodeAlterSchema(ctx *Context, node *tree.AlterSchema) (vitess.Statement, er
return nil, nil
}

// We can handle the common ALTER SCHEMA .. TO OWNER case since it's a no-op
if _, ok := node.Cmd.(*tree.AlterSchemaOwner); ok {
return NewNoOp([]string{"owners are unsupported"}), nil
}

return NotYetSupportedError("ALTER SCHEMA is not yet supported")
}
5 changes: 5 additions & 0 deletions server/ast/alter_sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ func nodeAlterSequence(ctx *Context, node *tree.AlterSequence) (vitess.Statement
return nil, nil
}

// We can handle the common ALTER SEQUENCE .. TO OWNER case since it's a no-op
if node.Owner != "" {
return NewNoOp([]string{"owners are unsupported"}), nil
}

return NotYetSupportedError("ALTER SEQUENCE is not yet supported")
}
5 changes: 5 additions & 0 deletions server/ast/alter_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ func nodeAlterType(ctx *Context, node *tree.AlterType) (vitess.Statement, error)
return nil, nil
}

// We can handle the common ALTER TYPE .. TO OWNER case since it's a no-op
if _, ok := node.Cmd.(*tree.AlterTypeOwner); ok {
return NewNoOp([]string{"owners are not supported"}), nil
}

return NotYetSupportedError("ALTER TYPE is not yet supported")
}
5 changes: 5 additions & 0 deletions server/ast/alter_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ func nodeAlterView(ctx *Context, stmt *tree.AlterView) (sqlparser.Statement, err
return nil, nil
}

// We can handle the common ALTER VIEW .. TO OWNER case since it's a no-op
if _, ok := stmt.Cmd.(*tree.AlterViewOwnerTo); ok {
return NewNoOp([]string{"owners are unsupported"}), nil
}

return NotYetSupportedError("ALTER VIEW is not yet supported")
}
87 changes: 87 additions & 0 deletions testing/go/alter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2025 Dolthub, Inc.
//
// 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 _go

import "testing"

// TestAlterStatements tests ALTER statements other than ALTER TABLE, mostly for stub functionality.
// These tests should move into their respective test files as real functionality for these ALTER statements is added.
func TestAlterStatements(t *testing.T) {
RunScripts(t, []ScriptTest{
{
Name: "alter database",
Assertions: []ScriptTestAssertion{
{
Query: "ALTER DATABASE postgres OWNER TO foo",
},
},
},
{
Name: "alter sequence",
SetUpScript: []string{
"CREATE SEQUENCE testseq",
},
Assertions: []ScriptTestAssertion{
{
Query: "ALTER SEQUENCE testseq OWNER TO foo",
},
},
},
{
Name: "alter type",
SetUpScript: []string{
"CREATE TYPE testtype AS ENUM ('a', 'b', 'c')",
},
Assertions: []ScriptTestAssertion{
{
Query: "ALTER TYPE testtype OWNER TO foo",
},
},
},
{
Name: "alter function",
SetUpScript: []string{
"CREATE FUNCTION testfunc() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql",
},
Assertions: []ScriptTestAssertion{
{
Query: "ALTER FUNCTION testfunc() OWNER TO foo",
},
},
},
{
Name: "alter schema",
SetUpScript: []string{
"CREATE SCHEMA testschema",
},
Assertions: []ScriptTestAssertion{
{
Query: "ALTER schema testschema OWNER TO foo",
},
},
},
{
Name: "alter view",
SetUpScript: []string{
"CREATE VIEW testview AS SELECT 1",
},
Assertions: []ScriptTestAssertion{
{
Query: "ALTER VIEW testview OWNER TO foo",
},
},
},
})
}
20 changes: 20 additions & 0 deletions testing/go/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ func TestCopy(t *testing.T) {
},
},
},
{
Name: "timestamp columns",
SetUpScript: []string{
"CREATE TABLE tbl1 (pk timestamp primary key, ts timestamp);",
},
Assertions: []ScriptTestAssertion{
{
Query: "COPY tbl1 FROM STDIN WITH (HEADER)",
CopyFromStdInFile: "tab-load-with-timestamp-col.sql",
},
{
Query: "select * from tbl1 order by pk;",
Expected: []sql.Row{
{"2020-12-19 19:00:00", "2021-04-04 20:00:00"},
{"2020-12-19 21:36:32.188", "2020-12-19 19:00:00"},
{"2021-04-04 20:00:00", "2020-12-19 21:36:32.188"},
},
},
},
},
{
Name: "basic csv",
SetUpScript: []string{
Expand Down
5 changes: 5 additions & 0 deletions testing/go/testdata/tab-load-with-timestamp-col.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id ts
2020-12-19 21:36:32.188-05 2020-12-19 19:00:00-05
2021-04-04 20:00:00-04 2020-12-19 21:36:32.188-05
2020-12-19 19:00:00-05 2021-04-04 20:00:00-04
\.