예제 #1
0
func (c *FrontendConnection) readBindMessage(msg *fbcore.Message) error {
	portalName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return err
	}
	if portalName != "" {
		return fmt.Errorf("attempted to bind to a named portal %q; only the unnamed portal is supported")
	}
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return err
	}
	if statementName != "" {
		return fmt.Errorf("attempted to bind statement %q, even though it has not been parsed yet", statementName)
	}
	numParamFormats, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return err
	}
	if numParamFormats != 0 {
		return fmt.Errorf("the number of parameter formats (%d) does not match the number of parameters in the query (0)", numParamFormats)
	}
	numParameters, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return err
	}
	if numParameters != 0 {
		return fmt.Errorf("the number of parameters provided by the client (%d) does not match the number of parameters in the query (0)", numParameters)
	}
	// TODO: ensure we're at the end of the packet
	return nil
}
예제 #2
0
func (c *FrontendConnection) readParseMessage(msg *fbcore.Message) (queryString string, err error) {
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return "", err
	}
	if statementName != "" {
		return "", fmt.Errorf("attempted to use statement name %q; only unnamed statements are supported")
	}
	queryString, err = fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return "", err
	}
	numParamTypes, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return "", err
	}
	if numParamTypes != 0 {
		return "", fmt.Errorf("attempted to prepare a statement with %d param types", numParamTypes)
	}
	// TODO: ensure we're at the end of the packet
	return queryString, nil
}