-
Notifications
You must be signed in to change notification settings - Fork 60
TNTP-3334: IPROTO_IS_SYNC support for begin/commit #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,26 +22,6 @@ type Prepared struct { | |||||||||||||||||||||||||||||||||||||||||
Conn *Connection | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
func fillPrepare(enc *msgpack.Encoder, expr string) error { | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeMapLen(1) | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeUint(uint64(iproto.IPROTO_SQL_TEXT)) | ||||||||||||||||||||||||||||||||||||||||||
return enc.EncodeString(expr) | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error { | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeMapLen(1) | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeUint(uint64(iproto.IPROTO_STMT_ID)) | ||||||||||||||||||||||||||||||||||||||||||
return enc.EncodeUint(uint64(stmt.StatementID)) | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error { | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeMapLen(2) | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeUint(uint64(iproto.IPROTO_STMT_ID)) | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeUint(uint64(stmt.StatementID)) | ||||||||||||||||||||||||||||||||||||||||||
enc.EncodeUint(uint64(iproto.IPROTO_SQL_BIND)) | ||||||||||||||||||||||||||||||||||||||||||
return encodeSQLBind(enc, args) | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// NewPreparedFromResponse constructs a Prepared object. | ||||||||||||||||||||||||||||||||||||||||||
func NewPreparedFromResponse(conn *Connection, resp Response) (*Prepared, error) { | ||||||||||||||||||||||||||||||||||||||||||
if resp == nil { | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -81,8 +61,16 @@ func NewPrepareRequest(expr string) *PrepareRequest { | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Body fills an msgpack.Encoder with the execute request body. | ||||||||||||||||||||||||||||||||||||||||||
func (req *PrepareRequest) Body(res SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
return fillPrepare(enc, req.expr) | ||||||||||||||||||||||||||||||||||||||||||
func (req *PrepareRequest) Body(_ SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
err := enc.EncodeMapLen(1) | ||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
err = enc.EncodeUint(uint64(iproto.IPROTO_SQL_TEXT)) | ||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
return enc.EncodeString(req.expr) | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+65
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a code style issue, but please add a blank line after an error check.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Context sets a passed context to the request. | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -126,8 +114,16 @@ func (req *UnprepareRequest) Conn() *Connection { | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Body fills an msgpack.Encoder with the execute request body. | ||||||||||||||||||||||||||||||||||||||||||
func (req *UnprepareRequest) Body(res SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
return fillUnprepare(enc, *req.stmt) | ||||||||||||||||||||||||||||||||||||||||||
func (req *UnprepareRequest) Body(_ SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
err := enc.EncodeMapLen(1) | ||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
err = enc.EncodeUint(uint64(iproto.IPROTO_STMT_ID)) | ||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
return enc.EncodeUint(uint64(req.stmt.StatementID)) | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Context sets a passed context to the request. | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -171,8 +167,24 @@ func (req *ExecutePreparedRequest) Args(args interface{}) *ExecutePreparedReques | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Body fills an msgpack.Encoder with the execute request body. | ||||||||||||||||||||||||||||||||||||||||||
func (req *ExecutePreparedRequest) Body(res SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
return fillExecutePrepared(enc, *req.stmt, req.args) | ||||||||||||||||||||||||||||||||||||||||||
func (req *ExecutePreparedRequest) Body(_ SchemaResolver, enc *msgpack.Encoder) error { | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For here and all other functions. |
||||||||||||||||||||||||||||||||||||||||||
err := enc.EncodeMapLen(2) | ||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
err = enc.EncodeUint(uint64(iproto.IPROTO_STMT_ID)) | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
err = enc.EncodeUint(uint64(req.stmt.StatementID)) | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
err = enc.EncodeUint(uint64(iproto.IPROTO_SQL_BIND)) | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
return encodeSQLBind(enc, req.args) | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Context sets a passed context to the request. | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.