github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/showwarnings.go (about) 1 // Copyright 2020-2021 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package plan 16 17 import ( 18 "github.com/dolthub/go-mysql-server/sql" 19 "github.com/dolthub/go-mysql-server/sql/types" 20 ) 21 22 // ShowWarnings is a node that shows the session warnings 23 type ShowWarnings []*sql.Warning 24 25 var _ sql.Node = (*ShowWarnings)(nil) 26 var _ sql.CollationCoercible = (*ShowWarnings)(nil) 27 28 // Resolved implements sql.Node interface. The function always returns true. 29 func (ShowWarnings) Resolved() bool { 30 return true 31 } 32 33 // WithChildren implements the Node interface. 34 func (sw ShowWarnings) WithChildren(children ...sql.Node) (sql.Node, error) { 35 if len(children) != 0 { 36 return nil, sql.ErrInvalidChildrenNumber.New(sw, len(children), 0) 37 } 38 39 return sw, nil 40 } 41 42 // CheckPrivileges implements the interface sql.Node. 43 func (sw ShowWarnings) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { 44 return true 45 } 46 47 // CollationCoercibility implements the interface sql.CollationCoercible. 48 func (ShowWarnings) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { 49 return sql.Collation_binary, 7 50 } 51 52 // String implements the fmt.Stringer interface. 53 func (ShowWarnings) String() string { 54 return "SHOW WARNINGS" 55 } 56 57 func (ShowWarnings) IsReadOnly() bool { 58 return true 59 } 60 61 // Schema returns a new Schema reference for "SHOW VARIABLES" query. 62 func (ShowWarnings) Schema() sql.Schema { 63 return sql.Schema{ 64 &sql.Column{Name: "Level", Type: types.LongText, Nullable: false}, 65 &sql.Column{Name: "Code", Type: types.Int32, Nullable: true}, 66 &sql.Column{Name: "Message", Type: types.LongText, Nullable: false}, 67 } 68 } 69 70 // Children implements sql.Node interface. The function always returns nil. 71 func (ShowWarnings) Children() []sql.Node { return nil }