// Free temporary LOBs prior to fetch. func lobVar_PreFetch(v *Variable) error { var isTemporary C.boolean var err error for i := uint(0); i < v.allocatedElements; i++ { if v.dataBytes != nil && uint(len(v.dataBytes)) > i && v.dataBytes[i] != 0 { if err = v.environment.CheckStatus( C.OCILobIsTemporary(v.environment.handle, v.environment.errorHandle, (*C.OCILobLocator)(unsafe.Pointer(&v.dataBytes[i])), &isTemporary), "LobIsTemporary"); err != nil { return err } if isTemporary == C.TRUE { // Py_BEGIN_ALLOW_THREADS if err = v.environment.CheckStatus( C.OCILobFreeTemporary(v.connection.handle, v.environment.errorHandle, (*C.OCILobLocator)(unsafe.Pointer(&v.dataBytes[i]))), "LobFreeTemporary"); err != nil { return err } // Py_END_ALLOW_THREADS } } } return nil }
func (bnd *bndLobPtr) close() (err error) { defer func() { if value := recover(); value != nil { err = errR(value) } }() // no need to clear bnd.buf // free temporary lob C.OCILobFreeTemporary( bnd.stmt.ses.srv.ocisvcctx, //OCISvcCtx *svchp, bnd.stmt.ses.srv.env.ocierr, //OCIError *errhp, bnd.ociLobLocator) //OCILobLocator *locp, // free lob locator handle C.OCIDescriptorFree( unsafe.Pointer(bnd.ociLobLocator), //void *descp, C.OCI_DTYPE_LOB) //ub4 type ); stmt := bnd.stmt bnd.stmt = nil bnd.value = nil bnd.ocibnd = nil bnd.ociLobLocator = nil stmt.putBnd(bndIdxLobPtr, bnd) return nil }
func (bnd *bndLobSlice) close() (err error) { defer func() { if value := recover(); value != nil { err = errR(value) } }() for n := 0; n < len(bnd.ociLobLocators); n++ { // free temporary lob C.OCILobFreeTemporary( bnd.stmt.ses.ocisvcctx, //OCISvcCtx *svchp, bnd.stmt.ses.srv.env.ocierr, //OCIError *errhp, bnd.ociLobLocators[n]) //OCILobLocator *locp, // free lob locator handle C.OCIDescriptorFree( unsafe.Pointer(bnd.ociLobLocators[n]), //void *descp, C.OCI_DTYPE_LOB) //ub4 type ); } stmt := bnd.stmt bnd.stmt = nil bnd.ocibnd = nil bnd.ociLobLocators = nil stmt.putBnd(bndIdxBinSlice, bnd) return nil }
func allocTempLob(stmt *Stmt) ( ociLobLocator *C.OCILobLocator, finish func(), err error, ) { // Allocate lob locator handle r := C.OCIDescriptorAlloc( unsafe.Pointer(stmt.ses.srv.env.ocienv), //CONST dvoid *parenth, (*unsafe.Pointer)(unsafe.Pointer(&ociLobLocator)), //dvoid **descpp, C.OCI_DTYPE_LOB, //ub4 type, 0, //size_t xtramem_sz, nil) //dvoid **usrmempp); if r == C.OCI_ERROR { return nil, nil, stmt.ses.srv.env.ociError() } else if r == C.OCI_INVALID_HANDLE { return nil, nil, errNew("unable to allocate oci lob handle during bind") } // Create temporary lob r = C.OCILobCreateTemporary( stmt.ses.srv.ocisvcctx, //OCISvcCtx *svchp, stmt.ses.srv.env.ocierr, //OCIError *errhp, ociLobLocator, //OCILobLocator *locp, C.OCI_DEFAULT, //ub2 csid, C.SQLCS_IMPLICIT, //ub1 csfrm, C.OCI_TEMP_BLOB, //ub1 lobtype, C.TRUE, //boolean cache, C.OCI_DURATION_SESSION) //OCIDuration duration); if r == C.OCI_ERROR { // free lob locator handle C.OCIDescriptorFree( unsafe.Pointer(ociLobLocator), //void *descp, C.OCI_DTYPE_LOB) //ub4 type ); return nil, nil, stmt.ses.srv.env.ociError() } return ociLobLocator, func() { C.OCILobFreeTemporary( stmt.ses.srv.ocisvcctx, //OCISvcCtx *svchp, stmt.ses.srv.env.ocierr, //OCIError *errhp, ociLobLocator) //OCILobLocator *locp, // free lob locator handle C.OCIDescriptorFree( unsafe.Pointer(ociLobLocator), //void *descp, C.OCI_DTYPE_LOB) //ub4 type ); }, nil }
// Free temporary LOBs prior to fetch. func lobVarPreFetch(v *Variable) (err error) { if v.dataBytes == nil { return } var ( isTemporary C.boolean hndl *C.OCILobLocator ) for i := uint(0); i < v.allocatedElements; i++ { //hndl = (*C.OCILobLocator)(v.getHandle(i)) if hndl, err = v.getLobLoc(i); err != nil { return } if hndl == nil { continue } if err = v.environment.CheckStatus( C.OCILobIsTemporary(v.environment.handle, v.environment.errorHandle, hndl, &isTemporary), "LobIsTemporary"); err != nil { return } if isTemporary == C.TRUE { // Py_BEGIN_ALLOW_THREADS if err = v.environment.CheckStatus( C.OCILobFreeTemporary(v.connection.handle, v.environment.errorHandle, hndl), "LobFreeTemporary"); err != nil { return } // Py_END_ALLOW_THREADS } } return }