@@ -100,7 +100,7 @@ func (t *tableEditor) Close(ctx *sql.Context) error {
100100
101101 // On the normal INSERT / UPDATE / DELETE path this happens at StatementComplete time, but for table rewrites it
102102 // only happens at Close
103- err := t .ea .ApplyEdits (t .editedTable )
103+ err := t .ea .ApplyEdits (ctx , t .editedTable )
104104 if err != nil {
105105 return err
106106 }
@@ -127,7 +127,7 @@ func (t *tableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) e
127127}
128128
129129func (t * tableEditor ) StatementComplete (ctx * sql.Context ) error {
130- err := t .ea .ApplyEdits (t .editedTable )
130+ err := t .ea .ApplyEdits (ctx , t .editedTable )
131131 if err != nil {
132132 return nil
133133 }
@@ -285,10 +285,10 @@ func (t *tableEditor) PreciseMatch() bool {
285285 return true
286286}
287287
288- func (t * tableEditor ) IndexedAccess (lookup sql.IndexLookup ) sql.IndexedTable {
288+ func (t * tableEditor ) IndexedAccess (ctx * sql. Context , lookup sql.IndexLookup ) sql.IndexedTable {
289289 // Before we return an indexed access for this table, we need to apply all the edits to the table
290290 // TODO: optimize this, should create some struct that encloses the tableEditor and filters based on the lookup
291- err := t .ea .ApplyEdits (t .editedTable )
291+ err := t .ea .ApplyEdits (ctx , t .editedTable )
292292 if err != nil {
293293 return nil
294294 }
@@ -378,7 +378,7 @@ type tableEditAccumulator interface {
378378 Get (value sql.Row ) (sql.Row , bool , error )
379379 // ApplyEdits updates the table provided with the inserts and deletes that have been added to the accumulator.
380380 // Does not clear the accumulator.
381- ApplyEdits (table * Table ) error
381+ ApplyEdits (ctx * sql. Context , table * Table ) error
382382 // GetByCols returns the row in the table, or the pending edits, matching the ones given
383383 GetByCols (value sql.Row , cols []int , prefixLengths []uint16 ) (sql.Row , bool , error )
384384 // Clear wipes all of the stored inserts and deletes that may or may not have been applied.
@@ -487,7 +487,7 @@ func (pke *pkTableEditAccumulator) GetByCols(value sql.Row, cols []int, prefixLe
487487}
488488
489489// ApplyEdits implements the tableEditAccumulator interface.
490- func (pke * pkTableEditAccumulator ) ApplyEdits (table * Table ) error {
490+ func (pke * pkTableEditAccumulator ) ApplyEdits (ctx * sql. Context , table * Table ) error {
491491
492492 if err := pke .deletes .Foreach (func (key string , val sql.Row ) error {
493493 return pke .deleteHelper (pke .tableData , val )
@@ -497,7 +497,7 @@ func (pke *pkTableEditAccumulator) ApplyEdits(table *Table) error {
497497 }
498498
499499 if err := pke .adds .Foreach (func (key string , val sql.Row ) error {
500- return pke .insertHelper (pke .tableData , val )
500+ return pke .insertHelper (ctx , pke .tableData , val )
501501
502502 }); err != nil {
503503 return err
@@ -600,8 +600,8 @@ func deleteRowFromIndexes(table *TableData, partKey string, rowIdx int) {
600600}
601601
602602// insertHelper inserts the given row into the given tableData.
603- func (pke * pkTableEditAccumulator ) insertHelper (table * TableData , row sql.Row ) error {
604- partIdx , err := table .partition (row )
603+ func (pke * pkTableEditAccumulator ) insertHelper (ctx * sql. Context , table * TableData , row sql.Row ) error {
604+ partIdx , err := table .partition (ctx , row )
605605 if err != nil {
606606 return err
607607 }
@@ -748,7 +748,7 @@ func (k *keylessTableEditAccumulator) GetByCols(value sql.Row, cols []int, prefi
748748}
749749
750750// ApplyEdits implements the tableEditAccumulator interface.
751- func (k * keylessTableEditAccumulator ) ApplyEdits (table * Table ) error {
751+ func (k * keylessTableEditAccumulator ) ApplyEdits (ctx * sql. Context , table * Table ) error {
752752 for _ , val := range k .deletes {
753753 err := k .deleteHelper (k .tableData , val )
754754 if err != nil {
@@ -757,7 +757,7 @@ func (k *keylessTableEditAccumulator) ApplyEdits(table *Table) error {
757757 }
758758
759759 for _ , val := range k .adds {
760- err := k .insertHelper (k .tableData , val )
760+ err := k .insertHelper (ctx , k .tableData , val )
761761 if err != nil {
762762 return err
763763 }
@@ -814,8 +814,8 @@ func (k *keylessTableEditAccumulator) deleteHelper(table *TableData, row sql.Row
814814}
815815
816816// insertHelper inserts into a keyless tableData.
817- func (k * keylessTableEditAccumulator ) insertHelper (table * TableData , row sql.Row ) error {
818- partIdx , err := table .partition (row )
817+ func (k * keylessTableEditAccumulator ) insertHelper (ctx * sql. Context , table * TableData , row sql.Row ) error {
818+ partIdx , err := table .partition (ctx , row )
819819 if err != nil {
820820 return err
821821 }
@@ -866,8 +866,9 @@ func verifyRowTypes(row sql.Row, schema sql.Schema) error {
866866 if wrapper , isWrapper := rowVal .(sql.AnyWrapper ); isWrapper {
867867 method , _ := reflect .TypeOf (wrapper ).MethodByName ("Unwrap" )
868868 valType = method .Type .Out (0 )
869+ } else {
870+ valType = reflect .TypeOf (rowVal )
869871 }
870- valType = reflect .TypeOf (rowVal )
871872 expectedType := col .Type .ValueType ()
872873 if valType != expectedType && rowVal != nil && ! valType .AssignableTo (expectedType ) {
873874 return fmt .Errorf ("Actual Value Type: %s, Expected Value Type: %s" , valType .String (), expectedType .String ())
0 commit comments