Skip to content

Commit

Permalink
fix: php 8.0 pdo will check the flag bit (#159) (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
dk-lockdown authored Jun 20, 2022
1 parent 2745593 commit 0fd83bb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/listener/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/cectc/dbpack/pkg/proto"
"github.com/cectc/dbpack/pkg/visitor"
"github.com/cectc/dbpack/third_party/parser"
"github.com/cectc/dbpack/third_party/parser/ast"
)

const initClientConnStatus = constant.ServerStatusAutocommit
Expand Down Expand Up @@ -576,7 +575,7 @@ func (l *MysqlListener) ExecuteCommand(ctx context.Context, c *mysql.Conn, data
// to extract the affected rows and last insert id from the result
// struct here since clients expect it.
flag := c.StatusFlags()
if _, ok := stmt.(*ast.BeginStmt); ok {
if l.executor.InLocalTransaction(ctx) {
flag = flag | constant.ServerStatusInTrans
}
return c.WriteOKPacket(rlt.AffectedRows, rlt.InsertId, flag, warn)
Expand Down Expand Up @@ -738,7 +737,11 @@ func (l *MysqlListener) ExecuteCommand(ctx context.Context, c *mysql.Conn, data
// We should not send any more packets after this, but make sure
// to extract the affected rows and last insert id from the result
// struct here since clients expect it.
return c.WriteOKPacket(rlt.AffectedRows, rlt.InsertId, c.StatusFlags(), warn)
flag := c.StatusFlags()
if l.executor.InLocalTransaction(ctx) {
flag = flag | constant.ServerStatusInTrans
}
return c.WriteOKPacket(rlt.AffectedRows, rlt.InsertId, flag, warn)
}

err = c.WriteFields(l.capabilities, rlt.Fields)
Expand Down

0 comments on commit 0fd83bb

Please sign in to comment.