From 8e9bccbe21dd77d3f6a5c3532301da3a1fd91490 Mon Sep 17 00:00:00 2001 From: Rafer Hazen Date: Thu, 25 Jul 2024 13:12:19 -0600 Subject: [PATCH] Extract Result#StatsEmpty Signed-off-by: Rafer Hazen --- go/sqltypes/result.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/go/sqltypes/result.go b/go/sqltypes/result.go index a42142dbff9..c1f63a1488b 100644 --- a/go/sqltypes/result.go +++ b/go/sqltypes/result.go @@ -324,10 +324,9 @@ func (result *Result) StripMetadata(incl querypb.ExecuteOptions_IncludedFields) // to another result.Note currently it doesn't handle cases like // if two results have different fields.We will enhance this function. func (result *Result) AppendResult(src *Result) { - if src.RowsAffected == 0 && len(src.Rows) == 0 && len(src.Fields) == 0 { + if src.StatsEmpty() && len(src.Rows) == 0 && len(src.Fields) == 0 { return } - if result.Fields == nil { result.Fields = src.Fields } @@ -345,6 +344,10 @@ func (result *Result) Stats() *Result { } } +func (result *Result) StatsEmpty() bool { + return result.RowsAffected == 0 +} + // MergeStats updates the receiver's stats by merging in the stats from src. func (result *Result) MergeStats(src *Result) { result.RowsAffected += src.RowsAffected