Skip to content

Commit

Permalink
Merge pull request #302 from taosdata/3.0
Browse files Browse the repository at this point in the history
merge 3.0 to main
  • Loading branch information
huskar-t authored Sep 29, 2024
2 parents 9d680c1 + 21d50e3 commit 55121b7
Show file tree
Hide file tree
Showing 29 changed files with 10,017 additions and 65 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- name: checkout TDengine by pr
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Cache server by pr
if: github.event_name == 'pull_request'
id: cache-server-pr
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ matrix.td_version }}-${{ steps.get_commit_id.outputs.commit_id }}
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
- name: get cache server by pr
if: github.event_name == 'pull_request'
id: get-cache-server-pr
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ matrix.td_version }}-${{ needs.build.outputs.commit_id }}
Expand All @@ -110,7 +110,7 @@ jobs:
cd release && sudo sh install.sh
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: copy taos cfg
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
steps:
- name: checkout TDengine by pr
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
ref: ${{ github.base_ref }}

- name: checkout TDengine manually
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
Expand All @@ -47,15 +47,15 @@ jobs:
- name: Cache server by pr
if: github.event_name == 'pull_request'
id: cache-server-pr
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.base_ref }}-${{ steps.get_commit_id.outputs.commit_id }}

- name: Cache server manually
if: github.event_name == 'workflow_dispatch'
id: cache-server-manually
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ inputs.tbBranch }}-${{ steps.get_commit_id.outputs.commit_id }}
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
- name: get cache server by pr
if: github.event_name == 'pull_request'
id: get-cache-server-pr
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.base_ref }}-${{ needs.build.outputs.commit_id }}
Expand All @@ -127,7 +127,7 @@ jobs:
- name: cache server manually
if: github.event_name == 'workflow_dispatch'
id: get-cache-server-manually
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ inputs.tbBranch }}-${{ needs.build.outputs.commit_id }}
Expand All @@ -143,7 +143,7 @@ jobs:
cd release && sudo sh install.sh
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: copy taos cfg
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
commit_id: ${{ steps.get_commit_id.outputs.commit_id }}
steps:
- name: checkout TDengine
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Cache server
id: cache-server
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.ref_name }}-${{ steps.get_commit_id.outputs.commit_id }}
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
steps:
- name: get cache server
id: get-cache-server
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.ref_name }}-${{ needs.build.outputs.commit_id }}
Expand All @@ -103,7 +103,7 @@ jobs:
cd release && sudo sh install.sh
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: copy taos cfg
run: |
Expand Down
59 changes: 59 additions & 0 deletions af/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ func (conn *Connector) Stmt() *Stmt {
return NewStmt(conn.taos)
}

// Stmt2 Prepare stmt2
func (conn *Connector) Stmt2(reqID int64, singleTableBindOnce bool) *Stmt2 {
return NewStmt2(conn.taos, reqID, singleTableBindOnce)
}

// InsertStmtWithReqID Prepare batch insert stmt with reqID
func (conn *Connector) InsertStmtWithReqID(reqID int64) *insertstmt.InsertStmt {
return insertstmt.NewInsertStmtWithReqID(conn.taos, reqID)
Expand Down Expand Up @@ -313,3 +318,57 @@ func (conn *Connector) GetTableVGroupID(db, table string) (vgID int, err error)
}
return
}

// InfluxDBInsertLinesWithReqID Insert data using influxdb line format
func (conn *Connector) InfluxDBInsertLinesWithReqID(lines string, precision string, reqID int64, ttl int, tbNameKey string) error {
locker.Lock()
_, result := wrapper.TaosSchemalessInsertRawTTLWithReqIDTBNameKey(conn.taos, lines, wrapper.InfluxDBLineProtocol, precision, ttl, reqID, tbNameKey)
locker.Unlock()
defer func() {
locker.Lock()
wrapper.TaosFreeResult(result)
locker.Unlock()
}()
code := wrapper.TaosError(result)
if code != 0 {
errStr := wrapper.TaosErrorStr(result)
return errors.NewError(code, errStr)
}
return nil
}

// OpenTSDBInsertTelnetLinesWithReqID Insert data using opentsdb telnet format
func (conn *Connector) OpenTSDBInsertTelnetLinesWithReqID(lines string, reqID int64, ttl int, tbNameKey string) error {
locker.Lock()
_, result := wrapper.TaosSchemalessInsertRawTTLWithReqIDTBNameKey(conn.taos, lines, wrapper.OpenTSDBTelnetLineProtocol, "", ttl, reqID, tbNameKey)
locker.Unlock()
defer func() {
locker.Lock()
wrapper.TaosFreeResult(result)
locker.Unlock()
}()
code := wrapper.TaosError(result)
if code != 0 {
errStr := wrapper.TaosErrorStr(result)
return errors.NewError(code, errStr)
}
return nil
}

// OpenTSDBInsertJsonPayloadWithReqID Insert data using opentsdb json format
func (conn *Connector) OpenTSDBInsertJsonPayloadWithReqID(payload string, reqID int64, ttl int, tbNameKey string) error {
locker.Lock()
_, result := wrapper.TaosSchemalessInsertRawTTLWithReqIDTBNameKey(conn.taos, payload, wrapper.OpenTSDBJsonFormatProtocol, "", ttl, reqID, tbNameKey)
locker.Unlock()
defer func() {
locker.Lock()
wrapper.TaosFreeResult(result)
locker.Unlock()
}()
code := wrapper.TaosError(result)
if code != 0 {
errStr := wrapper.TaosErrorStr(result)
return errors.NewError(code, errStr)
}
return nil
}
51 changes: 51 additions & 0 deletions af/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,57 @@ func TestConnector_QueryWithReqID(t *testing.T) {
}
}

func TestInfluxDBInsertLinesWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
err := db.InfluxDBInsertLinesWithReqID(raw, "ns", 0x1234, 0, "")
if err != nil {
t.Error(err)
return
}
err = db.InfluxDBInsertLinesWithReqID("wrong", "ns", 0x1234, 0, "")
assert.Errorf(t, err, "expect error")
}

func TestOpenTSDBInsertTelnetLinesWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
err := db.OpenTSDBInsertTelnetLinesWithReqID(
"sys_if_bytes_out 1479496100 1.3E3 host=web01 interface=eth0\nsys_procs_running 1479496100 42 host=web01",
0x2234, 0, "")

if err != nil {
t.Error(err)
return
}
err = db.OpenTSDBInsertTelnetLinesWithReqID(
"wrong",
0x2234, 0, "")
assert.Errorf(t, err, "expect error")
}

func TestOpenTSDBInsertJsonPayloadWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
err := db.OpenTSDBInsertJsonPayloadWithReqID(`{
"metric": "sys",
"timestamp":
"value": 18,
"tags": {
"host": "web01",
"dc": "lga"
}
}`, 0x3234, 0, "")
if err == nil {
t.Error("expect error")
return
}
err = db.OpenTSDBInsertJsonPayloadWithReqID(
"wrong",
0x3234, 0, "")
assert.Errorf(t, err, "expect error")
}

func TestNewConnector(t *testing.T) {
tc, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
assert.NoError(t, err)
Expand Down
3 changes: 1 addition & 2 deletions af/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ func (s *Stmt) UseResult() (driver.Rows, error) {
locker.Unlock()
numFields := wrapper.TaosNumFields(res)
rowsHeader, err := wrapper.ReadColumn(res, numFields)
h := async.GetHandler()
if err != nil {
async.PutHandler(h)
return nil, err
}
h := async.GetHandler()
precision := wrapper.TaosResultPrecision(res)
rs := &rows{
handler: h,
Expand Down
Loading

0 comments on commit 55121b7

Please sign in to comment.