// GetPrimary returns the Primary field if it's non-nil, zero value otherwise.
975519
func (u *UserEmail) GetPrimary() bool {
	if u == nil || u.Primary == nil {
		return false
	}
	return *u.Primary
}
985257
func (r *ProtoKeyValWrapper) GetPrevValue(prevValue proto.Message) (prevValueExist bool, err error) {
	exists, err := r.ProtoKeyVal.GetPrevValue(prevValue)
	if !exists || err != nil {
		return exists, err
	}
	_, err = r.decrypter.Decrypt(prevValue, r.decryptFunc)
	return exists, err
}
759229
func (mysqld *Mysqld) GetPrimaryKeyColumns(dbName, table string) ([]string, error) {
	conn, err := getPoolReconnect(context.TODO(), mysqld.dbaPool)
	if err != nil {
		return nil, err
	}
	defer conn.Recycle()
	qr, err := conn.ExecuteFetch(fmt.Sprintf("SHOW INDEX FROM %s.%s", sqlescape.EscapeID(dbName), sqlescape.EscapeID(table)), 100, true)
	if err != nil {
		return nil, err
	}
	keyNameIndex := -1
	seqInIndexIndex := -1
	columnNameIndex := -1
	for i, field := range qr.Fields {
		switch field.Name {
		case "Key_name":
			keyNameIndex = i
		case "Seq_in_index":
			seqInIndexIndex = i
		case "Column_name":
			columnNameIndex = i
		}
	}
	if keyNameIndex == -1 || seqInIndexIndex == -1 || columnNameIndex == -1 {
		return nil, fmt.Errorf("unknown columns in 'show index' result: %v", qr.Fields)
	}

	columns := make([]string, 0, 5)
	var expectedIndex int64 = 1
	for _, row := range qr.Rows {
		// skip non-primary keys
		if row[keyNameIndex].ToString() != "PRIMARY" {
			continue
		}

		// check the Seq_in_index is always increasing
		seqInIndex, err := sqltypes.ToInt64(row[seqInIndexIndex])
		if err != nil {
			return nil, err
		}
		if seqInIndex != expectedIndex {
			return nil, fmt.Errorf("unexpected index: %v != %v", seqInIndex, expectedIndex)
		}
		expectedIndex++

		columns = append(columns, row[columnNameIndex].ToString())
	}
	return columns, err
}
1229522
func (u *User) GetPrivateGists() int {
	if u == nil || u.PrivateGists == nil {
		return 0
	}
	return *u.PrivateGists
}
107401
func (b *PCMBuffer) SwitchPrimaryType(t PCMDataFormat) {
	if b == nil || t == b.DataType {
		return
	}
	switch t {
	case DataTypeI8:
		b.I8 = b.AsI8()
		b.I16 = nil
		b.I32 = nil
		b.F32 = nil
		b.F64 = nil
	case DataTypeI16:
		b.I8 = nil
		b.I16 = b.AsI16()
		b.I32 = nil
		b.F32 = nil
		b.F64 = nil
	case DataTypeI32:
		b.I8 = nil
		b.I16 = nil
		b.I32 = b.AsI32()
		b.F32 = nil
		b.F64 = nil
	case DataTypeF32:
		b.I8 = nil
		b.I16 = nil
		b.I32 = nil
		b.F32 = b.AsF32()
		b.F64 = nil
	case DataTypeF64:
		b.I8 = nil
		b.I16 = nil
		b.I32 = nil
		b.F32 = nil
		b.F64 = b.AsF64()
	}

	b.DataType = t
}
253140
func (whisper *Whisper) GetPrivateKey(id string) (*ecdsa.PrivateKey, error) {
	whisper.keyMu.RLock()
	defer whisper.keyMu.RUnlock()
	key := whisper.privateKeys[id]
	if key == nil {
		return nil, fmt.Errorf("invalid id")
	}
	return key, nil
}
410375
func (res *Resource) SetPrimaryFields(fields ...string) error {
	scope := gorm.Scope{Value: res.Value}
	res.PrimaryFields = nil

	if len(fields) > 0 {
		for _, fieldName := range fields {
			if field, ok := scope.FieldByName(fieldName); ok {
				res.PrimaryFields = append(res.PrimaryFields, field.StructField)
			} else {
				return fmt.Errorf("%v is not a valid field for resource %v", fieldName, res.Name)
			}
		}
		return nil
	}

	if primaryField := scope.PrimaryField(); primaryField != nil {
		res.PrimaryFields = []*gorm.StructField{primaryField.StructField}
		return nil
	}

	return fmt.Errorf("no valid primary field for resource %v", res.Name)
}
903129
func (r *Registry) getEntityParent(item mo.Entity, kind string) mo.Entity {
	for {
		parent := item.Entity().Parent

		item = r.Get(*parent).(mo.Entity)

		if item.Reference().Type == kind {
			return item
		}
	}
}
757261
func (s *User) SetPrimaryEmail(v string) *User {
	s.PrimaryEmail = &v
	return s
}
1061832
func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(dbName, table string) ([]string, error) {
	return []string{}, nil
}
1207933
func typeIsPrimative(typ reflect.Type) bool {
	return typeIsString(typ) || typeIsNumeric(typ) || typeIsBool(typ)
}
30441
func (c *MemberlistManager) SetPrimary(primary bool) {
	c.Lock()
	node := c.members[c.nodeName]
	if !node.SetPrimary(primary) {
		c.Unlock()
		return
	}
	c.members[c.nodeName] = node
	c.Unlock()
	nodePrimary.Set(primary)
	c.BroadcastUpdate()
}
696421
func (g *GPGKey) GetPrimaryKeyID() int64 {
	if g == nil || g.PrimaryKeyID == nil {
		return 0
	}
	return *g.PrimaryKeyID
}
809625
func (b *PCMBuffer) SwitchPrimaryType(t DataFormat) {
	if b == nil || t == b.DataType {
		return
	}
	switch t {
	case Integer:
		b.Ints = b.AsInts()
		b.Floats = nil
		b.Bytes = nil
	case Float:
		b.Floats = b.AsFloat64s()
		b.Ints = nil
		b.Bytes = nil
	case Byte:
		// TODO: get as bytes
		b.Floats = nil
		b.Ints = nil
	}
	b.DataType = t
}
234111
func (v *primitiveSchemaVisitor) VisitPrimitive(result *proto.Primitive) {
	v.Result = result
	v.Kind = "primitive"
}
94075
func (ppm *ProtoProducerMessage) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
	return false, nil
}
535015
func (e *Entity) primaryIdentity() *Identity {
	var firstIdentity *Identity
	for _, ident := range e.Identities {
		if firstIdentity == nil {
			firstIdentity = ident
		}
		if ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
			return ident
		}
	}
	return firstIdentity
}