package pgtype

import (
	
	
	
)
QChar is for PostgreSQL's special 8-bit-only "char" type more akin to the C language's char type, or Go's byte type. (Note that the name in PostgreSQL itself is "char", in double-quotes, and not char.) It gets used a lot in PostgreSQL's system tables to hold a single ASCII character value (eg pg_class.relkind). It is named Qchar for quoted char to disambiguate from SQL standard type char. Not all possible values of QChar are representable in the text format. Therefore, QChar does not implement TextEncoder and TextDecoder. In addition, database/sql Scanner and database/sql/driver Value are not implemented.
type QChar struct {
	Int    int8
	Status Status
}

func ( *QChar) ( interface{}) error {
	if  == nil {
		* = QChar{Status: Null}
		return nil
	}

	if ,  := .(interface{ () interface{} });  {
		 := .()
		if  !=  {
			return .()
		}
	}

	switch value := .(type) {
	case int8:
		* = QChar{Int: , Status: Present}
	case uint8:
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case int16:
		if  < math.MinInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case uint16:
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case int32:
		if  < math.MinInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case uint32:
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case int64:
		if  < math.MinInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case uint64:
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case int:
		if  < math.MinInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case uint:
		if  > math.MaxInt8 {
			return fmt.Errorf("%d is greater than maximum value for QChar", )
		}
		* = QChar{Int: int8(), Status: Present}
	case string:
		,  := strconv.ParseInt(, 10, 8)
		if  != nil {
			return 
		}
		* = QChar{Int: int8(), Status: Present}
	default:
		if ,  := underlyingNumberType();  {
			return .()
		}
		return fmt.Errorf("cannot convert %v to QChar", )
	}

	return nil
}

func ( QChar) () interface{} {
	switch .Status {
	case Present:
		return .Int
	case Null:
		return nil
	default:
		return .Status
	}
}

func ( *QChar) ( interface{}) error {
	return int64AssignTo(int64(.Int), .Status, )
}

func ( *QChar) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = QChar{Status: Null}
		return nil
	}

	if len() != 1 {
		return fmt.Errorf(`invalid length for "char": %v`, len())
	}

	* = QChar{Int: int8([0]), Status: Present}
	return nil
}

func ( QChar) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	return append(, byte(.Int)), nil