Skip to content

Commit ac6605b

Browse files
committed
sql: fix check external connection evaluation
Previously, `CHECK EXTERNAL CONNECTION '' WITH CONCURRENCY = (SELECT 1)` would panic because its not able to evaluate an expression containing a sub query. Now, passing a sub query will fail with a user error. ``` CHECK EXTERNAL CONNECTION NULLIF WITH CONCURRENTLY = EXISTS ( ( TABLE error ) ); ERROR: subqueries are not allowed in check_external_connection SQLSTATE: 0A000 ``` Release note: none Informs: #147876 Informs: #147877
1 parent 33e1034 commit ac6605b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/sql/check_external_connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func (n *checkExternalConnectionNode) Close(_ context.Context) {
150150
}
151151

152152
func (n *checkExternalConnectionNode) parseParams(params runParams) error {
153+
params.p.SemaCtx().Properties.Require("check_external_connection", tree.RejectSubqueries)
153154
exprEval := params.p.ExprEvaluator("CHECK EXTERNAL CONNECTION")
154155
loc, err := exprEval.String(params.ctx, n.node.URI)
155156
if err != nil {

pkg/sql/logictest/testdata/logic_test/show_external_connections

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ SHOW EXTERNAL CONNECTIONS
6868
connection_name connection_uri connection_type
6969
foo_conn nodelocal://1/foo STORAGE
7070
baz_conn nodelocal://1/baz STORAGE
71+
72+
# Regression test for #147877
73+
statement error subqueries are not allowed in check_external_connection
74+
CHECK EXTERNAL CONNECTION NULLIF WITH CONCURRENTLY = EXISTS ( ( TABLE error ) );

0 commit comments

Comments
 (0)