@@ -1596,6 +1596,8 @@ func (ef *execFactory) ConstructUpdate(
1596
1596
}
1597
1597
1598
1598
// If rows are not needed, no columns are returned.
1599
+ // TODO(mgartner): Combine returnCols allocations with allocations for
1600
+ // fetchCols and updateCols in constructUpdateRun.
1599
1601
var returnCols []catalog.Column
1600
1602
if rowsNeeded {
1601
1603
returnCols = makeColList (table , returnColOrdSet )
@@ -1719,8 +1721,7 @@ func (ef *execFactory) constructUpdateRun(
1719
1721
lockedIndexes cat.IndexOrdinals ,
1720
1722
) error {
1721
1723
tabDesc := table .(* optTable ).desc
1722
- fetchCols := makeColList (table , fetchColOrdSet )
1723
- updateCols := makeColList (table , updateColOrdSet )
1724
+ fetchCols , updateCols := makeColList2 (table , fetchColOrdSet , updateColOrdSet )
1724
1725
1725
1726
// Create the table updater.
1726
1727
ru , err := row .MakeUpdater (
@@ -2569,6 +2570,27 @@ func makeColList(table cat.Table, cols exec.TableColumnOrdinalSet) []catalog.Col
2569
2570
return ret
2570
2571
}
2571
2572
2573
+ // makeColList2 is similar to makeColList, but it takes two sets of ordinals and
2574
+ // allocates a single slice which is split into two.
2575
+ func makeColList2 (
2576
+ table cat.Table , a , b exec.TableColumnOrdinalSet ,
2577
+ ) ([]catalog.Column , []catalog.Column ) {
2578
+ tab := table .(optCatalogTableInterface )
2579
+ lenA , lenB := a .Len (), b .Len ()
2580
+ cols := make ([]catalog.Column , 0 , lenA + lenB )
2581
+ listA , listB := cols [:0 :lenA ], cols [lenA :lenA ]
2582
+ for i , n := 0 , table .ColumnCount (); i < n ; i ++ {
2583
+ col := tab .getCol (i )
2584
+ if a .Contains (i ) {
2585
+ listA = append (listA , col )
2586
+ }
2587
+ if b .Contains (i ) {
2588
+ listB = append (listB , col )
2589
+ }
2590
+ }
2591
+ return listA , listB
2592
+ }
2593
+
2572
2594
// makePublicToReturnColumnIndexMapping returns a map from the ordinals
2573
2595
// of the table's public columns to ordinals in the returnColDescs slice.
2574
2596
//
0 commit comments