@@ -14,7 +14,6 @@ type Backend struct {
|
|||||||
// Frontend message flyweights
|
// Frontend message flyweights
|
||||||
bind Bind
|
bind Bind
|
||||||
_close Close
|
_close Close
|
||||||
copyFail CopyFail
|
|
||||||
describe Describe
|
describe Describe
|
||||||
execute Execute
|
execute Execute
|
||||||
flush Flush
|
flush Flush
|
||||||
@@ -81,8 +80,6 @@ func (b *Backend) Receive() (FrontendMessage, error) {
|
|||||||
msg = &b.describe
|
msg = &b.describe
|
||||||
case 'E':
|
case 'E':
|
||||||
msg = &b.execute
|
msg = &b.execute
|
||||||
case 'f':
|
|
||||||
msg = &b.copyFail
|
|
||||||
case 'H':
|
case 'H':
|
||||||
msg = &b.flush
|
msg = &b.flush
|
||||||
case 'P':
|
case 'P':
|
||||||
|
|||||||
+9
-10
@@ -8,11 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CopyFail struct {
|
type CopyFail struct {
|
||||||
Error string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*CopyFail) Frontend() {}
|
func (*CopyFail) Backend() {}
|
||||||
func (*CopyFail) Backend() {}
|
|
||||||
|
|
||||||
func (dst *CopyFail) Decode(src []byte) error {
|
func (dst *CopyFail) Decode(src []byte) error {
|
||||||
idx := bytes.IndexByte(src, 0)
|
idx := bytes.IndexByte(src, 0)
|
||||||
@@ -20,17 +19,17 @@ func (dst *CopyFail) Decode(src []byte) error {
|
|||||||
return &invalidMessageFormatErr{messageType: "CopyFail"}
|
return &invalidMessageFormatErr{messageType: "CopyFail"}
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.Error = string(src[:idx])
|
dst.Message = string(src[:idx])
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (src *CopyFail) Encode(dst []byte) []byte {
|
func (src *CopyFail) Encode(dst []byte) []byte {
|
||||||
dst = append(dst, 'C')
|
dst = append(dst, 'f')
|
||||||
sp := len(dst)
|
sp := len(dst)
|
||||||
dst = pgio.AppendInt32(dst, -1)
|
dst = pgio.AppendInt32(dst, -1)
|
||||||
|
|
||||||
dst = append(dst, src.Error...)
|
dst = append(dst, src.Message...)
|
||||||
dst = append(dst, 0)
|
dst = append(dst, 0)
|
||||||
|
|
||||||
pgio.SetInt32(dst[sp:], int32(len(dst[sp:])))
|
pgio.SetInt32(dst[sp:], int32(len(dst[sp:])))
|
||||||
@@ -40,10 +39,10 @@ func (src *CopyFail) Encode(dst []byte) []byte {
|
|||||||
|
|
||||||
func (src *CopyFail) MarshalJSON() ([]byte, error) {
|
func (src *CopyFail) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(struct {
|
return json.Marshal(struct {
|
||||||
Type string
|
Type string
|
||||||
Error string
|
Message string
|
||||||
}{
|
}{
|
||||||
Type: "CopyFail",
|
Type: "CopyFail",
|
||||||
Error: src.Error,
|
Message: src.Message,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ func (src *CopyOutResponse) Encode(dst []byte) []byte {
|
|||||||
sp := len(dst)
|
sp := len(dst)
|
||||||
dst = pgio.AppendInt32(dst, -1)
|
dst = pgio.AppendInt32(dst, -1)
|
||||||
|
|
||||||
|
dst = append(dst, src.OverallFormat)
|
||||||
|
|
||||||
dst = pgio.AppendUint16(dst, uint16(len(src.ColumnFormatCodes)))
|
dst = pgio.AppendUint16(dst, uint16(len(src.ColumnFormatCodes)))
|
||||||
for _, fc := range src.ColumnFormatCodes {
|
for _, fc := range src.ColumnFormatCodes {
|
||||||
dst = pgio.AppendUint16(dst, fc)
|
dst = pgio.AppendUint16(dst, fc)
|
||||||
|
|||||||
Reference in New Issue
Block a user