Skip to content

Commit b8505db

Browse files
craig[bot]spilchen
andcommitted
Merge #154277
154277: sql/inspect: fix missing String() method for InspectDetails_Check_InspectCheckType r=spilchen a=spilchen Changed `goproto_enum_stringer = false` to `true` in jobs.proto to generate the required String() method. This fixes panics when using pb_to_json() on INSPECT job payloads. Added logictest verification. Release note: None Epic: CRDB-30356 Co-authored-by: Matt Spilchen <[email protected]>
2 parents 5ad1ee9 + 311ba9b commit b8505db

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pkg/jobs/jobspb/jobs.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ message InspectDetails {
14511451
message Check {
14521452
enum InspectCheckType {
14531453
option (gogoproto.goproto_enum_prefix) = false;
1454-
option (gogoproto.goproto_enum_stringer) = false;
1454+
option (gogoproto.goproto_enum_stringer) = true;
14551455

14561456
// UNSPECIFIED indicates an unset check type. This is invalid.
14571457
INSPECT_CHECK_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "InspectCheckUnspecified"];

pkg/sql/logictest/testdata/logic_test/inspect

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ SELECT description, status, finished IS NOT NULL AS finished FROM [SHOW JOBS] WH
2727
----
2828
EXPERIMENTAL SCRUB TABLE t1 AS OF SYSTEM TIME '-1us' succeeded true
2929

30+
# Verify the checks that were done.
31+
query TI
32+
SELECT
33+
json_extract_path_text(
34+
crdb_internal.pb_to_json('cockroach.sql.jobs.jobspb.Payload', payload),
35+
'inspectDetails', 'checks', '0', 'type'
36+
) AS check_type,
37+
jsonb_array_length(
38+
crdb_internal.pb_to_json('cockroach.sql.jobs.jobspb.Payload', payload) -> 'inspectDetails' -> 'checks'
39+
) AS num_checks
40+
FROM crdb_internal.system_jobs
41+
WHERE job_type = 'INSPECT'
42+
ORDER BY created DESC
43+
LIMIT 1
44+
----
45+
INSPECT_CHECK_INDEX_CONSISTENCY 1
46+
3047
subtest end
3148

3249
subtest scrub_job_multi_stmt_txn

0 commit comments

Comments
 (0)