Skip to content

Commit

Permalink
code health: place fill* functions in the beginning of the files
Browse files Browse the repository at this point in the history
File `requests.go` has `fill*` functions as well
as `prepare.go` file. We should sync with `requests.go`
and place `fill*` functions in the beginning of `prepare.go` file.

Follows up #117
Part of #101
  • Loading branch information
AnaNek committed Jul 26, 2022
1 parent 609268f commit 5fd3042
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ type Prepared struct {
Conn *Connection
}

func fillPrepare(enc *msgpack.Encoder, expr string) error {
enc.EncodeMapLen(1)
enc.EncodeUint64(KeySQLText)
return enc.EncodeString(expr)
}

func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error {
enc.EncodeMapLen(1)
enc.EncodeUint64(KeyStmtID)
return enc.EncodeUint64(uint64(stmt.StatementID))
}

func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error {
enc.EncodeMapLen(2)
enc.EncodeUint64(KeyStmtID)
enc.EncodeUint64(uint64(stmt.StatementID))
enc.EncodeUint64(KeySQLBind)
return encodeSQLBind(enc, args)
}

// NewPreparedFromResponse constructs a Prepared object.
func NewPreparedFromResponse(conn *Connection, resp *Response) (*Prepared, error) {
if resp == nil {
Expand Down Expand Up @@ -150,23 +170,3 @@ func (req *ExecutePreparedRequest) Context(ctx context.Context) *ExecutePrepared
req.ctx = ctx
return req
}

func fillPrepare(enc *msgpack.Encoder, expr string) error {
enc.EncodeMapLen(1)
enc.EncodeUint64(KeySQLText)
return enc.EncodeString(expr)
}

func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error {
enc.EncodeMapLen(1)
enc.EncodeUint64(KeyStmtID)
return enc.EncodeUint64(uint64(stmt.StatementID))
}

func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error {
enc.EncodeMapLen(2)
enc.EncodeUint64(KeyStmtID)
enc.EncodeUint64(uint64(stmt.StatementID))
enc.EncodeUint64(KeySQLBind)
return encodeSQLBind(enc, args)
}

0 comments on commit 5fd3042

Please sign in to comment.