Skip to content

Commit

Permalink
sql: Valid IDs in INSPECT SHARD (MaterializeInc#31180)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jkosh44 authored and antiguru committed Jan 24, 2025
1 parent 440a314 commit aa8f5ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sql/src/plan/statement/scl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ pub fn plan_inspect_shard(
// Always inspect the shard at the latest GlobalId.
let gid = scx
.catalog
.get_item(&id)
.try_get_item(&id)
.ok_or_else(|| sql_err!("item doesn't exist"))?
.at_version(RelationVersionSelector::Latest)
.global_id();
Ok(Plan::InspectShard(InspectShardPlan { id: gid }))
Expand Down
3 changes: 3 additions & 0 deletions test/sqllogictest/shard_errors.slt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ INSERT INTO bar VALUES (1);
# Make sure we get the error even if we project away all columns.
query error division by zero
SELECT count(*) FROM baz;

query error item doesn't exist
INSPECT SHARD 'u666'

0 comments on commit aa8f5ed

Please sign in to comment.