code: 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
  }
docs: // update updates all VLANs pending update in the database, clearing pending updates.
  // No-op unless computeChanges was called first. Idempotent until computeChanges is called again.