Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a6c22144
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a6c22144
编写于
12月 21, 2019
作者:
S
slguan
提交者:
GitHub
12月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #981 from taosdata/patch/tbase-1381
fix tbase-1381
上级
2ea71438
7148743e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
19 deletion
+20
-19
src/connector/go/src/taosSql/result.go
src/connector/go/src/taosSql/result.go
+20
-19
未找到文件。
src/connector/go/src/taosSql/result.go
浏览文件 @
a6c22144
...
...
@@ -25,13 +25,13 @@ package taosSql
import
"C"
import
(
"database/sql/driver"
"database/sql/driver"
"errors"
"strconv"
"unsafe"
"fmt"
"io"
"strconv"
"time"
"unsafe"
)
/******************************************************************************
...
...
@@ -41,10 +41,10 @@ import (
func
(
mc
*
taosConn
)
readColumns
(
count
int
)
([]
taosSqlField
,
error
)
{
columns
:=
make
([]
taosSqlField
,
count
)
var
result
unsafe
.
Pointer
var
result
unsafe
.
Pointer
result
=
C
.
taos_use_result
(
mc
.
taos
)
if
result
==
nil
{
return
nil
,
errors
.
New
(
"invalid result"
)
return
nil
,
errors
.
New
(
"invalid result"
)
}
pFields
:=
(
*
C
.
struct_taosField
)(
C
.
taos_fetch_fields
(
result
))
...
...
@@ -52,7 +52,7 @@ func (mc *taosConn) readColumns(count int) ([]taosSqlField, error) {
// TODO: Optimized rewriting !!!!
fields
:=
(
*
[
1
<<
30
]
C
.
struct_taosField
)(
unsafe
.
Pointer
(
pFields
))
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
//columns[i].tableName = ms.taos.
//fmt.Println(reflect.TypeOf(fields[i].name))
var
charray
[]
byte
...
...
@@ -60,14 +60,14 @@ func (mc *taosConn) readColumns(count int) ([]taosSqlField, error) {
//fmt.Println("fields[i].name[j]: ", fields[i].name[j])
if
fields
[
i
]
.
name
[
j
]
!=
0
{
charray
=
append
(
charray
,
byte
(
fields
[
i
]
.
name
[
j
]))
}
else
{
}
else
{
break
}
}
columns
[
i
]
.
name
=
string
(
charray
)
columns
[
i
]
.
length
=
(
uint32
)(
fields
[
i
]
.
bytes
)
columns
[
i
]
.
name
=
string
(
charray
)
columns
[
i
]
.
length
=
(
uint32
)(
fields
[
i
]
.
bytes
)
columns
[
i
]
.
fieldType
=
fieldType
(
fields
[
i
]
.
_type
)
columns
[
i
]
.
flags
=
0
columns
[
i
]
.
flags
=
0
// columns[i].decimals = 0
//columns[i].charSet = 0
}
...
...
@@ -91,6 +91,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
row
:=
C
.
taos_fetch_row
(
result
)
if
row
==
nil
{
rows
.
rs
.
done
=
true
C
.
taos_free_result
(
result
)
rows
.
mc
=
nil
return
io
.
EOF
}
...
...
@@ -98,7 +99,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
// because sizeof(void*) == sizeof(int*) == 8
// notes: sizeof(int) == 8 in go, but sizeof(int) == 4 in C.
for
i
:=
range
dest
{
currentRow
:=
(
unsafe
.
Pointer
)(
uintptr
(
*
((
*
int
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
row
))
+
uintptr
(
i
)
*
unsafe
.
Sizeof
(
int
(
0
)))))))
currentRow
:=
(
unsafe
.
Pointer
)(
uintptr
(
*
((
*
int
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
row
))
+
uintptr
(
i
)
*
unsafe
.
Sizeof
(
int
(
0
)))))))
if
currentRow
==
nil
{
dest
[
i
]
=
nil
...
...
@@ -107,7 +108,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
switch
rows
.
rs
.
columns
[
i
]
.
fieldType
{
case
C
.
TSDB_DATA_TYPE_BOOL
:
if
(
*
((
*
byte
)(
currentRow
)))
!=
0
{
if
(
*
((
*
byte
)(
currentRow
)))
!=
0
{
dest
[
i
]
=
true
}
else
{
dest
[
i
]
=
false
...
...
@@ -123,7 +124,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
break
case
C
.
TSDB_DATA_TYPE_INT
:
dest
[
i
]
=
(
int
)(
*
((
*
int32
)(
currentRow
)))
// notes int32 of go <----> int of C
dest
[
i
]
=
(
int
)(
*
((
*
int32
)(
currentRow
)))
// notes int32 of go <----> int of C
break
case
C
.
TSDB_DATA_TYPE_BIGINT
:
...
...
@@ -142,7 +143,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
charLen
:=
rows
.
rs
.
columns
[
i
]
.
length
var
index
uint32
binaryVal
:=
make
([]
byte
,
charLen
)
for
index
=
0
;
index
<
charLen
;
index
++
{
for
index
=
0
;
index
<
charLen
;
index
++
{
binaryVal
[
index
]
=
*
((
*
byte
)(
unsafe
.
Pointer
(
uintptr
(
currentRow
)
+
uintptr
(
index
))))
}
dest
[
i
]
=
string
(
binaryVal
[
:
])
...
...
@@ -152,7 +153,7 @@ func (rows *taosSqlRows) readRow(dest []driver.Value) error {
if
mc
.
cfg
.
parseTime
==
true
{
timestamp
:=
(
int64
)(
*
((
*
int64
)(
currentRow
)))
dest
[
i
]
=
timestampConvertToString
(
timestamp
,
int
(
C
.
taos_result_precision
(
result
)))
}
else
{
}
else
{
dest
[
i
]
=
(
int64
)(
*
((
*
int64
)(
currentRow
)))
}
break
...
...
@@ -182,12 +183,12 @@ func timestampConvertToString(timestamp int64, precision int) string {
var
decimal
,
sVal
,
nsVal
int64
if
precision
==
0
{
decimal
=
timestamp
%
1000
sVal
=
timestamp
/
1000
nsVal
=
decimal
*
1000
sVal
=
timestamp
/
1000
nsVal
=
decimal
*
1000
}
else
{
decimal
=
timestamp
%
1000000
sVal
=
timestamp
/
1000000
nsVal
=
decimal
*
1000000
sVal
=
timestamp
/
1000000
nsVal
=
decimal
*
1000000
}
date_time
:=
time
.
Unix
(
sVal
,
nsVal
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录