@@ -51,14 +51,14 @@ func requireCheckCountsMatch(t *testing.T, r *sqlutils.SQLRunner, jobID int64) {
5151// Returns the encoded index entry, expecting exactly one entry to be produced.
5252// Returns an error if the encoding fails or if multiple index entries are generated.
5353func encodeSecondaryIndexEntry (
54- row []tree.Datum , tableDesc catalog.TableDescriptor , index catalog.Index ,
54+ codec keys. SQLCodec , row []tree.Datum , tableDesc catalog.TableDescriptor , index catalog.Index ,
5555) (rowenc.IndexEntry , error ) {
5656 var colIDtoRowIndex catalog.TableColMap
5757 for i , c := range tableDesc .PublicColumns () {
5858 colIDtoRowIndex .Set (c .GetID (), i )
5959 }
6060 indexEntries , err := rowenc .EncodeSecondaryIndex (
61- context .Background (), keys . SystemSQLCodec , tableDesc , index ,
61+ context .Background (), codec , tableDesc , index ,
6262 colIDtoRowIndex , row , rowenc .EmptyVectorIndexEncodingHelper , true , /* includeEmpty */
6363 )
6464 if err != nil {
@@ -77,12 +77,13 @@ func encodeSecondaryIndexEntry(
7777// if multiple entries are produced.
7878func deleteSecondaryIndexEntry (
7979 ctx context.Context ,
80+ codec keys.SQLCodec ,
8081 row []tree.Datum ,
8182 kvDB * kv.DB ,
8283 tableDesc catalog.TableDescriptor ,
8384 index catalog.Index ,
8485) error {
85- entry , err := encodeSecondaryIndexEntry (row , tableDesc , index )
86+ entry , err := encodeSecondaryIndexEntry (codec , row , tableDesc , index )
8687 if err != nil {
8788 return err
8889 }
@@ -96,12 +97,13 @@ func deleteSecondaryIndexEntry(
9697// if multiple entries are produced.
9798func insertSecondaryIndexEntry (
9899 ctx context.Context ,
100+ codec keys.SQLCodec ,
99101 row []tree.Datum ,
100102 kvDB * kv.DB ,
101103 tableDesc catalog.TableDescriptor ,
102104 index catalog.Index ,
103105) error {
104- entry , err := encodeSecondaryIndexEntry (row , tableDesc , index )
106+ entry , err := encodeSecondaryIndexEntry (codec , row , tableDesc , index )
105107 if err != nil {
106108 return err
107109 }
@@ -119,7 +121,6 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
119121 cl := serverutils .StartCluster (t , numNodes , base.TestClusterArgs {
120122 ReplicationMode : base .ReplicationManual ,
121123 ServerArgs : base.TestServerArgs {
122- DefaultTestTenant : base .TestIsSpecificToStorageLayerAndNeedsASystemTenant ,
123124 Knobs : base.TestingKnobs {
124125 Inspect : & sql.InspectTestingKnobs {
125126 InspectIssueLogger : issueLogger ,
@@ -131,11 +132,12 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
131132 },
132133 })
133134 defer cl .Stopper ().Stop (ctx )
135+ s := cl .ApplicationLayer (0 )
134136
135- db := cl . ServerConn ( 0 )
136- kvDB := cl . Server ( 0 ) .DB ()
137- codec := cl . Server ( 0 ) .Codec ()
138- ie := cl . Server ( 0 ) .InternalExecutor ().(* sql.InternalExecutor )
137+ db := s . SQLConn ( t )
138+ kvDB := s .DB ()
139+ codec := s .Codec ()
140+ ie := s .InternalExecutor ().(* sql.InternalExecutor )
139141 r := sqlutils .MakeSQLRunner (db )
140142
141143 for _ , tc := range []struct {
@@ -411,7 +413,7 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
411413 tc .missingIndexEntrySelector )
412414 t .Logf ("Corrupting %d rows that match filter by deleting secondary index keys: %s" , len (rows ), tc .missingIndexEntrySelector )
413415 for _ , row := range rows {
414- err = deleteSecondaryIndexEntry (ctx , row , kvDB , tableDesc , secIndex )
416+ err = deleteSecondaryIndexEntry (ctx , codec , row , kvDB , tableDesc , secIndex )
415417 require .NoError (t , err )
416418 }
417419 }
@@ -425,7 +427,7 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
425427 t .Logf ("Corrupting %d rows by inserting keys into secondary index returned by this query: %s" ,
426428 len (rows ), tc .danglingIndexEntryInsertQuery )
427429 for _ , row := range rows {
428- err = insertSecondaryIndexEntry (ctx , row , kvDB , tableDesc , secIndex )
430+ err = insertSecondaryIndexEntry (ctx , codec , row , kvDB , tableDesc , secIndex )
429431 require .NoError (t , err )
430432 }
431433 }
0 commit comments