github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/show_privileges.go (about) 1 // Copyright 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 // ShowPrivileges represents the statement SHOW PRIVILEGES. 23 type ShowPrivileges struct{} 24 25 var _ sql.Node = (*ShowPrivileges)(nil) 26 var _ sql.CollationCoercible = (*ShowPrivileges)(nil) 27 28 // NewShowPrivileges returns a new ShowPrivileges node. 29 func NewShowPrivileges() *ShowPrivileges { 30 return &ShowPrivileges{} 31 } 32 33 // Schema implements the interface sql.Node. 34 func (n *ShowPrivileges) Schema() sql.Schema { 35 return sql.Schema{ 36 &sql.Column{Name: "Privilege", Type: types.LongText}, 37 &sql.Column{Name: "Context", Type: types.LongText}, 38 &sql.Column{Name: "Comment", Type: types.LongText}, 39 } 40 } 41 42 // String implements the interface sql.Node. 43 func (n *ShowPrivileges) String() string { 44 return "SHOW PRIVILEGES" 45 } 46 47 // Resolved implements the interface sql.Node. 48 func (n *ShowPrivileges) Resolved() bool { 49 return true 50 } 51 52 func (n *ShowPrivileges) IsReadOnly() bool { 53 return true 54 } 55 56 // Children implements the interface sql.Node. 57 func (n *ShowPrivileges) Children() []sql.Node { 58 return nil 59 } 60 61 // WithChildren implements the interface sql.Node. 62 func (n *ShowPrivileges) WithChildren(children ...sql.Node) (sql.Node, error) { 63 if len(children) != 0 { 64 return nil, sql.ErrInvalidChildrenNumber.New(n, len(children), 0) 65 } 66 return n, nil 67 } 68 69 // CheckPrivileges implements the interface sql.Node. 70 func (n *ShowPrivileges) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { 71 return true 72 } 73 74 // CollationCoercibility implements the interface sql.CollationCoercible. 75 func (*ShowPrivileges) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { 76 return sql.Collation_binary, 7 77 } 78 79 // RowIter implements the interface sql.Node. 80 func (n *ShowPrivileges) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) { 81 return sql.RowsToRowIter( 82 sql.Row{"Alter", "Tables", "To alter the table"}, 83 sql.Row{"Alter routine", "Functions,Procedures", "To alter or drop stored functions/procedures"}, 84 sql.Row{"Create", "Databases,Tables,Indexes", "To create new databases and tables"}, 85 sql.Row{"Create routine", "Databases", "To use CREATE FUNCTION/PROCEDURE"}, 86 sql.Row{"Create role", "Server Admin", "To create new roles"}, 87 sql.Row{"Create temporary tables", "Databases", "To use CREATE TEMPORARY TABLE"}, 88 sql.Row{"Create view", "Tables", "To create new views"}, 89 sql.Row{"Create user", "Server Admin", "To create new users"}, 90 sql.Row{"Delete", "Tables", "To delete existing rows"}, 91 sql.Row{"Drop", "Databases,Tables", "To drop databases, tables, and views"}, 92 sql.Row{"Drop role", "Server Admin", "To drop roles"}, 93 sql.Row{"Event", "Server Admin", "To create, alter, drop and execute events"}, 94 sql.Row{"Execute", "Functions,Procedures", "To execute stored routines"}, 95 sql.Row{"File", "File access on server", "To read and write files on the server"}, 96 sql.Row{"Grant option", "Databases,Tables,Functions,Procedures", "To give to other users those privileges you possess"}, 97 sql.Row{"Index", "Tables", "To create or drop indexes"}, 98 sql.Row{"Insert", "Tables", "To insert data into tables"}, 99 sql.Row{"Lock tables", "Databases", "To use LOCK TABLES (together with SELECT privilege)"}, 100 sql.Row{"Process", "Server Admin", "To view the plain text of currently executing queries"}, 101 sql.Row{"Proxy", "Server Admin", "To make proxy user possible"}, 102 sql.Row{"References", "Databases,Tables", "To have references on tables"}, 103 sql.Row{"Reload", "Server Admin", "To reload or refresh tables, logs and privileges"}, 104 sql.Row{"Replication client", "Server Admin", "To ask where the slave or master servers are"}, 105 sql.Row{"Replication slave", "Server Admin", "To read binary log events from the master"}, 106 sql.Row{"Select", "Tables", "To retrieve rows from table"}, 107 sql.Row{"Show databases", "Server Admin", "To see all databases with SHOW DATABASES"}, 108 sql.Row{"Show view", "Tables", "To see views with SHOW CREATE VIEW"}, 109 sql.Row{"Shutdown", "Server Admin", "To shut down the server"}, 110 sql.Row{"Super", "Server Admin", "To use KILL thread, SET GLOBAL, CHANGE MASTER, etc."}, 111 sql.Row{"Trigger", "Tables", "To use triggers"}, 112 sql.Row{"Create tablespace", "Server Admin", "To create/alter/drop tablespaces"}, 113 sql.Row{"Update", "Tables", "To update existing rows"}, 114 sql.Row{"Usage", "Server Admin", "No privileges - allow connect only"}, 115 sql.Row{"ENCRYPTION_KEY_ADMIN", "Server Admin", ""}, 116 sql.Row{"INNODB_REDO_LOG_ARCHIVE", "Server Admin", ""}, 117 sql.Row{"REPLICATION_APPLIER", "Server Admin", ""}, 118 sql.Row{"INNODB_REDO_LOG_ENABLE", "Server Admin", ""}, 119 sql.Row{"SET_USER_ID", "Server Admin", ""}, 120 sql.Row{"SERVICE_CONNECTION_ADMIN", "Server Admin", ""}, 121 sql.Row{"GROUP_REPLICATION_ADMIN", "Server Admin", ""}, 122 sql.Row{"AUDIT_ABORT_EXEMPT", "Server Admin", ""}, 123 sql.Row{"GROUP_REPLICATION_STREAM", "Server Admin", ""}, 124 sql.Row{"CLONE_ADMIN", "Server Admin", ""}, 125 sql.Row{"SYSTEM_USER", "Server Admin", ""}, 126 sql.Row{"AUTHENTICATION_POLICY_ADMIN", "Server Admin", ""}, 127 sql.Row{"SHOW_ROUTINE", "Server Admin", ""}, 128 sql.Row{"BACKUP_ADMIN", "Server Admin", ""}, 129 sql.Row{"CONNECTION_ADMIN", "Server Admin", ""}, 130 sql.Row{"PERSIST_RO_VARIABLES_ADMIN", "Server Admin", ""}, 131 sql.Row{"RESOURCE_GROUP_ADMIN", "Server Admin", ""}, 132 sql.Row{"SESSION_VARIABLES_ADMIN", "Server Admin", ""}, 133 sql.Row{"SYSTEM_VARIABLES_ADMIN", "Server Admin", ""}, 134 sql.Row{"APPLICATION_PASSWORD_ADMIN", "Server Admin", ""}, 135 sql.Row{"FLUSH_OPTIMIZER_COSTS", "Server Admin", ""}, 136 sql.Row{"AUDIT_ADMIN", "Server Admin", ""}, 137 sql.Row{"BINLOG_ADMIN", "Server Admin", ""}, 138 sql.Row{"BINLOG_ENCRYPTION_ADMIN", "Server Admin", ""}, 139 sql.Row{"FLUSH_STATUS", "Server Admin", ""}, 140 sql.Row{"FLUSH_TABLES", "Server Admin", ""}, 141 sql.Row{"FLUSH_USER_RESOURCES", "Server Admin", ""}, 142 sql.Row{"XA_RECOVER_ADMIN", "Server Admin", ""}, 143 sql.Row{"PASSWORDLESS_USER_ADMIN", "Server Admin", ""}, 144 sql.Row{"TABLE_ENCRYPTION_ADMIN", "Server Admin", ""}, 145 sql.Row{"ROLE_ADMIN", "Server Admin", ""}, 146 sql.Row{"REPLICATION_SLAVE_ADMIN", "Server Admin", ""}, 147 sql.Row{"RESOURCE_GROUP_USER", "Server Admin", ""}, 148 ), nil 149 }