-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
86161: externalconn: support `SHOW CREATE EXTERNAL CONNECTION` r=benbardin a=adityamaru This change adds support for `SHOW CREATE EXTERNAL CONNECTION` and `SHOW CREATE ALL EXTERNAL CONNECTIONS` that displays the connection name and the statement used to create the external connection. This displays unredacted information of the underlying resource and is therefore restricted to admin only or by the owner of the external connection object. Note, synthetic privileges do not have a concept of external connections at the moment. So, the operations are limited to admin only until that functionality is added. Informs: #85905 Release note (sql change): Add support for `SHOW CREATE EXTERNAL CONNECTION` and `SHOW CREATE ALL EXTERNAL CONNECTIONS` that displays the connection name and the unredacted query used to create the external connection. This can only be run by users of the admin role today. Release justification: low risk change to improve observability into external connections 86229: sql/parser: add `sequence_name_list` and `view_name_list` r=stbof a=ajwerner This will hopefully make for better diagrams. Fixes #86059 Release justification: docs only change Release note: None Co-authored-by: Aditya Maru <[email protected]> Co-authored-by: Andrew Werner <[email protected]>
- Loading branch information
Showing
26 changed files
with
537 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
drop_sequence_stmt ::= | ||
'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* 'CASCADE' | ||
| 'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* 'RESTRICT' | ||
| 'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'CASCADE' | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'RESTRICT' | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* | ||
'DROP' 'SEQUENCE' sequence_name_list 'CASCADE' | ||
| 'DROP' 'SEQUENCE' sequence_name_list 'RESTRICT' | ||
| 'DROP' 'SEQUENCE' sequence_name_list | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list 'CASCADE' | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list 'RESTRICT' | ||
| 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
drop_table_stmt ::= | ||
'DROP' 'TABLE' table_name ( ( ',' table_name ) )* 'CASCADE' | ||
| 'DROP' 'TABLE' table_name ( ( ',' table_name ) )* 'RESTRICT' | ||
| 'DROP' 'TABLE' table_name ( ( ',' table_name ) )* | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'CASCADE' | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'RESTRICT' | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* | ||
'DROP' 'TABLE' table_name_list 'CASCADE' | ||
| 'DROP' 'TABLE' table_name_list 'RESTRICT' | ||
| 'DROP' 'TABLE' table_name_list | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list 'CASCADE' | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list 'RESTRICT' | ||
| 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
drop_view_stmt ::= | ||
'DROP' 'VIEW' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'VIEW' 'IF' 'EXISTS' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'MATERIALIZED' 'VIEW' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) | ||
'DROP' 'VIEW' view_name_list ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'VIEW' 'IF' 'EXISTS' view_name_list ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'MATERIALIZED' 'VIEW' view_name_list ( 'CASCADE' | 'RESTRICT' | ) | ||
| 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' view_name_list ( 'CASCADE' | 'RESTRICT' | ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
for_locking_item ::= | ||
'FOR' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' | ||
| 'FOR' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' | ||
| 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' | ||
| 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' | ||
| 'FOR' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' | ||
| 'FOR' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' | ||
| 'FOR' 'KEY' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' | ||
| 'FOR' 'KEY' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' | ||
'FOR' 'UPDATE' 'OF' table_name_list 'SKIP' 'LOCKED' | ||
| 'FOR' 'UPDATE' 'OF' table_name_list 'NOWAIT' | ||
| 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name_list 'SKIP' 'LOCKED' | ||
| 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name_list 'NOWAIT' | ||
| 'FOR' 'SHARE' 'OF' table_name_list 'SKIP' 'LOCKED' | ||
| 'FOR' 'SHARE' 'OF' table_name_list 'NOWAIT' | ||
| 'FOR' 'KEY' 'SHARE' 'OF' table_name_list 'SKIP' 'LOCKED' | ||
| 'FOR' 'KEY' 'SHARE' 'OF' table_name_list 'NOWAIT' |
3 changes: 3 additions & 0 deletions
3
docs/generated/sql/bnf/show_create_external_connections_stmt.bnf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
show_create_external_connections_stmt ::= | ||
'SHOW' 'CREATE' 'ALL' 'EXTERNAL' 'CONNECTIONS' | ||
| 'SHOW' 'CREATE' 'EXTERNAL' 'CONNECTION' string_or_placeholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
pkg/ccl/cloudccl/externalconn/testdata/multi-tenant/show_create_external_connections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
subtest basic-show-create-ec | ||
|
||
initialize tenant=10 | ||
---- | ||
|
||
disable-check-external-storage | ||
---- | ||
|
||
disable-check-kms | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION nodelocal AS 'nodelocal://1/foo'; | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION kms AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted'; | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION kafka AS 'kafka://broker.address.com:9092'; | ||
---- | ||
|
||
query-sql | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
kafka CREATE EXTERNAL CONNECTION 'kafka' AS 'kafka://broker.address.com:9092' | ||
kms CREATE EXTERNAL CONNECTION 'kms' AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted' | ||
nodelocal CREATE EXTERNAL CONNECTION 'nodelocal' AS 'nodelocal://1/foo' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION nodelocal | ||
---- | ||
nodelocal CREATE EXTERNAL CONNECTION 'nodelocal' AS 'nodelocal://1/foo' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION kms | ||
---- | ||
kms CREATE EXTERNAL CONNECTION 'kms' AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION kafka | ||
---- | ||
kafka CREATE EXTERNAL CONNECTION 'kafka' AS 'kafka://broker.address.com:9092' | ||
|
||
|
||
enable-check-external-storage | ||
---- | ||
|
||
enable-check-kms | ||
---- | ||
|
||
subtest end | ||
|
||
subtest owner-or-admin | ||
|
||
# Create an external connection as root, only root should be able to SHOW this object. | ||
exec-sql | ||
CREATE EXTERNAL CONNECTION foo AS 'nodelocal://1/foo' | ||
---- | ||
|
||
exec-sql | ||
CREATE USER testuser | ||
---- | ||
|
||
exec-sql | ||
GRANT SYSTEM EXTERNALCONNECTION TO testuser | ||
---- | ||
|
||
query-sql user=testuser | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
pq: must be admin to run `SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
|
||
query-sql user=testuser | ||
SHOW CREATE EXTERNAL CONNECTION foo | ||
---- | ||
pq: must be admin or owner of the External Connection "foo" | ||
|
||
# Create External Connection where testuser is the owner, they should be able to SHOW this object. | ||
exec-sql user=testuser | ||
CREATE EXTERNAL CONNECTION bar AS 'nodelocal://1/foo' | ||
---- | ||
|
||
query-sql user=testuser | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
pq: must be admin to run `SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
|
||
# TODO(aditymaru): Synthetic privileges do not have a concept of owners. Once they do, testuser will | ||
# be able to run this query successfully since they are the owner of the External Connection object. | ||
# query-sql user=testuser | ||
# SHOW CREATE EXTERNAL CONNECTION bar | ||
# ---- | ||
|
||
subtest end |
92 changes: 92 additions & 0 deletions
92
pkg/ccl/cloudccl/externalconn/testdata/show_create_external_connections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
subtest basic-show-create-ec | ||
|
||
disable-check-external-storage | ||
---- | ||
|
||
disable-check-kms | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION nodelocal AS 'nodelocal://1/foo'; | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION kms AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted'; | ||
---- | ||
|
||
exec-sql | ||
CREATE EXTERNAL CONNECTION kafka AS 'kafka://broker.address.com:9092'; | ||
---- | ||
|
||
query-sql | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
kafka CREATE EXTERNAL CONNECTION 'kafka' AS 'kafka://broker.address.com:9092' | ||
kms CREATE EXTERNAL CONNECTION 'kms' AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted' | ||
nodelocal CREATE EXTERNAL CONNECTION 'nodelocal' AS 'nodelocal://1/foo' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION nodelocal | ||
---- | ||
nodelocal CREATE EXTERNAL CONNECTION 'nodelocal' AS 'nodelocal://1/foo' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION kms | ||
---- | ||
kms CREATE EXTERNAL CONNECTION 'kms' AS 'gs:///cmk?AUTH=implicit&CREDENTIALS=wont-be-redacted' | ||
|
||
query-sql | ||
SHOW CREATE EXTERNAL CONNECTION kafka | ||
---- | ||
kafka CREATE EXTERNAL CONNECTION 'kafka' AS 'kafka://broker.address.com:9092' | ||
|
||
enable-check-external-storage | ||
---- | ||
|
||
enable-check-kms | ||
---- | ||
|
||
subtest end | ||
|
||
subtest owner-or-admin | ||
|
||
# Create an external connection as root, only root should be able to SHOW this object. | ||
exec-sql | ||
CREATE EXTERNAL CONNECTION foo AS 'nodelocal://1/foo' | ||
---- | ||
|
||
exec-sql | ||
CREATE USER testuser | ||
---- | ||
|
||
exec-sql | ||
GRANT SYSTEM EXTERNALCONNECTION TO testuser | ||
---- | ||
|
||
query-sql user=testuser | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
pq: must be admin to run `SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
|
||
query-sql user=testuser | ||
SHOW CREATE EXTERNAL CONNECTION foo | ||
---- | ||
pq: must be admin or owner of the External Connection "foo" | ||
|
||
# Create External Connection where testuser is the owner, they should be able to SHOW this object. | ||
exec-sql user=testuser | ||
CREATE EXTERNAL CONNECTION bar AS 'nodelocal://1/foo' | ||
---- | ||
|
||
query-sql user=testuser | ||
SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
---- | ||
pq: must be admin to run `SHOW CREATE ALL EXTERNAL CONNECTIONS | ||
|
||
# TODO(aditymaru): Synthetic privileges do not have a concept of owners. Once they do, testuser will | ||
# be able to run this query successfully since they are the owner of the External Connection object. | ||
# query-sql user=testuser | ||
# SHOW CREATE EXTERNAL CONNECTION bar | ||
# ---- | ||
|
||
subtest end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.