package pgproto3

import (
	
	
	

	
)

type Execute struct {
	Portal  string
	MaxRows uint32
}

// Frontend identifies this message as sendable by a PostgreSQL frontend.
func (*Execute) () {}

// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
// type identifier and 4 byte message length.
func ( *Execute) ( []byte) error {
	 := bytes.NewBuffer()

	,  := .ReadBytes(0)
	if  != nil {
		return 
	}
	.Portal = string([:len()-1])

	if .Len() < 4 {
		return &invalidMessageFormatErr{messageType: "Execute"}
	}
	.MaxRows = binary.BigEndian.Uint32(.Next(4))

	return nil
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *Execute) ( []byte) []byte {
	 = append(, 'E')
	 := len()
	 = pgio.AppendInt32(, -1)

	 = append(, .Portal...)
	 = append(, 0)

	 = pgio.AppendUint32(, .MaxRows)

	pgio.SetInt32([:], int32(len([:])))

	return 
}

// MarshalJSON implements encoding/json.Marshaler.
func ( Execute) () ([]byte, error) {
	return json.Marshal(struct {
		    string
		  string
		 uint32
	}{
		:    "Execute",
		:  .Portal,
		: .MaxRows,
	})
}