Skip to content

Commit 82b360d

Browse files
authored
sql: Valid IDs in INSPECT SHARD (#31180)
Previously, INSPECT SHARD would panic if it was given an ID that didn't belong to any item. This commit fixes the issue by returning an error instead. Fixes #MaterializeInc/database-issues/issues/8910
1 parent ad94d8e commit 82b360d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/sql/src/plan/statement/scl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ pub fn plan_inspect_shard(
151151
// Always inspect the shard at the latest GlobalId.
152152
let gid = scx
153153
.catalog
154-
.get_item(&id)
154+
.try_get_item(&id)
155+
.ok_or_else(|| sql_err!("item doesn't exist"))?
155156
.at_version(RelationVersionSelector::Latest)
156157
.global_id();
157158
Ok(Plan::InspectShard(InspectShardPlan { id: gid }))

test/sqllogictest/shard_errors.slt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ INSERT INTO bar VALUES (1);
4141
# Make sure we get the error even if we project away all columns.
4242
query error division by zero
4343
SELECT count(*) FROM baz;
44+
45+
query error item doesn't exist
46+
INSPECT SHARD 'u666'

0 commit comments

Comments
 (0)