Skip to content

Commit 0313a71

Browse files
craig[bot]yuzefovichZhouXing19spilchen
committed
155566: serverutils: fix log message for globalDefaultSelectionOverride r=yuzefovich a=yuzefovich Previously, if we used `globalDefaultSelectionOverride` to force usage of shared process tenant, we'd still see a log message as if external process tenant was started. This was the case since we didn't use the right boolean, and this is now fixed. Epic: None Release note: None 156150: datumrange: fix comment in GetRangesBeforeAndAfter r=ZhouXing19 a=ZhouXing19 Previously, the string terminator suffix bytes (0 1) are incorrectly padded with zero bytes. This commit is to correct it. Epic: None Release note: None 156273: sql/inspect: exclude REFCURSOR[] from index consistency comparisons r=spilchen a=spilchen The index consistency check previously filtered out REFCURSOR columns when constructing join predicates, but failed to do the same for REFCURSOR[] (arrays of cursors). Like REFCURSOR, these cannot be used in comparison operations. This change ensures that both REFCURSOR and REFCURSOR[] columns are properly excluded from such comparisons. Informs: #155483 Epic: CRDB-55075 Release note: none Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: ZhouXing19 <[email protected]> Co-authored-by: Matt Spilchen <[email protected]>
4 parents 35ec42c + b1b5d35 + d161a11 + 3fa40cd commit 0313a71

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

pkg/sql/inspect/index_consistency_check.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2929
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
3030
"github.com/cockroachdb/cockroach/pkg/sql/spanutils"
31-
"github.com/cockroachdb/cockroach/pkg/sql/types"
3231
"github.com/cockroachdb/cockroach/pkg/util/hlc"
3332
"github.com/cockroachdb/cockroach/pkg/util/log"
3433
"github.com/cockroachdb/errors"
@@ -149,9 +148,8 @@ func (c *indexConsistencyCheck) Start(
149148
}
150149
col := c.tableDesc.PublicColumns()[pos]
151150
otherColumns = append(otherColumns, col)
152-
if col.GetType().Family() == types.RefCursorFamily {
153-
// Refcursor values do not support equality comparison, so we cannot use
154-
// them in the join predicates that detect inconsistencies.
151+
if !tree.EqCmpAllowedForEquivalentTypes(col.GetType(), col.GetType()) {
152+
// We cannot use types in join predicates that don't allow for equality comparisons.
155153
return
156154
}
157155
joinColumns = append(joinColumns, col)

pkg/sql/logictest/testdata/logic_test/inspect

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,26 +514,47 @@ subtest end
514514
subtest refcursor_stored_column
515515

516516
statement ok
517-
CREATE TABLE refcursor_tbl (id INT PRIMARY KEY, a INT, c REFCURSOR);
517+
CREATE TABLE refcursor_tbl (id INT PRIMARY KEY, a INT, c REFCURSOR, d REFCURSOR[]);
518518

519519
statement ok
520-
INSERT INTO refcursor_tbl VALUES (1, 10, 'cursor1'), (2, 20, 'cursor2');
520+
INSERT INTO refcursor_tbl VALUES
521+
(1, 10, 'cursor1', ARRAY['c1a', 'c1b']::REFCURSOR[]),
522+
(2, 20, 'cursor2', ARRAY['c2a', 'c2b']::REFCURSOR[]);
521523

522524
# Verify that we cannot index the refcursor. They can only be included
523525
# in an index as stored columns.
524526
statement error pq: unimplemented: column c has type refcursor, which is not indexable
525527
CREATE INDEX idx_refcursor ON refcursor_tbl (c);
526528

527529
statement ok
528-
CREATE INDEX idx_refcursor ON refcursor_tbl (a) STORING (c);
530+
CREATE INDEX idx_a_c ON refcursor_tbl (a) STORING (c);
531+
532+
statement ok
533+
CREATE INDEX idx_a_d ON refcursor_tbl (a) STORING (d);
529534

530535
statement ok
531536
INSPECT TABLE refcursor_tbl WITH OPTIONS INDEX ALL;
532537

533538
query TI
534539
SELECT * FROM last_inspect_job;
535540
----
536-
succeeded 1
541+
succeeded 2
542+
543+
# Test with hash optimization disabled to ensure JOIN-based consistency check works.
544+
statement ok
545+
SET CLUSTER SETTING sql.inspect.index_consistency_hash.enabled = false;
546+
547+
statement ok
548+
INSPECT TABLE refcursor_tbl WITH OPTIONS INDEX ALL;
549+
550+
query TI
551+
SELECT * FROM last_inspect_job;
552+
----
553+
succeeded 2
554+
555+
# Re-enable hash optimization.
556+
statement ok
557+
SET CLUSTER SETTING sql.inspect.index_consistency_hash.enabled = true;
537558

538559
statement ok
539560
DROP TABLE refcursor_tbl;

pkg/sql/sem/tree/datumrange/range.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ import (
3737
// [\bluejay - \boar] represents the after range.
3838
//
3939
// bear := [18 98 101 97 114 0 1 ]
40-
// => [101 97 114 0 0 0 0 0 ]
40+
// => [101 97 114 0 1 0 0 0 ]
4141
//
4242
// bluejay := [18 98 108 117 101 106 97 121 0 1]
43-
// => [108 117 101 106 97 121 0 0 ]
43+
// => [108 117 101 106 97 121 0 1 ]
4444
//
4545
// boar := [18 98 111 97 114 0 1 ]
46-
// => [111 97 114 0 0 0 0 0 ]
46+
// => [111 97 114 0 1 0 0 0 ]
4747
//
4848
// bobcat := [18 98 111 98 99 97 116 0 1 ]
49-
// => [111 98 99 97 116 0 0 0 ]
49+
// => [111 98 99 97 116 0 1 0 ]
5050
//
5151
// We can now find the range before/after by finding the difference between
5252
// the lower and upper bounds:

pkg/testutils/serverutils/test_server_shim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func ShouldStartDefaultTestTenant(
141141
t.Logf("cluster virtualization disabled in global scope due to issue: #%d (expected label: %s)", issueNum, label)
142142
}
143143
} else {
144-
t.Log(defaultTestTenantMessage(shared) + "\n(override via TestingSetDefaultTenantSelectionOverride)")
144+
t.Log(defaultTestTenantMessage(override.SharedProcessMode()) + "\n(override via TestingSetDefaultTenantSelectionOverride)")
145145
}
146146
return override
147147
}

0 commit comments

Comments
 (0)