Ejemplo n.º 1
0
import (
	"fmt"
	"io"
	"unsafe"

	"gopkg.in/errgo.v1"
)

const useLobRead2 = true

// Compile-time guarantees for interface implementations.
var _ = io.Writer(&ExternalLobVar{})
var _ = io.Reader(&ExternalLobVar{})
var _ = io.ReaderAt(&ExternalLobVar{})
var _ = io.WriterAt(&ExternalLobVar{})

// Defines the routines for handling LOB variables external to this module.

// ExternalLobVar is an external LOB var type.
// It is NOT concurrent-safe ATM.
type ExternalLobVar struct {
	lobVar           *Variable
	idx              uint
	internalFetchNum uint
	isFile           bool
	rwPos            int64
}

func (lv ExternalLobVar) getHandle() *C.OCILobLocator {
	lob, _ := lv.lobVar.getLobLoc(lv.idx)
Ejemplo n.º 2
0
			n += int64(k)
			if lr.off == lr.Length {
				break
			}
		}
		if lr.piece == C.OCI_FIRST_PIECE {
			lr.piece = C.OCI_NEXT_PIECE
		}
	}
	return n, nil
}

// TODO(tgulacsi): find how to return lobReadWriter.

var _ = io.ReaderAt((*lobReadWriter)(nil))
var _ = io.WriterAt((*lobReadWriter)(nil))

type lobReadWriter struct {
	ses           *Ses
	ociLobLocator *C.OCILobLocator
	charsetForm   C.ub1
	size          C.oraub8
}

// Size returns the actual size of the LOB.
func (lrw lobReadWriter) Size() uint64 {
	return uint64(lrw.size)
}

// Close the LOB.
func (lrw *lobReadWriter) Close() error {