@@ -1401,6 +1401,25 @@ func ordinalsToIndexes(table cat.Table, ords cat.IndexOrdinals) []catalog.Index
1401
1401
return retval
1402
1402
}
1403
1403
1404
+ func ordinalsToIndexes2 (
1405
+ table cat.Table , a , b cat.IndexOrdinals ,
1406
+ ) ([]catalog.Index , []catalog.Index ) {
1407
+ lenA , lenB := len (a ), len (b )
1408
+ if lenA + lenB == 0 {
1409
+ return nil , nil
1410
+ }
1411
+
1412
+ indexes := make ([]catalog.Index , lenA + lenB )
1413
+ indexesA , indexesB := indexes [:lenA :lenA ], indexes [lenA :]
1414
+ for i , idx := range a {
1415
+ indexesA [i ] = table .Index (idx ).(* optIndex ).idx
1416
+ }
1417
+ for i , idx := range b {
1418
+ indexesB [i ] = table .Index (idx ).(* optIndex ).idx
1419
+ }
1420
+ return indexesA , indexesB
1421
+ }
1422
+
1404
1423
func (ef * execFactory ) ConstructInsert (
1405
1424
input exec.Node ,
1406
1425
table cat.Table ,
@@ -1724,11 +1743,12 @@ func (ef *execFactory) constructUpdateRun(
1724
1743
fetchCols , updateCols := makeColList2 (table , fetchColOrdSet , updateColOrdSet )
1725
1744
1726
1745
// Create the table updater.
1746
+ tombstoneIdxs , lockIdxs := ordinalsToIndexes2 (table , uniqueWithTombstoneIndexes , lockedIndexes )
1727
1747
ru , err := row .MakeUpdater (
1728
1748
ef .planner .ExecCfg ().Codec ,
1729
1749
tabDesc ,
1730
- ordinalsToIndexes ( table , uniqueWithTombstoneIndexes ) ,
1731
- ordinalsToIndexes ( table , lockedIndexes ) ,
1750
+ tombstoneIdxs ,
1751
+ lockIdxs ,
1732
1752
updateCols ,
1733
1753
fetchCols ,
1734
1754
row .UpdaterDefault ,
@@ -1799,11 +1819,12 @@ func (ef *execFactory) ConstructUpsert(
1799
1819
}
1800
1820
1801
1821
// Create the table updater, which does the bulk of the update-related work.
1822
+ tombstoneIdxs , lockIdxs := ordinalsToIndexes2 (table , uniqueWithTombstoneIndexes , lockedIndexes )
1802
1823
ru , err := row .MakeUpdater (
1803
1824
ef .planner .ExecCfg ().Codec ,
1804
1825
tabDesc ,
1805
- ordinalsToIndexes ( table , uniqueWithTombstoneIndexes ) ,
1806
- ordinalsToIndexes ( table , lockedIndexes ) ,
1826
+ tombstoneIdxs ,
1827
+ lockIdxs ,
1807
1828
updateCols ,
1808
1829
fetchCols ,
1809
1830
row .UpdaterDefault ,
0 commit comments