コード例 #1
0
// readCmd reads a value from the db and stores it in the env.
func readCmd(c *cmd, txn *client.Txn, t *testing.T) *roachpb.Error {
	r, pErr := txn.Get(c.getKey())
	if pErr != nil {
		return pErr
	}
	if r.Value != nil {
		c.env[c.key] = r.ValueInt()
		c.debug = fmt.Sprintf("[%d ts=%d]", r.ValueInt(), r.Timestamp())
	}
	return nil
}
コード例 #2
0
// readCmd reads a value from the db and stores it in the env.
func readCmd(c *cmd, txn *client.Txn, t *testing.T) error {
	r, err := txn.Get(c.getKey())
	if err != nil {
		return err
	}
	var value int64
	if r.Value != nil {
		value = r.ValueInt()
	}
	c.env[c.key] = value
	c.debug = fmt.Sprintf("[%d]", value)
	return nil
}
コード例 #3
0
ファイル: lease.go プロジェクト: csdigi/cockroach
// resolveName resolves a table name to a descriptor ID by looking in the
// database. If the mapping is not found, errDescriptorNotFound is returned.
func (m *LeaseManager) resolveName(
	txn *client.Txn, dbID sqlbase.ID, tableName string,
) (sqlbase.ID, error) {
	nameKey := tableKey{dbID, tableName}
	key := nameKey.Key()
	gr, err := txn.Get(key)
	if err != nil {
		return 0, err
	}
	if !gr.Exists() {
		return 0, errDescriptorNotFound
	}
	return sqlbase.ID(gr.ValueInt()), nil
}