gibero

package module
v0.0.0-...-5f484e2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

README

Gibero (WIP)

Tibero-Driver for Go's database/sql package

install

go get -u github.com/sankooc/gibero

usage

package main

import (
   "database/sql"
   _ "github.com/sankooc/gibero"
)

func main() {
   db, _ := sql.Open("tibero", "tibero://username:password@127.0.0.1:1521/dbname")
 // transaction
   tx, _ := db.Begin()
   db.Exec("insert into TEST_TABLE(NUM,VAR_B) values ( ?, ? )", .21, "SANKOOC-")
   tx.Commit()
 // query
 resultSet, _ := db.Query("SELECT ID, ACCOUNT FROM TEST_DB")
   for resultSet.Next() {
   	var id int64
   	var account string
   // support string,int64,float64,time.Time 
   	resultSet.Scan(&id, &account)
   	log.Printf("id %d %s \n", id, account)
   }
}

Documentation

Index

Constants

View Source
const (
	TYPE_FORWARD_ONLY       uint32 = 1003
	TYPE_SCROLL_INSENSITIVE        = 1004
	TYPE_SCROLL_SENSITIVE          = 1005
	CONCUR_READ_ONLY               = 1007
	CONCUR_UPDATABLE               = 1008
)

Variables

View Source
var NEGATIVE_FLAG byte = 0xF0
View Source
var NUM_OFFSET byte = 0x80
View Source
var RTFWRD = &RsetType{1, 1003, 1007}
View Source
var RTFWUP = &RsetType{2, 1003, 1008}
View Source
var RTSIRD = &RsetType{3, 1004, 1007}
View Source
var RTSIUP = &RsetType{4, 1004, 1008}
View Source
var RTSSRD = &RsetType{5, 1005, 1008}
View Source
var RTSSUP = &RsetType{6, 1005, 1007}
View Source
var RTTNULL = &RsetType{0, -1, -1}
View Source
var TB_VERBOSE = false

Functions

func AuthRequestCmd

func AuthRequestCmd(username string, password string, dbname string, program string, publicK []byte) []byte

AUTH_REQ_WITH_VER

func BytesToPrivateKey

func BytesToPrivateKey(raw []byte, password []byte) (*rsa.PrivateKey, error)

func BytesToPublicKey

func BytesToPublicKey(raw []byte) (*rsa.PublicKey, error)

func CLOSE_CSR_CMD

func CLOSE_CSR_CMD(v uint32) []byte

func CLOSE_LOB_CMD

func CLOSE_LOB_CMD(v uint32) []byte

func CLOSE_SESSION_CMD

func CLOSE_SESSION_CMD(v uint32) []byte

func CLOSE_TID_CMD

func CLOSE_TID_CMD() []byte

func CLOSE_XA_CMD

func CLOSE_XA_CMD(v uint32) []byte

func CMDtail

func CMDtail(writer *ByteWriter) []byte

func CommitCMD

func CommitCMD() []byte

func DecodeDouble

func DecodeDouble(inputData []byte) float64

func DecodeInt

func DecodeInt(inputData []byte) int64

func DecodeNumber

func DecodeNumber(inputData []byte) interface{}

func DecodePadString

func DecodePadString(size uint32, data []byte) []byte

func DecryptWithPrivateKey

func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

func EncodeFloat

func EncodeFloat(num float64, bitSize int) ([]byte, error)

func EncodeInt

func EncodeInt(val int) []byte

func EncodeInt64

func EncodeInt64(val int64) []byte

func EncodePadString

func EncodePadString(data []byte) []byte

func EncodeUint64

func EncodeUint64(val uint64) []byte

func EncryptWithPublicKey

func EncryptWithPublicKey(plainText []byte, publickey *rsa.PublicKey) []byte

func FormatPEM

func FormatPEM(public_key string) []byte

func FromNumber

func FromNumber(inputData []byte) (mantissa uint64, negative bool, exponent int, mantissaDigits int, err error)

func PKExchangeCmd

func PKExchangeCmd() []byte

func PrepareStatementCMD

func PrepareStatementCMD(sql string, autoComit uint32, prefetch uint32, flag bool)

func PrintHex

func PrintHex(tag string, data []byte)

func RSA_Encrypt

func RSA_Encrypt(plainText []byte, publickey []byte) ([]byte, error)

func ReadMsg

func ReadMsg(reader *ByteReader) (*Message, *EReply)

func RollbackCMD

func RollbackCMD(str string) []byte

func SQLCMD

func SQLCMD(autoComit uint32, prefetch uint32, sql string) []byte

func ToNumber

func ToNumber(mantissa []byte, negative bool, exponent int) []byte

func UDecodeString

func UDecodeString(decorder *encoding.Decoder, size uint32, data []byte, atEOF bool) []byte

Types

type ByteReader

type ByteReader struct {
	Cur   uint32
	Data  []byte
	Total uint32
	// contains filtered or unexported fields
}

func CreateReader

func CreateReader(reader io.Reader, data []byte, offset int) *ByteReader

func (*ByteReader) ReadDBString

func (reader *ByteReader) ReadDBString() string

type ByteWriter

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

func CreateWriter

func CreateWriter() *ByteWriter

func (*ByteWriter) Data

func (writer *ByteWriter) Data() []byte

func (*ByteWriter) InsertBig32

func (writer *ByteWriter) InsertBig32(val uint32, start uint32)

func (*ByteWriter) Size

func (writer *ByteWriter) Size() uint32

func (*ByteWriter) WriteBig32

func (writer *ByteWriter) WriteBig32(val uint32)

func (*ByteWriter) WriteBig64

func (writer *ByteWriter) WriteBig64(val uint64)

func (*ByteWriter) WriteByte

func (writer *ByteWriter) WriteByte(val byte)

func (*ByteWriter) WriteCLNT

func (writer *ByteWriter) WriteCLNT(size uint32, params []*TbclntInfoParam)

func (*ByteWriter) WriteDBFloat

func (writer *ByteWriter) WriteDBFloat(val float64, bitSize int)

func (*ByteWriter) WriteDBInteger

func (writer *ByteWriter) WriteDBInteger(val int64)

func (*ByteWriter) WriteDBMinLenString

func (writer *ByteWriter) WriteDBMinLenString(val string)

func (*ByteWriter) WriteDBString

func (writer *ByteWriter) WriteDBString(val string)

func (*ByteWriter) WriteDate

func (writer *ByteWriter) WriteDate(ti *time.Time)

func (*ByteWriter) WriteNLS

func (writer *ByteWriter) WriteNLS(size uint32, params []*TbclntInfoParam)

func (*ByteWriter) WriteTimestamp

func (writer *ByteWriter) WriteTimestamp(ti *time.Time)

type BytesBinder

type BytesBinder []byte

type ConnectMessage

type ConnectMessage struct {
	*Message
	// contains filtered or unexported fields
}

type DBByte32

type DBByte32 []byte

type DBServer

type DBServer interface {
	Connect()
	// contains filtered or unexported methods
}

type DateBinder

type DateBinder time.Time

type Deserializable

type Deserializable interface {
	// contains filtered or unexported methods
}

type EReply

type EReply struct {
	*Message
	// contains filtered or unexported fields
}

type Float32Binder

type Float32Binder float32

type Float64Binder

type Float64Binder float64

type FloatScan

type FloatScan float64

type IntegerBinder

type IntegerBinder int64

type IntegerScan

type IntegerScan int64

type Message

type Message struct {
	MsgType     uint32
	MsgBodySize uint32
	Tsn         uint64
}

func (*Message) DeserializeFromBytes

func (msg *Message) DeserializeFromBytes(data []byte)

type OkReply

type OkReply struct {
	*Message
	// contains filtered or unexported fields
}

type PKExchangeMessage

type PKExchangeMessage struct {
	*Message
	SessKey *DBByte32
}

type ParamBinder

type ParamBinder interface {
	// contains filtered or unexported methods
}

type PrepareStatement

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

func (*PrepareStatement) Close

func (ps *PrepareStatement) Close() error

func (*PrepareStatement) Exec

func (ps *PrepareStatement) Exec(args []driver.Value) (driver.Result, error)

func (*PrepareStatement) NumInput

func (ps *PrepareStatement) NumInput() int

func (*PrepareStatement) Query

func (ps *PrepareStatement) Query(args []driver.Value) (driver.Rows, error)

type RsetType

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

type SQLException

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

type Serializable

type Serializable interface {
	// contains filtered or unexported methods
}

type SessionInfoMessage

type SessionInfoMessage struct {
	*Message
	// contains filtered or unexported fields
}

type Singleton

type Singleton struct {
	*TiberoDSN
	// contains filtered or unexported fields
}

func (*Singleton) Connect

func (m *Singleton) Connect()

type StringBinder

type StringBinder string

type StringScan

type StringScan string

type TConnector

type TConnector struct {
	*TiberoDriver
	// contains filtered or unexported fields
}

func (*TConnector) Begin

func (connector *TConnector) Begin() (driver.Tx, error)

func (*TConnector) Close

func (connector *TConnector) Close() error

func (*TConnector) Commit

func (connector *TConnector) Commit() error

func (*TConnector) Connect

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

func (*TConnector) Driver

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

func (*TConnector) Prepare

func (connector *TConnector) Prepare(query string) (driver.Stmt, error)

func (*TConnector) Rollback

func (connector *TConnector) Rollback() error

type TbColumnDesc

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

type TbMsgExecuteCountReply

type TbMsgExecuteCountReply struct {
	*Message
	// contains filtered or unexported fields
}

func (*TbMsgExecuteCountReply) LastInsertId

func (reply *TbMsgExecuteCountReply) LastInsertId() (int64, error)

func (*TbMsgExecuteCountReply) RowsAffected

func (reply *TbMsgExecuteCountReply) RowsAffected() (int64, error)

type TbMsgExecutePrefetchReply

type TbMsgExecutePrefetchReply struct {
	*Message
	// contains filtered or unexported fields
}

func (*TbMsgExecutePrefetchReply) Close

func (msg *TbMsgExecutePrefetchReply) Close() error

func (*TbMsgExecutePrefetchReply) Columns

func (msg *TbMsgExecutePrefetchReply) Columns() []string

func (*TbMsgExecutePrefetchReply) Next

func (replay *TbMsgExecutePrefetchReply) Next(dest []driver.Value) error

type TbResultSet

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

func (*TbResultSet) Scan

func (rs *TbResultSet) Scan(param ...any)

type TbTimestamp

type TbTimestamp [12]byte

type TbclntInfoParam

type TbclntInfoParam struct {
	ClntParamId  uint32
	ClntParamVal string
}

type Tibero

type Tibero struct {
	DBServer
	// contains filtered or unexported fields
}

func CreateDB

func CreateDB(host string, username string, password string, dbname string) *Tibero

func CreateTibero

func CreateTibero(dsn *TiberoDSN) *Tibero

type TiberoDSN

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

func DsnConvert

func DsnConvert(dsn string) *TiberoDSN

type TiberoDriver

type TiberoDriver struct{}

func (*TiberoDriver) Open

func (driver *TiberoDriver) Open(url string) (driver.Conn, error)

func (*TiberoDriver) OpenConnector

func (driver *TiberoDriver) OpenConnector(dsn string) (driver.Connector, error)

type Tibero_CMD_CODE

type Tibero_CMD_CODE uint32
const (
	CLOSE_CSR     Tibero_CMD_CODE = 22
	CLOSE_SESSION Tibero_CMD_CODE = 28
	CLOSE_LOB     Tibero_CMD_CODE = 50
	CLOSE_XA      Tibero_CMD_CODE = 67
	CLOSE_TID     Tibero_CMD_CODE = 226
)

type TimestampBinder

type TimestampBinder time.Time

type TimestempScan

type TimestempScan [12]byte

Jump to

Keyboard shortcuts

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