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: with grant option/grant option for #72123

Merged
merged 1 commit into from
Dec 4, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ trace.debug.enable boolean false if set, traces for recent requests can be seen
trace.jaeger.agent string the address of a Jaeger agent to receive traces using the Jaeger UDP Thrift protocol, as <host>:<port>. If no port is specified, 6381 will be used.
trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 21.2-20 set the active cluster version in the format '<major>.<minor>'
version version 21.2-22 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@
<tr><td><code>trace.jaeger.agent</code></td><td>string</td><td><code></code></td><td>the address of a Jaeger agent to receive traces using the Jaeger UDP Thrift protocol, as <host>:<port>. If no port is specified, 6381 will be used.</td></tr>
<tr><td><code>trace.opentelemetry.collector</code></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.2-20</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.2-22</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
24 changes: 12 additions & 12 deletions docs/generated/sql/bnf/grant_stmt.bnf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
grant_stmt ::=
'GRANT' 'ALL' 'PRIVILEGES' 'ON' targets 'TO' role_spec_list
| 'GRANT' 'ALL' 'ON' targets 'TO' role_spec_list
| 'GRANT' privilege_list 'ON' targets 'TO' role_spec_list
'GRANT' 'ALL' 'PRIVILEGES' 'ON' targets 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'ON' targets 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'ON' targets 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'TO' role_spec_list
| 'GRANT' privilege_list 'TO' role_spec_list 'WITH' 'ADMIN' 'OPTION'
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'TYPE' target_types 'TO' role_spec_list
| 'GRANT' 'ALL' 'ON' 'TYPE' target_types 'TO' role_spec_list
| 'GRANT' privilege_list 'ON' 'TYPE' target_types 'TO' role_spec_list
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' 'ALL' 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' privilege_list 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' 'ALL' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' privilege_list 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'TYPE' target_types 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'ON' 'TYPE' target_types 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'ON' 'TYPE' target_types 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'PRIVILEGES' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' 'ALL' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
12 changes: 12 additions & 0 deletions docs/generated/sql/bnf/revoke_stmt.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ revoke_stmt ::=
'REVOKE' 'ALL' 'PRIVILEGES' 'ON' targets 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'ON' targets 'FROM' role_spec_list
| 'REVOKE' privilege_list 'ON' targets 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'PRIVILEGES' 'ON' targets 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'ON' targets 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privilege_list 'ON' targets 'FROM' role_spec_list
| 'REVOKE' privilege_list 'FROM' role_spec_list
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' privilege_list 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'PRIVILEGES' 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' privilege_list 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'PRIVILEGES' 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privilege_list 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'PRIVILEGES' 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' privilege_list 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'PRIVILEGES' 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privilege_list 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'PRIVILEGES' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'ALL' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' privilege_list 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'PRIVILEGES' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'ALL' 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privilege_list 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
20 changes: 12 additions & 8 deletions docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,27 @@ discard_stmt ::=
'DISCARD' 'ALL'

grant_stmt ::=
'GRANT' privileges 'ON' targets 'TO' role_spec_list
'GRANT' privileges 'ON' targets 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privilege_list 'TO' role_spec_list
| 'GRANT' privilege_list 'TO' role_spec_list 'WITH' 'ADMIN' 'OPTION'
| 'GRANT' privileges 'ON' 'TYPE' target_types 'TO' role_spec_list
| 'GRANT' privileges 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' privileges 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list
| 'GRANT' privileges 'ON' 'TYPE' target_types 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privileges 'ON' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option
| 'GRANT' privileges 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'TO' role_spec_list opt_with_grant_option

prepare_stmt ::=
'PREPARE' table_alias_name prep_type_clause 'AS' preparable_stmt

revoke_stmt ::=
'REVOKE' privileges 'ON' targets 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privileges 'ON' targets 'FROM' role_spec_list
| 'REVOKE' privilege_list 'FROM' role_spec_list
| 'REVOKE' 'ADMIN' 'OPTION' 'FOR' privilege_list 'FROM' role_spec_list
| 'REVOKE' privileges 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privileges 'ON' 'TYPE' target_types 'FROM' role_spec_list
| 'REVOKE' privileges 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privileges 'ON' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' privileges 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list
| 'REVOKE' 'GRANT' 'OPTION' 'FOR' privileges 'ON' 'ALL' 'TABLES' 'IN' 'SCHEMA' schema_name_list 'FROM' role_spec_list

savepoint_stmt ::=
'SAVEPOINT' name
Expand Down Expand Up @@ -321,6 +325,10 @@ targets ::=
role_spec_list ::=
( role_spec ) ( ( ',' role_spec ) )*

opt_with_grant_option ::=
'WITH' 'GRANT' 'OPTION'
|

privilege_list ::=
( privilege ) ( ( ',' privilege ) )*

Expand Down Expand Up @@ -2338,10 +2346,6 @@ alter_default_privileges_target_object ::=
| 'TYPES'
| 'SCHEMAS'

opt_with_grant_option ::=
'WITH' 'GRANT' 'OPTION'
|

role_option ::=
'CREATEROLE'
| 'NOCREATEROLE'
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ func remapPublicSchemas(
// In CockroachDB, root is our substitute for the postgres user.
publicSchemaPrivileges := descpb.NewBasePrivilegeDescriptor(security.AdminRoleName())
// By default, everyone has USAGE and CREATE on the public schema.
publicSchemaPrivileges.Grant(security.PublicRoleName(), privilege.List{privilege.CREATE, privilege.USAGE})
publicSchemaPrivileges.Grant(security.PublicRoleName(), privilege.List{privilege.CREATE, privilege.USAGE}, false)
publicSchemaDesc := schemadesc.NewBuilder(&descpb.SchemaDescriptor{
ParentID: db.GetID(),
Name: tree.PublicSchema,
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/importccl/import_table_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func MakeTestingSimpleTableDescriptor(
Privileges: descpb.NewPrivilegeDescriptor(
security.PublicRoleName(),
privilege.SchemaPrivileges,
privilege.List{},
security.RootUserName(),
),
}).BuildCreatedMutableSchema()
Expand Down
Loading