From e11034b7d2b217039e81a66832e07aec1aa5a56c Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 24 Sep 2016 12:03:55 +0800 Subject: [PATCH] sql: Log statements to event log earlier This ensures that all statements get logged, particularly COMMIT and ROLLBACK, which were handled with an early return before the previous location of the logging statement. --- sql/executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/executor.go b/sql/executor.go index dbfef1e97143..0c486a4b8f85 100644 --- a/sql/executor.go +++ b/sql/executor.go @@ -881,6 +881,9 @@ func (e *Executor) execStmtInOpenTxn( planMaker.evalCtx.SetTxnTimestamp(txnState.sqlTimestamp) planMaker.evalCtx.SetStmtTimestamp(e.cfg.Clock.PhysicalTime()) + session := planMaker.session + log.Event(session.context, stmt.String()) + // TODO(cdo): Figure out how to not double count on retries. e.updateStmtCounts(stmt) switch s := stmt.(type) { @@ -980,9 +983,6 @@ func (e *Executor) execStmtInOpenTxn( return Result{PGTag: s.StatementTag()}, nil } - session := planMaker.session - log.Event(session.context, stmt.String()) - result, err := e.execStmt(stmt, planMaker, implicitTxn /* autoCommit */) if err != nil { if traceSQL {