// Update updates the global sql bind cache.
767242
func (h *BindHandle) Update(fullLoad bool) (err error) {
	sql := "select original_sql, bind_sql, default_db, status, create_time, update_time, charset, collation from mysql.bind_info"
	if !fullLoad {
		sql += " where update_time >= \"" + h.lastUpdateTime.String() + "\""
	}

	// No need to acquire the session context lock for ExecRestrictedSQL, it
	// uses another background session.
	rows, _, err := h.sctx.Context.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(nil, sql)
	if err != nil {
		return err
	}

	// Make sure there is only one goroutine writes the cache.
	h.bindInfo.Lock()
	newCache := h.bindInfo.Value.Load().(cache).copy()
	defer func() {
		h.bindInfo.Value.Store(newCache)
		h.bindInfo.Unlock()
	}()

	for _, row := range rows {
		hash, meta, err := h.newBindMeta(newBindRecord(row))
		// Update lastUpdateTime to the newest one.
		if meta.UpdateTime.Compare(h.lastUpdateTime) > 0 {
			h.lastUpdateTime = meta.UpdateTime
		}
		if err != nil {
			logutil.Logger(context.Background()).Error("update bindinfo failed", zap.Error(err))
			continue
		}

		newCache.removeStaleBindMetas(hash, meta)
		if meta.Status == Using {
			newCache[hash] = append(newCache[hash], meta)
		}
	}
	return nil
}
357394
func update(ctx context.Context, db transactor, fn func(*bolt.Tx) error) error {
	tx, ok := ctx.Value(transactionKey{}).(*bolt.Tx)
	if !ok {
		return db.Update(fn)
	} else if !tx.Writable() {
		return errors.Wrap(bolt.ErrTxNotWritable, "unable to use transaction from context")
	}
	return fn(tx)
}
644442
func (lh *LookupHash) Update(vcursor VCursor, oldValues []sqltypes.Value, ksid []byte, newValues []sqltypes.Value) error {
	v, err := vunhash(ksid)
	if err != nil {
		return fmt.Errorf("lookup.Update.vunhash: %v", err)
	}
	return lh.lkp.Update(vcursor, oldValues, sqltypes.NewUint64(v), newValues)
}
95388
func (me *Dataset) Update(i interface{}) *CrudExec {
	sql, args, err := me.ToUpdateSql(i)
	return newCrudExec(me.database, err, sql, args...)
}
1311918
func (b *BoltKeyspace) Update(key string, value []byte) error {
    return b.Insert(key, value)
}
744423
func (o *querySet) Update(values Params) (int64, error) {
	return o.orm.alias.DbBaser.UpdateBatch(o.orm.db, o, o.mi, o.cond, values, o.orm.alias.TZ)
}
1030024
func (ag *AuthGroup) Update(db XODB) error {
	var err error

	// if doesn't exist, bail
	if !ag._exists {
		return errors.New("update failed: does not exist")
	}

	// if deleted, bail
	if ag._deleted {
		return errors.New("update failed: marked for deletion")
	}

	// sql query
	const sqlstr = `UPDATE auth_group SET ` +
		`name = ?` +
		` WHERE id = ?`

	// run query
	XOLog(sqlstr, ag.Name, ag.ID)
	_, err = db.Exec(sqlstr, ag.Name, ag.ID)
	return err
}
453985
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
	stats, err := c.fs.BcacheStats()
	if err != nil {
		return fmt.Errorf("failed to retrieve bcache stats: %v", err)
	}

	for _, s := range stats {
		c.updateBcacheStats(ch, s)
	}
	return nil
}
202534
func (ff *firstRowFunction) Update(row []types.Datum, groupKey []byte, ectx context.Context) error {
	ctx := ff.getContext(groupKey)
	if ctx.GotFirstRow {
		return nil
	}
	if len(ff.Args) != 1 {
		return errors.New("Wrong number of args for AggFuncFirstRow")
	}
	value, err := ff.Args[0].Eval(row, ectx)
	if err != nil {
		return errors.Trace(err)
	}
	ctx.Value = value
	ctx.GotFirstRow = true
	return nil
}
554397
func (s *ExpDecaySample) Update(v int64) {
	s.update(time.Now(), v)
}
100840
func (t *KVMsTable) update(c context.Context) error {
	// Avoid using the database connection to prepare unnecessary statements.
	if len(t.updates) == 0 {
		return nil
	}

	db := database.Get(c)
	// TODO(smut): Update IP address.
	stmt, err := db.PrepareContext(c, `
		UPDATE kvms
		SET description = ?, mac_address = ?, state = ?, platform_id = ?, rack_id = ?
		WHERE id = ?
	`)
	if err != nil {
		return errors.Annotate(err, "failed to prepare statement").Err()
	}
	defer stmt.Close()

	// Update each KVM in the table. It's more efficient to update the slice of
	// KVMs once at the end rather than for each update, so use a defer.
	updated := make(map[int64]*KVM, len(t.updates))
	defer func() {
		for _, kvm := range t.current {
			if u, ok := updated[kvm.Id]; ok {
				kvm.MacAddress = u.MacAddress
				kvm.Description = u.Description
				kvm.State = u.State
				kvm.PlatformId = u.PlatformId
				kvm.RackId = u.RackId
			}
		}
	}()
	for len(t.updates) > 0 {
		kvm := t.updates[0]
		if _, err := stmt.ExecContext(c, kvm.Description, kvm.MacAddress, kvm.State, kvm.PlatformId, kvm.RackId, kvm.Id); err != nil {
			return errors.Annotate(err, "failed to update KVM %q", kvm.Name).Err()
		}
		updated[kvm.Id] = kvm
		t.updates = t.updates[1:]
		logging.Infof(c, "Updated KVM %q", kvm.Name)
	}
	return nil
}
1330337
func (lkp *lookupInternal) Update(vcursor VCursor, oldValues []sqltypes.Value, ksid sqltypes.Value, newValues []sqltypes.Value) error {
	if err := lkp.Delete(vcursor, [][]sqltypes.Value{oldValues}, ksid); err != nil {
		return err
	}
	return lkp.Create(vcursor, [][]sqltypes.Value{newValues}, []sqltypes.Value{ksid}, false /* ignoreMode */)
}
606100
func (g *StandardGauge) Update(v int64) {
	atomic.StoreInt64(&g.value, v)
}
466182
func (s *SourcesStore) Update(ctx context.Context, src chronograf.Source) error {
	if err := s.client.db.Update(func(tx *bolt.Tx) error {
		return s.update(ctx, src, tx)
	}); err != nil {
		return err
	}

	return nil
}
605035
func (c *Cluster) Update() error {
	c.mu.Lock()
	defer c.mu.Unlock()
	if err := c.cacheHosts(); err != nil {
		return microerror.Mask(err)
	}

	err := c.reindex()
	if err != nil {
		return microerror.Mask(err)
	}
	return nil
}
1345793
func (t *VLANsTable) update(c context.Context) error {
	// Avoid using the database connection to prepare unnecessary statements.
	if len(t.updates) == 0 {
		return nil
	}

	db := database.Get(c)
	stmt, err := db.PrepareContext(c, `
		UPDATE vlans
		SET alias = ?, state = ?, cidr_block = ?
		WHERE id = ?
	`)
	if err != nil {
		return errors.Annotate(err, "failed to prepare statement").Err()
	}
	defer stmt.Close()

	// Update each VLAN in the table. It's more efficient to update the slice of
	// VLANs once at the end rather than for each update, so use a defer.
	updated := make(map[int64]*VLAN, len(t.updates))
	defer func() {
		for _, vlan := range t.current {
			if u, ok := updated[vlan.Id]; ok {
				vlan.Alias = u.Alias
				vlan.State = u.State
				vlan.CidrBlock = u.CidrBlock
			}
		}
	}()
	for len(t.updates) > 0 {
		vlan := t.updates[0]
		if _, err := stmt.ExecContext(c, vlan.Alias, vlan.State, vlan.CidrBlock, vlan.Id); err != nil {
			return errors.Annotate(err, "failed to update VLAN %d", vlan.Id).Err()
		}
		updated[vlan.Id] = vlan
		t.updates = t.updates[1:]
		logging.Infof(c, "Updated VLAN %d", vlan.Id)
	}
	return nil
}
385992
func (c *cache) Update(req *pb.FindFullHashesRequest, resp *pb.FindFullHashesResponse) {
	c.Lock()
	defer c.Unlock()
	now := c.now()

	if c.pttls == nil {
		c.pttls = make(map[hashPrefix]map[ThreatDescriptor]time.Time)
		c.nttls = make(map[hashPrefix]time.Time)
	}

	// Insert each threat match into the cache by full hash.
	for _, tm := range resp.GetMatches() {
		fullHash := hashPrefix(tm.GetThreat().Hash)
		if !fullHash.IsFull() {
			continue
		}
		if c.pttls[fullHash] == nil {
			c.pttls[fullHash] = make(map[ThreatDescriptor]time.Time)
		}
		var dur time.Duration
		if tmCacheDur := tm.GetCacheDuration(); tmCacheDur != nil {
			dur = time.Duration(tm.GetCacheDuration().Seconds) * time.Second
		} else {
			dur = 0
		}
		td := ThreatDescriptor{
			ThreatType:      ThreatType(tm.ThreatType),
			PlatformType:    PlatformType(tm.PlatformType),
			ThreatEntryType: ThreatEntryType(tm.ThreatEntryType),
		}
		c.pttls[fullHash][td] = now.Add(dur)
	}

	// Insert negative TTLs for partial hashes.
	if resp.GetNegativeCacheDuration() != nil {
		dur := time.Duration(resp.GetNegativeCacheDuration().Seconds) * time.Second
		nttl := now.Add(dur)
		for _, te := range req.GetThreatInfo().GetThreatEntries() {
			partialHash := hashPrefix(te.Hash)
			c.nttls[partialHash] = nttl
		}
	}
}