From 0a2b67c5c5f6fcb3b4bd53d3fc91c660ce0352d3 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Wed, 2 Dec 2020 09:32:01 -0600 Subject: [PATCH] CopyFromSlice should remember error --- copy_from.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/copy_from.go b/copy_from.go index c4540f3e..1e4d1373 100644 --- a/copy_from.go +++ b/copy_from.go @@ -45,6 +45,7 @@ type copyFromSlice struct { next func(int) ([]interface{}, error) idx int len int + err error } func (cts *copyFromSlice) Next() bool { @@ -53,11 +54,15 @@ func (cts *copyFromSlice) Next() bool { } func (cts *copyFromSlice) Values() ([]interface{}, error) { - return cts.next(cts.idx) + values, err := cts.next(cts.idx) + if err != nil { + cts.err = err + } + return values, err } func (cts *copyFromSlice) Err() error { - return nil + return cts.err } // CopyFromSource is the interface used by *Conn.CopyFrom as the source for copy data.