Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// LobVar_PreFetch()
//   Free temporary LOBs prior to fetch.
//-----------------------------------------------------------------------------
static int LobVar_PreFetch(
    udt_LobVar *var)                    // variable to free
{
    boolean isTemporary;
    sword status;
    ub4 i;

    for (i = 0; i < var->allocatedElements; i++) {
        if (var->data[i]) {
            status = OCILobIsTemporary(var->environment->handle,
                    var->environment->errorHandle, var->data[i], &isTemporary);
            if (Environment_CheckForError(var->environment, status,
                    "LobVar_PreFetch(): is temporary LOB?") < 0)
                return -1;
            if (isTemporary) {
                Py_BEGIN_ALLOW_THREADS
                status = OCILobFreeTemporary(var->connection->handle,
                        var->environment->errorHandle, var->data[i]);
                Py_END_ALLOW_THREADS
                if (Environment_CheckForError(var->environment, status,
                        "LobVar_PreFetch(): free temporary LOB") < 0)
                    return -1;
            }
        }
    }
Exemplo n.º 2
0
bool SqlLob::isTemporary() const
{
	bOOlean flag;
	sword res = OCICALL(OCILobIsTemporary(_conn._env, _conn._env._errh, _loc, &flag));
	oci_check_error(__TROTL_HERE__, _conn._env._errh, res);
	return !!flag;
};
Exemplo n.º 3
0
bool BindParLob::isTemporary(unsigned _row) const
{
	bOOlean flag;
	sword res = OCICALL(OCILobIsTemporary(_env, _env._errh, ((OCILobLocator**)valuep)[_row], &flag));
	oci_check_error(__TROTL_HERE__, _env._errh, res);
	return !!flag;
}
Exemplo n.º 4
0
static void oci8_lob_free(oci8_base_t *base)
{
    oci8_lob_t *lob = (oci8_lob_t *)base;
    boolean is_temporary;

    if (have_OCILobIsTemporary && lob->svchp != NULL
        && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
        && is_temporary) {

        /* FIXME: This may stall the GC. */
        OCILobFreeTemporary(lob->svchp, oci8_errhp, lob->base.hp.lob);
    }
    lob->svc = Qnil;
    lob->svchp = NULL;
}
Exemplo n.º 5
0
static VALUE oci8_make_lob(VALUE klass, oci8_svcctx_t *svcctx, OCILobLocator *s)
{
    oci8_lob_t *lob;
    boolean is_temp;
    VALUE lob_obj;

    lob_obj = rb_class_new_instance(1, &svcctx->base.self, klass);
    lob = TO_LOB(lob_obj);
    /* If 's' is a temporary lob, use OCILobLocatorAssign instead. */
    chker2(OCILobIsTemporary(oci8_envhp, oci8_errhp, s, &is_temp), &svcctx->base);
    if (is_temp)
        chker2(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, s, &lob->base.hp.lob),
               &svcctx->base);
    else
        chker2(OCILobAssign(oci8_envhp, oci8_errhp, s, &lob->base.hp.lob),
               &svcctx->base);
    return lob_obj;
}
Exemplo n.º 6
0
static VALUE oci8_lob_clone(VALUE self)
{
    oci8_lob_t *lob = TO_LOB(self);
    oci8_lob_t *newlob;
    VALUE newobj = lob->svcctx ? lob->svcctx->base.self : Qnil;
    boolean is_temporary;

    newobj = rb_class_new_instance(1, &newobj, CLASS_OF(self));
    newlob = DATA_PTR(newobj);
    if (OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
        && is_temporary) {
        oci8_svcctx_t *svcctx = check_svcctx(lob);
        chker2(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob),
               &svcctx->base);
    } else {
        chker2(OCILobAssign(oci8_envhp, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob), &lob->base);
    }
    return newobj;
}
Exemplo n.º 7
0
static void oci8_lob_free(oci8_base_t *base)
{
    oci8_lob_t *lob = (oci8_lob_t *)base;
    boolean is_temporary;
    oci8_svcctx_t *svcctx = lob->svcctx;

    if (svcctx != NULL
        && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
        && is_temporary) {
        oci8_temp_lob_t *temp_lob = ALLOC(oci8_temp_lob_t);

        temp_lob->next = svcctx->temp_lobs;
        temp_lob->lob = lob->base.hp.lob;
        svcctx->temp_lobs = temp_lob;
        lob->base.type = 0;
        lob->base.closed = 1;
        lob->base.hp.ptr = NULL;
    }
    lob->svcctx = NULL;
}
Exemplo n.º 8
0
static VALUE oci8_lob_clone(VALUE self)
{
    oci8_lob_t *lob = DATA_PTR(self);
    oci8_lob_t *newlob;
    VALUE newobj;
    sword rv;
    boolean is_temporary;

    newobj = rb_funcall(CLASS_OF(self), oci8_id_new, 1, lob->svc);
    newlob = DATA_PTR(newobj);
    if (have_OCILobLocatorAssign_nb && have_OCILobIsTemporary
            && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
            && is_temporary) {
        oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc);
        rv = OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob);
    } else {
        rv = OCILobAssign(oci8_envhp, oci8_errhp, lob->base.hp.lob, &newlob->base.hp.lob);
    }
    if (rv != OCI_SUCCESS) {
        oci8_raise(oci8_errhp, rv, NULL);
    }
    return newobj;
}