Skip to content

Commit

Permalink
Merge pull request taosdata#160 from taosdata/fix/TS-3289
Browse files Browse the repository at this point in the history
fix: stmt reclaim fields
  • Loading branch information
huskar-t authored Apr 27, 2023
2 parents 934621f + 60a13ee commit ba2c7d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions taosSql/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (stmt *Stmt) CheckNamedValue(v *driver.NamedValue) error {
errStr := wrapper.TaosStmtErrStr(stmt.stmt)
return errors.NewError(code, errStr)
}
defer wrapper.TaosStmtReclaimFields(stmt.stmt, fieldsP)
stmt.cols = wrapper.StmtParseFields(num, fieldsP)
}
if v.Ordinal > len(stmt.cols) {
Expand Down
5 changes: 5 additions & 0 deletions wrapper/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,8 @@ func StmtParseFields(num int, fields unsafe.Pointer) []*StmtField {
}
return result
}

// TaosStmtReclaimFields DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields);
func TaosStmtReclaimFields(stmt unsafe.Pointer, fields unsafe.Pointer) {
C.taos_stmt_reclaim_fields(stmt, (*C.TAOS_FIELD_E)(fields))
}
3 changes: 3 additions & 0 deletions wrapper/stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,13 +760,15 @@ func TestGetFields(t *testing.T) {
t.Error(err)
return
}
defer TaosStmtReclaimFields(stmt, tagsP)
code, columnCount, columnsP := TaosStmtGetColFields(stmt)
if code != 0 {
errStr := TaosStmtErrStr(stmt)
err = taosError.NewError(code, errStr)
t.Error(err)
return
}
defer TaosStmtReclaimFields(stmt, columnsP)
columns := StmtParseFields(columnCount, columnsP)
tags := StmtParseFields(tagCount, tagsP)
assert.Equal(t, []*StmtField{
Expand Down Expand Up @@ -859,6 +861,7 @@ func TestGetFieldsCommonTable(t *testing.T) {
t.Error(err)
return
}
defer TaosStmtReclaimFields(stmt, columnsP)
columns := StmtParseFields(columnCount, columnsP)
assert.Equal(t, []*StmtField{
{"ts", 9, 0, 0, 8},
Expand Down

0 comments on commit ba2c7d3

Please sign in to comment.