From 30a609d2f552cd9e8c7e4c8f2982d1bf71d3c590 Mon Sep 17 00:00:00 2001 From: Rafael Chacon Date: Thu, 28 Mar 2019 11:28:41 -0700 Subject: [PATCH] Fix potential nil pointer error Signed-off-by: Rafael Chacon --- go/vt/vttablet/tabletserver/tabletserver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go/vt/vttablet/tabletserver/tabletserver.go b/go/vt/vttablet/tabletserver/tabletserver.go index d9d2529604b..003b27708a0 100644 --- a/go/vt/vttablet/tabletserver/tabletserver.go +++ b/go/vt/vttablet/tabletserver/tabletserver.go @@ -1076,12 +1076,16 @@ func (tsv *TabletServer) ExecuteBatch(ctx context.Context, target *querypb.Targe defer tsv.endRequest(false) defer tsv.handlePanicAndSendLogStats("batch", nil, nil) + if options == nil { + options = &querypb.ExecuteOptions{} + } + // When all these conditions are met, we send the queries directly // to the MySQL without creating a transaction. This optimization // yields better throughput. // Setting ExecuteOptions_AUTOCOMMIT will get a connection out of the // pool without actually begin/commit the transaction. - if (options == nil || options.TransactionIsolation == querypb.ExecuteOptions_DEFAULT) && + if (options.TransactionIsolation == querypb.ExecuteOptions_DEFAULT) && tsv.qe.autoCommit.Get() && asTransaction && tsv.qe.passthroughDMLs.Get() {