Esempio n. 1
0
static void core_gen_tx_bytestr_alias_field(ib_tx_t *tx,
                                            const char *name,
                                            ib_bytestr_t *val)
{
    ib_field_t *f;

    assert(tx != NULL);
    assert(name != NULL);
    assert(val != NULL);

    ib_status_t rc = ib_field_create_no_copy(&f, tx->mp,
                                             name, strlen(name),
                                             IB_FTYPE_BYTESTR,
                                             val);
    if (rc != IB_OK) {
        ib_log_warning(tx->ib, "Failed to create \"%s\" field: %s",
                       name, ib_status_to_string(rc));
        return;
    }

    rc = ib_data_add(tx->data, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
            "Failed add \"%s\" field to transaction data store: %s",
            name, ib_status_to_string(rc)
        );
    }
}
Esempio n. 2
0
static void core_gen_tx_bytestr_alias(ib_tx_t *tx,
                                      const char *name,
                                      ib_bytestr_t *val)
{

    assert(tx != NULL);
    assert(name != NULL);
    assert(val != NULL);

    ib_field_t *f;
    ib_var_source_t *source;
    ib_status_t rc;

    rc = ib_field_create_no_copy(
             &f,
             tx->mp,
             name, strlen(name),
             IB_FTYPE_BYTESTR,
             val
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to create \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_acquire(
             &source,
             tx->mp,
             ib_var_store_config(tx->var_store),
             name, strlen(name)
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to acquire \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_set(source, tx->var_store, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
                          "Failed add \"%s\" var to transaction: %s",
                          name, ib_status_to_string(rc)
                         );
    }
}
Esempio n. 3
0
Field create_no_copy(
    MemoryPool    pool,
    const char*   name,
    size_t        name_length,
    Field::type_e type,
    void*         mutable_in_value
)
{
    ib_field_t* f = NULL;

    ib_status_t rc = ib_field_create_no_copy(
        &f,
        pool.ib(),
        name, name_length,
        static_cast<ib_ftype_t>(type),
        mutable_in_value
    );
    throw_if_error(rc);

    return Field(f);
}
Esempio n. 4
0
ib_status_t ib_field_create_bytestr_alias(
    ib_field_t **pf,
    ib_mpool_t  *mp,
    const char  *name,
    size_t       nlen,
    uint8_t     *val,
    size_t       vlen
)
{
    ib_status_t rc;
    ib_bytestr_t *bs;

    rc = ib_bytestr_alias_mem(&bs, mp, val, vlen);
    if (rc != IB_OK) {
        goto failed;
    }

    rc = ib_field_create_no_copy(
        pf, mp, name, nlen,
        IB_FTYPE_BYTESTR,
        ib_ftype_bytestr_mutable_in(bs)
    );
    if (rc != IB_OK) {
        goto failed;
    }

    ib_field_util_log_debug("FIELD_CREATE_BYTESTR_ALIAS", (*pf));

    return IB_OK;

failed:
    /* Make sure everything is cleaned up on failure. */
    *pf = NULL;

    return rc;
}