作者:optimus
项目:or
func (bnd *bndBfile) close() (err error) {
defer func() {
if value := recover(); value != nil {
err = errR(value)
}
}()
if bnd.cDirectoryAlias != nil {
C.free(unsafe.Pointer(bnd.cDirectoryAlias))
}
if bnd.cFilename != nil {
C.free(unsafe.Pointer(bnd.cFilename))
}
if bnd.ociLobLocator != nil {
C.OCIDescriptorFree(
unsafe.Pointer(bnd.ociLobLocator), //void *descp,
C.OCI_DTYPE_FILE) //ub4 type );
}
stmt := bnd.stmt
bnd.stmt = nil
bnd.ocibnd = nil
bnd.ociLobLocator = nil
bnd.cDirectoryAlias = nil
bnd.cFilename = nil
stmt.putBnd(bndIdxBfile, bnd)
return nil
}
作者:salahwadi
项目:goracl
// Allocate a variable and define it for the given statement.
func (cur *Cursor) varDefine(numElements, position uint) (*Variable, error) {
var param *C.OCIParam
// retrieve parameter descriptor
if cur.handle == nil {
log.Printf("WARN: nil cursor handle in varDefine!")
}
// log.Printf("retrieve parameter descriptor cur.handle=%s pos=%d", cur.handle, position)
if CTrace {
ctrace("OCIParamGet(cur=%p, HTYPE_STMT, env=%p, param=%p, position=%d)",
cur.handle, "HTYPE_STMT", cur.environment.errorHandle,
¶m, position)
}
if err := cur.environment.CheckStatus(
C.OCIParamGet(unsafe.Pointer(cur.handle), C.OCI_HTYPE_STMT,
cur.environment.errorHandle,
(*unsafe.Pointer)(unsafe.Pointer(¶m)), C.ub4(position)),
"parameter"); err != nil {
log.Printf("NO PARAM! %s", err)
return nil, err
}
// log.Printf("got param handle")
// call the helper to do the actual work
v, err := cur.variableDefineHelper(param, position, numElements)
// log.Printf("variable defined err=%s nil?%s", err, err == nil)
if CTrace {
ctrace("OCIDescriptorFree(%p, DTYPE_PARAM)", param)
}
C.OCIDescriptorFree(unsafe.Pointer(param), C.OCI_DTYPE_PARAM)
return v, err
}
作者:optimus
项目:or
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
}
作者:ricsmani
项目:or
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
}
作者:optimus
项目:or
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
}
作者:optimus
项目:or
func (bnd *bndIntervalYMSlice) free(n int) {
defer func() {
recover()
}()
C.OCIDescriptorFree(
unsafe.Pointer(bnd.ociIntervals[n]), //void *descp,
C.OCI_DTYPE_INTERVAL_YM) //ub4 type );
}
作者:optimus
项目:or
func (def *defTime) free() {
defer func() {
recover()
}()
C.OCIDescriptorFree(
unsafe.Pointer(def.ociDateTime), //void *descp,
C.OCI_DTYPE_TIMESTAMP_TZ) //ub4 type );
}
作者:optimus
项目:or
func (bnd *bndTimeSlice) free(n int) {
defer func() {
recover()
}()
C.OCIDescriptorFree(
unsafe.Pointer(bnd.ociDateTimes[n]), //void *descp,
C.OCI_DTYPE_TIMESTAMP_TZ) //ub4 type );
}
作者:optimus
项目:or
func (def *defBfile) free() {
defer func() {
recover()
}()
C.OCIDescriptorFree(
unsafe.Pointer(def.ociLobLocator), //void *descp,
C.OCI_DTYPE_FILE) //ub4 type );
}
作者:bradfit
项目:go-sql-tes
// Prepare for variable destruction.
func lobVar_Finalize(v *Variable) error {
for i := uint(0); i < v.allocatedElements; i++ {
if v.dataBytes != nil && uint(len(v.dataBytes)) > i && v.dataBytes[i] != 0 {
C.OCIDescriptorFree(unsafe.Pointer(&v.dataBytes[i]), C.OCI_DTYPE_LOB)
}
}
return nil
}
作者:optimus
项目:or
func (def *defIntervalDS) free() {
defer func() {
recover()
}()
C.OCIDescriptorFree(
unsafe.Pointer(def.ociInterval), //void *descp,
C.OCI_DTYPE_INTERVAL_DS) //timeDefine.descTypeCode) //ub4 type );
}
作者:ricsmani
项目:or
func (def *defLob) free() {
if def.ociLobLocator == nil { // dissociated or already freed
return
}
C.OCIDescriptorFree(
unsafe.Pointer(def.ociLobLocator), //void *descp,
C.OCI_DTYPE_LOB) //ub4 type );
def.ociLobLocator = nil
}
作者:vine
项目:goracl
// Prepare for variable destruction.
func lobVarFinalize(v *Variable) error {
var j int
for i := uint(0); i < v.allocatedElements; i++ {
j = int(i * v.typ.size)
if v.dataBytes != nil && len(v.dataBytes) > j && v.dataBytes[j] != 0 {
C.OCIDescriptorFree(unsafe.Pointer(&v.dataBytes[j]), C.OCI_DTYPE_LOB)
}
}
return nil
}
作者:jprobinso
项目:go-oci
func (rc *OCI8Rows) Close() error {
for _, col := range rc.cols {
if col.kind == C.SQLT_CLOB || col.kind == C.SQLT_BLOB {
C.OCIDescriptorFree(
col.pbuf,
C.OCI_DTYPE_LOB)
} else {
C.free(col.pbuf)
}
}
return rc.s.Close()
}
作者:tgulacs
项目:go-sql-tes
// Prepare for variable destruction.
func lobVarFinalize(v *Variable) error {
if v == nil || v.dataBytes == nil {
return nil
}
for i := uint(0); i < v.allocatedElements; i++ {
if CTrace {
ctrace("lobVarFinalize(lob=%x)", v.getHandle(i))
}
C.OCIDescriptorFree(v.getHandle(i), C.OCI_DTYPE_LOB)
}
return nil
}
作者:tgulacs
项目:go-sql-tes
// intervalVarFinalize prepares for variable destruction.
func intervalVarFinalize(v *Variable) error {
var status C.sword
var handle unsafe.Pointer
for i := uint(0); i < v.allocatedElements; i++ {
if handle = unsafe.Pointer(getIntervalHandle(v, i)); handle != nil {
if status = C.OCIDescriptorFree(handle, C.OCI_DTYPE_INTERVAL_DS); status != C.OCI_SUCCESS {
return fmt.Errorf("error freeing Interval %d. handle %p: %d",
i, handle, status)
}
}
}
return nil
}
作者:optimus
项目:or
func (bnd *bndIntervalYM) close() (err error) {
defer func() {
if value := recover(); value != nil {
err = errR(value)
}
}()
C.OCIDescriptorFree(
unsafe.Pointer(bnd.ociInterval), //void *descp,
C.OCI_DTYPE_INTERVAL_YM) //timeDefine.descTypeCode) //ub4 type );
stmt := bnd.stmt
bnd.stmt = nil
bnd.ocibnd = nil
bnd.ociInterval = nil
stmt.putBnd(bndIdxIntervalYM, bnd)
return nil
}
作者:ricsmani
项目:or
func lobClose(ses *Ses, lob *C.OCILobLocator) error {
if lob == nil {
return nil
}
//Log.Infof("OCILobClose %p\n%s", lob, getStack(1))
r := C.OCILobClose(
ses.ocisvcctx, //OCISvcCtx *svchp,
ses.srv.env.ocierr, //OCIError *errhp,
lob, //OCILobLocator *locp,
)
C.OCIDescriptorFree(unsafe.Pointer(lob), //void *descp,
C.OCI_DTYPE_LOB) //ub4 type );
if r == C.OCI_ERROR {
return ses.srv.env.ociError()
}
return nil
}
作者:salahwadi
项目:goracl
// Prepare for variable destruction.
func lobVarFinalize(v *Variable) error {
if v == nil || v.dataBytes == nil {
return nil
}
var err error
for i := uint(0); i < v.allocatedElements; i++ {
hndl, e := v.getLobLoc(i)
if CTrace {
ctrace("lobVarFinalize(lob=%x) err=%v", hndl, e)
}
if e == nil {
C.OCIDescriptorFree(unsafe.Pointer(hndl), C.OCI_DTYPE_LOB)
} else if err == nil {
err = e
}
}
return err
}
作者:optimus
项目:or
func (bnd *bndIntervalDSSlice) close() (err error) {
defer func() {
if value := recover(); value != nil {
err = errR(value)
}
}()
for n := 0; n < len(bnd.ociIntervals); n++ {
C.OCIDescriptorFree(
unsafe.Pointer(bnd.ociIntervals[n]), //void *descp,
C.OCI_DTYPE_INTERVAL_DS) //ub4 type );
}
stmt := bnd.stmt
bnd.stmt = nil
bnd.ocibnd = nil
bnd.ociIntervals = nil
stmt.putBnd(bndIdxIntervalDSSlice, bnd)
return nil
}