yasdb

package module
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 18 Imported by: 1

README

yasdb-go|崖山数据库GO语言驱动程序

yasdb-go 是 YashanDB 官方 Go 语言数据库驱动,完全兼容 Go 标准的 database/sql 接口,依赖崖山数据库C驱动。

特性
  • ✅ 全面兼容 Go 1.18+
  • ✅ 符合 Go 标准 database/sql 接口
  • ✅ 预处理语句与批量操作
  • ✅ 事务支持
  • ✅ 上下文控制(Cancel/Timeout)
  • ✅ 多版本运行时检测与自动适配
环境准备(CGO + C 客户端)

本驱动依赖 YashanDB C 客户端,不同操作系统配置方式不同:

平台 在线安装 离线安装
Linux docs/linux_online.md docs/linux_offline.md
Windows docs/windows_online.md docs/windows_offline.md
  • C 客户端下载:yashandb-client
  • Windows 另需 64 位 GCC(MinGW-w64 / TDM-GCC)以编译 CGO。
快速引入
go get github.com/yashan-technologies/yashandb-go@v1.4.2
import _ "github.com/yashan-technologies/yashandb-go"

db, err := sql.Open("yasdb", "sys/password@127.0.0.1:1688")

更多示例见 _examples 目录。

DSN的填写说明

参考教程: DSN format

兼容性说明
GO驱动版本 版本发布时间 新特性 最低兼容C驱动版本 完全支持C驱动版本
1.4.2 2026.3.18 首版本支持 v23.4.1.100 v23.4.1.100
测试说明(向量 / 版本要求)

运行全量测试示例:

go test -v ./... -dsn "sys/password@127.0.0.1:1688"
  • 向量(Vector)相关用例TestVector*)对版本有额外要求:需要 YashanDB 23.5+,并且需要配套的 C 客户端(yashandb-client 23.5+)。否则可能出现以下错误并导致全量测试失败:
    • 数据库不支持向量语法YAS-04225 invalid word 3
    • C 客户端过旧YAS-20001 symbol yacDescAlloc2 not found in yacli library
  • 全量测试耗时TestManyQueryRowGosql 会执行大量 QueryRow(默认 10000 次),在 Linux/远程网络环境下耗时数分钟属正常现象,可使用 -short 跳过该压力用例。

更完整的测试说明见:docs/testing.md

Documentation

Overview

Copyright 2022, YashanDB and/or its affiliates. All rights reserved. YashanDB Driver for golang is licensed under the terms of the mulan PSL v2.0

License: http://license.coscl.org.cn/MulanPSL2 Home page: https://www.yashandb.com/

Copyright 2022, YashanDB and/or its affiliates. All rights reserved. YashanDB Driver for golang is licensed under the terms of the mulan PSL v2.0

License: http://license.coscl.org.cn/MulanPSL2 Home page: https://www.yashandb.com/

Index

Constants

View Source
const (
	SS_UNKNOWN     serverStatus = 255
	SS_UNCONNECTED serverStatus = 0
	SS_NORMAL      serverStatus = 1
)
View Source
const (
	DBG_RUNNING_ATTR_STATUS      DebugRunningAttr = 0
	DBG_RUNNING_ATTR_OBJ_ID      DebugRunningAttr = 1
	DBG_RUNNING_ATTR_SUB_ID      DebugRunningAttr = 2
	DBG_RUNNING_ATTR_LINE_NO     DebugRunningAttr = 3
	DBG_RUNNING_ATTR_CLASS_NAME  DebugRunningAttr = 4
	DBG_RUNNING_ATTR_METHOD_NAME DebugRunningAttr = 5

	DBG_FRAME_ATTR_OBJ_ID      DebugFrameAttr = 0
	DBG_FRAME_ATTR_SUB_ID      DebugFrameAttr = 1
	DBG_FRAME_ATTR_LINE_NO     DebugFrameAttr = 2
	DBG_FRAME_ATTR_STACK_NO    DebugFrameAttr = 3
	DBG_FRAME_ATTR_CLASS_NAME  DebugFrameAttr = 4
	DBG_FRAME_ATTR_METHOD_NAME DebugFrameAttr = 5

	DBG_VAR_ATTR_BLOCK_NO   DebugVarAttr = 0
	DBG_VAR_ATTR_TYPE       DebugVarAttr = 1
	DBG_VAR_ATTR_IS_GLOBAL  DebugVarAttr = 2
	DBG_VAR_ATTR_NAME       DebugVarAttr = 3
	DBG_VAR_ATTR_VALUE_SIZE DebugVarAttr = 4

	DBG_BP_ATTR_OBJ_ID  DebugBpAttr = 0
	DBG_BP_ATTR_SUB_ID  DebugBpAttr = 1
	DBG_BP_ATTR_LINE_NO DebugBpAttr = 2

	DBG_STATUS_OFF DebuggerStatus = 0
	DBG_STATUS_ON  DebuggerStatus = 1

	DEFAULT_ATTRS_BUFFER = 68*2 + 1
)
View Source
const PdbgOutputDefaultBufSize = 65534*2 + 1

Variables

View Source
var (
	CST_UNKNOW cliSqlType = 0
	CST_SELECT cliSqlType = 1
	CST_INSERT cliSqlType = 2
	CST_UPDATE cliSqlType = 3
	CST_DELETE cliSqlType = 4
	CST_PLSQL  cliSqlType = 126
)
View Source
var (
	ValueTypeUint64Err = errors.New("the value parameter type must be *uint64")
	ValueTypeUint16Err = errors.New("the value parameter type must be *uint16")
	ValueTypeUint32Err = errors.New("the value parameter type must be *uint32")
	ValueTypeStringErr = errors.New("the value parameter type must be *string")
)
View Source
var DateTimeFormats = map[DTF]string{
	DateTimeMicroZone: "2006-01-02 15:04:05.999999 -07:00",
	DateTimeZone:      "2006-01-02 15:04:05 -07:00",
	DateTimeMicro:     "2006-01-02 15:04:05.999999",
	DateTime:          "2006-01-02 15:04:05",
	Date:              "2006-01-02",
	TimeMicro:         "15:04:05.999999",
	Time:              "15:04:05",
}

DateTimeFormats holds all datetime format strings

View Source
var ErrInsertIdUnsupport = errors.New("last insert id is unsupport")

Functions

func ConvertToNameValue

func ConvertToNameValue(args ...any) ([]driver.NamedValue, error)

func FormatTime

func FormatTime(format string, t time.Time) string

取值范围/格式:[0001-01-01 00:00:00.000000,9999-12-31 23:59:59.999999],[-15:59~+15:59],支持的格式符:'YYYY'/'YYY'/'YY'/'Y'/'MM'/'MON'/'MONTH'/'DD'/'D'/'DAY'/'HH'/'HH12'/'HH24'/'MI'/'SS'/'AM'/'A.M.'/'PM'/'P.M.'/'FF'/'FF1'/'FF2'/'FF3'/'FF4'/'FF5'/'FF6'/'FF7'/'FF8'/'FF9'/'TZH'/'TZM'

doc: https://cod-doc.yasdb.com/yashandb/23.4/zh/Reference-Manual/Configuration-Parameters.html#timestamp-format

func FormatYMInterval

func FormatYMInterval(format string, year, month int32) string

func GetDatabaseTypeName

func GetDatabaseTypeName(yapiType uint32) string

func GetDatabaseTypeSize

func GetDatabaseTypeSize(yType C.YapiType) int32

func NewOutputBindValue

func NewOutputBindValue(dest interface{}, opts ...outputBindOpt) (*outputBindInfo, error)

func NewYasRow

func NewYasRow(size uint32, yacType C.YapiType, precision uint8, scale int8, nullable uint8) *yasRow

func PbdgGetBindOutValue

func PbdgGetBindOutValue(stmt *YasStmt) error

func PdbgAbort

func PdbgAbort(stmt *YasStmt) error

func PdbgAddBreakpoint

func PdbgAddBreakpoint(stmt *YasStmt, objId uint64, subId uint16, lineNo uint32) (uint32, error)

func PdbgCheckVersion

func PdbgCheckVersion(stmt *YasStmt, objId uint64, subId uint16, version uint32) error

func PdbgContinue

func PdbgContinue(stmt *YasStmt) error

func PdbgDeleteAllBreakpoints

func PdbgDeleteAllBreakpoints(stmt *YasStmt) error

func PdbgDeleteBreakpoint

func PdbgDeleteBreakpoint(stmt *YasStmt, objId uint64, subId uint16, lineNo uint32) error

func PdbgGetAllFrames

func PdbgGetAllFrames(stmt *YasStmt) (uint32, error)

func PdbgGetAllVars

func PdbgGetAllVars(stmt *YasStmt) (uint32, error)

func PdbgGetBreakpointAttrs

func PdbgGetBreakpointAttrs(stmt *YasStmt, id uint32, attr DebugBpAttr, value interface{}) error

func PdbgGetBreakpointsCount

func PdbgGetBreakpointsCount(stmt *YasStmt) (uint32, error)

func PdbgGetFrameAttrs

func PdbgGetFrameAttrs(stmt *YasStmt, id uint32, attr DebugFrameAttr, value interface{}) error

func PdbgGetRunningAttrs

func PdbgGetRunningAttrs(stmt *YasStmt, attr DebugRunningAttr, value interface{}) error

func PdbgGetVarAttrs

func PdbgGetVarAttrs(stmt *YasStmt, id uint32, attr DebugVarAttr, value interface{}) error

func PdbgGetVarValue

func PdbgGetVarValue(stmt *YasStmt, id uint32) (string, error)

func PdbgStart

func PdbgStart(stmt *YasStmt, objId uint64, subId uint16) error

func PdbgStatementClose

func PdbgStatementClose(stmt *YasStmt) error

func PdbgStepInto

func PdbgStepInto(stmt *YasStmt) error

func PdbgStepNext

func PdbgStepNext(stmt *YasStmt) error

func PdbgStepOut

func PdbgStepOut(stmt *YasStmt) error

func SetClientDriverName

func SetClientDriverName(name string)

func SetDebugMode

func SetDebugMode()

func WithBindSize

func WithBindSize(bindSize uint32) outputBindOpt

func WithCursor added in v1.4.4

func WithCursor() outputBindOpt

func WithTypeBigInt

func WithTypeBigInt() outputBindOpt

func WithTypeBit

func WithTypeBit() outputBindOpt

func WithTypeBlob

func WithTypeBlob() outputBindOpt

func WithTypeBool

func WithTypeBool() outputBindOpt

func WithTypeChar

func WithTypeChar() outputBindOpt

func WithTypeClob

func WithTypeClob() outputBindOpt

func WithTypeCursor added in v1.4.4

func WithTypeCursor() outputBindOpt

func WithTypeDSInterval

func WithTypeDSInterval() outputBindOpt

func WithTypeDate

func WithTypeDate() outputBindOpt

func WithTypeDouble

func WithTypeDouble() outputBindOpt

func WithTypeFloat

func WithTypeFloat() outputBindOpt

func WithTypeInteger

func WithTypeInteger() outputBindOpt

func WithTypeNumber

func WithTypeNumber() outputBindOpt

func WithTypeNvarchar

func WithTypeNvarchar() outputBindOpt

func WithTypeRaw

func WithTypeRaw() outputBindOpt

func WithTypeRowid

func WithTypeRowid() outputBindOpt

func WithTypeSmallInt

func WithTypeSmallInt() outputBindOpt

func WithTypeTimestamp

func WithTypeTimestamp() outputBindOpt

func WithTypeTimestampLocalTimeZone

func WithTypeTimestampLocalTimeZone() outputBindOpt

func WithTypeTimestampTimeZone

func WithTypeTimestampTimeZone() outputBindOpt

func WithTypeTinyint

func WithTypeTinyint() outputBindOpt

func WithTypeVarchar

func WithTypeVarchar() outputBindOpt

func WithTypeVector added in v1.4.4

func WithTypeVector() outputBindOpt

func WithTypeYMInterval

func WithTypeYMInterval() outputBindOpt

Types

type BindOutDestTypeErr

type BindOutDestTypeErr struct {
	TypeFormat string
}

func NewBindOutDestTypeErr

func NewBindOutDestTypeErr(typeFormat string) *BindOutDestTypeErr

func (*BindOutDestTypeErr) Error

func (d *BindOutDestTypeErr) Error() string

type CompatVector added in v1.4.4

type CompatVector string
const (
	CV_NULL   CompatVector = "null"
	CV_YASHAN CompatVector = "yashan"
	CV_MYSQL  CompatVector = "mysql"
)

type DSInterval added in v1.4.4

type DSInterval struct {
	Day     int32
	DayTime time.Time // 只取time中的hour,minute,second,Nanosecond(实际上只到微妙)
}

https://cod-doc.yasdb.com/yashandb/23.4alpha/zh/All-Manuals/Development-Guide/SQL-Reference-Manual/Data-Types/Date-Time-Types.html#%E5%A4%A9%E5%88%B0%E7%A7%92%E9%97%B4%E9%9A%94%E7%B1%BB%E5%9E%8B-interval-day-to-second-data-type

func NewDSInterval added in v1.4.4

func NewDSInterval(day int32, dayTime time.Time) DSInterval

type DTF added in v1.4.4

type DTF int8
const (
	DateTimeMicroZone DTF = iota
	DateTimeZone
	DateTimeMicro
	DateTime
	Date
	TimeMicro
	Time
)

type DataSourceName

type DataSourceName struct {
	User         string
	Password     string
	Url          string
	DataPath     string
	IsAutoCommit bool
	// contains filtered or unexported fields
}

func ParseDSN

func ParseDSN(dsnStr string) (*DataSourceName, error)

ParseDSN parses a DataSourceName used to connect to YashanDB

It expects to receive a string in the form:

[username/[password]@]host[:port][?param1=value1&...&paramN=valueN] OR YASDB_DATA_PATH[?param1=value1&...&paramN=valueN] Supported parameters are:

autocommit - When it is true, the transaction will be automatically committed every time an SQL statement is executed. Default is false

type DebugBpAttr

type DebugBpAttr int8

type DebugConfigOpt added in v1.4.4

type DebugConfigOpt func(*debugConfig)

func WithDebugCallTempalate added in v1.4.4

func WithDebugCallTempalate(call string, args ...any) DebugConfigOpt

func WithDebugEnableOutput added in v1.4.4

func WithDebugEnableOutput() DebugConfigOpt

func WithDebugOutputCacheSize added in v1.4.4

func WithDebugOutputCacheSize(cacheSize uint32) DebugConfigOpt

func WithDebugOutputMaxLineLen added in v1.4.4

func WithDebugOutputMaxLineLen(maxLineLen uint32) DebugConfigOpt

type DebugFrameAttr

type DebugFrameAttr int8

type DebugRunningAttr

type DebugRunningAttr int8

type DebugVarAttr

type DebugVarAttr int8

type DebuggerStatus

type DebuggerStatus int8

type Number added in v1.4.4

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

Number 是 YashanDB NUMBER 类型的无损文本包装。 零值 Number{} 表示 NULL。

func NewNumber added in v1.4.4

func NewNumber(s string) Number

NewNumber 创建一个有效的 Number,s 为 NUMBER 的十进制文本表示。

func (Number) Float64 added in v1.4.4

func (n Number) Float64() (float64, error)

Float64 将 Number 转换为 float64。NULL 或非法文本时返回错误。

func (Number) Int64 added in v1.4.4

func (n Number) Int64() (int64, error)

Int64 将 Number 转换为 int64。NULL 或非整数文本时返回错误。

func (Number) IsNull added in v1.4.4

func (n Number) IsNull() bool

IsNull 返回 Number 是否为 NULL。

func (Number) MarshalJSON added in v1.4.4

func (n Number) MarshalJSON() ([]byte, error)

MarshalJSON 实现 json.Marshaler。NULL 序列化为 null,有效值序列化为 JSON 字符串(如 "123.45"),避免 JSON 数字消费者丢失精度。

func (Number) MarshalText added in v1.4.4

func (n Number) MarshalText() ([]byte, error)

MarshalText 实现 encoding.TextMarshaler。NULL 时返回 nil。

func (*Number) Scan added in v1.4.4

func (n *Number) Scan(src interface{}) error

Scan 实现 sql.Scanner,从数据库或 Go 值中读取 NUMBER。 支持的源类型:nil、string、[]byte、Number、*Number、int64、int、int32、float64、float32。

func (Number) String added in v1.4.4

func (n Number) String() string

String 返回 Number 的十进制文本表示。NULL 时返回空字符串。

func (Number) Text added in v1.4.4

func (n Number) Text() (string, bool)

Text 返回文本和有效性。

func (*Number) UnmarshalJSON added in v1.4.4

func (n *Number) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 json.Unmarshaler。支持 null、JSON 字符串和 JSON 数字。

func (*Number) UnmarshalText added in v1.4.4

func (n *Number) UnmarshalText(text []byte) error

UnmarshalText 实现 encoding.TextUnmarshaler。

func (Number) Valid added in v1.4.4

func (n Number) Valid() bool

Valid 返回 Number 是否有效(非 NULL)。

func (Number) Value added in v1.4.4

func (n Number) Value() (driver.Value, error)

Value 实现 driver.Valuer。NULL 返回 nil;有效值返回十进制文本字符串。

type PdbgBreakpointAttr

type PdbgBreakpointAttr struct {
	Id     uint32
	ObjId  uint64
	SubId  uint16
	LineNo uint32
}

func PdbgGetAllBreakpointAttrs

func PdbgGetAllBreakpointAttrs(stmt *YasStmt) ([]*PdbgBreakpointAttr, error)

type PdbgFrameData

type PdbgFrameData struct {
	Id         uint32
	ObjId      uint64
	SubId      uint16
	LineNo     uint32
	StackNo    uint32
	ClassName  string
	MethodName string
}

func PdbgGetAllFrameAttrs

func PdbgGetAllFrameAttrs(stmt *YasStmt) ([]*PdbgFrameData, error)

type PdbgRunningAttr

type PdbgRunningAttr struct {
	Status     DebuggerStatus
	ObjId      uint64
	SubId      uint16
	LineNo     uint32
	ClassName  string
	MethodName string
}

func PdbgGetAllRunningAttrs

func PdbgGetAllRunningAttrs(stmt *YasStmt) (*PdbgRunningAttr, error)

type PdbgVarAttr

type PdbgVarAttr struct {
	Id           uint32
	BlockNo      uint32
	DataType     uint8
	DataTypeName string
	GlobalLevel  uint8
	Name         string
	Size         uint32
	Value        string
}

func PdbgGetAllVarAttrs

func PdbgGetAllVarAttrs(stmt *YasStmt) ([]*PdbgVarAttr, error)

type PlsqlDebug

type PlsqlDebug struct {
	Stmt *YasStmt
	// contains filtered or unexported fields
}

func NewPlsqlDebug

func NewPlsqlDebug(dsn string, opts ...DebugConfigOpt) (*PlsqlDebug, error)

NewPlsqlDebug 创建新的连接并初始化 PlsqlDebug(原有签名不变)。

func NewPlsqlDebugWithConn added in v1.4.4

func NewPlsqlDebugWithConn(conn *YasConn, opts ...DebugConfigOpt) (*PlsqlDebug, error)

NewPlsqlDebugWithConn 复用已有连接创建 PlsqlDebug。 调用方持有 conn 的所有权 — Close() 会关闭 conn; 用 CloseWithoutConn() 释放 PDBG 资源但保留共享连接。

func (*PlsqlDebug) Abort

func (p *PlsqlDebug) Abort() error

func (*PlsqlDebug) AddBreakpoint

func (p *PlsqlDebug) AddBreakpoint(objId uint64, subId uint16, lineNo uint32) (uint32, error)

func (*PlsqlDebug) CheckVersion

func (p *PlsqlDebug) CheckVersion(objId uint64, subId uint16, version uint32) error

func (*PlsqlDebug) Close

func (p *PlsqlDebug) Close() error

Close 关闭所有语句并关闭底层连接(原有签名不变)。

func (*PlsqlDebug) CloseWithoutConn added in v1.4.4

func (p *PlsqlDebug) CloseWithoutConn() error

CloseWithoutConn 关闭所有语句但保留底层连接。 用于共享连接场景:释放 PDBG 资源但不关闭 YasConn。

func (*PlsqlDebug) Continue

func (p *PlsqlDebug) Continue() error

func (*PlsqlDebug) DeleteAllBreakpoint

func (p *PlsqlDebug) DeleteAllBreakpoint() error

func (*PlsqlDebug) DeleteBreakpoint

func (p *PlsqlDebug) DeleteBreakpoint(objId uint64, subId uint16, lineNo uint32) error

func (*PlsqlDebug) GetAllBreakpointAttrs

func (p *PlsqlDebug) GetAllBreakpointAttrs() ([]*PdbgBreakpointAttr, error)

func (*PlsqlDebug) GetAllFrameAttrs

func (p *PlsqlDebug) GetAllFrameAttrs() ([]*PdbgFrameData, error)

func (*PlsqlDebug) GetAllFrames

func (p *PlsqlDebug) GetAllFrames() (uint32, error)

func (*PlsqlDebug) GetAllRunningAttrs

func (p *PlsqlDebug) GetAllRunningAttrs() (*PdbgRunningAttr, error)

func (*PlsqlDebug) GetAllVarAttrs

func (p *PlsqlDebug) GetAllVarAttrs() ([]*PdbgVarAttr, error)

func (*PlsqlDebug) GetAllVars

func (p *PlsqlDebug) GetAllVars() (uint32, error)

func (*PlsqlDebug) GetBindOutValue

func (p *PlsqlDebug) GetBindOutValue() error

func (*PlsqlDebug) GetBreakpointAttrs

func (p *PlsqlDebug) GetBreakpointAttrs(id uint32, attr DebugBpAttr, value interface{}) error

func (*PlsqlDebug) GetBreakpointsCount

func (p *PlsqlDebug) GetBreakpointsCount() (uint32, error)

func (*PlsqlDebug) GetFrameAttrs

func (p *PlsqlDebug) GetFrameAttrs(id uint32, attr DebugFrameAttr, value interface{}) error

func (*PlsqlDebug) GetOutput added in v1.4.4

func (p *PlsqlDebug) GetOutput() ([]string, error)

func (*PlsqlDebug) GetRunningAttrs

func (p *PlsqlDebug) GetRunningAttrs(attr DebugRunningAttr, value interface{}) error

func (*PlsqlDebug) GetVarAttrs

func (p *PlsqlDebug) GetVarAttrs(id uint32, attr DebugVarAttr, value interface{}) error

func (*PlsqlDebug) GetVarValue

func (p *PlsqlDebug) GetVarValue(id uint32) (string, error)

func (*PlsqlDebug) PdbgGetOutput added in v1.4.4

func (p *PlsqlDebug) PdbgGetOutput() (string, error)

func (*PlsqlDebug) Start

func (p *PlsqlDebug) Start(objId uint64, subId uint16) error

func (*PlsqlDebug) StepInto

func (p *PlsqlDebug) StepInto() error

func (*PlsqlDebug) StepNext

func (p *PlsqlDebug) StepNext() error

func (*PlsqlDebug) StepOut

func (p *PlsqlDebug) StepOut() error

type Vector added in v1.4.4

type Vector struct {
	Data   interface{}  // []float32, []float64, 或 []int8
	Dim    uint16       // 向量维度
	Format VectorFormat // 格式类型
}

Vector 向量数据类型

func (*Vector) Scan added in v1.4.4

func (v *Vector) Scan(src interface{}) error

Scan 实现 sql.Scanner 接口,支持从数据库扫描 Vector 数据

func (Vector) String added in v1.4.4

func (v Vector) String() string

String 返回 Vector 的字符串表示

func (Vector) Value added in v1.4.4

func (v Vector) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口。 返回 Vector 的字符串表示,供 gorm 等上层 ORM 做日志格式化。 实际的参数绑定由 YasStmt.CheckNamedValue 直接识别 Vector 类型走专用路径, 不依赖 Value() 的返回值。注意:不能返回 v 自身,否则 gorm logger 会无限递归。

type VectorFormat added in v1.4.4

type VectorFormat uint8

VectorFormat 向量格式枚举

const (
	VectorFormatFlex    VectorFormat = 0 // 灵活格式
	VectorFormatFloat16 VectorFormat = 1 // 半精度浮点
	VectorFormatFloat32 VectorFormat = 2 // 单精度浮点
	VectorFormatFloat64 VectorFormat = 3 // 双精度浮点
	VectorFormatInt8    VectorFormat = 4 // 8位整数
)

type VectorScanError added in v1.4.4

type VectorScanError struct {
	Type string
}

func (*VectorScanError) Error added in v1.4.4

func (e *VectorScanError) Error() string

type YasBaseError

type YasBaseError struct {
	Code int
	Msg  string
}

func ErrDataPathNoExist

func ErrDataPathNoExist(p string) *YasBaseError

func ErrDbFetchEOF

func ErrDbFetchEOF() *YasBaseError

func ErrDbTypeUnsupport

func ErrDbTypeUnsupport(dbType int) *YasBaseError

func ErrDsnNoSet

func ErrDsnNoSet() *YasBaseError

func ErrDsnNoStandard

func ErrDsnNoStandard(dsn string) *YasBaseError

func ErrEnvInit

func ErrEnvInit() *YasBaseError

func ErrNoConnect

func ErrNoConnect() *YasBaseError

func ErrNoCursorHandle added in v1.4.4

func ErrNoCursorHandle() *YasBaseError

func ErrOutputBindValue

func ErrOutputBindValue() *YasBaseError

func ErrStmtInit

func ErrStmtInit() *YasBaseError

func ErrStmtNoOpen

func ErrStmtNoOpen() *YasBaseError

func ErrUnknowType

func ErrUnknowType(v interface{}) *YasBaseError

func ErrVectorNil added in v1.4.4

func ErrVectorNil() *YasBaseError

func (*YasBaseError) Error

func (e *YasBaseError) Error() string

type YasConn

type YasConn struct {
	Env  *C.YapiEnv
	Conn *C.YapiConnect
	// contains filtered or unexported fields
}

func GenYasconn

func GenYasconn(dsnStr string) (*YasConn, error)

func (*YasConn) Begin

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

func (*YasConn) BeginTx

func (conn *YasConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

func (*YasConn) Cancel added in v1.4.4

func (conn *YasConn) Cancel() error

func (*YasConn) Close

func (conn *YasConn) Close() error

func (*YasConn) Ping

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

func (*YasConn) Prepare

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

func (*YasConn) PrepareContext

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

func (*YasConn) ResetSession

func (conn *YasConn) ResetSession(ctx context.Context) error

type YasConnector

type YasConnector struct {
}

func (*YasConnector) Connect

func (connectot *YasConnector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a connection to the database.

func (*YasConnector) Driver

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

Driver returns the underlying Driver of the Connector, mainly to maintain compatibility with the Driver method on sql.DB.

type YasDBError

type YasDBError struct {
	Code     int
	Msg      string
	SqlState string
	Line     int
	Column   int
}

func (*YasDBError) Error

func (e *YasDBError) Error() string

type YasResult

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

func (*YasResult) LastInsertId

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

LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.

func (*YasResult) RowsAffected

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

RowsAffected returns the number of rows affected by the query.

type YasRows

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

func (*YasRows) Close

func (r *YasRows) Close() error

Close closes the rows iterator.

func (*YasRows) ColumnTypeDatabaseTypeName

func (r *YasRows) ColumnTypeDatabaseTypeName(index int) string

RowsColumnTypeDatabaseTypeName return the database system type name without the length. Type names should be uppercase.

func (*YasRows) ColumnTypeLength

func (r *YasRows) ColumnTypeLength(index int) (length int64, ok bool)

RowsColumnTypeLength return the length of the column type if the column is a variable length type. If the column is not a variable length type ok should return false. If length is not limited other than system limits, it should return math.MaxInt64.

func (*YasRows) ColumnTypeNullable

func (r *YasRows) ColumnTypeNullable(index int) (nullable, ok bool)

func (*YasRows) ColumnTypePrecisionScale

func (r *YasRows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)

func (*YasRows) ColumnTypeScanType

func (r *YasRows) ColumnTypeScanType(index int) reflect.Type

ColumnTypeScanType return the value type that can be used to scan types into. For example, the database column type "bigint" this should return "reflect.TypeOf(int64(0))".

func (*YasRows) Columns

func (r *YasRows) Columns() []string

Columns returns the names of the columns.

func (*YasRows) Next

func (r *YasRows) Next(dest []driver.Value) error

Next is called to populate the next row of data into the provided slice. The provided slice will be the same size as the Columns() are wide.

Next should return io.EOF when there are no more rows.

The dest should not be written to outside of Next. Care should be taken when closing Rows not to modify a buffer held in dest.

type YasStmt

type YasStmt struct {
	Conn *YasConn
	Stmt *C.YapiStmt

	SqlType uint32
	Sqlstr  string

	sync.Mutex
	// contains filtered or unexported fields
}

func PrepareContext

func PrepareContext(conn *YasConn, ctx context.Context, query string) (*YasStmt, error)

func (*YasStmt) CheckNamedValue

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

CheckNamedValue is called before passing arguments to the driver and is called in place of any ColumnConverter. CheckNamedValue must do type validation and conversion as appropriate for the driver.

func (*YasStmt) Close

func (stmt *YasStmt) Close() error

Close closes the statement.

func (*YasStmt) Exec deprecated

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

Exec executes a query that doesn't return rows, such as an INSERT or UPDATE.

Deprecated: Drivers should implement StmtExecContext instead (or additionally).

func (*YasStmt) ExecContext

func (stmt *YasStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.

ExecContext must honor the context timeout and return when it is canceled.

func (*YasStmt) NumInput

func (stmt *YasStmt) NumInput() int

NumInput returns the number of placeholder parameters.

func (*YasStmt) Query deprecated

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

Query executes a query that may return rows, such as a SELECT.

Deprecated: Drivers should implement StmtQueryContext instead (or additionally).

func (*YasStmt) QueryContext

func (stmt *YasStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

QueryContext executes a query that may return rows, such as a SELECT.

QueryContext must honor the context timeout and return when it is canceled.

type YasTx

type YasTx struct {
	Conn *YasConn
}

func (*YasTx) Commit

func (tx *YasTx) Commit() error

Commit transaction commit

func (*YasTx) Rollback

func (tx *YasTx) Rollback() error

Rollback transaction rollback

type YasdbDriver

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

func (*YasdbDriver) Conn

func (yasDriver *YasdbDriver) Conn() *YasConn

func (*YasdbDriver) Open

func (yasDriver *YasdbDriver) Open(dsnStr string) (driver.Conn, error)

Open returns a new connection to the database.

Directories

Path Synopsis
bind command
blob command
clob command
compat_vector command
context command
date command
emoji command
int command
null command
number command
plsql command
raw command
simple command
sqlout command
ssl_root_cer command
stress command
vector command
xml command

Jump to

Keyboard shortcuts

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