Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge/3.0to3.1 #213

Merged
merged 46 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
68f96e2
Merge pull request #175 from taosdata/main
huskar-t Jun 14, 2023
709f4ff
feat: move stmt field to common and add json tag
huskar-t Jul 11, 2023
dbd9a06
fix: get offset after seek
huskar-t Jul 11, 2023
e4f8e72
Merge pull request #182 from taosdata/feat/TD-25182/3.0
huskar-t Jul 11, 2023
5db18bf
enh: support tmq_position tmq_committed tmq_commit_offset_sync tmq_co…
huskar-t Aug 3, 2023
bc8b329
fix: ignore assignment.offset
huskar-t Aug 3, 2023
b99355e
fix: ci
huskar-t Aug 3, 2023
1d3c00f
fix: ci
huskar-t Aug 3, 2023
f59137f
fix: ci
huskar-t Aug 3, 2023
95706b0
fix: ci
huskar-t Aug 3, 2023
d373208
fix: ci
huskar-t Aug 3, 2023
09e8a3e
fix: position judgment error
huskar-t Aug 4, 2023
e792740
Merge pull request #183 from taosdata/enh/xftan/TD-25339
huskar-t Aug 4, 2023
b416fc1
enh: add commit_offset committed position over ws
huskar-t Aug 24, 2023
69a35ed
fix: describe table return 5 columns
huskar-t Aug 24, 2023
cab38e7
Merge pull request #189 from taosdata/enh/xftan/TD-25345
huskar-t Aug 24, 2023
5a614c1
enh: support varbinary and fix pointer check
huskar-t Aug 25, 2023
b7a0ca6
fix: stmt bind varbinary
huskar-t Sep 19, 2023
a8fdd64
fix: varbinary column type default byte array
huskar-t Sep 19, 2023
b0f9b69
Merge pull request #191 from taosdata/enh/xftan/TD-25867
huskar-t Sep 19, 2023
f98e215
fix: add field length to stmt bind param
sunpe Sep 22, 2023
8b83ab2
Merge pull request #196 from taosdata/fix/sunpeng/TD-25348-add-length…
sunpe Sep 22, 2023
c350517
enh: support whitelist
huskar-t Sep 22, 2023
24d812e
Merge pull request #197 from taosdata/enh/TD-25733/whitelist
huskar-t Sep 22, 2023
13aca2b
fix: stmt data length list
huskar-t Sep 25, 2023
b7dcba3
Merge pull request #198 from taosdata/fix/stmt/lengthoffset
sunpe Sep 25, 2023
b87efc2
enh: support taos_set_conn_mode
huskar-t Sep 26, 2023
5ab5921
Merge pull request #199 from taosdata/enh/xftan/TS-4042
huskar-t Sep 26, 2023
fefe825
enh: add api required by ws
sunpe Sep 27, 2023
353c14f
fix: fix build TDengine
huskar-t Sep 28, 2023
b065578
fix: fix build TDengine
huskar-t Sep 28, 2023
bba9cc3
fix: fix build TDengine
huskar-t Sep 28, 2023
9b9dab2
Merge pull request #200 from taosdata/enh/sunpeng/TD-25691-add-interf…
huskar-t Sep 28, 2023
1b47372
enh: support drop user notify
huskar-t Sep 28, 2023
2ec7278
Merge pull request #201 from taosdata/enh/xftan/TS-3926
huskar-t Sep 28, 2023
7bf5254
Merge branch 'main' into merge/xftan/mainto3.0
huskar-t Oct 24, 2023
a3e7562
test: fix tmq test
huskar-t Oct 24, 2023
a3d62aa
Merge pull request #204 from taosdata/merge/xftan/mainto3.0
huskar-t Oct 24, 2023
238c225
enh: support geometry
huskar-t Oct 25, 2023
9e29944
ci: upgrade to ubuntu 2204
huskar-t Oct 25, 2023
c4e277f
fix: stmt varbinary test
huskar-t Oct 25, 2023
9bd79d4
Merge pull request #206 from taosdata/enh/xftan/TD-26332/geometry
huskar-t Oct 25, 2023
30b341b
fix: parse large string length with uint16
huskar-t Nov 8, 2023
2bc55f7
Merge pull request #208 from taosdata/fix/xftan/largestring-3.0
huskar-t Nov 8, 2023
a83526c
Merge remote-tracking branch 'origin/3.0' into merge/3.0to3.1
huskar-t Nov 9, 2023
1a621db
fix: remove unimplemented C methods
huskar-t Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enh: add api required by ws
  • Loading branch information
sunpe committed Sep 27, 2023
commit fefe825b28cc27d1df1864bd856821f5ec0658cf
13 changes: 13 additions & 0 deletions wrapper/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/taosdata/driver-go/v3/common"
"github.com/taosdata/driver-go/v3/common/stmt"
taosError "github.com/taosdata/driver-go/v3/errors"
taosTypes "github.com/taosdata/driver-go/v3/types"
)

Expand Down Expand Up @@ -709,3 +710,15 @@ func StmtParseFields(num int, fields unsafe.Pointer) []*stmt.StmtField {
func TaosStmtReclaimFields(stmt unsafe.Pointer, fields unsafe.Pointer) {
C.taos_stmt_reclaim_fields(stmt, (*C.TAOS_FIELD_E)(fields))
}

// TaosStmtGetParam DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes)
func TaosStmtGetParam(stmt unsafe.Pointer, idx int) (dataType int, dataLength int, err error) {
code := C.taos_stmt_get_param(stmt, C.int(idx), (*C.int)(unsafe.Pointer(&dataType)), (*C.int)(unsafe.Pointer(&dataLength)))
if code != 0 {
err = &taosError.TaosError{
Code: int32(code),
ErrStr: TaosStmtErrStr(stmt),
}
}
return
}
43 changes: 43 additions & 0 deletions wrapper/stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,3 +1145,46 @@ func TestTaosStmtSetTags(t *testing.T) {
assert.Equal(t, int32(102), data[0][2].(int32))
assert.Equal(t, []byte(`{"a":"b"}`), data[0][3].([]byte))
}

func TestTaosStmtGetParam(t *testing.T) {
conn, err := TaosConnect("", "root", "taosdata", "", 0)
assert.NoError(t, err)
defer TaosClose(conn)

err = exec(conn, "drop database if exists test_stmt_get_param")
assert.NoError(t, err)
err = exec(conn, "create database if not exists test_stmt_get_param")
assert.NoError(t, err)
defer exec(conn, "drop database if exists test_stmt_get_param")

err = exec(conn,
"create table if not exists test_stmt_get_param.stb(ts TIMESTAMP,current float,voltage int,phase float) TAGS (groupid int,location varchar(24))")
assert.NoError(t, err)

stmt := TaosStmtInit(conn)
assert.NotNilf(t, stmt, "failed to init stmt")
defer TaosStmtClose(stmt)

code := TaosStmtPrepare(stmt, "insert into test_stmt_get_param.tb_0 using test_stmt_get_param.stb tags(?,?) values (?,?,?,?)")
assert.Equal(t, 0, code, TaosStmtErrStr(stmt))

dt, dl, err := TaosStmtGetParam(stmt, 0) // ts
assert.NoError(t, err)
assert.Equal(t, 9, dt)
assert.Equal(t, 8, dl)

dt, dl, err = TaosStmtGetParam(stmt, 1) // current
assert.NoError(t, err)
assert.Equal(t, 6, dt)
assert.Equal(t, 4, dl)

dt, dl, err = TaosStmtGetParam(stmt, 2) // voltage
assert.NoError(t, err)
assert.Equal(t, 4, dt)
assert.Equal(t, 4, dl)

dt, dl, err = TaosStmtGetParam(stmt, 3) // phase
assert.NoError(t, err)
assert.Equal(t, 6, dt)
assert.Equal(t, 4, dl)
}
21 changes: 21 additions & 0 deletions wrapper/taosc.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,24 @@ func TaosGetTablesVgID(conn unsafe.Pointer, db string, tables []string) (vgIDs [
func TaosSetConnMode(conn unsafe.Pointer, mode int, value int) int {
return int(C.taos_set_conn_mode(conn, C.int(mode), C.int(value)))
}

// TaosGetCurrentDB DLL_EXPORT int taos_get_current_db(TAOS *taos, char *database, int len, int *required)
func TaosGetCurrentDB(conn unsafe.Pointer) (db string, err error) {
cDb := C.CString(db)
defer C.free(unsafe.Pointer(cDb))
var required int

code := C.taos_get_current_db(conn, cDb, C.int(193), (*C.int)(unsafe.Pointer(&required)))
if code != 0 {
err = errors.NewError(int(code), TaosErrorStr(nil))
}
db = C.GoString(cDb)

return
}

// TaosGetServerInfo DLL_EXPORT const char *taos_get_server_info(TAOS *taos)
func TaosGetServerInfo(conn unsafe.Pointer) string {
info := C.taos_get_server_info(conn)
return C.GoString(info)
}
25 changes: 25 additions & 0 deletions wrapper/taosc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,28 @@ func TestTaosSetConnMode(t *testing.T) {
t.Errorf("TaosSetConnMode() error code= %d, msg: %s", code, TaosErrorStr(nil))
}
}

func TestTaosGetCurrentDB(t *testing.T) {
conn, err := TaosConnect("", "root", "taosdata", "", 0)
assert.NoError(t, err)
defer TaosClose(conn)
dbName := "current_db_test"
_ = exec(conn, fmt.Sprintf("drop database if exists %s", dbName))
err = exec(conn, fmt.Sprintf("create database %s", dbName))
assert.NoError(t, err)
defer func() {
_ = exec(conn, fmt.Sprintf("drop database if exists %s", dbName))
}()
_ = exec(conn, fmt.Sprintf("use %s", dbName))
db, err := TaosGetCurrentDB(conn)
assert.NoError(t, err)
assert.Equal(t, dbName, db)
}

func TestTaosGetServerInfo(t *testing.T) {
conn, err := TaosConnect("", "root", "taosdata", "", 0)
assert.NoError(t, err)
defer TaosClose(conn)
info := TaosGetServerInfo(conn)
assert.NotEmpty(t, info)
}