From b7ba65c3c1e7e2639c09584384f5a686dffdc576 Mon Sep 17 00:00:00 2001 From: Steven Li Date: Fri, 22 Nov 2019 18:47:04 -0800 Subject: [PATCH 1/5] Partial fix of #761, corrected bad characters --- .../tdenginedocs-en/super-table/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/documentation/tdenginedocs-en/super-table/index.html b/documentation/tdenginedocs-en/super-table/index.html index 3ebb0775b5..21e7669a19 100644 --- a/documentation/tdenginedocs-en/super-table/index.html +++ b/documentation/tdenginedocs-en/super-table/index.html @@ -6,9 +6,9 @@

Like a table, you can create, show, delete and describe STables. Most query operations on tables can be applied to STable too, including the aggregation and selector functions. For queries on a STable, if no tags filter, the operations are applied to all the tables created via this STable. If there is a tag filter, the operations are applied only to a subset of the tables which satisfy the tag filter conditions. It will be very convenient to use tags to put devices into different groups for aggregation.

Create a STable

Similiar to creating a standard table, syntax is:

-
CREATE TABLE <stable_name> (<field_name> TIMESTAMP, field_name1 field_type,…) TAGS(tag_name tag_type, …)
+
CREATE TABLE <stable_name> (<field_name> TIMESTAMP, field_name1 field_type, ...) TAGS(tag_name tag_type, ...)

New keyword "tags" is introduced, where tag_name is the tag name, and tag_type is the associated data type.

-

Note:

+

Note:

  1. The bytes of all tags together shall be less than 512
  2. Tag's data type can not be time stamp or nchar
  3. @@ -30,12 +30,12 @@ tags (location binary(20), type int) create table t4 using thermometer tags ('shanghai', 20); create table t5 using thermometer tags ('new york', 10);

    Aggregate Tables via STable

    -

    You can group a set of tables together by specifying the tags filter condition, then apply the aggregation operations. The result set can be grouped and ordered based on tag value. Syntax is:

    -
    SELECT function<field_name>,… 
    +

    You can group a set of tables together by specifying the tags filter condition, then apply the aggregation operations. The result set can be grouped and ordered based on tag value. Syntax is:

    +
    SELECT function<field_name>, ... 
      FROM <stable_name> 
    - WHERE <tag_name> <[=|<=|>=|<>] values..> ([AND|OR] …)
    + WHERE <tag_name> <[=|<=|>=|<>] values..> ([AND|OR] ...
      INTERVAL (<time range>)
    - GROUP BY <tag_name>, <tag_name>…
    + GROUP BY <tag_name>, <tag_name> ... 
      ORDER BY <tag_name> <asc|desc>
      SLIMIT <group_limit>
      SOFFSET <group_offset>
    @@ -75,9 +75,9 @@ INTERVAL(10M)
    DROP TABLE <stable_name>

    To delete a STable, all the tables created via this STable shall be deleted first, otherwise, it will fail.

    List the Associated Tables of a STable

    -
    SELECT TBNAME,[TAG_NAME,…] FROM <stable_name> WHERE <tag_name> <[=|=<|>=|<>] values..> ([AND|OR] …)
    +
    SELECT TBNAME,[TAG_NAME, ...] FROM <stable_name> WHERE <tag_name> <[=|=<|>=|<>] values..> ([AND|OR] ...)

    It will list all the tables which satisfy the tag filter conditions. The tables are all created from this specific STable. TBNAME is a new keyword introduced, it is the table name associated with the STable.

    -
    SELECT COUNT(TBNAME) FROM <stable_name> WHERE <tag_name> <[=|=<|>=|<>] values..> ([AND|OR] …)
    +
    SELECT COUNT(TBNAME) FROM <stable_name> WHERE <tag_name> <[=|=<|>=|<>] values..> ([AND|OR] ...)

    The above SQL statement will list the number of tables in a STable, which satisfy the filter condition.

    Management of Tags

    You can add, delete and change the tags for a STable, and you can change the tag value of a table. The SQL commands are listed below.

    From 30773c4ed29c3b5105fbe01ace2ad704200a4fd6 Mon Sep 17 00:00:00 2001 From: lihui Date: Sat, 23 Nov 2019 11:30:11 +0800 Subject: [PATCH 2/5] [TBASE-1215] --- src/client/src/tscServer.c | 2 +- src/system/detail/src/mgmtDb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 1f528bbda3..5b41b6966f 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1807,7 +1807,7 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) { pMsg += sizeof(SMgmtHead); pCreateDbMsg = (SCreateDbMsg *)pMsg; - strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db)); + (void)extractDBName(pMeterMetaInfo->name, pCreateDbMsg->db); // only send db name, then recombining db name + acctId on the mgmt pMsg += sizeof(SCreateDbMsg); msgLen = pMsg - pStart; diff --git a/src/system/detail/src/mgmtDb.c b/src/system/detail/src/mgmtDb.c index ba1b966cfb..a005b24779 100644 --- a/src/system/detail/src/mgmtDb.c +++ b/src/system/detail/src/mgmtDb.c @@ -256,7 +256,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) { pDb = malloc(sizeof(SDbObj)); memset(pDb, 0, sizeof(SDbObj)); - strcpy(pDb->name, pCreate->db); + sprintf(pDb->name, "%s.%s", pAcct->acctId, pCreate->db); // set fullname strcpy(pCreate->acct, pAcct->user); pDb->createdTime = taosGetTimestampMs(); pDb->cfg = *pCreate; From 6eeb797cb30474516cd6bc807a79e4bbe28cea59 Mon Sep 17 00:00:00 2001 From: lihui Date: Sat, 23 Nov 2019 11:59:27 +0800 Subject: [PATCH 3/5] [TBASE-1215] --- src/system/detail/src/mgmtDb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/detail/src/mgmtDb.c b/src/system/detail/src/mgmtDb.c index a005b24779..100c353a62 100644 --- a/src/system/detail/src/mgmtDb.c +++ b/src/system/detail/src/mgmtDb.c @@ -256,7 +256,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) { pDb = malloc(sizeof(SDbObj)); memset(pDb, 0, sizeof(SDbObj)); - sprintf(pDb->name, "%s.%s", pAcct->acctId, pCreate->db); // set fullname + sprintf(pDb->name, "%d.%s", pAcct->acctId, pCreate->db); // set fullname strcpy(pCreate->acct, pAcct->user); pDb->createdTime = taosGetTimestampMs(); pDb->cfg = *pCreate; From 27657f2eb49af2c68a212b44ba7fcf0ecd7a3424 Mon Sep 17 00:00:00 2001 From: lihui Date: Sat, 23 Nov 2019 15:26:33 +0800 Subject: [PATCH 4/5] [TBASE-1215 ROLLBACK] --- src/client/src/tscServer.c | 2 +- src/system/detail/src/mgmtDb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 5b41b6966f..1f528bbda3 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1807,7 +1807,7 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) { pMsg += sizeof(SMgmtHead); pCreateDbMsg = (SCreateDbMsg *)pMsg; - (void)extractDBName(pMeterMetaInfo->name, pCreateDbMsg->db); // only send db name, then recombining db name + acctId on the mgmt + strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db)); pMsg += sizeof(SCreateDbMsg); msgLen = pMsg - pStart; diff --git a/src/system/detail/src/mgmtDb.c b/src/system/detail/src/mgmtDb.c index 100c353a62..ba1b966cfb 100644 --- a/src/system/detail/src/mgmtDb.c +++ b/src/system/detail/src/mgmtDb.c @@ -256,7 +256,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) { pDb = malloc(sizeof(SDbObj)); memset(pDb, 0, sizeof(SDbObj)); - sprintf(pDb->name, "%d.%s", pAcct->acctId, pCreate->db); // set fullname + strcpy(pDb->name, pCreate->db); strcpy(pCreate->acct, pAcct->user); pDb->createdTime = taosGetTimestampMs(); pDb->cfg = *pCreate; From 69c8df7119f78d10f966f3a0965c60f9c4a8280b Mon Sep 17 00:00:00 2001 From: localvar Date: Mon, 25 Nov 2019 09:37:20 +0800 Subject: [PATCH 5/5] fix tbase-1233: go connector cause client crash --- src/connector/go/src/taosSql/rows.go | 15 ++++++++------- src/connector/go/src/taosSql/taosSqlCgo.go | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/connector/go/src/taosSql/rows.go b/src/connector/go/src/taosSql/rows.go index 6407fc334e..5040dca06d 100755 --- a/src/connector/go/src/taosSql/rows.go +++ b/src/connector/go/src/taosSql/rows.go @@ -118,14 +118,15 @@ func (rows *taosSqlRows) ColumnTypeScanType(i int) reflect.Type { return rows.rs.columns[i].scanType() } -func (rows *taosSqlRows) Close() (err error) { - mc := rows.mc - if mc == nil { - return nil +func (rows *taosSqlRows) Close() error { + if rows.mc != nil { + result := C.taos_use_result(rows.mc.taos) + if result != nil { + C.taos_free_result(result) + } + rows.mc = nil } - - rows.mc = nil - return err + return nil } func (rows *taosSqlRows) HasNextResultSet() (b bool) { diff --git a/src/connector/go/src/taosSql/taosSqlCgo.go b/src/connector/go/src/taosSql/taosSqlCgo.go index fcef14045f..cc3aaa1658 100755 --- a/src/connector/go/src/taosSql/taosSqlCgo.go +++ b/src/connector/go/src/taosSql/taosSqlCgo.go @@ -39,7 +39,7 @@ func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsaf defer C.free(unsafe.Pointer(cpass)) defer C.free(unsafe.Pointer(cdb)) - taosObj := C.taos_connect(cip, cuser, cpass, cdb, (C.int)(port)) + taosObj := C.taos_connect(cip, cuser, cpass, cdb, (C.ushort)(port)) if taosObj == nil { return nil, errors.New("taos_connect() fail!") }