Skip to content

Commit

Permalink
Merge pull request #191 from taosdata/enh/xftan/TD-25867
Browse files Browse the repository at this point in the history
enh: support varbinary and fix pointer check
  • Loading branch information
huskar-t authored Sep 19, 2023
2 parents cab38e7 + a8fdd64 commit b0f9b69
Show file tree
Hide file tree
Showing 20 changed files with 264 additions and 158 deletions.
2 changes: 2 additions & 0 deletions common/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
NullTime = reflect.TypeOf(types.NullTime{})
NullBool = reflect.TypeOf(types.NullBool{})
NullString = reflect.TypeOf(types.NullString{})
Bytes = reflect.TypeOf([]byte{})
NullJson = reflect.TypeOf(types.NullJson{})
UnknownType = reflect.TypeOf(new(interface{})).Elem()
)
Expand All @@ -40,4 +41,5 @@ var ColumnTypeMap = map[int]reflect.Type{
TSDB_DATA_TYPE_NCHAR: NullString,
TSDB_DATA_TYPE_TIMESTAMP: NullTime,
TSDB_DATA_TYPE_JSON: NullJson,
TSDB_DATA_TYPE_VARBINARY: Bytes,
}
3 changes: 3 additions & 0 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
TSDB_DATA_TYPE_UINT_Str = "INT UNSIGNED"
TSDB_DATA_TYPE_UBIGINT_Str = "BIGINT UNSIGNED"
TSDB_DATA_TYPE_JSON_Str = "JSON"
TSDB_DATA_TYPE_VARBINARY_Str = "VARBINARY"
)

var TypeNameMap = map[int]string{
Expand All @@ -83,6 +84,7 @@ var TypeNameMap = map[int]string{
TSDB_DATA_TYPE_UINT: TSDB_DATA_TYPE_UINT_Str,
TSDB_DATA_TYPE_UBIGINT: TSDB_DATA_TYPE_UBIGINT_Str,
TSDB_DATA_TYPE_JSON: TSDB_DATA_TYPE_JSON_Str,
TSDB_DATA_TYPE_VARBINARY: TSDB_DATA_TYPE_VARBINARY_Str,
}

var NameTypeMap = map[string]int{
Expand All @@ -102,6 +104,7 @@ var NameTypeMap = map[string]int{
TSDB_DATA_TYPE_UINT_Str: TSDB_DATA_TYPE_UINT,
TSDB_DATA_TYPE_UBIGINT_Str: TSDB_DATA_TYPE_UBIGINT,
TSDB_DATA_TYPE_JSON_Str: TSDB_DATA_TYPE_JSON,
TSDB_DATA_TYPE_VARBINARY_Str: TSDB_DATA_TYPE_VARBINARY,
}

const (
Expand Down
12 changes: 12 additions & 0 deletions common/param/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ func (c *ColumnType) AddBinary(strMaxLen int) *ColumnType {
return c
}

func (c *ColumnType) AddVarBinary(strMaxLen int) *ColumnType {
if c.column >= c.size {
return c
}
c.value[c.column] = &types.ColumnType{
Type: types.TaosVarBinaryType,
MaxLen: strMaxLen,
}
c.column += 1
return c
}

func (c *ColumnType) AddNchar(strMaxLen int) *ColumnType {
if c.column >= c.size {
return c
Expand Down
16 changes: 16 additions & 0 deletions common/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ func (p *Param) SetBinary(offset int, value []byte) {
p.value[offset] = taosTypes.TaosBinary(value)
}

func (p *Param) SetVarBinary(offset int, value []byte) {
if offset >= p.size {
return
}
p.value[offset] = taosTypes.TaosVarBinary(value)
}

func (p *Param) SetNchar(offset int, value string) {
if offset >= p.size {
return
Expand Down Expand Up @@ -252,6 +259,15 @@ func (p *Param) AddBinary(value []byte) *Param {
return p
}

func (p *Param) AddVarBinary(value []byte) *Param {
if p.offset >= p.size {
return p
}
p.value[p.offset] = taosTypes.TaosVarBinary(value)
p.offset += 1
return p
}

func (p *Param) AddNchar(value string) *Param {
if p.offset >= p.size {
return p
Expand Down
Loading

0 comments on commit b0f9b69

Please sign in to comment.