Пример #1
0
// internalSize returns the size in bytes (!) of the LOB variable for internal comsumption.
func (lv *ExternalLobVar) internalSize() (length C.ub4, err error) {
	if CTrace {
		ctrace("%s.internalSize", lv)
	}

	// Py_BEGIN_ALLOW_THREADS
	if CTrace {
		ctrace("OCILobGetLength(conn=%p, pos=%d lob=%x, &length=%p)",
			lv.lobVar.connection.handle, lv.idx*lv.lobVar.typ.size,
			lv.getHandleBytes(), &length)
		//buf := make([]byte, 8192)
		//ctrace("Stack: %s", buf[:runtime.Stack(buf, false)])
		//ctrace("data[%d]=%p", lv.idx, lob)
	}
	if err = lv.lobVar.environment.CheckStatus(
		C.OCILobGetLength(lv.lobVar.connection.handle,
			lv.lobVar.environment.errorHandle,
			lv.getHandle(), &length),
		"LobGetLength"); err != nil {
		return
	}
	// Py_END_ALLOW_THREADS
	if lv.lobVar.typ == ClobVarType {
		length *= C.ub4(lv.lobVar.environment.MaxBytesPerCharacter)
	} else if lv.lobVar.typ == NClobVarType {
		length *= 2
	}

	return
}
Пример #2
0
func (v *Variable) getLobInternalSize(pos uint) (length C.ub4, err error) {
	switch v.typ {
	case ClobVarType, NClobVarType, BlobVarType, BFileVarType:
	default:
		return 0, errgo.Newf("getLobInternalSize is usable only for LOB vars! not for %T", v.typ)
	}
	lob, _ := v.getLobLoc(pos)
	// Py_BEGIN_ALLOW_THREADS
	if CTrace {
		ctrace("OCILobGetLength(conn=%p, pos=%d lob=%x, &length=%p)",
			v.connection.handle, pos*v.typ.size, lob, &length)
		//buf := make([]byte, 8192)
		//ctrace("Stack: %s", buf[:runtime.Stack(buf, false)])
		//ctrace("data[%d]=%p", pos, lob)
	}
	if err = v.environment.CheckStatus(
		C.OCILobGetLength(v.connection.handle,
			v.environment.errorHandle, lob,
			&length),
		"LobGetLength"); err != nil {
		return
	}
	// Py_END_ALLOW_THREADS

	return
}
Пример #3
0
// internalSize returns the size of the LOB variable for internal comsumption.
func (lv *ExternalLobVar) internalSize() (length C.ub4, err error) {
	// Py_BEGIN_ALLOW_THREADS
	if err = lv.lobVar.environment.CheckStatus(
		C.OCILobGetLength(lv.lobVar.connection.handle,
			lv.lobVar.environment.errorHandle,
			(*C.OCILobLocator)(unsafe.Pointer(&lv.lobVar.dataBytes[lv.pos*lv.lobVar.size])),
			&length),
		"LobGetLength"); err != nil {
		return
	}
	// Py_END_ALLOW_THREADS

	return
}