oci8

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 36 Imported by: 0

README

go-oci8

GoDoc Reference Build Status Go Report Card

Description

Golang Oracle database driver conforming to the Go database/sql interface

Installation

Install Oracle full client or Instant Client:

https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html

Install a C/C++ compiler

Install pkg-config, edit your package config file oci8.pc (examples below), then set environment variable PKG_CONFIG_PATH to oci8.pc file location (Or can use Go tag noPkgConfig then setup environment variables CGO_CFLAGS and CGO_LDFLAGS)

Go get with Go version 1.9 or higher

go get github.com/mattn/go-oci8

Try the simple select example:

https://godoc.org/github.com/mattn/go-oci8#example-package--SqlSelect

If you have a build error it is normaly because of a misconfiguration, make sure to search close issues for help

oci8.pc Examples

Windows
prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX
exec_prefix=${prefix}
libdir=C:/app/instantclient_12_2/sdk/oci/lib/msvc
includedir=C:/app/instantclient_12_2/sdk/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: oci8
Description: oci8 library
Libs: -L${libdir} -loci
Cflags: -I${includedir}
Version: 12.2
Linux
prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX
exec_prefix=${prefix}
libdir=/usr/lib/oracle/12.2/client64/lib
includedir=/usr/include/oracle/12.2/client64

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: oci8
Description: oci8 library
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}
Version: 12.2
MacOs

Please install pkg-config with brew if not already present. Download the instant client and the sdk and unpack it e.g. in your Downloads folder and create therein a file names oci8.pc. Please replace <username> with your actual username.

prefixdir=/Users/<username>/Downloads/instantclient_12_2/
libdir=${prefixdir}
includedir=${prefixdir}/sdk/include

Name: OCI
Description: Oracle database driver
Version: 12.2
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}

You also have to set these environment variables (e.g. permanently by adding them to your .bashrc)

export LD_LIBRARY_PATH=/Users/<username>/Downloads/instantclient_12_2
export PKG_CONFIG_PATH=/Users/<username>/Downloads/instantclient_12_2

SQL Examples

SQL examples can be found in the GoDoc reference:

https://godoc.org/github.com/mattn/go-oci8

And in _example:

https://github.com/mattn/go-oci8/tree/master/_example

Author

Yasuhiro Matsumoto (a.k.a mattn)

Special Thanks

Jamil Djadala

Documentation

Index

Constants

View Source
const (
	InsertSqlTemplate = "INSERT INTO %s (%s) VALUES (%s)"
	DeleteSqlTemplate = "DELETE FROM %s WHERE %s = :1"
	UpdateSqlTemplate = "UPDATE %s SET %s WHERE %s = :1"
	SelectSqlTemplate = "SELECT %s FROM %s WHERE %s IN %s"
)
View Source
const (
	DeleteUndoLogSql         = "DELETE FROM undo_log WHERE xid = :1 and branch_id = :2"
	DeleteUndoLogByCreateSql = "DELETE FROM undo_log WHERE log_created <= :1 LIMIT :2"
	InsertUndoLogSql         = "INSERT INTO UNDO_LOG (id, branch_id, xid, context, rollback_info, log_status, log_created, log_modified)" +
		"VALUES (UNDO_LOG_SEQ.NEXTVAL, :1, :2, :3, :4, :5, sysdate, sysdate)"
	SelectUndoLogSql = "SELECT branch_id, xid, context, rollback_info, log_status FROM undo_log " +
		"WHERE xid = :1 AND branch_id = :2"
)
View Source
const (
	BIT SqlDataType = -7

	TINYINT = -6

	SMALLINT = 5

	INTEGER = 4

	BIGINT = -5

	FLOAT = 6

	REAL = 7

	DOUBLE = 8

	NUMERIC = 2

	DECIMAL = 3

	CHAR = 1

	VARCHAR = 12

	LONGVARCHAR = -1

	DATE = 91

	TIME = 92

	TIMESTAMP = 93

	BINARY = -2

	VARBINARY = -3

	LONGVARBINARY = -4

	NULL = 0

	OTHER = 1111

	JAVA_OBJECT = 2000

	DISTINCT = 2001

	STRUCT = 2002

	ARRAY = 2003

	BLOB = 2004

	CLOB = 2005

	REF = 2006

	DATALINK = 70

	BOOLEAN = 16

	ROWID = -8

	NCHAR = -15

	NVARCHAR = -9

	LONGNVARCHAR = -16

	NCLOB = 2011

	SQLXML = 2009

	REF_CURSOR = 2012

	TIME_WITH_TIMEZONE = 2013

	TIMESTAMP_WITH_TIMEZONE = 2014
)
View Source
const XID = "XID"

Variables

View Source
var (
	// ErrOCIInvalidHandle is OCI_INVALID_HANDLE
	ErrOCIInvalidHandle = errors.New("OCI_INVALID_HANDLE")
	// ErrOCISuccessWithInfo is OCI_SUCCESS_WITH_INFO
	ErrOCISuccessWithInfo = errors.New("OCI_SUCCESS_WITH_INFO")
	// ErrOCIReservedForIntUse is OCI_RESERVED_FOR_INT_USE
	ErrOCIReservedForIntUse = errors.New("OCI_RESERVED_FOR_INT_USE")
	// ErrOCINoData is OCI_NO_DATA
	ErrOCINoData = errors.New("OCI_NO_DATA")
	// ErrOCINeedData is OCI_NEED_DATA
	ErrOCINeedData = errors.New("OCI_NEED_DATA")
	// ErrOCIStillExecuting is OCI_STILL_EXECUTING
	ErrOCIStillExecuting = errors.New("OCI_STILL_EXECUTING")

	// ErrNoRowid is result has no rowid
	ErrNoRowid = errors.New("result has no rowid")

	// Driver is the sql driver
	Driver = &DriverStruct{
		Logger: log.New(ioutil.Discard, "", 0),
	}
)
View Source
var (
	DBKEYS_SPLIT_CHAR = ","
)
View Source
var EXPIRE_TIME = 15 * time.Minute
View Source
var ORACLEKeyword = map[string]string{}/* 110 elements not displayed */

110 key words

View Source
var SqlDataTypes = map[string]int32{
	"BIT":                     -7,
	"TINYINT":                 -6,
	"SMALLINT":                5,
	"INTEGER":                 4,
	"BIGINT":                  -5,
	"FLOAT":                   6,
	"REAL":                    7,
	"DOUBLE":                  8,
	"NUMERIC":                 2,
	"DECIMAL":                 3,
	"CHAR":                    1,
	"VARCHAR":                 12,
	"LONGVARCHAR":             -1,
	"DATE":                    91,
	"TIME":                    92,
	"TIMESTAMP":               93,
	"BINARY":                  -2,
	"VARBINARY":               -3,
	"LONGVARBINARY":           -4,
	"NULL":                    0,
	"OTHER":                   1111,
	"JAVA_OBJECT":             2000,
	"DISTINCT":                2001,
	"STRUCT":                  2002,
	"ARRAY":                   2003,
	"BLOB":                    2004,
	"CLOB":                    2005,
	"REF":                     2006,
	"DATALINK":                70,
	"BOOLEAN":                 16,
	"ROWID":                   -8,
	"NCHAR":                   -15,
	"NVARCHAR":                -9,
	"LONGNVARCHAR":            -16,
	"NCLOB":                   2011,
	"SQLXML":                  2009,
	"REF_CURSOR":              2012,
	"TIME_WITH_TIMEZONE":      2013,
	"TIMESTAMP_WITH_TIMEZONE": 2014,
}

Functions

func AppendInParam

func AppendInParam(size int) string

func Check

func Check(fieldOrTableName string) bool

Check oralce 保留字

func CheckAndReplace

func CheckAndReplace(fieldOrTableName string) string

func CheckEscape

func CheckEscape(fieldOrTableName string) bool

func DeleteBuildUndoSql

func DeleteBuildUndoSql(undoLog sqlUndoLog) string

func GetColumns

func GetColumns(conn *Conn, dbName, tableName string) ([]schema.ColumnMeta, error)

func GetIndexes

func GetIndexes(conn *Conn, dbName, tableName string) ([]schema.IndexMeta, error)

func GetLastInsertId

func GetLastInsertId(id int64) string

GetLastInsertId returns rowid from LastInsertId

func GetSqlDataType

func GetSqlDataType(dataType string) int32

func InitDataResourceManager

func InitDataResourceManager()

func InitTableMetaCache

func InitTableMetaCache(dbName string)

func InsertBuildUndoSql

func InsertBuildUndoSql(undoLog sqlUndoLog) string

func NewConnector

func NewConnector(hosts ...string) driver.Connector

NewConnector returns a new database connector

func QueryEscape

func QueryEscape(s string) string

QueryEscape escapes the string so it can be safely placed inside a URL query.

func QueryUnescape

func QueryUnescape(s string) (string, error)

QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

func RegisterResource

func RegisterResource(dsn string)

func UpdateBuildUndoSql

func UpdateBuildUndoSql(undoLog sqlUndoLog) string

Types

type BuildUndoSql

type BuildUndoSql func(undoLog sqlUndoLog) string

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is Oracle connection

func (*Conn) Begin

func (conn *Conn) Begin() (driver.Tx, error)

Begin starts a transaction

func (*Conn) BeginTx

func (conn *Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error)

BeginTx starts a transaction

func (*Conn) Close

func (conn *Conn) Close() error

Close a connection

func (*Conn) Ping

func (conn *Conn) Ping(ctx context.Context) error

Ping database connection

func (*Conn) Prepare

func (conn *Conn) Prepare(query string) (driver.Stmt, error)

Prepare prepares a query

func (*Conn) PrepareContext

func (conn *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext prepares a query with context

type Connector

type Connector struct {
	// Logger is used to log connection ping errors
	Logger *log.Logger

	DSNstring string
	// contains filtered or unexported fields
}

Connector is the sql driver connector

func (*Connector) Connect

func (connector *Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a new database connection

func (*Connector) Driver

func (connector *Connector) Driver() driver.Driver

Driver returns the OCI8 driver

type DSN

type DSN struct {
	Connect  string
	Username string
	Password string
	// contains filtered or unexported fields
}

DSN is Oracle Data Source Name

func ParseDSN

func ParseDSN(dsnString string) (dsn *DSN, err error)

ParseDSN parses a DSN used to connect to Oracle

It expects to receive a string in the form:

[username/[password]@]host[:port][/service_name][?param1=value1&...&paramN=valueN]

Connection timeout can be set in the Oracle files: sqlnet.ora as SQLNET.OUTBOUND_CONNECT_TIMEOUT or tnsnames.ora as CONNECT_TIMEOUT

Supported parameters are:

loc - the time location for reading timestamp (without time zone). Defaults to UTC Note that writing a timestamp (without time zone) just truncates the time zone.

isolation - the isolation level that can be set to: READONLY, SERIALIZABLE, or DEFAULT

prefetch_rows - the number of top level rows to be prefetched. Defaults to 0. A 0 means unlimited rows.

prefetch_memory - the max memory for top level rows to be prefetched. Defaults to 4096. A 0 means unlimited memory.

questionph - when true, enables question mark placeholders. Defaults to false. (uses strconv.ParseBool to check for true)

type DataSourceManager

type DataSourceManager struct {
	RpcClient     *rpc_client.RpcRemoteClient
	ResourceCache map[string]*Connector
}

func (DataSourceManager) BranchCommit

func (resourceManager DataSourceManager) BranchCommit(branchType meta.BranchType, xid string, branchID int64,
	resourceID string, applicationData []byte) (meta.BranchStatus, error)

func (DataSourceManager) BranchRegister

func (resourceManager DataSourceManager) BranchRegister(branchType meta.BranchType, resourceID string,
	clientID string, xid string, applicationData []byte, lockKeys string) (int64, error)

func (DataSourceManager) BranchReport

func (resourceManager DataSourceManager) BranchReport(branchType meta.BranchType, xid string, branchID int64,
	status meta.BranchStatus, applicationData []byte) error

func (DataSourceManager) BranchRollback

func (resourceManager DataSourceManager) BranchRollback(branchType meta.BranchType, xid string, branchID int64,
	resourceID string, applicationData []byte) (meta.BranchStatus, error)

func (DataSourceManager) GetBranchType

func (resourceManager DataSourceManager) GetBranchType() meta.BranchType

func (DataSourceManager) LockQuery

func (resourceManager DataSourceManager) LockQuery(branchType meta.BranchType, resourceID string, xid string,
	lockKeys string) (bool, error)

type DriverStruct

type DriverStruct struct {
	// Logger is used to log connection ping errors, defaults to discard
	// To log set it to something like: log.New(os.Stderr, "oci8 ", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile)
	Logger *log.Logger
}

DriverStruct is Oracle driver struct

func (*DriverStruct) Open

func (drv *DriverStruct) Open(dsnString string) (driver.Conn, error)

Open opens a new database connection

type EscapeError

type EscapeError string

EscapeError for invalid escape

func (EscapeError) Error

func (e EscapeError) Error() string

Error returns string for invalid URL escape

type OracleUndoExecutor

type OracleUndoExecutor struct {
	// contains filtered or unexported fields
}

func NewOracleUndoExecutor

func NewOracleUndoExecutor(undoLog sqlUndoLog) OracleUndoExecutor

func (OracleUndoExecutor) Execute

func (executor OracleUndoExecutor) Execute(conn *Conn) error

type OracleUndoLogManager added in v0.1.2

type OracleUndoLogManager struct {
}

func GetUndoLogManager

func GetUndoLogManager() OracleUndoLogManager

func (OracleUndoLogManager) BatchDeleteUndoLog added in v0.1.2

func (manager OracleUndoLogManager) BatchDeleteUndoLog(conn *Conn, xids []string, branchIDs []int64) error

func (OracleUndoLogManager) DeleteUndoLog added in v0.1.2

func (manager OracleUndoLogManager) DeleteUndoLog(conn *Conn, xid string, branchID int64) error

func (OracleUndoLogManager) DeleteUndoLogByLogCreated added in v0.1.2

func (manager OracleUndoLogManager) DeleteUndoLogByLogCreated(conn *Conn, logCreated time.Time, limitRows int) (sql.Result, error)

func (OracleUndoLogManager) FlushUndoLogs added in v0.1.2

func (manager OracleUndoLogManager) FlushUndoLogs(conn *Conn) error

func (OracleUndoLogManager) Undo added in v0.1.2

func (manager OracleUndoLogManager) Undo(conn *Conn, xid string, branchID int64, resourceID string) error

type PbBranchUndoLog

type PbBranchUndoLog struct {
	Xid                  string          `protobuf:"bytes,1,opt,name=XID,proto3" json:"XID,omitempty"`
	BranchID             int64           `protobuf:"varint,2,opt,name=BranchID,proto3" json:"BranchID,omitempty"`
	SqlUndoLogs          []*PbSqlUndoLog `protobuf:"bytes,3,rep,name=SqlUndoLogs,proto3" json:"SqlUndoLogs,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

func (*PbBranchUndoLog) Descriptor

func (*PbBranchUndoLog) Descriptor() ([]byte, []int)

func (*PbBranchUndoLog) GetBranchID

func (m *PbBranchUndoLog) GetBranchID() int64

func (*PbBranchUndoLog) GetSqlUndoLogs

func (m *PbBranchUndoLog) GetSqlUndoLogs() []*PbSqlUndoLog

func (*PbBranchUndoLog) GetXid

func (m *PbBranchUndoLog) GetXid() string

func (*PbBranchUndoLog) ProtoMessage

func (*PbBranchUndoLog) ProtoMessage()

func (*PbBranchUndoLog) Reset

func (m *PbBranchUndoLog) Reset()

func (*PbBranchUndoLog) String

func (m *PbBranchUndoLog) String() string

func (*PbBranchUndoLog) XXX_DiscardUnknown

func (m *PbBranchUndoLog) XXX_DiscardUnknown()

func (*PbBranchUndoLog) XXX_Marshal

func (m *PbBranchUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbBranchUndoLog) XXX_Merge

func (m *PbBranchUndoLog) XXX_Merge(src proto.Message)

func (*PbBranchUndoLog) XXX_Size

func (m *PbBranchUndoLog) XXX_Size() int

func (*PbBranchUndoLog) XXX_Unmarshal

func (m *PbBranchUndoLog) XXX_Unmarshal(b []byte) error

type PbField

type PbField struct {
	Name                 string   `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
	KeyType              int32    `protobuf:"varint,2,opt,name=KeyType,proto3" json:"KeyType,omitempty"`
	Type                 int32    `protobuf:"zigzag32,3,opt,name=Type,proto3" json:"Type,omitempty"`
	Value                []byte   `protobuf:"bytes,4,opt,name=Value,proto3" json:"Value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PbField) Descriptor

func (*PbField) Descriptor() ([]byte, []int)

func (*PbField) GetKeyType

func (m *PbField) GetKeyType() int32

func (*PbField) GetName

func (m *PbField) GetName() string

func (*PbField) GetType

func (m *PbField) GetType() int32

func (*PbField) GetValue

func (m *PbField) GetValue() []byte

func (*PbField) ProtoMessage

func (*PbField) ProtoMessage()

func (*PbField) Reset

func (m *PbField) Reset()

func (*PbField) String

func (m *PbField) String() string

func (*PbField) XXX_DiscardUnknown

func (m *PbField) XXX_DiscardUnknown()

func (*PbField) XXX_Marshal

func (m *PbField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbField) XXX_Merge

func (m *PbField) XXX_Merge(src proto.Message)

func (*PbField) XXX_Size

func (m *PbField) XXX_Size() int

func (*PbField) XXX_Unmarshal

func (m *PbField) XXX_Unmarshal(b []byte) error

type PbRow

type PbRow struct {
	Fields               []*PbField `protobuf:"bytes,1,rep,name=Fields,proto3" json:"Fields,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*PbRow) Descriptor

func (*PbRow) Descriptor() ([]byte, []int)

func (*PbRow) GetFields

func (m *PbRow) GetFields() []*PbField

func (*PbRow) ProtoMessage

func (*PbRow) ProtoMessage()

func (*PbRow) Reset

func (m *PbRow) Reset()

func (*PbRow) String

func (m *PbRow) String() string

func (*PbRow) XXX_DiscardUnknown

func (m *PbRow) XXX_DiscardUnknown()

func (*PbRow) XXX_Marshal

func (m *PbRow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbRow) XXX_Merge

func (m *PbRow) XXX_Merge(src proto.Message)

func (*PbRow) XXX_Size

func (m *PbRow) XXX_Size() int

func (*PbRow) XXX_Unmarshal

func (m *PbRow) XXX_Unmarshal(b []byte) error

type PbSqlUndoLog

type PbSqlUndoLog struct {
	SqlType              int32           `protobuf:"varint,1,opt,name=SqlType,proto3" json:"SqlType,omitempty"`
	TableName            string          `protobuf:"bytes,2,opt,name=TableName,proto3" json:"TableName,omitempty"`
	BeforeImage          *PbTableRecords `protobuf:"bytes,3,opt,name=BeforeImage,proto3" json:"BeforeImage,omitempty"`
	AfterImage           *PbTableRecords `protobuf:"bytes,4,opt,name=AfterImage,proto3" json:"AfterImage,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

func (*PbSqlUndoLog) Descriptor

func (*PbSqlUndoLog) Descriptor() ([]byte, []int)

func (*PbSqlUndoLog) GetAfterImage

func (m *PbSqlUndoLog) GetAfterImage() *PbTableRecords

func (*PbSqlUndoLog) GetBeforeImage

func (m *PbSqlUndoLog) GetBeforeImage() *PbTableRecords

func (*PbSqlUndoLog) GetSqlType

func (m *PbSqlUndoLog) GetSqlType() int32

func (*PbSqlUndoLog) GetTableName

func (m *PbSqlUndoLog) GetTableName() string

func (*PbSqlUndoLog) ProtoMessage

func (*PbSqlUndoLog) ProtoMessage()

func (*PbSqlUndoLog) Reset

func (m *PbSqlUndoLog) Reset()

func (*PbSqlUndoLog) String

func (m *PbSqlUndoLog) String() string

func (*PbSqlUndoLog) XXX_DiscardUnknown

func (m *PbSqlUndoLog) XXX_DiscardUnknown()

func (*PbSqlUndoLog) XXX_Marshal

func (m *PbSqlUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbSqlUndoLog) XXX_Merge

func (m *PbSqlUndoLog) XXX_Merge(src proto.Message)

func (*PbSqlUndoLog) XXX_Size

func (m *PbSqlUndoLog) XXX_Size() int

func (*PbSqlUndoLog) XXX_Unmarshal

func (m *PbSqlUndoLog) XXX_Unmarshal(b []byte) error

type PbTableRecords

type PbTableRecords struct {
	TableName            string   `protobuf:"bytes,1,opt,name=TableName,proto3" json:"TableName,omitempty"`
	Rows                 []*PbRow `protobuf:"bytes,2,rep,name=Rows,proto3" json:"Rows,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*PbTableRecords) Descriptor

func (*PbTableRecords) Descriptor() ([]byte, []int)

func (*PbTableRecords) GetRows

func (m *PbTableRecords) GetRows() []*PbRow

func (*PbTableRecords) GetTableName

func (m *PbTableRecords) GetTableName() string

func (*PbTableRecords) ProtoMessage

func (*PbTableRecords) ProtoMessage()

func (*PbTableRecords) Reset

func (m *PbTableRecords) Reset()

func (*PbTableRecords) String

func (m *PbTableRecords) String() string

func (*PbTableRecords) XXX_DiscardUnknown

func (m *PbTableRecords) XXX_DiscardUnknown()

func (*PbTableRecords) XXX_Marshal

func (m *PbTableRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PbTableRecords) XXX_Merge

func (m *PbTableRecords) XXX_Merge(src proto.Message)

func (*PbTableRecords) XXX_Size

func (m *PbTableRecords) XXX_Size() int

func (*PbTableRecords) XXX_Unmarshal

func (m *PbTableRecords) XXX_Unmarshal(b []byte) error

type ProtoBufUndoLogParser

type ProtoBufUndoLogParser struct {
}

func (ProtoBufUndoLogParser) Decode

func (parser ProtoBufUndoLogParser) Decode(data []byte) *branchUndoLog

func (ProtoBufUndoLogParser) Encode

func (parser ProtoBufUndoLogParser) Encode(branchUndoLog *branchUndoLog) []byte

func (ProtoBufUndoLogParser) GetDefaultContent

func (parser ProtoBufUndoLogParser) GetDefaultContent() []byte

func (ProtoBufUndoLogParser) GetName

func (parser ProtoBufUndoLogParser) GetName() string

type RawBytes

type RawBytes []byte

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is Oracle result

func (*Result) LastInsertId

func (result *Result) LastInsertId() (int64, error)

LastInsertId returns last inserted ID

func (*Result) RowsAffected

func (result *Result) RowsAffected() (int64, error)

RowsAffected returns rows affected

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows is Oracle rows

func (*Rows) Close

func (rows *Rows) Close() error

Close closes rows

func (*Rows) ColumnTypeDatabaseTypeName

func (rows *Rows) ColumnTypeDatabaseTypeName(i int) string

ColumnTypeDatabaseTypeName implement RowsColumnTypeDatabaseTypeName.

func (*Rows) ColumnTypeLength

func (rows *Rows) ColumnTypeLength(i int) (int64, bool)

ColumnTypeLength is returning OCI_ATTR_DATA_SIZE, which is max data size in bytes. Note this is not returing length of the column type, like the 20 in FLOAT(20), which is what is normally expected. TODO: Should / can it be changed to return length of the column type?

func (*Rows) ColumnTypeScanType

func (rows *Rows) ColumnTypeScanType(i int) reflect.Type

ColumnTypeScanType implement RowsColumnTypeScanType.

func (*Rows) Columns

func (rows *Rows) Columns() []string

Columns returns column names

func (*Rows) Next

func (rows *Rows) Next(dest []driver.Value) error

Next gets next row

type SQLType

type SQLType byte
const (
	SQLType_SELECT SQLType = iota

	SQLType_INSERT

	SQLType_UPDATE

	SQLType_DELETE

	SQLType_SELECT_FOR_UPDATE

	SQLType_REPLACE

	SQLType_TRUNCATE

	SQLType_CREATE

	SQLType_DROP

	SQLType_LOAD

	SQLType_MERGE

	SQLType_SHOW

	SQLType_ALTER

	SQLType_RENAME

	SQLType_DUMP

	SQLType_DEBUG

	SQLType_EXPLAIN

	SQLType_PROCEDURE

	SQLType_DESC

	SQLType_SET SQLType = 27

	SQLType_RELOAD SQLType = 28

	SQLType_SELECT_UNION SQLType = 29

	SQLType_CREATE_TABLE SQLType = 30

	SQLType_DROP_TABLE SQLType = 31

	SQLType_ALTER_TABLE SQLType = 32

	SQLType_SAVE_POINT SQLType = 33

	SQLType_SELECT_FROM_UPDATE SQLType = 34

	SQLType_MULTI_DELETE SQLType = 35

	SQLType_MULTI_UPDATE SQLType = 36

	SQLType_CREATE_INDEX SQLType = 37

	SQLType_DROP_INDEX SQLType = 38
)

func (SQLType) String

func (sqlType SQLType) String() string

type SqlDataType

type SqlDataType int32

type State

type State byte
const (
	Normal State = iota
	GlobalFinished
)

func (State) String

func (state State) String() string

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt is Oracle statement

func (*Stmt) CheckNamedValue

func (stmt *Stmt) CheckNamedValue(namedValue *driver.NamedValue) error

CheckNamedValue checks a named value

func (*Stmt) Close

func (stmt *Stmt) Close() error

Close closes the statement

func (*Stmt) Exec

func (stmt *Stmt) Exec(args []driver.Value) (driver.Result, error)

Exec runs an exec query

func (*Stmt) NumInput

func (stmt *Stmt) NumInput() int

NumInput returns the number of input

func (*Stmt) Query

func (stmt *Stmt) Query(args []driver.Value) (driver.Rows, error)

Query runs a query

type TableMetaCache

type TableMetaCache struct {
	// contains filtered or unexported fields
}

func GetTableMetaCache

func GetTableMetaCache(dbName string) (*TableMetaCache, error)

func (*TableMetaCache) FetchSchema

func (cache *TableMetaCache) FetchSchema(conn *Conn, tableName string) (schema.TableMeta, error)

func (*TableMetaCache) GetCacheKey

func (cache *TableMetaCache) GetCacheKey(tableName string) string

func (*TableMetaCache) GetTableMeta

func (cache *TableMetaCache) GetTableMeta(conn *Conn, tableName string) (schema.TableMeta, error)

func (*TableMetaCache) Refresh

func (cache *TableMetaCache) Refresh(conn *Conn, resourceID string)

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx is Oracle transaction

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit transaction commit

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback transaction rollback

type UndoLogParser

type UndoLogParser interface {
	GetName() string

	// return the default content if undo log is empty
	GetDefaultContent() []byte

	Encode(branchUndoLog *branchUndoLog) []byte

	Decode(data []byte) *branchUndoLog
}

func GetUndoLogParser

func GetUndoLogParser() UndoLogParser

type Values

type Values map[string][]string

Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.

func ParseQuery

func ParseQuery(query string) (m Values, err error)

ParseQuery parses the URL-encoded query string and returns a map listing the values specified for each key. ParseQuery always returns a non-nil map containing all the valid query parameters found; err describes the first decoding error encountered, if any.

func (Values) Add

func (v Values) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Values) Del

func (v Values) Del(key string)

Del deletes the values associated with key.

func (Values) Encode

func (v Values) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") not sorted by key

func (Values) Get

func (v Values) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.

func (Values) Set

func (v Values) Set(key, value string)

Set sets the key to value. It replaces any existing values.

Directories

Path Synopsis
_example
nls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL