Skip to content

Commit

Permalink
server: Support flag 128 in execution of prepared statements (#36732)
Browse files Browse the repository at this point in the history
close #36731
  • Loading branch information
dveeden authored Aug 4, 2022
1 parent ac91c75 commit a6475a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
7 changes: 7 additions & 0 deletions parser/mysql/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,10 @@ const (
// Reference linking https://dev.mysql.com/doc/refman/5.7/en/partitioning-limitations.html.
PartitionCountLimit = 8192
)

// This is enum_cursor_type in MySQL
const (
CursorTypeReadOnly = 1 << iota
CursorTypeForUpdate
CursorTypeScrollable
)
21 changes: 9 additions & 12 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,18 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e

flag := data[pos]
pos++
// Please refer to https://dev.mysql.com/doc/internals/en/com-stmt-execute.html
// Please refer to https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html
// The client indicates that it wants to use cursor by setting this flag.
// 0x00 CURSOR_TYPE_NO_CURSOR
// 0x01 CURSOR_TYPE_READ_ONLY
// 0x02 CURSOR_TYPE_FOR_UPDATE
// 0x04 CURSOR_TYPE_SCROLLABLE
// Now we only support forward-only, read-only cursor.
var useCursor bool
switch flag {
case 0:
useCursor = false
case 1:
useCursor := false
if flag&mysql.CursorTypeReadOnly > 0 {
useCursor = true
default:
return mysql.NewErrf(mysql.ErrUnknown, "unsupported flag %d", nil, flag)
}
if flag&mysql.CursorTypeForUpdate > 0 {
return mysql.NewErrf(mysql.ErrUnknown, "unsupported flag: CursorTypeForUpdate", nil)
}
if flag&mysql.CursorTypeScrollable > 0 {
return mysql.NewErrf(mysql.ErrUnknown, "unsupported flag: CursorTypeScrollable", nil)
}

// skip iteration-count, always 1
Expand Down

0 comments on commit a6475a1

Please sign in to comment.