From adc482360fa452a47fb53ce8d05b8e7490263e63 Mon Sep 17 00:00:00 2001 From: Vivek Menezes Date: Thu, 14 Mar 2019 14:33:33 -0400 Subject: [PATCH] sql: fix error being swallowed by the sql row writer This fixes data inconsistencies when value encoding fails for some reason. Release note: None --- pkg/sql/row/writer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/sql/row/writer.go b/pkg/sql/row/writer.go index 8d85695f03c2..6e023848d2ad 100644 --- a/pkg/sql/row/writer.go +++ b/pkg/sql/row/writer.go @@ -717,7 +717,7 @@ func (ru *Updater) UpdateRow( ru.marshaled, ru.UpdateColIDtoRowIndex, &ru.key, &ru.value, ru.valueBuf, insertPutFn, true /* overwrite */, traceKV) if err != nil { - return ru.newValues, nil + return nil, err } // Update secondary indexes. @@ -808,11 +808,10 @@ func (ru *Updater) UpdateRow( if err := ru.Fks.addIndexChecks(ctx, oldValues, ru.newValues, traceKV); err != nil { return nil, err } - if !ru.Fks.hasFKs() { - return ru.newValues, nil - } - if err := ru.Fks.checker.runCheck(ctx, oldValues, ru.newValues); err != nil { - return nil, err + if ru.Fks.hasFKs() { + if err := ru.Fks.checker.runCheck(ctx, oldValues, ru.newValues); err != nil { + return nil, err + } } }