提交 a4be3261 编写于 作者: G Ganlin Zhao

Merge branch 'develop' into feature/TD-11216

......@@ -1239,7 +1239,7 @@ taosd -C
| 内部配置 | No |
| 适用范围 | 仅服务端适用 |
| 含义 | 配置要进行有损压缩的浮点数据类型 |
| 取值范围 | float:只对float类型进行有损压缩<br/>double:只对double类型进行有损压缩<br/>float|double:float double都进行有损压缩 |
| 取值范围 | float:只对float类型进行有损压缩<br/>double:只对double类型进行有损压缩<br/>float\|double:float double都进行有损压缩 |
| 缺省值 | 默认为空字符串,关闭有损压缩 |
| 补充说明 | 2.4.0.10版本新增。|
......
......@@ -59,14 +59,14 @@ When TDengine receives the application's request packet, it first writes the req
There are two system configuration parameters involved:
- walLevel: WAL level, 0: do not write wal; 1: write wal, but do not execute fsync; 2: write wal and execute fsync.
- walLevel: WAL level, 0: do not write WAL; 1: write WAL, but do not execute fsync; 2: write WAL and execute fsync.
- fsync: the cycle in which fsync is executed when walLevel is set to 2. Setting to 0 means that fsync is executed immediately whenever there is a write.
To guarantee 100% data safe, you need to set walLevel to 2 and fsync to 0. In that way, the write speed will decrease. However, if the number of threads starting to write data on the application side reaches a certain number (more than 50), the performance of writing data will also be good, only about 30% lower than that of fsync set to 3000 milliseconds.
### Disaster recovery
The cluster of TDengine provides high-availability of the system and implements disaster recovery through the multipl-replica mechanism.
The cluster of TDengine provides high-availability of the system and implements disaster recovery through the multiple-replica mechanism.
TDengine cluster is managed by mnode. In order to ensure the high reliability of the mnode, multiple mnode replicas can be configured. The number of replicas is determined by system configuration parameter numOfMnodes. In order to support high reliability, it needs to be set to be greater than 1. In order to ensure the strong consistency of metadata, mnode replicas duplicate data synchronously to ensure the strong consistency of metadata.
......@@ -114,8 +114,8 @@ Data in different application scenarios often have different data characteristic
- minRows: the minimum number of records in a file block, in pieces, default: 100.
- maxRows: the maximum number of records in a file block, in pieces, default: 4096.
- comp: file compression flag bit, 0: off; 1: one-stage compression; 2: two-stage compression. Default: 2.
- walLevel: WAL level. 1: write wal, but do not execute fsync; 2: write wal and execute fsync. Default: 1.
- fsync: the period during which fsync is executed when wal is set to 2. Setting to 0 means that fsync is executed immediately whenever a write happens, in milliseconds, and the default value is 3000.
- walLevel: WAL level. 1: write WAL, but do not execute fsync; 2: write WAL and execute fsync. Default: 1.
- fsync: the period during which fsync is executed when WAL is set to 2. Setting to 0 means that fsync is executed immediately whenever a write happens, in milliseconds, and the default value is 3000.
- cache: the size of the memory block in megabytes (MB), default: 16.
- blocks: how many cache-sized memory blocks are in each VNODE (TSDB). Therefore, the memory size used by a VNODE is roughly (cache * blocks), in blocks, and the default value is 4.
- replica: number of replicas; value range: 1-3, in items, default value: 1
......@@ -377,7 +377,7 @@ The system administrator can query the connection, ongoing query and stream comp
SHOW CONNECTIONS;
```
Show the connection of the database, and one column shows ip: port, which is the IP address and port number of the connection.
Show the connection of the database, and one column shows IP: port, which is the IP address and port number of the connection.
```mysql
KILL CONNECTION <connection-id>;
......@@ -442,7 +442,7 @@ Some CLI options are needed to use the script:
sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -E <notifier uid>
```
2. Use TDengine data source plugin's builtin [Aliyun SMS](https://www.aliyun.com/product/sms) alerting support with `-s` flag, and input these options:
2. Use TDengine data source plugin's built-in [Aliyun SMS](https://www.aliyun.com/product/sms) alerting support with `-s` flag, and input these options:
1. Access key id with option `-I`
2. Access key secret with option `K`
3. Access key sign name with option `-S`
......@@ -468,7 +468,7 @@ After installing TDengine, the following directories or files are generated in t
| **Directory/File** | **Description** |
| ------------------------- | ------------------------------------------------------------ |
| /usr/local/taos/bin | TEngine’s executable directory. The executables are connected to the/usr/bin directory via softly links. |
| /usr/local/taos/bin | TDengine’s executable directory. The executables are connected to the/usr/bin directory via softly links. |
| /usr/local/taos/connector | TDengine’s various connector directories. |
| /usr/local/taos/driver | TDengine’s dynamic link library directory. Connect to /usr/lib directory via soft links. |
| /usr/local/taos/examples | TDengine’s application example directory for various languages. |
......
......@@ -819,7 +819,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
pOneDataSrc->rowIdx, pIndex->colIndex);
char *data = pInfo->prevRow[i];
int32_t ret = columnValueAscendingComparator(data, newRow, pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, newRow, pColInfo->info.type, pColInfo->info.bytes, true);
if (ret == 0) {
continue;
} else {
......@@ -881,7 +881,7 @@ static bool isSameGroup(SArray* orderColumnList, SSDataBlock* pBlock, char** dat
assert(pIndex->colId == pColInfo->info.colId);
char *data = dataCols[i];
int32_t ret = columnValueAscendingComparator(data, pColInfo->pData, pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, pColInfo->pData, pColInfo->info.type, pColInfo->info.bytes, true);
if (ret == 0) {
continue;
} else {
......@@ -1067,7 +1067,7 @@ static int32_t doSlimitImpl(SOperatorInfo* pOperator, SSLimitOperatorInfo* pInfo
SColumnInfo *pColInfo = &pColInfoData->info;
char *d = rowIndex * pColInfo->bytes + (char *)pColInfoData->pData;
int32_t ret = columnValueAscendingComparator(pInfo->prevRow[i], d, pColInfo->type, pColInfo->bytes);
int32_t ret = columnValueAscendingComparator(pInfo->prevRow[i], d, pColInfo->type, pColInfo->bytes, true);
if (ret != 0) { // it is a new group
samegroup = false;
break;
......
......@@ -2827,7 +2827,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
case TSDB_FUNC_ELAPSED:
case TSDB_FUNC_MODE:
case TSDB_FUNC_STATE_COUNT:
case TSDB_FUNC_STATE_DURATION:{
case TSDB_FUNC_STATE_DURATION:
case TSDB_FUNC_HYPERLOGLOG:{
// 1. valid the number of parameters
int32_t numOfParams =
(pItem->pNode->Expr.paramList == NULL) ? 0 : (int32_t)taosArrayGetSize(pItem->pNode->Expr.paramList);
......@@ -2898,7 +2899,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
if (functionId == TSDB_FUNC_MODE && pColumnSchema->colId == PRIMARYKEY_TIMESTAMP_COL_INDEX &&
pColumnSchema->type == TSDB_DATA_TYPE_TIMESTAMP){
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg29);
} else if (!IS_NUMERIC_TYPE(pSchema->type) && (functionId != TSDB_FUNC_ELAPSED) && (functionId != TSDB_FUNC_MODE)) {
} else if (!IS_NUMERIC_TYPE(pSchema->type) && (functionId != TSDB_FUNC_ELAPSED) &&
(functionId != TSDB_FUNC_MODE) && (functionId != TSDB_FUNC_HYPERLOGLOG)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} else if (IS_UNSIGNED_NUMERIC_TYPE(pSchema->type) &&
(functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_DERIVATIVE)) {
......@@ -3362,8 +3364,14 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg12);
}
if(functionId == TSDB_FUNC_UNIQUE){
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS;
if(functionId == TSDB_FUNC_UNIQUE){ // consider of memory size
if(pSchema->bytes < 10){
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 100;
}else if(pSchema->bytes < 100){
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 10;
}else{
GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS;
}
}
// todo REFACTOR
// set the first column ts for top/bottom query
......@@ -4163,7 +4171,8 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
(functionId == TSDB_FUNC_HISTOGRAM) ||
(functionId == TSDB_FUNC_UNIQUE) ||
(functionId == TSDB_FUNC_MODE) ||
(functionId == TSDB_FUNC_TAIL)) {
(functionId == TSDB_FUNC_TAIL) ||
(functionId == TSDB_FUNC_HYPERLOGLOG)) {
if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, (int32_t)pExpr->base.param[0].i64, &type, &bytes,
&interBytes, 0, true, NULL) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_OPERATION;
......
......@@ -14,11 +14,11 @@ namespace Sample.UtilsTools
static string db = "";
static short port = 0;
static string globalDbName = "csharp_example_db";
//get a tdengine connection
//get a TDengine connection
public static IntPtr TDConnection()
{
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, GetConfigPath());
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
TDengine.Options((int)TDengineInitOption.TSDB_OPTION_CONFIGDIR, GetConfigPath());
TDengine.Options((int)TDengineInitOption.TSDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
TDengine.Init();
IntPtr conn = TDengine.Connect(ip, user, password, db, port);
......@@ -100,18 +100,18 @@ namespace Sample.UtilsTools
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
int fieldCount = metas.Count;
// metas.ForEach((item) => { Console.Write("{0} ({1}) \t|\t", item.name, item.size); });
List<TDengineMeta> metaList = GetResField(res);
int fieldCount = metaList.Count;
// metaList.ForEach((item) => { Console.Write("{0} ({1}) \t|\t", item.name, item.size); });
List<Object> datas = QueryRes(res, metas);
for (int index = 0; index < datas.Count; index++)
List<Object> dataList = QueryRes(res, metaList);
for (int index = 0; index < dataList.Count; index++)
{
if (index % fieldCount == 0 && index != 0)
{
Console.WriteLine("");
}
Console.Write("{0} \t|\t", datas[index].ToString());
Console.Write("{0} \t|\t", dataList[index].ToString());
}
Console.WriteLine("");
......@@ -127,10 +127,10 @@ namespace Sample.UtilsTools
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
List<TDengineMeta> meta = GetResField(res);
result.Add(colName);
dataRaw = QueryRes(res, metas);
dataRaw = QueryRes(res, meta);
result.Add(dataRaw);
if (TDengine.ErrorNo(res) != 0)
......@@ -161,7 +161,7 @@ namespace Sample.UtilsTools
{
if (TDengine.Close(conn) == 0)
{
Console.WriteLine("close connection sucess");
Console.WriteLine("close connection success");
}
else
{
......@@ -171,8 +171,8 @@ namespace Sample.UtilsTools
}
public static List<TDengineMeta> GetResField(IntPtr res)
{
List<TDengineMeta> metas = TDengine.FetchFields(res);
return metas;
List<TDengineMeta> meta = TDengine.FetchFields(res);
return meta;
}
public static void ExitProgram()
{
......@@ -187,16 +187,16 @@ namespace Sample.UtilsTools
{
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
dataRaw = QueryRes(res, metas);
List<TDengineMeta> meta = GetResField(res);
dataRaw = QueryRes(res, meta);
return dataRaw;
}
private static List<Object> QueryRes(IntPtr res, List<TDengineMeta> metas)
private static List<Object> QueryRes(IntPtr res, List<TDengineMeta> meta)
{
IntPtr taosRow;
List<Object> dataRaw = new List<Object>();
int fieldCount = metas.Count;
int fieldCount = meta.Count;
while ((taosRow = TDengine.FetchRows(res)) != IntPtr.Zero)
{
dataRaw.AddRange(FetchRow(taosRow,res));
......@@ -295,7 +295,7 @@ namespace Sample.UtilsTools
dataRaw.Add(v16);
break;
default:
dataRaw.Add("nonsupport data type value");
dataRaw.Add("nonsupport data type");
break;
}
......
......@@ -44,8 +44,8 @@ namespace TDengineDriver
TSDB_OPTION_LOCALE = 0,
TSDB_OPTION_CHARSET = 1,
TSDB_OPTION_TIMEZONE = 2,
TDDB_OPTION_CONFIGDIR = 3,
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
TSDB_OPTION_CONFIGDIR = 3,
TSDB_OPTION_SHELL_ACTIVITY_TIMER = 4
}
enum TaosField
{
......@@ -147,7 +147,7 @@ namespace TDengineDriver
/// <summary>
/// User defined callback function for interface "QueryAsync()"
/// ,actually is a delegate in .Net.
/// This function aim to handel the taoRes which points to
/// This function aim to handle the taoRes which points to
/// the caller method's sql resultset.
/// </summary>
/// <param name="param"> This parameter will sent by caller method (QueryAsync()).</param>
......@@ -234,10 +234,10 @@ namespace TDengineDriver
{
// const int fieldSize = 68;
List<TDengineMeta> metas = new List<TDengineMeta>();
List<TDengineMeta> metaList = new List<TDengineMeta>();
if (res == IntPtr.Zero)
{
return metas;
return metaList;
}
int fieldCount = FieldCount(res);
......@@ -250,11 +250,11 @@ namespace TDengineDriver
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
meta.type = Marshal.ReadByte(fieldsPtr + offset + (int)TaosField.TYPE_OFFSET);
meta.size = Marshal.ReadInt16(fieldsPtr + offset + (int)TaosField.BYTES_OFFSET);
metas.Add(meta);
metaList.Add(meta);
}
return metas;
return metaList;
}
[DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)]
......@@ -430,7 +430,7 @@ namespace TDengineDriver
/// returned in this API is unknown.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>piont the error message</returns>
/// <returns>point the error message</returns>
[DllImport("taos", EntryPoint = "taos_stmt_errstr", CallingConvention = CallingConvention.Cdecl)]
static extern private IntPtr StmtErrPtr(IntPtr stmt);
......@@ -452,9 +452,9 @@ namespace TDengineDriver
// Async Query
/// <summary>
/// This API uses non-blocking call mode.
/// Application can open mutilple tables and manipulate(query or insert) opened table concurrently.
/// So applications must ensure that opetations on the same table is compeletly serialized.
/// Becuase that will cause some query and insert operations cannot be performed.
/// Application can open multiple tables and manipulate(query or insert) opened table concurrently.
/// So applications must ensure that opetations on the same table is completely serialized.
/// Because that will cause some query and insert operations cannot be performed.
/// </summary>
/// <param name="taos"> A taos connection return by Connect()</param>
/// <param name="sql">sql command need to execute</param>
......@@ -575,7 +575,7 @@ namespace TDengineDriver
/// </param>
/// <param name="param">First parameter provide by application for callback usage.
/// While callback,this parameter is provided to the application.</param>
/// <param name="callback2">The second callback function which will be caled when the continuous query
/// <param name="callback2">The second callback function which will be called when the continuous query
/// stop automatically.</param>
/// <returns> Return null indicate creation failed, not null for success.</returns>
[DllImport("taos", EntryPoint = "taos_open_stream", CallingConvention = CallingConvention.Cdecl)]
......
......@@ -17,17 +17,17 @@ namespace TDengineDriver
TAOS_BIND bind = new TAOS_BIND();
byte[] boolByteArr = BitConverter.GetBytes(val);
int boolByteArrSize = Marshal.SizeOf(boolByteArr[0]) * boolByteArr.Length;
IntPtr bo = Marshal.AllocHGlobal(1);
Marshal.Copy(boolByteArr, 0, bo, boolByteArr.Length);
IntPtr c_bool = Marshal.AllocHGlobal(1);
Marshal.Copy(boolByteArr, 0, c_bool, boolByteArr.Length);
int length = sizeof(Boolean);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL;
bind.buffer = bo;
bind.buffer = c_bool;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -38,17 +38,17 @@ namespace TDengineDriver
byte[] tinyIntByteArr = BitConverter.GetBytes(val);
int tinyIntByteArrSize = Marshal.SizeOf(tinyIntByteArr[0]) * tinyIntByteArr.Length;
IntPtr uManageTinyInt = Marshal.AllocHGlobal(tinyIntByteArrSize);
Marshal.Copy(tinyIntByteArr, 0, uManageTinyInt, tinyIntByteArr.Length);
IntPtr c_tinyint = Marshal.AllocHGlobal(tinyIntByteArrSize);
Marshal.Copy(tinyIntByteArr, 0, c_tinyint, tinyIntByteArr.Length);
int length = sizeof(sbyte);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT;
bind.buffer = uManageTinyInt;
bind.buffer = c_tinyint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -58,17 +58,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageSmallInt = Marshal.AllocHGlobal(sizeof(short));
Marshal.WriteInt16(uManageSmallInt, val);
IntPtr c_smallint = Marshal.AllocHGlobal(sizeof(short));
Marshal.WriteInt16(c_smallint, val);
int length = sizeof(short);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT;
bind.buffer = uManageSmallInt;
bind.buffer = c_smallint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -77,17 +77,17 @@ namespace TDengineDriver
public static TAOS_BIND BindInt(int val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageInt = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(uManageInt, val);
IntPtr c_int = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(c_int, val);
int length = sizeof(int);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT;
bind.buffer = uManageInt;
bind.buffer = c_int;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -97,17 +97,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageBigInt = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(uManageBigInt, val);
IntPtr c_bigint = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(c_bigint, val);
int length = sizeof(long);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT;
bind.buffer = uManageBigInt;
bind.buffer = c_bigint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -117,17 +117,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageTinyInt = Marshal.AllocHGlobal(sizeof(byte));
Marshal.WriteByte(uManageTinyInt, val);
IntPtr c_unsigned_tinyint = Marshal.AllocHGlobal(sizeof(byte));
Marshal.WriteByte(c_unsigned_tinyint, val);
int length = sizeof(byte);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT;
bind.buffer = uManageTinyInt;
bind.buffer = c_unsigned_tinyint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -139,17 +139,17 @@ namespace TDengineDriver
byte[] uSmallIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uSmallIntByteArr[0]) * uSmallIntByteArr.Length;
IntPtr uManageUnsignSmallInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uSmallIntByteArr, 0, uManageUnsignSmallInt, uSmallIntByteArr.Length);
IntPtr c_unsigned_smallint = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uSmallIntByteArr, 0, c_unsigned_smallint, uSmallIntByteArr.Length);
int length = sizeof(UInt16);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT;
bind.buffer = uManageUnsignSmallInt;
bind.buffer = c_unsigned_smallint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -159,19 +159,19 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
byte[] uManageIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uManageIntByteArr[0]) * uManageIntByteArr.Length;
IntPtr uManageInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uManageIntByteArr, 0, uManageInt, uManageIntByteArr.Length);
byte[] byteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length;
IntPtr c_unsigned_int = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(byteArr, 0, c_unsigned_int, byteArr.Length);
int length = sizeof(uint);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT;
bind.buffer = uManageInt;
bind.buffer = c_unsigned_int;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -181,19 +181,19 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
byte[] uManageBigIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uManageBigIntByteArr[0]) * uManageBigIntByteArr.Length;
IntPtr uManageBigInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uManageBigIntByteArr, 0, uManageBigInt, uManageBigIntByteArr.Length);
byte[] byteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length;
IntPtr c_unsigned_bigint = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(byteArr, 0, c_unsigned_bigint, byteArr.Length);
int length = sizeof(ulong);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT;
bind.buffer = uManageBigInt;
bind.buffer = c_unsigned_bigint;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -203,19 +203,19 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
byte[] floatByteArr = BitConverter.GetBytes(val);
int floatByteArrSize = Marshal.SizeOf(floatByteArr[0]) * floatByteArr.Length;
IntPtr uManageFloat = Marshal.AllocHGlobal(floatByteArrSize);
Marshal.Copy(floatByteArr, 0, uManageFloat, floatByteArr.Length);
byte[] byteArr = BitConverter.GetBytes(val);
int floatByteArrSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length;
IntPtr c_float = Marshal.AllocHGlobal(floatByteArrSize);
Marshal.Copy(byteArr, 0, c_float, byteArr.Length);
int length = sizeof(float);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT;
bind.buffer = uManageFloat;
bind.buffer = c_float;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -225,19 +225,19 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
byte[] doubleByteArr = BitConverter.GetBytes(val);
int doubleByteArrSize = Marshal.SizeOf(doubleByteArr[0]) * doubleByteArr.Length;
IntPtr uManageDouble = Marshal.AllocHGlobal(doubleByteArrSize);
Marshal.Copy(doubleByteArr, 0, uManageDouble, doubleByteArr.Length);
byte[] byteArr = BitConverter.GetBytes(val);
int doubleByteArrSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length;
IntPtr c_double = Marshal.AllocHGlobal(doubleByteArrSize);
Marshal.Copy(byteArr, 0, c_double, byteArr.Length);
int length = sizeof(Double);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE;
bind.buffer = uManageDouble;
bind.buffer = c_double;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......@@ -247,17 +247,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
// IntPtr umanageBinary = Marshal.StringToHGlobalAnsi(val);
IntPtr umanageBinary = Marshal.StringToCoTaskMemUTF8(val);
// IntPtr unmanagedBinary = Marshal.StringToHGlobalAnsi(val);
IntPtr c_str = Marshal.StringToCoTaskMemUTF8(val);
var strToBytes = System.Text.Encoding.UTF8.GetBytes(val);
int leng = strToBytes.Length;
int length = strToBytes.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
Marshal.WriteInt64(lenPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY;
bind.buffer = umanageBinary;
bind.buffer_length = leng;
bind.buffer = c_str;
bind.buffer_length = length;
bind.length = lenPtr;
bind.is_null = IntPtr.Zero;
......@@ -267,17 +267,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
var strToBytes = System.Text.Encoding.UTF8.GetBytes(val);
// IntPtr umanageNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val);
IntPtr umanageNchar = (IntPtr)Marshal.StringToCoTaskMemUTF8(val);
// IntPtr unmanagedNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val);
IntPtr c_str = (IntPtr)Marshal.StringToCoTaskMemUTF8(val);
int leng = strToBytes.Length;
int length = strToBytes.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
Marshal.WriteInt64(lenPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR;
bind.buffer = umanageNchar;
bind.buffer_length = leng;
bind.buffer = c_str;
bind.buffer_length = length;
bind.length = lenPtr;
bind.is_null = IntPtr.Zero;
......@@ -301,17 +301,17 @@ namespace TDengineDriver
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageTs = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(uManageTs, ts);
IntPtr c_long = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(c_long, ts);
int length = sizeof(long);
IntPtr lengPtr = Marshal.AllocHGlobal(4);
Marshal.WriteInt32(lengPtr, length);
IntPtr lengthPtr = Marshal.AllocHGlobal(4);
Marshal.WriteInt32(lengthPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP;
bind.buffer = uManageTs;
bind.buffer = c_long;
bind.buffer_length = length;
bind.length = lengPtr;
bind.length = lengthPtr;
bind.is_null = IntPtr.Zero;
return bind;
......
......@@ -17,7 +17,7 @@ namespace TDengineDriver
int byteSize = sizeof(byte);
//TAOS_MULTI_BIND.buffer
IntPtr unmanagedBoolArr = Marshal.AllocHGlobal(elementCount * typeSize);
IntPtr c_bool_ptr = Marshal.AllocHGlobal(elementCount * typeSize);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -26,7 +26,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(unmanagedBoolArr, typeSize * i, Convert.ToByte(arr[i] ?? false));
Marshal.WriteByte(c_bool_ptr, typeSize * i, Convert.ToByte(arr[i] ?? false));
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -34,7 +34,7 @@ namespace TDengineDriver
}
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL;
multiBind.buffer = unmanagedBoolArr;
multiBind.buffer = c_bool_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -53,7 +53,7 @@ namespace TDengineDriver
int intSize = sizeof(int);
//TAOS_MULTI_BIND.buffer
IntPtr unmanagedTintIntArr = Marshal.AllocHGlobal(elementCount);
IntPtr c_tinyint_ptr = Marshal.AllocHGlobal(elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -64,7 +64,7 @@ namespace TDengineDriver
Byte[] toByteArr = BitConverter.GetBytes(arr[i] ?? sbyte.MinValue);
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(unmanagedTintIntArr, typeSize * i, toByteArr[0]);
Marshal.WriteByte(c_tinyint_ptr, typeSize * i, toByteArr[0]);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -73,7 +73,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT;
multiBind.buffer = unmanagedTintIntArr;
multiBind.buffer = c_tinyint_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -92,7 +92,7 @@ namespace TDengineDriver
int byteSize = sizeof(byte);
//TAOS_MULTI_BIND.buffer
IntPtr unmanagedSmallIntArr = Marshal.AllocHGlobal(elementCount * typeSize);
IntPtr c_smallint_ptr = Marshal.AllocHGlobal(elementCount * typeSize);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -101,7 +101,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteInt16(unmanagedSmallIntArr, typeSize * i, arr[i] ?? short.MinValue);
Marshal.WriteInt16(c_smallint_ptr, typeSize * i, arr[i] ?? short.MinValue);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -110,7 +110,7 @@ namespace TDengineDriver
}
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT;
multiBind.buffer = unmanagedSmallIntArr;
multiBind.buffer = c_smallint_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -127,7 +127,7 @@ namespace TDengineDriver
int byteSize = sizeof(byte);
//TAOS_MULTI_BIND.buffer
IntPtr intBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_int_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -136,7 +136,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteInt32(intBuff, typeSize * i, arr[i] ?? int.MinValue);
Marshal.WriteInt32(c_int_ptr, typeSize * i, arr[i] ?? int.MinValue);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -145,7 +145,7 @@ namespace TDengineDriver
}
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT;
multiBind.buffer = intBuff;
multiBind.buffer = c_int_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -162,7 +162,7 @@ namespace TDengineDriver
int byteSize = sizeof(byte);
//TAOS_MULTI_BIND.buffer
IntPtr intBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_long_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -171,7 +171,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteInt64(intBuff, typeSize * i, arr[i] ?? long.MinValue);
Marshal.WriteInt64(c_long_ptr, typeSize * i, arr[i] ?? long.MinValue);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -181,7 +181,7 @@ namespace TDengineDriver
}
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT;
multiBind.buffer = intBuff;
multiBind.buffer = c_long_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -200,7 +200,7 @@ namespace TDengineDriver
float[] arrTmp = new float[elementCount];
//TAOS_MULTI_BIND.buffer
IntPtr floatBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_float_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -216,11 +216,11 @@ namespace TDengineDriver
Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0));
}
//set TAOS_MULTI_BIND.buffer
Marshal.Copy(arrTmp, 0, floatBuff, elementCount);
Marshal.Copy(arrTmp, 0, c_float_ptr, elementCount);
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT;
multiBind.buffer = floatBuff;
multiBind.buffer = c_float_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -239,7 +239,7 @@ namespace TDengineDriver
double[] arrTmp = new double[elementCount];
//TAOS_MULTI_BIND.buffer
IntPtr doubleBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_double_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -255,11 +255,11 @@ namespace TDengineDriver
Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0));
}
//set TAOS_MULTI_BIND.buffer
Marshal.Copy(arrTmp, 0, doubleBuff, elementCount);
Marshal.Copy(arrTmp, 0, c_double_ptr, elementCount);
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE;
multiBind.buffer = doubleBuff;
multiBind.buffer = c_double_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -277,7 +277,7 @@ namespace TDengineDriver
//used to replace null
//TAOS_MULTI_BIND.buffer
IntPtr uTinyIntBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_unsigned_tinyint_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -287,7 +287,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(uTinyIntBuff, typeSize * i, arr[i] ?? byte.MaxValue);
Marshal.WriteByte(c_unsigned_tinyint_ptr, typeSize * i, arr[i] ?? byte.MaxValue);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -297,7 +297,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT;
multiBind.buffer = uTinyIntBuff;
multiBind.buffer = c_unsigned_tinyint_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -315,7 +315,7 @@ namespace TDengineDriver
//used to replace null
//TAOS_MULTI_BIND.buffer
IntPtr uSmallIntBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_unsigned_smallint_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -328,7 +328,7 @@ namespace TDengineDriver
for (int j = 0; j < byteArr.Length; j++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(uSmallIntBuff, typeSize * i + j * byteSize, byteArr[j]);
Marshal.WriteByte(c_unsigned_smallint_ptr, typeSize * i + j * byteSize, byteArr[j]);
}
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
......@@ -339,7 +339,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT;
multiBind.buffer = uSmallIntBuff;
multiBind.buffer = c_unsigned_smallint_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -357,7 +357,7 @@ namespace TDengineDriver
//used to replace null
//TAOS_MULTI_BIND.buffer
IntPtr uIntBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_unsigned_int_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -370,7 +370,7 @@ namespace TDengineDriver
for (int j = 0; j < byteArr.Length; j++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(uIntBuff, typeSize * i + j * byteSize, byteArr[j]);
Marshal.WriteByte(c_unsigned_int_ptr, typeSize * i + j * byteSize, byteArr[j]);
}
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
......@@ -381,7 +381,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT;
multiBind.buffer = uIntBuff;
multiBind.buffer = c_unsigned_int_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -399,7 +399,7 @@ namespace TDengineDriver
//used to replace null
//TAOS_MULTI_BIND.buffer
IntPtr uBigIntBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_unsigned_bigint_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -412,7 +412,7 @@ namespace TDengineDriver
for (int j = 0; j < byteArr.Length; j++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteByte(uBigIntBuff, typeSize * i + j * byteSize, byteArr[j]);
Marshal.WriteByte(c_unsigned_bigint_ptr, typeSize * i + j * byteSize, byteArr[j]);
}
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
......@@ -423,7 +423,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT;
multiBind.buffer = uBigIntBuff;
multiBind.buffer = c_unsigned_bigint_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -439,7 +439,7 @@ namespace TDengineDriver
//The size of the buffer is typeSize * elementCount
//This buffer is used to store TAOS_MULTI_BIND.buffer
int typeSize = MaxElementLength(arr);
//This intSize is used to calcuate buffer size of the struct TAOS_MULTI_BIND's
//This intSize is used to calculate buffer size of the struct TAOS_MULTI_BIND's
//length. The buffer is intSize * elementCount,which is used to store TAOS_MULTI_BIND.length
int intSize = sizeof(int);
//This byteSize is used to calculate the buffer size of the struct TAOS_MULTI_BIND.is_null
......@@ -452,7 +452,7 @@ namespace TDengineDriver
//TAOS_MULTI_BIND.is_null
IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount);
//TAOS_MULTI_BIND.buffer
IntPtr uNcharBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_char_prt = Marshal.AllocHGlobal(typeSize * elementCount);
for (int i = 0; i < elementCount; i++)
{
......@@ -464,7 +464,7 @@ namespace TDengineDriver
for (int j = 0; j < itemLength; j++)
{
//Read byte after byte
Marshal.WriteByte(uNcharBuff, i * typeSize + j, decodeByte[j]);
Marshal.WriteByte(c_char_prt, i * typeSize + j, decodeByte[j]);
}
}
//Set TAOS_MULTI_BIND.length
......@@ -474,7 +474,7 @@ namespace TDengineDriver
}
//Config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY;
multiBind.buffer = uNcharBuff;
multiBind.buffer = c_char_prt;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -491,7 +491,7 @@ namespace TDengineDriver
//The size of the buffer is typeSize * elementCount
//This buffer is used to store TAOS_MULTI_BIND.buffer
int typeSize = MaxElementLength(arr);
//This intSize is used to calcuate buffer size of the struct TAOS_MULTI_BIND's
//This intSize is used to calculate buffer size of the struct TAOS_MULTI_BIND's
//length. The buffer is intSize * elementCount,which is used to store TAOS_MULTI_BIND.length
int intSize = sizeof(int);
//This byteSize is used to calculate the buffer size of the struct TAOS_MULTI_BIND.is_null
......@@ -503,7 +503,7 @@ namespace TDengineDriver
//TAOS_MULTI_BIND.is_null
IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount);
//TAOS_MULTI_BIND.buffer
IntPtr uNcharBuff = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_char_prt = Marshal.AllocHGlobal(typeSize * elementCount);
for (int i = 0; i < elementCount; i++)
{
......@@ -515,7 +515,7 @@ namespace TDengineDriver
for (int j = 0; j < itemLength; j++)
{
//Read byte after byte
Marshal.WriteByte(uNcharBuff, i * typeSize + j, decodeByte[j]);
Marshal.WriteByte(c_char_prt, i * typeSize + j, decodeByte[j]);
}
}
//Set TAOS_MULTI_BIND.length
......@@ -525,7 +525,7 @@ namespace TDengineDriver
}
//Config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR;
multiBind.buffer = uNcharBuff;
multiBind.buffer = c_char_prt;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......@@ -542,7 +542,7 @@ namespace TDengineDriver
int intSize = sizeof(int);
int byteSize = sizeof(byte);
//TAOS_MULTI_BIND.buffer
IntPtr unmanagedTsArr = Marshal.AllocHGlobal(typeSize * elementCount);
IntPtr c_long_ptr = Marshal.AllocHGlobal(typeSize * elementCount);
//TAOS_MULTI_BIND.length
IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount);
//TAOS_MULTI_BIND.is_null
......@@ -551,7 +551,7 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
//set TAOS_MULTI_BIND.buffer
Marshal.WriteInt64(unmanagedTsArr, typeSize * i, arr[i]);
Marshal.WriteInt64(c_long_ptr, typeSize * i, arr[i]);
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
......@@ -560,7 +560,7 @@ namespace TDengineDriver
//config TAOS_MULTI_BIND
multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP;
multiBind.buffer = unmanagedTsArr;
multiBind.buffer = c_long_ptr;
multiBind.buffer_length = (ulong)typeSize;
multiBind.length = lengthArr;
multiBind.is_null = nullArr;
......
......@@ -116,7 +116,7 @@ namespace Test.UtilsTools.DataSource
}
// Get the tag data within and string list
// Which will be retrieved as a string List
private static List<String> GetTagCnData()
private static List<String> GetTagCNData()
{
List<String> tagData = new List<String>();
tagData.Add(true.ToString());
......@@ -136,7 +136,7 @@ namespace Test.UtilsTools.DataSource
}
// A line of data that's without CN character.
// Which is construct as an TAOS_BIND array
public static TAOS_BIND[] GetNtableCNRow()
public static TAOS_BIND[] GetNTableCNRow()
{
TAOS_BIND[] binds = new TAOS_BIND[15];
binds[0] = TaosBind.BindTimestamp(1637064040000);
......@@ -157,7 +157,7 @@ namespace Test.UtilsTools.DataSource
return binds;
}
//Get and list data that will be insert into table
public static List<String> GetNtableCNRowData()
public static List<String> GetNTableCNRowData()
{
var data = new List<string>{
"1637064040000",
......@@ -180,16 +180,16 @@ namespace Test.UtilsTools.DataSource
}
// Get the data value and tag values which have chinese characters
// And retrieved as a string list.This is single Line.
public static List<String> GetStableCNRowData()
public static List<String> GetSTableCNRowData()
{
List<String> columnData = GetNtableCNRowData();
List<String> tagData = GetTagCnData();
List<String> columnData = GetNTableCNRowData();
List<String> tagData = GetTagCNData();
columnData.AddRange(tagData);
return columnData;
}
// A line of data that's without CN character
public static TAOS_BIND[] GetNtableRow()
public static TAOS_BIND[] GetNTableRow()
{
TAOS_BIND[] binds = new TAOS_BIND[15];
binds[0] = TaosBind.BindTimestamp(1637064040000);
......@@ -209,8 +209,8 @@ namespace Test.UtilsTools.DataSource
binds[14] = TaosBind.BindNil();
return binds;
}
// A List of data ,use as expectResData. The value is equal to getNtableRow()
public static List<String> GetNtableRowData()
// A List of data ,use as expectResData. The value is equal to getNTableRow()
public static List<String> GetNTableRowData()
{
var data = new List<string>{
"1637064040000",
......@@ -232,7 +232,7 @@ namespace Test.UtilsTools.DataSource
return data;
}
// Five lines of data, that is construct as taos_mutli_bind array.
// Five lines of data, that is construct as taos_multi_bind array.
// There aren't any CN character
public static TAOS_MULTI_BIND[] GetMultiBindArr()
{
......@@ -280,8 +280,8 @@ namespace Test.UtilsTools.DataSource
}
return rowData;
}
// Five lines of data, that is construct as taos_mutli_bind array.
// There aren some CN characters and letters.
// Five lines of data, that is construct as taos_multi_bind array.
// There are some CN characters and letters.
public static TAOS_MULTI_BIND[] GetMultiBindCNArr()
{
TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14];
......@@ -332,7 +332,7 @@ namespace Test.UtilsTools.DataSource
public static List<String> GetMultiBindStableCNRowData()
{
List<String> columnData = new List<string>();
List<String> tagData = GetTagCnData();
List<String> tagData = GetTagCNData();
for (int i = 0; i < tsArr.Length; i++)
{
columnData.Add(tsArr[i].ToString());
......@@ -371,18 +371,18 @@ namespace Test.UtilsTools.DataSource
TaosBind.FreeTaosBind(binds);
}
public static void FreeTaosMBind(TAOS_MULTI_BIND[] mbinds)
public static void FreeTaosMBind(TAOS_MULTI_BIND[] mBinds)
{
TaosMultiBind.FreeTaosBind(mbinds);
TaosMultiBind.FreeTaosBind(mBinds);
}
//Get the TDengineMeta list from the ddl either normal table or stable
public static List<TDengineMeta> GetMetaFromDLL(string dllStr)
public static List<TDengineMeta> GetMetaFromDDL(string dllStr)
{
var expectResMeta = new List<TDengineMeta>();
//"CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT);";
int bracetInd = dllStr.IndexOf("(");
int bracketInd = dllStr.IndexOf("(");
//(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT);
string subDllStr = dllStr.Substring(bracetInd);
string subDllStr = dllStr.Substring(bracketInd);
String[] stableSeparators = new String[] { "tags", "TAGS" };
//(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT)
......
......@@ -6,19 +6,19 @@ using Xunit;
using Test.UtilsTools.ResultSet;
namespace Cases
{
public class FetchFieldCases
public class FetchFieldsCases
{
/// <author>xiaolei</author>
/// <Name>FetchFieldCases.TestFetchFieldJsonTag</Name>
/// <Name>FetchFieldsCases.TestFetchFieldsJsonTag</Name>
/// <describe>test taos_fetch_fields(), check the meta data</describe>
/// <filename>TaosFeild.cs</filename>
/// <filename>FetchFields.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "FetchFieldCases.TestFetchFieldJsonTag()")]
public void TestFetchFieldJsonTag()
[Fact(DisplayName = "FetchFieldsCases.TestFetchFieldsJsonTag()")]
public void TestFetchFieldsJsonTag()
{
IntPtr conn = UtilsTools.TDConnection();
IntPtr _res = IntPtr.Zero;
string tableName = "fetchfeilds";
string tableName = "fetch_fields";
var expectResMeta = new List<TDengineMeta> {
UtilsTools.ConstructTDengineMeta("ts", "timestamp"),
UtilsTools.ConstructTDengineMeta("b", "bool"),
......
......@@ -7,15 +7,15 @@ using System.Collections.Generic;
using Test.UtilsTools.ResultSet;
namespace Cases
{
public class InsertCnCharacterCases
public class InsertCNCases
{
/// <author>xiaolei</author>
/// <Name>InsertCnCharacterCases.TestInsertCnToNtable</Name>
/// <describe>test insert Chinese character into normal table's nchar column</describe>
/// <Name>InsertCNCases.TestNTable</Name>
/// <describe>Test insert Chinese characters into normal table's nchar column</describe>
/// <filename>InsertCn.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "InsertCnCharacterCases.TestInsertCnToNtable()")]
public void TestInsertCnToNtable()
[Fact(DisplayName = "InsertCNCases.TestNTable()")]
public void TestNTable()
{
IntPtr conn = UtilsTools.TDConnection();
IntPtr _res = IntPtr.Zero;
......@@ -37,7 +37,7 @@ namespace Cases
String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9);
String selectSql = "select * from " + tableName;
String dropSql = "drop table " + tableName;
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
UtilsTools.ExecuteUpdate(conn, dropTb);
UtilsTools.ExecuteUpdate(conn, createTb);
......@@ -64,12 +64,12 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>InsertCnCharacterCases.TestInsertCnToStable</Name>
/// <Name>InsertCNCases.TestSTable</Name>
/// <describe>test insert Chinese character into stable's nchar column,both tag and column</describe>
/// <filename>InsertCn.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "InsertCnCharacterCases.TestInsertCnToStable()")]
public void TestInsertCnToStable()
[Fact(DisplayName = "InsertCNCases.TestSTable()")]
public void TestSTable()
{
IntPtr conn = UtilsTools.TDConnection();
IntPtr _res = IntPtr.Zero;
......@@ -84,15 +84,15 @@ namespace Cases
1637064047000,8,"8&涛思数据taos",
1637064048000,9,"&涛思数据taos9"
};
var tagData = new List<Object>{1,"涛思数据",};
var tagData = new List<Object> { 1, "涛思数据", };
String dropTb = "drop table if exists " + tableName;
String createTb = $"create table {tableName} (ts timestamp,v4 int,blob nchar(200))tags(id int,name nchar(50));";
String insertSql = UtilsTools.ConstructInsertSql(tableName+"_sub1", tableName, colData, tagData, 9);
String insertSql = UtilsTools.ConstructInsertSql(tableName + "_sub1", tableName, colData, tagData, 9);
String selectSql = "select * from " + tableName;
String dropSql = "drop table " + tableName;
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData,tagData,9);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 9);
UtilsTools.ExecuteUpdate(conn, dropTb);
UtilsTools.ExecuteUpdate(conn, createTb);
......@@ -118,12 +118,12 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>InsertCnCharacterCases.TestInsertMutilCnToNtable</Name>
/// <Name>InsertCNCases.TestInsertMultiNTable</Name>
/// <describe>test insert Chinese character into normal table's multiple nchar columns</describe>
/// <filename>InsertCn.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "InsertCnCharacterCases.TestInsertMutilCnToNtable()")]
public void TestInsertMutilCnToNtable()
[Fact(DisplayName = "InsertCNCases.TestInsertMultiNTable()")]
public void TestInsertMultiNTable()
{
IntPtr conn = UtilsTools.TDConnection();
IntPtr _res = IntPtr.Zero;
......@@ -140,11 +140,11 @@ namespace Cases
};
String dropTb = "drop table if exists " + tableName;
String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),coutry binary(200));";
String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),country binary(200));";
String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9);
String selectSql = "select * from " + tableName;
String dropSql = "drop table " + tableName;
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
UtilsTools.ExecuteUpdate(conn, dropTb);
UtilsTools.ExecuteUpdate(conn, createTb);
......@@ -168,16 +168,16 @@ namespace Cases
Assert.Equal(colData[i].ToString(), actualResData[i]);
}
}
/// <author>xiaolei</author>
/// <Name>InsertCnCharacterCases.TestInsertMutilCnToStable</Name>
/// <Name>InsertCNCases.TestInsertMultiSTable</Name>
/// <describe>test insert Chinese character into stable's multiple nchar columns</describe>
/// <filename>InsertCn.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "InsertCnCharacterCases.TestInsertMutilCnToStable()")]
public void TestInsertMutilCnToStable()
[Fact(DisplayName = "InsertCNCases.TestInsertMultiSTable()")]
public void TestInsertMultiSTable()
{
IntPtr conn = UtilsTools.TDConnection();
IntPtr conn = UtilsTools.TDConnection();
IntPtr _res = IntPtr.Zero;
string tableName = "cn_multi_insert_nchar_stable";
var colData = new List<Object>{1637064040000,1,"涛思数据","保利广场","Beijing","China",
......@@ -190,7 +190,7 @@ namespace Cases
1637064047000,8,"8&涛思数据taos","incluse阿斯顿发","NewYork","US",
1637064048000,9,"&涛思数据taos9","123黑化肥werq会挥……&¥%发!afsdfa","NewYork","US",
};
var tagData = new List<Object>{1,"涛思数据","中国北方&南方长江黄河!49wq","tdengine"};
var tagData = new List<Object> { 1, "涛思数据", "中国北方&南方长江黄河!49wq", "tdengine" };
String dropTb = "drop table if exists " + tableName;
String createTb = $"create table if not exists {tableName} (ts timestamp," +
$"v4 int," +
......@@ -203,12 +203,12 @@ namespace Cases
$"name nchar(50)," +
$"addr nchar(200)," +
$"en_name binary(200));";
String insertSql = UtilsTools.ConstructInsertSql(tableName+"_sub1", tableName, colData, tagData, 9);
String insertSql = UtilsTools.ConstructInsertSql(tableName + "_sub1", tableName, colData, tagData, 9);
String selectSql = "select * from " + tableName;
String dropSql = "drop table " + tableName;
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData,tagData,9);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 9);
UtilsTools.ExecuteUpdate(conn, dropTb);
UtilsTools.ExecuteUpdate(conn, createTb);
......
using TDengineDriver;
using Test.UtilsTools;
using System;
using System.Runtime.InteropServices;
using Xunit;
using System.Collections.Generic;
using Test.UtilsTools.DataSource;
......@@ -47,7 +46,7 @@ namespace Cases
};
var tagData = new List<Object> { 1, "tag_one", "标签壹" };
String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3);
var querySql = $"select * from {tableName}";
......@@ -133,7 +132,7 @@ namespace Cases
var colDataActual = colData.GetRange(8, 8);
var tagData = new List<Object> { 1, "tag_one", "标签壹" };
String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colDataActual, tagData, 1);
colDataActual.ForEach((item) => { Console.Write("{0}\t", item); });
......@@ -228,7 +227,7 @@ namespace Cases
String insertSql1 = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData1, tagData1, 3);
String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData1, tagData2, 3);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<Object> expectResData = UtilsTools.CombineColAndTagData(colData1, tagData1, 3);
UtilsTools.ExecuteUpdate(conn, dropSql);
......
......@@ -10,14 +10,14 @@ namespace Cases
public class NormalTableStmtCases
{
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindSingleLineCn</Name>
/// <Name>NormalTableStmtCases.TestBindSingleLineCN</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLineCn()")]
public void TestBindSingleLineCn()
[Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLineCN()")]
public void TestBindSingleLineCN()
{
string tableName = "normal_tablestmt_cases_test_bind_single_line_cn";
string tableName = "ntb_stmt_cases_test_bind_single_line_cn";
String createTb = $"create table if not exists {tableName} (" +
"ts timestamp," +
"tt tinyint," +
......@@ -38,9 +38,9 @@ namespace Cases
string insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
string dropSql = $"drop table if exists {tableName}";
string querySql = "select * from " + tableName;
TAOS_BIND[] _valuesRow = DataSource.GetNtableCNRow();
List<string> expectResData = DataSource.GetNtableCNRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
TAOS_BIND[] _valuesRow = DataSource.GetNTableCNRow();
List<string> expectResData = DataSource.GetNTableCNRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection();
UtilsTools.ExecuteUpdate(conn, dropSql);
......@@ -76,14 +76,14 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindColumnCn</Name>
/// <Name>NormalTableStmtCases.TestBindColumnCN</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "NormalTableStmtCases.TestBindColumnCn()")]
public void TestBindColumnCn()
[Fact(DisplayName = "NormalTableStmtCases.TestBindColumnCN()")]
public void TestBindColumnCN()
{
string tableName = "normal_tablestmt_cases_test_bind_column_cn";
string tableName = "ntb_stmt_cases_test_bind_column_cn";
String createTb = $"create table if not exists {tableName} " +
" (" +
"ts timestamp," +
......@@ -104,8 +104,8 @@ namespace Cases
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName} ";
List<string> expectResData = DataSource.GetMultiBindCNRowData();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection();
UtilsTools.ExecuteUpdate(conn, dropSql);
......@@ -115,26 +115,26 @@ namespace Cases
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mBind[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -158,15 +158,15 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindMultiLineCn</Name>
/// <Name>NormalTableStmtCases.TestBindMultiLineCN</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLineCn()")]
public void TestBindMultiLineCn()
[Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLineCN()")]
public void TestBindMultiLineCN()
{
string tableName = "normal_tablestmt_cases_test_bind_multi_lines_cn";
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
string tableName = "ntb_stmt_cases_test_bind_multi_lines_cn";
TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindCNArr();
String createTb = $"create table if not exists {tableName} " +
" (" +
"ts timestamp," +
......@@ -187,7 +187,7 @@ namespace Cases
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName} ";
List<string> expectResData = DataSource.GetMultiBindCNRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection(); ;
UtilsTools.ExecuteUpdate(conn, dropSql);
......@@ -196,12 +196,12 @@ namespace Cases
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.BindParamBatch(stmt, mBind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -228,13 +228,13 @@ namespace Cases
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindSingleLine</Name>
/// <describe>Test stmt insert sinle line data into normal table</describe>
/// <describe>Test stmt insert single line data into normal table</describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLine")]
public void TestBindSingleLine()
{
string tableName = "normal_tablestmt_cases_test_bind_single_line";
string tableName = "ntb_stmt_cases_test_bind_single_line";
String createTb = $"create table if not exists {tableName} (" +
"ts timestamp," +
"tt tinyint," +
......@@ -255,9 +255,9 @@ namespace Cases
string insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
string dropSql = $"drop table if exists {tableName}";
string querySql = "select * from " + tableName;
TAOS_BIND[] valuesRow = DataSource.GetNtableRow();
List<string> expectResData = DataSource.GetNtableRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
TAOS_BIND[] valuesRow = DataSource.GetNTableRow();
List<string> expectResData = DataSource.GetNTableRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection();
UtilsTools.ExecuteQuery(conn, dropSql);
......@@ -296,7 +296,7 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>NtableMutipleLine.TestBindMultiLine</Name>
/// <Name>NTableMultipleLine.TestBindMultiLine</Name>
/// <describe>Test stmt insert multiple rows of data into normal table</describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
......@@ -324,8 +324,8 @@ namespace Cases
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName} ";
List<string> expectResData = DataSource.GetMultiBindResData();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection();
UtilsTools.ExecuteUpdate(conn, dropSql);
......@@ -335,11 +335,11 @@ namespace Cases
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.BindParamBatch(stmt, mBind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -365,14 +365,14 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>NtableColumnByColumn.TestBindColumnCn</Name>
/// <Name>NormalTableStmtCases.TestBindColumnCn</Name>
/// <describe>Test stmt insert multiple rows of data into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "NormalTableStmtCases.TestBindColumn()")]
public void TestBindColumn()
{
string tableName = "normal_tablestmt_cases_test_bind_column_cn";
string tableName = "ntb_stmt_cases_test_bind_column_cn";
DataSource data = new DataSource();
String createTb = $"create table if not exists {tableName} " +
" (" +
......@@ -394,8 +394,8 @@ namespace Cases
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName} ";
List<string> expectResData = DataSource.GetMultiBindResData();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createTb);
TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createTb);
IntPtr conn = UtilsTools.TDConnection();
......@@ -406,26 +406,26 @@ namespace Cases
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBinds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......
......@@ -5,7 +5,7 @@ using Test.UtilsTools.DataSource;
namespace Cases
{
public class StmtStableQuery
public class StmtSTableQuery
{
public void Test(IntPtr conn, string tableName)
{
......@@ -26,7 +26,7 @@ namespace Cases
}
}
public class StmtNtableQuery
public class StmtNTableQuery
{
public void Test(IntPtr conn, string tableName)
{
......
......@@ -11,14 +11,14 @@ namespace Cases
public class StableStmtCases
{
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindSingleLineCn</Name>
/// <Name>StableStmtCases.TestBindSingleLineCN</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "StableStmtCases.TestBindSingleLineCn()")]
public void TestBindSingleLineCn()
[Fact(DisplayName = "StableStmtCases.TestBindSingleLineCN()")]
public void TestBindSingleLineCN()
{
string tableName = "stable_stmt_cases_test_bind_single_line_cn";
string tableName = "stb_stmt_cases_test_bind_single_line_cn";
String createSql = $"create stable if not exists {tableName} " +
" (ts timestamp," +
"v1 tinyint," +
......@@ -52,10 +52,10 @@ namespace Cases
");";
String insertSql = $"insert into ? using {tableName} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName} ;";
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
List<String> expectResData = DataSource.GetStableCNRowData();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<String> expectResData = DataSource.GetSTableCNRowData();
TAOS_BIND[] tags = DataSource.GetCNTags();
TAOS_BIND[] binds = DataSource.GetNtableCNRow();
TAOS_BIND[] binds = DataSource.GetNTableCNRow();
IntPtr conn = UtilsTools.TDConnection();
UtilsTools.ExecuteUpdate(conn, dropSql);
......@@ -95,14 +95,14 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindColumnCn</Name>
/// <Name>StableStmtCases.TestBindColumnCN</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "StableStmtCases.TestBindColumnCn()")]
public void TestBindColumnCn()
[Fact(DisplayName = "StableStmtCases.TestBindColumnCN()")]
public void TestBindColumnCN()
{
string tableName = "stable_stmt_cases_test_bindcolumn_cn";
string tableName = "stb_stmt_cases_test_bindcolumn_cn";
String createSql = $"create stable if not exists {tableName} " +
"(ts timestamp," +
"b bool," +
......@@ -137,8 +137,8 @@ namespace Cases
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName};";
TAOS_BIND[] tags = DataSource.GetCNTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<String> expectResData = DataSource.GetMultiBindStableCNRowData();
IntPtr conn = UtilsTools.TDConnection();
......@@ -149,27 +149,27 @@ namespace Cases
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBinds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -195,14 +195,14 @@ namespace Cases
}
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindMultiLineCn</Name>
/// <Name>StableStmtCases.TestBindMultiLineCN</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
[Fact(DisplayName = "StableStmtCases.TestBindMultiLineCn()")]
public void TestBindMultiLineCn()
[Fact(DisplayName = "StableStmtCases.TestBindMultiLineCN()")]
public void TestBindMultiLineCN()
{
string tableName = "stable_stmt_cases_test_bind_multi_line_cn";
string tableName = "stb_stmt_cases_test_bind_multi_line_cn";
String createSql = $"create stable if not exists {tableName} " +
"(ts timestamp," +
"b bool," +
......@@ -237,8 +237,8 @@ namespace Cases
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName};";
TAOS_BIND[] tags = DataSource.GetCNTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindCNArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<String> expectResData = DataSource.GetMultiBindStableCNRowData();
IntPtr conn = UtilsTools.TDConnection();
......@@ -248,13 +248,13 @@ namespace Cases
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.BindParamBatch(stmt, mBinds);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBinds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -285,7 +285,7 @@ namespace Cases
[Fact(DisplayName = "StableStmtCases.TestBindMultiLine()")]
public void TestBindMultiLine()
{
string tableName = "stable_stmt_cases_test_bind_multi_line";
string tableName = "stb_stmt_cases_test_bind_multi_line";
string createSql = $"create stable if not exists {tableName} " +
"(ts timestamp," +
"b bool," +
......@@ -320,8 +320,8 @@ namespace Cases
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName};";
TAOS_BIND[] tags = DataSource.GetTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<String> expectResData = DataSource.GetMultiBindStableRowData();
IntPtr conn = UtilsTools.TDConnection();
......@@ -331,13 +331,13 @@ namespace Cases
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.BindParamBatch(stmt, mBinds);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBinds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......@@ -373,7 +373,7 @@ namespace Cases
[Fact(DisplayName = "StableStmtCases.TestBindColumn()")]
public void TestBindColumn()
{
string tableName = "stable_stmt_cases_test_bindcolumn";
string tableName = "stb_stmt_cases_test_bindcolumn";
string createSql = $"create stable if not exists {tableName} " +
"(ts timestamp," +
"b bool," +
......@@ -408,8 +408,8 @@ namespace Cases
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String dropSql = $"drop table if exists {tableName};";
TAOS_BIND[] tags = DataSource.GetTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDLL(createSql);
TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr();
List<TDengineMeta> expectResMeta = DataSource.GetMetaFromDDL(createSql);
List<String> expectResData = DataSource.GetMultiBindStableRowData();
IntPtr conn = UtilsTools.TDConnection();
......@@ -420,27 +420,27 @@ namespace Cases
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
DataSource.FreeTaosMBind(mBinds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
......
using System;
using TDengineDriver;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
namespace Test.UtilsTools.ResultSet
{
......@@ -17,10 +15,10 @@ namespace Test.UtilsTools.ResultSet
resultData = UtilsTools.GetResData(res);
}
public ResultSet(List<TDengineMeta> metas, List<String> datas)
public ResultSet(List<TDengineMeta> meta, List<String> data)
{
resultMeta = metas;
resultData = datas;
resultMeta = meta;
resultData = data;
}
public List<String> GetResultData()
......@@ -35,5 +33,4 @@ namespace Test.UtilsTools.ResultSet
}
}
\ No newline at end of file
......@@ -31,12 +31,12 @@ namespace XUnit.Case.Orderers
yield return testCase;
}
}
private static TValue GetOrCreate<TKey, TValue>(
IDictionary<TKey, TValue> dictionary, TKey key)
where TKey : struct
where TValue : new() =>
dictionary.TryGetValue(key, out TValue? result)
dictionary.TryGetValue(key, out TValue result)
? result
: (dictionary[key] = new TValue());
}
......
......@@ -14,11 +14,11 @@ namespace Test.UtilsTools
static string password = "taosdata";
static string db = "";
static short port = 0;
//get a tdengine connection
//get a TDengine connection
public static IntPtr TDConnection()
{
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, GetConfigPath());
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
TDengine.Options((int)TDengineInitOption.TSDB_OPTION_CONFIGDIR, GetConfigPath());
TDengine.Options((int)TDengineInitOption.TSDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
TDengine.Init();
IntPtr conn = TDengine.Connect(ip, user, password, db, port);
// UtilsTools.ExecuteUpdate(conn, "drop database if exists csharp");
......@@ -99,16 +99,16 @@ namespace Test.UtilsTools
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
int fieldCount = metas.Count;
List<TDengineMeta> metaList = GetResField(res);
int fieldCount = metaList.Count;
IntPtr rowdata;
List<string> datas = QueryRes(res, metas);
for (int i = 0; i < metas.Count; i++)
List<string> dataList = QueryRes(res, metaList);
for (int i = 0; i < metaList.Count; i++)
{
for (int j = 0; j < datas.Count; j++)
for (int j = 0; j < dataList.Count; j++)
{
Console.Write(" {0} \t|", datas[j]);
Console.Write(" {0} \t|", dataList[j]);
}
Console.WriteLine("");
}
......@@ -125,10 +125,10 @@ namespace Test.UtilsTools
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
List<TDengineMeta> metaList = GetResField(res);
result.Add(colName);
dataRaw = QueryRes(res, metas);
dataRaw = QueryRes(res, metaList);
result.Add(dataRaw);
if (TDengine.ErrorNo(res) != 0)
......@@ -159,7 +159,7 @@ namespace Test.UtilsTools
{
if (TDengine.Close(conn) == 0)
{
Console.WriteLine("close connection sucess");
Console.WriteLine("close connection success");
}
else
{
......@@ -169,8 +169,8 @@ namespace Test.UtilsTools
}
public static List<TDengineMeta> GetResField(IntPtr res)
{
List<TDengineMeta> metas = TDengine.FetchFields(res);
return metas;
List<TDengineMeta> metaList = TDengine.FetchFields(res);
return metaList;
}
public static void AssertEqual(string expectVal, string actualVal)
{
......@@ -274,11 +274,11 @@ namespace Test.UtilsTools
return _meta;
}
private static List<string> QueryRes(IntPtr res, List<TDengineMeta> metas)
private static List<string> QueryRes(IntPtr res, List<TDengineMeta> meta)
{
IntPtr taosRow;
List<string> dataRaw = new List<string>();
int fieldCount = metas.Count;
int fieldCount = meta.Count;
while ((taosRow = TDengine.FetchRows(res)) != IntPtr.Zero)
{
dataRaw.AddRange(FetchRow(taosRow, res));
......@@ -294,7 +294,7 @@ namespace Test.UtilsTools
// Generate insert sql for the with the coldata and tag data
public static string ConstructInsertSql(string table, string stable, List<Object> colData, List<Object> tagData, int numOfRows)
{
int numofFileds = colData.Count / numOfRows;
int numOfFields = colData.Count / numOfRows;
StringBuilder insertSql;
if (stable == "")
......@@ -339,7 +339,7 @@ namespace Test.UtilsTools
insertSql.Append(colData[i]);
}
if ((i + 1) % numofFileds == 0 && (i + 1) != colData.Count)
if ((i + 1) % numOfFields == 0 && (i + 1) != colData.Count)
{
insertSql.Append(")(");
}
......@@ -500,8 +500,8 @@ namespace Test.UtilsTools
{
ExitProgram();
}
List<TDengineMeta> metas = GetResField(res);
dataRaw = QueryRes(res, metas);
List<TDengineMeta> meta = GetResField(res);
dataRaw = QueryRes(res, meta);
return dataRaw;
}
}
......
......@@ -8,7 +8,7 @@ namespace TDengineDriver.Test
{
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameBool</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's bool meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's bool meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -24,7 +24,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameTINYINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's TinnyInt's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's TinnyInt's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -40,7 +40,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameSMALLINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's SMALLINT's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's SMALLINT's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -56,7 +56,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's INT's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's INT's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -72,7 +72,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameBIGINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's BIGINT's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's BIGINT's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -88,7 +88,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameUTINYINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's TINYINT UNSIGNED's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's TINYINT UNSIGNED's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -104,7 +104,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameUSMALLINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's SMALLINT UNSIGNED's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's SMALLINT UNSIGNED's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -120,7 +120,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameUINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's INT UNSIGNED's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's INT UNSIGNED's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -136,7 +136,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameUBIGINT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's BIGINT UNSIGNED's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's BIGINT UNSIGNED's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -152,7 +152,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameFLOAT</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's FLOAT's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's FLOAT's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -168,7 +168,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameDOUBLE</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's DOUBLE's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's DOUBLE's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -184,7 +184,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameSTRING</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's BINARY's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's BINARY's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -200,7 +200,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameTIMESTAMP</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's TIMESTAMP's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's TIMESTAMP's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -216,7 +216,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameNCHAR</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's NCHAR's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's NCHAR's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......@@ -232,7 +232,7 @@ namespace TDengineDriver.Test
}
/// <author>xiaolei</author>
/// <Name>TestTDengineMeta.TestTypeNameUndefined</Name>
/// <describe>Unit test for oject TDengineDriver.TDengineMeta's undefine's meta info</describe>
/// <describe>Unit test for object TDengineDriver.TDengineMeta's undefine's meta info</describe>
/// <filename>TestTDengineMeta.cs</filename>
/// <result>pass or failed </result>
[Fact]
......
......@@ -1135,7 +1135,7 @@ public class JsonTagTest {
}
Assert.assertEquals(8, count);
Assert.assertEquals("\"femail\"", s);
Assert.assertEquals("\"收到货\"", s);
close(resultSet);
}
......
......@@ -1149,7 +1149,7 @@ public class RestfulJsonTagTest {
}
Assert.assertEquals(8, count);
Assert.assertEquals("\"femail\"", s);
Assert.assertEquals("\"收到货\"", s);
close(resultSet);
}
......
......@@ -1146,7 +1146,7 @@ public class WSJsonTagTest {
}
Assert.assertEquals(8, count);
Assert.assertEquals("\"femail\"", s);
Assert.assertEquals("\"收到货\"", s);
close(resultSet);
}
......
Subproject commit f36b07f710d661dca88fdd70e73b5e3e16a960e0
Subproject commit 94aec03df22881e336b0b59737a41eb3b1e60c2d
......@@ -84,6 +84,9 @@ static char* offlineReason[] = {
"timezone not match",
"locale not match",
"charset not match",
"flowctrl not match",
"slaveQuery not match",
"adjustMaster not match",
"unknown",
};
......
......@@ -93,9 +93,9 @@ int32_t twcslen(const wchar_t *wcs) {
}
int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) {
for (int32_t i = 0; i < bytes; ++i) {
int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i * 4);
int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i * 4);
for (int32_t i = 0; i < bytes; i += TSDB_NCHAR_SIZE) {
int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i);
int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i);
if ((f1 == 0 && f2 != 0) || (f1 != 0 && f2 == 0)) {
return f1 - f2;
......
......@@ -59,13 +59,16 @@ ELSE ()
CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
BUILD_COMMAND
COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
INSTALL_COMMAND
COMMAND curl -sL https://github.com/upx/upx/releases/download/v3.96/upx-3.96-${PLATFORM_ARCH_STR}_linux.tar.xz -o upx.tar.xz && tar -xvJf upx.tar.xz -C ${CMAKE_BINARY_DIR} --strip-components 1 > /dev/null && ${CMAKE_BINARY_DIR}/upx taosadapter || :
COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
)
ELSEIF (TD_DARWIN)
include(ExternalProject)
......@@ -78,12 +81,15 @@ ELSE ()
CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
BUILD_COMMAND
COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
INSTALL_COMMAND
COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
)
ELSE ()
MESSAGE("${Yellow} Windows system still use original embedded httpd ${ColourReset}")
......
......@@ -89,8 +89,9 @@ extern "C" {
#define TSDB_FUNC_QSTART 47
#define TSDB_FUNC_QSTOP 48
#define TSDB_FUNC_QDURATION 49
#define TSDB_FUNC_HYPERLOGLOG 50
#define TSDB_FUNC_MAX_NUM 50
#define TSDB_FUNC_MAX_NUM 51
#define TSDB_FUNCSTATE_SO 0x1u // single output
#define TSDB_FUNCSTATE_MO 0x2u // dynamic number of output, not multinumber of output e.g., TOP/BOTTOM
......
......@@ -254,7 +254,7 @@ int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1
struct SSDataBlock;
int32_t compare_aRv(struct SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, int32_t rowIndex, char** buffer, int32_t order);
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes);
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes, bool lenFirst);
#ifdef __cplusplus
}
......
......@@ -78,8 +78,8 @@ typedef struct SDiskbasedResultBuf {
#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) // in bytes
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
#define MAX_UNIQUE_RESULT_ROWS (1000)
#define MAX_UNIQUE_RESULT_SIZE (1024*1024*1)
#define MAX_UNIQUE_RESULT_ROWS (10000)
#define MAX_UNIQUE_RESULT_SIZE (1024*1024*10)
#define MAX_MODE_INNER_RESULT_ROWS (1000000)
#define MAX_MODE_INNER_RESULT_SIZE (1024*1024*10)
/**
......
......@@ -29,6 +29,7 @@
#include "queryLog.h"
#include "qUdf.h"
#include "tcompare.h"
#include "hashfunc.h"
#define GET_INPUT_DATA_LIST(x) ((char *)((x)->pInput))
#define GET_INPUT_DATA(x, y) (GET_INPUT_DATA_LIST(x) + (y) * (x)->inputBytes)
......@@ -256,11 +257,157 @@ typedef struct {
char data[];
} TailUnit;
typedef struct STailInfo {
typedef struct {
int32_t num;
TailUnit **res;
} STailInfo;
static void *getOutputInfo(SQLFunctionCtx *pCtx) {
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
// only the first_stage_merge is directly written data into final output buffer
if (pCtx->stableQuery && pCtx->currentStage != MERGE_STAGE) {
return pCtx->pOutput;
} else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer
return GET_ROWCELL_INTERBUF(pResInfo);
}
}
/* hyperloglog start */
#define HLL_BUCKET_BITS 14 // The bits of the bucket
#define HLL_DATA_BITS (64-HLL_BUCKET_BITS)
#define HLL_BUCKETS (1<<HLL_BUCKET_BITS)
#define HLL_BUCKET_MASK (HLL_BUCKETS-1)
#define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2)
typedef struct {
uint8_t buckets[HLL_BUCKETS]; // Data bytes.
} SHLLInfo;
static void hllBucketHisto(uint8_t *buckets, int32_t* bucketHisto) {
uint64_t *word = (uint64_t*) buckets;
uint8_t *bytes;
for (int32_t j = 0; j < HLL_BUCKETS>>3; j++) {
if (*word == 0) {
bucketHisto[0] += 8;
} else {
bytes = (uint8_t*) word;
bucketHisto[bytes[0]]++;
bucketHisto[bytes[1]]++;
bucketHisto[bytes[2]]++;
bucketHisto[bytes[3]]++;
bucketHisto[bytes[4]]++;
bucketHisto[bytes[5]]++;
bucketHisto[bytes[6]]++;
bucketHisto[bytes[7]]++;
}
word++;
}
}
static double hllTau(double x) {
if (x == 0. || x == 1.) return 0.;
double zPrime;
double y = 1.0;
double z = 1 - x;
do {
x = sqrt(x);
zPrime = z;
y *= 0.5;
z -= pow(1 - x, 2)*y;
} while(zPrime != z);
return z / 3;
}
static double hllSigma(double x) {
if (x == 1.0) return INFINITY;
double zPrime;
double y = 1;
double z = x;
do {
x *= x;
zPrime = z;
z += x * y;
y += y;
} while(zPrime != z);
return z;
}
// estimate the cardinality, the algorithm refer this paper: "New cardinality estimation algorithms for HyperLogLog sketches"
static uint64_t hllCountCnt(uint8_t *buckets) {
double m = HLL_BUCKETS;
int32_t buckethisto[64] = {0};
hllBucketHisto(buckets,buckethisto);
double z = m * hllTau((m-buckethisto[HLL_DATA_BITS+1])/(double)m);
for (int j = HLL_DATA_BITS; j >= 1; --j) {
z += buckethisto[j];
z *= 0.5;
}
z += m * hllSigma(buckethisto[0]/(double)m);
double E = llroundl(HLL_ALPHA_INF*m*m/z);
return (uint64_t) E;
}
static uint8_t hllCountNum(void *ele, int32_t elesize, int32_t *buk) {
uint64_t hash = MurmurHash3_64(ele,elesize);
int32_t index = hash & HLL_BUCKET_MASK;
hash >>= HLL_BUCKET_BITS;
hash |= ((uint64_t)1<<HLL_DATA_BITS);
uint64_t bit = 1;
uint8_t count = 1;
while((hash & bit) == 0) {
count++;
bit <<= 1;
}
*buk = index;
return count;
}
static void hll_function(SQLFunctionCtx *pCtx) {
SHLLInfo *pHLLInfo = getOutputInfo(pCtx);
for (int32_t i = 0; i < pCtx->size; ++i) {
char *val = GET_INPUT_DATA(pCtx, i);
if (isNull(val, pCtx->inputType)) {
continue;
}
int32_t elesize = pCtx->inputBytes;
if(IS_VAR_DATA_TYPE(pCtx->inputType)) {
elesize = varDataLen(val);
val = varDataVal(val);
}
int32_t index = 0;
uint8_t count = hllCountNum(val,elesize,&index);
uint8_t oldcount = pHLLInfo->buckets[index];
if (count > oldcount) {
pHLLInfo->buckets[index] = count;
}
}
GET_RES_INFO(pCtx)->numOfRes = 1;
}
static void hll_func_merge(SQLFunctionCtx *pCtx) {
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
SHLLInfo *pHLLInfo = (SHLLInfo *)GET_ROWCELL_INTERBUF(pResInfo);
SHLLInfo *pData = (SHLLInfo *)GET_INPUT_DATA_LIST(pCtx);
for (int i = 0; i < HLL_BUCKETS; i++) {
if (pData->buckets[i] > pHLLInfo->buckets[i]) {
pHLLInfo->buckets[i] = pData->buckets[i];
}
}
}
static void hll_func_finalizer(SQLFunctionCtx *pCtx) {
SHLLInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
GET_RES_INFO(pCtx)->numOfRes = 1;
*(uint64_t *)(pCtx->pOutput) = hllCountCnt(pInfo->buckets);
doFinalizer(pCtx);
}
/* hyperloglog end */
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type,
int32_t *bytes, int32_t *interBytes, int16_t extLength, bool isSuperTable, SUdfInfo* pUdfInfo) {
if (!isValidDataType(dataType)) {
......@@ -428,6 +575,11 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
*bytes = (sizeof(STailInfo) + (sizeof(TailUnit) + dataBytes + POINTER_BYTES + extLength) * param);
*interBytes = *bytes;
return TSDB_CODE_SUCCESS;
} else if (functionId == TSDB_FUNC_HYPERLOGLOG) {
*type = TSDB_DATA_TYPE_BINARY;
*bytes = sizeof(SHLLInfo);
*interBytes = sizeof(SHLLInfo);
return TSDB_CODE_SUCCESS;
} else if (functionId == TSDB_FUNC_SAMPLE) {
*type = TSDB_DATA_TYPE_BINARY;
......@@ -584,11 +736,15 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
// the output column may be larger than sizeof(STopBotInfo)
*interBytes = (int32_t)size;
} else if (functionId == TSDB_FUNC_HYPERLOGLOG) {
*type = TSDB_DATA_TYPE_UBIGINT;
*bytes = sizeof(uint64_t);
*interBytes = sizeof(SHLLInfo);
} else if (functionId == TSDB_FUNC_SAMPLE) {
*type = (int16_t)dataType;
*bytes = dataBytes;
size_t size = sizeof(SSampleFuncInfo) + dataBytes*param + sizeof(int64_t)*param + extLength*param;
*interBytes = (int32_t)size;
*type = (int16_t)dataType;
*bytes = dataBytes;
size_t size = sizeof(SSampleFuncInfo) + dataBytes*param + sizeof(int64_t)*param + extLength*param;
*interBytes = (int32_t)size;
} else if (functionId == TSDB_FUNC_LAST_ROW) {
*type = (int16_t)dataType;
*bytes = dataBytes;
......@@ -2407,18 +2563,6 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
tfree(pData);
}
static void *getOutputInfo(SQLFunctionCtx *pCtx) {
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
// only the first_stage_merge is directly written data into final output buffer
if (pCtx->stableQuery && pCtx->currentStage != MERGE_STAGE) {
return pCtx->pOutput;
} else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer
return GET_ROWCELL_INTERBUF(pResInfo);
}
}
/*
* keep the intermediate results during scan data blocks in the format of:
* +-----------------------------------+-------------one value pair-----------+------------next value pair-----------+
......@@ -5350,7 +5494,7 @@ static void unique_function(SQLFunctionCtx *pCtx) {
do_unique_function(pCtx, pInfo, k, pData, NULL, pCtx->inputBytes, pCtx->inputType);
if (sizeof(SUniqueFuncInfo) + pInfo->num * (sizeof(UniqueUnit) + pCtx->inputBytes + pCtx->tagInfo.tagsLen) >= MAX_UNIQUE_RESULT_SIZE
|| (pInfo->num > MAX_UNIQUE_RESULT_ROWS)){
|| (pInfo->num > pCtx->param[0].i64)){
GET_RES_INFO(pCtx)->numOfRes = -1; // mark out of memory
return;
}
......@@ -5371,7 +5515,7 @@ static void unique_function_merge(SQLFunctionCtx *pCtx) {
do_unique_function(pCtx, pOutput, timestamp, data, tags, pCtx->outputBytes, pCtx->outputType);
if (sizeof(SUniqueFuncInfo) + pOutput->num * (sizeof(UniqueUnit) + pCtx->outputBytes + pCtx->tagInfo.tagsLen) >= MAX_UNIQUE_RESULT_SIZE
|| (pOutput->num > MAX_UNIQUE_RESULT_ROWS)){
|| (pOutput->num > pCtx->param[0].i64)){
GET_RES_INFO(pCtx)->numOfRes = -1; // mark out of memory
return;
}
......@@ -5689,7 +5833,10 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
// }else{
// GET_RES_INFO(pCtx)->numOfRes = pRes->num;
// }
if (GET_RES_INFO(pCtx)->numOfRes <= 0) return;
if (GET_RES_INFO(pCtx)->numOfRes <= 0) {
doFinalizer(pCtx);
return;
}
taosqsort(pRes->res, pRes->num, POINTER_BYTES, NULL, tailComparFn);
......@@ -5697,6 +5844,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
void *data = calloc(size, GET_RES_INFO(pCtx)->numOfRes);
if(!data){
qError("calloc error in tail_func_finalizer: size:%d, num:%d", (int32_t)size, GET_RES_INFO(pCtx)->numOfRes);
doFinalizer(pCtx);
return;
}
for(int32_t i = 0; i < GET_RES_INFO(pCtx)->numOfRes; i++){
......@@ -5887,16 +6035,16 @@ static void window_duration_function(SQLFunctionCtx *pCtx) {
*
*/
int32_t functionCompatList[] = {
// count, sum, avg, min, max, stddev, percentile, apercentile, first, last
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
// last_row, top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_comp
4, -1, -1, 1, 1, 1, 1, 1, 1, -1,
// tag, colprj, tagprj, arithm, diff, first_dist, last_dist, stddev_dst, interp rate, irate
1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1,
// tid_tag, deriv, csum, mavg, sample, block_info, elapsed, histogram, unique, mode, tail
6, 8, -1, -1, -1, 7, 1, -1, -1, 1, -1,
// stateCount, stateDuration, wstart, wstop, wduration, qstart, qstop, qduration,
1, 1, 1, 1, 1, 1, 1, 1,
// count, sum, avg, min, max, stddev, percentile, apercentile, first, last
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
// last_row, top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_comp
4, -1, -1, 1, 1, 1, 1, 1, 1, -1,
// tag, colprj, tagprj, arithm, diff, first_dist, last_dist, stddev_dst, interp rate, irate
1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1,
// tid_tag, deriv, csum, mavg, sample, block_info, elapsed, histogram, unique, mode, tail
6, 8, -1, -1, -1, 7, 1, -1, -1, 1, -1,
// stateCount, stateDuration, wstart, wstop, wduration, qstart, qstop, qduration, hyperloglog
1, 1, 1, 1, 1, 1, 1, 1, 1,
};
SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
......@@ -6501,5 +6649,17 @@ SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
doFinalizer,
copy_function,
dataBlockRequired,
},
{
// 50
"hyperloglog",
TSDB_FUNC_HYPERLOGLOG,
TSDB_FUNC_HYPERLOGLOG,
TSDB_BASE_FUNC_SO,
function_setup,
hll_function,
hll_func_finalizer,
hll_func_merge,
dataBlockRequired,
}
};
......@@ -283,28 +283,25 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
return (in1 != NULL && in2 != NULL) ? supporter->comFunc(in1, in2) : 0;
}
static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock) {
if (pRuntimeEnv->pQueryAttr->pGroupbyExpr == NULL || pRuntimeEnv->pQueryAttr->pGroupbyExpr->numOfGroupCols <= 0){
static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock, SQLFunctionCtx *pCtx) {
// first groupby column is sort column
SColIndex* pFirstGroupCol = taosArrayGet(pRuntimeEnv->pQueryAttr->pGroupbyExpr->columnInfo, 0);
if (pFirstGroupCol == NULL) {
return;
}
if (pRuntimeEnv->pQueryAttr->order.orderColId <= 0){
return;
}
SColIndex* pColIndex = taosArrayGet(pRuntimeEnv->pQueryAttr->pGroupbyExpr->columnInfo, 0);
// get dataOffset and index on pRuntimeEnv->pQueryAttr->pExpr1
int16_t dataOffset = 0;
int16_t type = 0;
for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) {
SColumnInfoData* pColInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock->pDataBlock, j);
if (pColInfoData->info.colId == pColIndex->colId) {
type = pColInfoData->info.type;
if (pCtx[j].colId == pFirstGroupCol->colId) {
type = pRuntimeEnv->pQueryAttr->pExpr1[j].base.resType;
break;
}
dataOffset += pColInfoData->info.bytes;
}
SRowCompSupporter support = {.pRuntimeEnv = pRuntimeEnv, .dataOffset = dataOffset, .comFunc = getComparFunc(type, 0)};
taosArraySortPWithExt(pGroupResInfo->pRows, compareRowData, &support);
}
......@@ -7128,7 +7125,7 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) {
initGroupResInfo(&pRuntimeEnv->groupResInfo, &pInfo->binfo.resultRowInfo);
if (!pRuntimeEnv->pQueryAttr->stableQuery) {
sortGroupResByOrderList(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pInfo->binfo.pRes);
sortGroupResByOrderList(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pInfo->binfo.pRes, pInfo->binfo.pCtx);
}
toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pInfo->binfo.pRes);
......@@ -9568,7 +9565,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
pQueryAttr->needTableSeqScan = pQueryMsg->needTableSeqScan;
pQueryAttr->needReverseScan = pQueryMsg->needReverseScan;
pQueryAttr->stateWindow = pQueryMsg->stateWindow;
pQueryAttr->vgId = vgId;
pQueryAttr->pFilters = pFilters;
pQueryAttr->range = pQueryMsg->range;
......
......@@ -366,7 +366,7 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) {
}
}
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes) {
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes, bool lenFirst) {
if (type == TSDB_DATA_TYPE_JSON){
bool canReturn = true;
int32_t result = jsonCompareUnit(f1, f2, &canReturn);
......@@ -387,31 +387,48 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
case TSDB_DATA_TYPE_BINARY: {
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
if (len1 != len2) {
return len1 > len2? 1:-1;
} else {
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
// length first compare
if(lenFirst) {
if(len1 > len2)
return 1;
else if( len1 < len2)
return -1;
}
// compare context
int32_t ret = strncmp(varDataVal(f1), varDataVal(f2), len1>len2 ? len2:len1);
if (ret == 0) {
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
}
return (ret < 0) ? -1 : 1;
}
return (ret < 0) ? -1 : 1;
};
case TSDB_DATA_TYPE_NCHAR: { // todo handle the var string compare
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
if (len1 != len2) {
return len1 > len2 ? 1 : -1;
} else {
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
// length first compare
if(lenFirst) {
if(len1 > len2)
return 1;
else if( len1 < len2)
return -1;
}
// compare context
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1>len2 ? len2:len1);
if (ret == 0) {
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
}
return (ret < 0) ? -1 : 1;
}
return (ret < 0) ? -1 : 1;
};
case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2));
case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
......@@ -442,7 +459,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
} else {
SSchemaEx *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes);
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes, strcmp(pSchema->field.name, TSQL_TBNAME_L) == 0);
if (ret == 0) {
continue;
} else {
......@@ -471,7 +488,7 @@ int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, in
return ret;
}
} else {
int32_t ret = columnValueAscendingComparator(data, buffer[i], pColInfo->info.type, pColInfo->info.bytes);
int32_t ret = columnValueAscendingComparator(data, buffer[i], pColInfo->info.type, pColInfo->info.bytes, false);
if (ret == 0) {
continue;
} else {
......@@ -503,7 +520,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
} else {
SSchemaEx *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes);
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->field.type, pSchema->field.bytes, strcmp(pSchema->field.name, TSQL_TBNAME_L) == 0);
if (ret == 0) {
continue;
} else {
......
......@@ -39,13 +39,10 @@ int32_t getRowNumForMultioutput(SQueryAttr* pQueryAttr, bool topBottomQuery, boo
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_BOTTOM ||
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_SAMPLE ||
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_HISTOGRAM ||
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_TAIL) {
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_TAIL ||
pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_UNIQUE) {
return (int32_t)pQueryAttr->pExpr1[i].base.param[0].i64;
}
if (pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_UNIQUE){
return MAX_UNIQUE_RESULT_ROWS;
}
}
}
......
......@@ -33,7 +33,8 @@ typedef void (*_hash_free_fn_t)(void *param);
*/
uint32_t MurmurHash3_32(const char *key, uint32_t len);
/**
uint64_t MurmurHash3_64(const void *key, uint32_t len);
/**
*
* @param key
* @param len
......
......@@ -183,16 +183,16 @@ int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) {
int32_t len1 = varDataLen(pLeft);
int32_t len2 = varDataLen(pRight);
if (len1 != len2) {
return len1 > len2? 1:-1;
} else {
int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1);
if (ret == 0) {
int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1>len2 ? len2:len1);
if (ret == 0) {
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
} else {
return ret > 0 ? 1:-1;
}
}
return (ret < 0) ? -1 : 1;
}
int32_t compareLenPrefixedStrDesc(const void* pLeft, const void* pRight) {
......@@ -203,16 +203,16 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
int32_t len1 = varDataLen(pLeft);
int32_t len2 = varDataLen(pRight);
if (len1 != len2) {
return len1 > len2? 1:-1;
} else {
int32_t ret = memcmp((wchar_t*) pLeft, (wchar_t*) pRight, len1);
if (ret == 0) {
int32_t ret = tasoUcs4Compare(varDataVal(pLeft), varDataVal(pRight), len1>len2 ? len2:len1);
if (ret == 0) {
if (len1 > len2)
return 1;
else if(len1 < len2)
return -1;
else
return 0;
} else {
return ret > 0 ? 1 : -1;
}
}
return (ret < 0) ? -1 : 1;
}
int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) {
......@@ -750,7 +750,8 @@ int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn){
}
}
int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
int32_t
doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
if (type == TSDB_DATA_TYPE_JSON){
bool canReturn = true;
int32_t result = jsonCompareUnit(f1, f2, &canReturn);
......@@ -771,33 +772,8 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2));
case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2));
case TSDB_DATA_TYPE_NCHAR:{
tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
if (t1->len != t2->len) {
return t1->len > t2->len? 1:-1;
}
int32_t ret = memcmp((wchar_t*) t1, (wchar_t*) t2, t2->len);
if (ret == 0) {
return ret;
}
return (ret < 0) ? -1 : 1;
}
default: { // todo refactor
tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
if (t1->len != t2->len) {
return t1->len > t2->len? 1:-1;
} else {
int32_t ret = strncmp(t1->data, t2->data, t1->len);
if (ret == 0) {
return 0;
} else {
return ret < 0? -1:1;
}
}
}
case TSDB_DATA_TYPE_NCHAR: return compareLenPrefixedWStr(f1, f2);
default: // BINARY AND NULL AND SO ON
return compareLenPrefixedStr(f1, f2);
}
}
......@@ -78,6 +78,42 @@ uint32_t MurmurHash3_32(const char *key, uint32_t len) {
return h1;
}
uint64_t MurmurHash3_64(const void *key, uint32_t len) {
const uint64_t m = 0x87c37b91114253d5;
const int r = 47;
uint32_t seed = 0x12345678;
uint64_t h = seed ^ (len * m);
const uint8_t *data = (const uint8_t *)key;
const uint8_t *end = data + (len-(len&7));
while(data != end) {
uint64_t k = *((uint64_t*)data);
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
h *= m;
data += 8;
}
switch(len & 7) {
case 7: h ^= (uint64_t)data[6] << 48; /* fall-thru */
case 6: h ^= (uint64_t)data[5] << 40; /* fall-thru */
case 5: h ^= (uint64_t)data[4] << 32; /* fall-thru */
case 4: h ^= (uint64_t)data[3] << 24; /* fall-thru */
case 3: h ^= (uint64_t)data[2] << 16; /* fall-thru */
case 2: h ^= (uint64_t)data[1] << 8; /* fall-thru */
case 1: h ^= (uint64_t)data[0];
h *= m; /* fall-thru */
};
h ^= h >> r;
h *= m;
h ^= h >> r;
return h;
}
uint32_t taosIntHash_32(const char *key, uint32_t UNUSED_PARAM(len)) { return *(uint32_t *)key; }
uint32_t taosIntHash_16(const char *key, uint32_t UNUSED_PARAM(len)) { return *(uint16_t *)key; }
uint32_t taosIntHash_8(const char *key, uint32_t UNUSED_PARAM(len)) { return *(uint8_t *)key; }
......
......@@ -525,6 +525,8 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) {
for (i = 1; isdigit(z[i]); i++) {
}
uint32_t j = i;
/* here is the 1u/1a/2s/3m/9y */
if ((z[i] == 'b' || z[i] == 'u' || z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' ||
z[i] == 'y' || z[i] == 'w' ||
......@@ -559,6 +561,14 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) {
}
*tokenId = TK_FLOAT;
}
if (*tokenId == TK_INTEGER && z[j] != '\0') {
char c = z[j] | 0x20;
if (c >= 'a' && c <= 'z') {
*tokenId = TK_ID;
}
}
return i;
}
case '[': {
......
......@@ -34,7 +34,6 @@ class TDTestCase:
def run(self):
tdSql.prepare()
print("============== STEP 1 ===== prepare data & validate json string")
tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json, tagint int)")
tdSql.error("create table if not exists jsons1(ts timestamp, data json) tags(tagint int)")
......@@ -379,8 +378,8 @@ class TDTestCase:
tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag")
tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
tdSql.checkRows(8)
tdSql.checkData(0, 0, 2)
tdSql.checkData(0, 1, '"femail"')
tdSql.checkData(1, 0, 2)
tdSql.checkData(1, 1, '"femail"')
tdSql.checkData(2, 0, 1)
tdSql.checkData(2, 1, 11)
tdSql.checkData(5, 0, 1)
......@@ -398,8 +397,8 @@ class TDTestCase:
tdSql.checkData(2, 1, "false")
tdSql.checkData(5, 0, 1)
tdSql.checkData(5, 1, 11)
tdSql.checkData(7, 0, 2)
tdSql.checkData(7, 1, '"femail"')
tdSql.checkData(6, 0, 2)
tdSql.checkData(6, 1, '"femail"')
# test stddev with group by json tag
tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1'")
......@@ -407,8 +406,8 @@ class TDTestCase:
tdSql.checkData(0, 1, None)
tdSql.checkData(1, 0, 0)
tdSql.checkData(1, 1, "null")
tdSql.checkData(7, 0, 11)
tdSql.checkData(7, 1, '"femail"')
tdSql.checkData(6, 0, 11)
tdSql.checkData(6, 1, '"femail"')
res = tdSql.getColNameList("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'")
cname_list = []
......@@ -422,8 +421,8 @@ class TDTestCase:
tdSql.checkData(0, 1, 4)
tdSql.checkData(1, 1, 24)
tdSql.checkData(1, 2, None)
tdSql.checkData(10, 1, 1)
tdSql.checkData(10, 2, '"femail"')
tdSql.checkData(8, 1, 1)
tdSql.checkData(8, 2, '"femail"')
# test having
tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0")
......@@ -437,7 +436,7 @@ class TDTestCase:
tdSql.query("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)")
tdSql.checkRows(11)
tdSql.checkData(0, 0, '"femail"')
tdSql.checkData(1, 0, '"femail"')
tdSql.checkData(2, 0, 5)
res = tdSql.getColNameList("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)")
......
###################################################################
# Copyright (c) 2021 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def caseDescription(self):
'''
case1<markwang>: [TD-13893] hyperloglog unique
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
def run(self):
print("running {}".format(__file__))
tdSql.execute("drop database if exists hll")
tdSql.execute("create database if not exists hll")
tdSql.execute('use hll')
tdSql.execute('create table shll (ts timestamp, dbig bigint, dsmall smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dnchar nchar(4093), dbinary binary(64), dtime timestamp) tags (tbinary nchar(4093), tint int)')
tdSql.execute('create table hll1 using shll tags ("t1", 1)')
tdSql.execute('create table hll2 using shll tags ("t2", 2)')
tdSql.execute('insert into hll1 values("2021-10-17 00:31:31", 1, -3276, true, 253, 3.32333, 4.984392323, "你好", "sddd", 333) ("2022-01-24 00:31:32", 1, -32767, false, 254, NULL, 4.982392323, "你好吗", "sdf",2323)')
tdSql.execute('insert into hll2 values("2021-10-15 00:31:33", 1, NULL, true, 23, 3.4, 4.982392323, "你好吗", "sdf", 333) ("2021-12-24 00:31:34", 2, 32767, NULL, NULL, NULL, 4.982392323, NULL, "sddd", NULL) ("2022-01-01 08:00:05", 19, 3276, true, 2, 3.323222, 4.92323, "试试", "sddd", 1645434434000)')
tdSql.execute('insert into hll2 values("2021-10-17 00:31:31", NULL, 32767, true, 123, 3.323232333, 4.2, NULL, NULL, NULL) ("2022-01-01 08:00:06", NULL, NULL, NULL, 35, 3.323232333, NULL, "试试", NULL, 1645434434000) ("2022-01-01 08:00:07", 9, 54, true, 25, 3.32333, NULL, "试试", NULL, 1645434434001)')
## test normal table
tdSql.query('select hyperloglog(ts) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 6)
tdSql.query('select hyperloglog(dbig) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 4)
tdSql.query('select hyperloglog(dsmall) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 3)
tdSql.query('select hyperloglog(dbool) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.query('select hyperloglog(dtiny) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 5)
tdSql.query('select hyperloglog(dfloat) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 4)
tdSql.query('select hyperloglog(ddouble) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 3)
tdSql.query('select hyperloglog(dnchar) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
tdSql.query('select hyperloglog(dbinary) from hll2')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
## test super table
tdSql.query('select hyperloglog(dnchar) from shll')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 3)
# test group by
#group by column
tdSql.query('select hyperloglog(dnchar) from shll group by dnchar')
tdSql.checkRows(4)
tdSql.checkData(0, 0, 0)
tdSql.checkData(1, 0, 1)
tdSql.checkData(2, 0, 1)
tdSql.checkData(3, 0, 1)
tdSql.query('select hyperloglog(dsmall) from shll group by dnchar')
tdSql.checkRows(4)
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 0, 1)
tdSql.checkData(2, 0, 1)
tdSql.checkData(3, 0, 2)
tdSql.query('select hyperloglog(dsmall) from hll2 group by dnchar')
tdSql.checkRows(3)
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 0, 0)
tdSql.checkData(2, 0, 2)
#group by tbname
tdSql.query('select hyperloglog(dsmall) from shll group by tbname')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 2)
tdSql.checkData(1, 0, 3)
#group by tag
tdSql.query('select hyperloglog(dnchar) from shll group by tint')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 2)
tdSql.checkData(1, 0, 2)
#test order by
#order by column [desc]
tdSql.query('select hyperloglog(dnchar) from shll group by dnchar order by dnchar desc')
tdSql.checkRows(4)
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 0, 1)
tdSql.checkData(2, 0, 1)
tdSql.checkData(3, 0, 0)
#order by tag
tdSql.query('select hyperloglog(dsmall) from shll group by tint order by tint desc')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 3)
tdSql.checkData(1, 0, 2)
# error
tdSql.error("select hyperloglog(ts,1) from shll")
#interval
tdSql.query('select hyperloglog(dnchar) from shll interval(1s)')
tdSql.checkRows(7)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 1)
tdSql.checkData(2, 0, "2021-12-24 00:31:34")
tdSql.checkData(2, 1, 0)
tdSql.checkData(3, 1, 1)
tdSql.checkData(4, 1, 1)
tdSql.checkData(5, 1, 1)
tdSql.checkData(6, 1, 1)
tdSql.query('select hyperloglog(dnchar) from shll interval(1w)')
tdSql.checkRows(4)
tdSql.checkData(0, 1, 2)
tdSql.checkData(1, 1, 0)
tdSql.checkData(2, 1, 1)
tdSql.checkData(3, 1, 1)
#state_window
tdSql.query('select hyperloglog(dnchar) from hll2 state_window(dsmall)')
tdSql.checkRows(5)
#session
tdSql.query('select hyperloglog(dbinary) from hll2 session(ts,2w)')
tdSql.checkRows(2)
tdSql.checkData(0, 0, "2021-10-15 00:31:33")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 0, "2021-12-24 00:31:34")
tdSql.checkData(1, 1, 1)
#where
tdSql.query('select hyperloglog(dbinary) from shll where dnchar="试试"')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.query('select hyperloglog(dbinary) from shll where ts <= "2022-01-01 08:00:05"')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
#slimit/soffset
tdSql.query('select hyperloglog(dsmall) from shll group by dnchar slimit 2 soffset 2')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 0, 2)
#limit/offset
tdSql.query('select hyperloglog(dnchar) from shll interval(1s) limit 1,3')
tdSql.checkRows(3)
tdSql.checkData(0, 0, "2021-10-17 00:31:31")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 0)
tdSql.checkData(2, 1, 1)
#having
tdSql.query('select hyperloglog(dsmall) from shll group by dnchar having hyperloglog(dsmall)>1')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
#subquery
tdSql.query('select hyperloglog(dbinary) from (select dbinary from shll where dnchar = "试试")')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
#union
tdSql.query('select hyperloglog(dtiny) from hll1 union all select hyperloglog(dtiny) from hll2')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 2)
tdSql.checkData(1, 0, 5)
#join
tdSql.execute('create table shll1 (ts timestamp, dbig bigint, dsmall smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dnchar nchar(4093), dbinary binary(64), dtime timestamp) tags (tbinary nchar(4093), tint int)')
tdSql.execute('create table hll11 using shll1 tags ("t1", 1)')
tdSql.execute('insert into hll11 values("2021-10-17 00:31:31", 1, -3276, true, 253, 3.32333, 4.984392323, "你好", "sddd", 333) ("2022-01-24 00:31:32", 1, -32767, false, 254, NULL, 4.982392323, "你好吗", "sdf",2323)')
tdSql.query('select hyperloglog(shll1.ddouble) from shll, shll1 where shll.ts=shll1.ts and shll.tint=shll1.tint')
tdSql.checkRows(1)
tdSql.checkData(0, 0, 2)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -117,15 +117,15 @@ class TDTestCase:
tdSql.execute('insert into D002 values("2021-11-17 20:31:31", 1, 3276, true, NULL, 3.32322, 4.982392323, "你好吗", "sdf", 333)')
tdSql.query('select mode(num) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 3276)
tdSql.checkData(1, 0, None)
tdSql.checkData(1, 0, 3276)
tdSql.checkData(0, 0, None)
tdSql.query('select mode(dfloat) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, None)
tdSql.query('select mode(dchar) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, "你好吗")
tdSql.checkData(1, 0, "试试")
tdSql.checkData(1, 0, "你好吗")
tdSql.checkData(0, 0, "试试")
tdSql.query('select mode(dchar) from smode group by dchar')
tdSql.checkRows(4)
tdSql.query('select mode(dbool) from smode group by dchar')
......@@ -144,7 +144,7 @@ class TDTestCase:
tdSql.checkData(1, 1, "d002")
#group by tag
tdSql.query('select mode(ddouble) from smode group by location')
tdSql.query('select mode(ddouble) from smode group by location order by location desc')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 4.982392323)
tdSql.checkData(0, 1, "Beijing.haidian")
......
......@@ -116,10 +116,10 @@ class TDTestCase:
#group by column
tdSql.query('select tail(dtiny,2) from tail2 group by dnchar')
tdSql.checkRows(5)
tdSql.checkData(0, 0, "2021-10-15 00:31:33")
tdSql.checkData(0, 1, 23)
tdSql.checkData(2, 0, "2021-12-24 00:31:34")
tdSql.checkData(2, 1, None)
tdSql.checkData(2, 0, "2021-10-15 00:31:33")
tdSql.checkData(2, 1, 23)
tdSql.checkData(1, 0, "2021-12-24 00:31:34")
tdSql.checkData(1, 1, None)
tdSql.checkData(4, 0, "2022-01-01 08:00:07")
tdSql.checkData(4, 1, 25)
tdSql.query('select tail(dtiny,2,1) from tail2 group by dnchar')
......@@ -130,8 +130,8 @@ class TDTestCase:
tdSql.checkData(0, 1, 123)
tdSql.checkData(2, 0, "2021-10-17 00:31:31")
tdSql.checkData(2, 1, 253)
tdSql.checkData(4, 0, "2022-01-01 08:00:07")
tdSql.checkData(4, 1, 25)
tdSql.checkData(6, 0, "2022-01-01 08:00:07")
tdSql.checkData(6, 1, 25)
tdSql.query('select tail(dtiny,2,1) from stail group by dnchar')
tdSql.checkRows(5)
......
......@@ -142,11 +142,11 @@ class TDTestCase:
tdSql.query('select ts,unique(voltage) from unique group by location')
tdSql.checkRows(8)
tdSql.checkData(0, 2, 1)
tdSql.checkData(0, 3, "Beijing.haidian")
tdSql.checkData(3, 2, 1)
tdSql.checkData(3, 3, "Beijing.Chaoyang")
tdSql.checkData(5, 2, 1)
tdSql.checkData(5, 3, "Beijing.Tongzhou")
tdSql.checkData(5, 3, "Beijing.haidian")
tdSql.checkData(0, 2, 1)
tdSql.checkData(0, 3, "Beijing.Chaoyang")
tdSql.checkData(2, 2, 1)
tdSql.checkData(2, 3, "Beijing.Tongzhou")
#group by ts
tdSql.query('select ts,unique(voltage) from unique group by ts')
tdSql.checkRows(9)
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import os
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def caseDescription(self):
'''
[TD-13928] taosBenchmark improve user interface
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
cmd = "taosBenchmark -f ./5-taos-tools/taosbenchmark/json/custom_col_tag.json"
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.execute("reset query cache")
tdSql.query("describe db.stb")
tdSql.checkData(0, 0, "ts")
tdSql.checkData(1, 0, "first")
tdSql.checkData(2, 0, "second")
tdSql.checkData(3, 0, "second_1")
tdSql.checkData(4, 0, "second_2")
tdSql.checkData(5, 0, "second_3")
tdSql.checkData(6, 0, "second_4")
tdSql.checkData(7, 0, "third")
tdSql.checkData(8, 0, "forth")
tdSql.checkData(9, 0, "forth_1")
tdSql.checkData(10, 0, "forth_2")
tdSql.checkData(11, 0, "single")
tdSql.checkData(12, 0, "multiple")
tdSql.checkData(13, 0, "multiple_1")
tdSql.checkData(14, 0, "multiple_2")
tdSql.checkData(15, 0, "multiple_3")
tdSql.checkData(16, 0, "multiple_4")
tdSql.checkData(17, 0, "thensingle")
tdSql.checkData(18, 0, "thenmultiple")
tdSql.checkData(19, 0, "thenmultiple_1")
tdSql.checkData(20, 0, "thenmultiple_2")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
......@@ -70,6 +70,59 @@ class TDTestCase:
tdSql.checkData(27, 1, "SMALLINT UNSIGNED")
tdSql.checkData(28, 1, "BINARY")
tdSql.checkData(28, 2, 19)
tdSql.query("select count(*) from db.stb where c0 >= 0 and c0 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c1 >= 0 and c1 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c2 >= 0 and c2 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c3 >= 0 and c3 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c4 >= 0 and c4 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c5 >= 0 and c5 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c6 >= 0 and c6 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c8 = 'd1' or c8 = 'd2'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c9 >= 0 and c9 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c10 >= 0 and c10 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c11 >= 0 and c11 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c12 >= 0 and c12 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c13 = 'b1' or c13 = 'b2'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t0 >= 0 and t0 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t1 >= 0 and t1 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t2 >= 0 and t2 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t3 >= 0 and t3 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t4 >= 0 and t4 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t5 >= 0 and t5 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t6 >= 0 and t6 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t8 = 'd1' or t8 = 'd2'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t9 >= 0 and t9 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t10 >= 0 and t10 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t11 >= 0 and t11 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t12 >= 0 and t12 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t13 = 'b1' or t13 = 'b2'")
tdSql.checkData(0, 0, 160)
cmd = "taosBenchmark -f ./5-taos-tools/taosbenchmark/json/sml_insert_alltypes.json"
tdLog.info("%s" % cmd)
......@@ -192,6 +245,58 @@ class TDTestCase:
tdSql.checkData(27, 1, "SMALLINT UNSIGNED")
tdSql.checkData(28, 1, "BINARY")
tdSql.checkData(28, 2, 19)
tdSql.query("select count(*) from db.stb where c0 >= 0 and c0 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c1 >= 0 and c1 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c2 >= 0 and c2 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c3 >= 0 and c3 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c4 >= 0 and c4 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c5 >= 0 and c5 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c6 >= 0 and c6 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c8 like 'd1%' or c8 like 'd2%'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c9 >= 0 and c9 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c10 >= 0 and c10 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c11 >= 0 and c11 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c12 >= 0 and c12 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where c13 like 'b1%' or c13 like 'b2%'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t0 >= 0 and t0 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t1 >= 0 and t1 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t2 >= 0 and t2 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t3 >= 0 and t3 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t4 >= 0 and t4 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t5 >= 0 and t5 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t6 >= 0 and t6 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t8 like 'd1%' or t8 like 'd2%'")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t9 >= 0 and t9 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t10 >= 0 and t10 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t11 >= 0 and t11 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t12 >= 0 and t12 <= 10")
tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb where t13 like 'b1%' or t13 like 'b2%'")
tdSql.checkData(0, 0, 160)
def stop(self):
......
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 4,
"thread_pool_size": 20,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"prepared_rand": 10,
"chinese": "no",
"insert_interval": 0,
"num_of_records_per_req": 10,
"databases": [{
"dbinfo": {
"name": "db",
"drop": "yes",
"replica": 1,
"days": 10,
"cache": 16,
"blocks": 8,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 1
},
"super_tables": [{
"name": "stb",
"child_table_exists":"no",
"childtable_count": 8,
"childtable_prefix": "stb_",
"escape_character": "yes",
"auto_create_table": "no",
"batch_create_tbl_num": 10,
"data_source": "rand",
"insert_mode": "taosc",
"line_protocol": "line",
"childtable_limit": -10,
"childtable_offset": 10,
"insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"partial_col_num": 0,
"columns": [{
"type": "INT",
"name": "first"
}, {
"type": "UINT",
"name": "second",
"count": 5
},{
"type": "double",
"name": "third"
},{
"type": "float",
"name": "forth",
"count": 3
}],
"tags": [{
"type": "INT",
"name": "single"
}, {
"type": "UINT",
"name": "multiple",
"count": 5
},{
"type": "double",
"name": "thensingle"
},{
"type": "float",
"name": "thenmultiple",
"count": 3
}]
}]
}]
}
\ No newline at end of file
......@@ -55,8 +55,17 @@
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
"partial_col_num": 999,
"columns": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 29, "count":1,
"values": ["d1", "d2"]
}, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 23, "count":1,
"values": ["b1","b2"]
}],
"tags": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 17, "count":1,
"values": ["d1", "d2"]
}, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 19, "count":1,
"values": ["b1","b2"]
}]
}]
}]
}
......@@ -56,8 +56,16 @@
"use_sample_ts": "no",
"tags_file": "",
"partial_col_num": 999,
"columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
"columns": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 29, "count":1,
"values": ["d1", "d2"]
}, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 23, "count":1,
"values": ["b1","b2"]
}],
"tags": [{"type": "TIMESTAMP","max": 10, "min": 0},{"type": "INT","max": 10, "min": 0}, {"type": "BIGINT","max": 10, "min": 0}, {"type": "FLOAT","max": 10, "min": 0}, {"type": "DOUBLE","max": 10, "min": 0}, {"type": "SMALLINT","max": 10, "min": 0}, {"type": "TINYINT","max": 10, "min": 0}, {"type": "BOOL","max": 10, "min": 0}, {"type": "NCHAR","len": 17, "count":1,
"values": ["d1", "d2"]
}, {"type": "UINT","max": 10, "min": 0}, {"type": "UBIGINT","max": 10, "min": 0}, {"type": "UTINYINT","max": 10, "min": 0}, {"type": "USMALLINT","max": 10, "min": 0}, {"type": "BINARY", "len": 19, "count":1,
"values": ["b1","b2"]
}]
}]
}]
}
......@@ -98,10 +98,13 @@ class TDTestCase:
tdSql.checkData(0, 0, 't2')
tdSql.checkData(1, 0, 't1')
tdSql.query("select btag from st")
tdSql.checkRows(2)
tdSql.query("select btag from st where tbname = 't1'")
tdSql.checkRows(1)
tdSql.checkData(0, 0, "test")
tdSql.query("select btag from st where tbname = 't2'")
tdSql.checkRows(1)
tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, "test")
tdSql.query("select * from st where btag = 'test'")
tdSql.checkRows(2)
......
......@@ -303,7 +303,7 @@
20,,script,./test.sh -f general/parser/auto_create_tb_drop_tb.sim
20,,script,./test.sh -f general/import/basic.sim
20,2,script,./test.sh -f general/alter/dnode.sim
20,,script,./test.sh -f general/compute/cast.sim
20,,script,eval sh -c \"if [ `uname -m` != aarch64 ]; then ./test.sh -f general/compute/cast.sim; fi\"
20,,script,./test.sh -f general/compute/string_funcs.sim
20,,develop-test,python3 test.py -f 2-query/lower_func.py
20,,develop-test,python3 test.py -f 2-query/upper_func.py
......@@ -560,11 +560,12 @@
10,,script,./test.sh -f unique/stable/replica2_vnode3.sim
10,,pytest,python3 testCompress.py
10,,pytest,python3 test.py -f client/client.py
10,,script,./test.sh -f general/parser/scalar_expression.sim
10,,script,eval sh -c \"if [ `uname -m` != aarch64 ]; then ./test.sh -f general/parser/scalar_expression.sim; fi\"
10,,script,./test.sh -f general/compute/scalar_pow.sim
9,,script,./test.sh -f general/parser/alter1.sim
9,,script,./test.sh -f general/db/delete.sim
9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py
9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py
9,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py
9,,pytest,python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py
9,,pytest,python3 test.py -f stream/showStreamExecTimeisNull.py
9,,pytest,python3 test.py -f query/bug1876.py
......@@ -788,7 +789,7 @@
3,,pytest,python3 test.py -f tag_lite/binary.py
3,,pytest,python3 test.py -f query/filterAllIntTypes.py
3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py
3,,script,./test.sh -f general/compute/scalar_triangle.sim
3,,script,eval sh -c \"if [ `uname -m` != aarch64 ]; then ./test.sh -f general/compute/scalar_triangle.sim; fi\"
3,,script,./test.sh -f general/compute/scalar_str_concat_len.sim
3,,develop-test,python3 ./test.py -f 2-query/function_tail.py
2,,develop-test,python3 ./test.py -f 2-query/function_unique.py
......
......@@ -272,10 +272,11 @@ function run_thread() {
flock -x $lock_file -c "echo \"${hosts[index]} ret:${ret} ${line}\" >>$log_dir/failed.log"
mkdir -p $log_dir/${case_file}.coredump
local remote_coredump_dir="${workdirs[index]}/tmp/thread_volume/$thread_no/coredump"
cmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/"
local scpcmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
if [ -z ${passwords[index]} ]; then
cmd="scp -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/"
scpcmd="scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
fi
cmd="$scpcmd:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/"
$cmd # 2>/dev/null
local case_info=`echo "$line"|cut -d, -f 3,4`
local corefile=`ls $log_dir/${case_file}.coredump/`
......@@ -287,6 +288,15 @@ function run_thread() {
echo -e "\e[34m log file: $log_dir/$case_file.log \e[0m"
if [ ! -z "$corefile" ]; then
echo -e "\e[34m corefiles: $corefile \e[0m"
local build_dir=$log_dir/build_${hosts[index]}
local remote_build_dir="${workdirs[index]}/TDinternal/debug/build"
mkdir $build_dir 2>/dev/null
if [ $? -eq 0 ]; then
# scp build binary
cmd="$scpcmd:${remote_build_dir}/* ${build_dir}/"
echo "$cmd"
$cmd >/dev/null
fi
fi
fi
done
......
......@@ -84,10 +84,10 @@ class WorkerThread:
# self._thread = threading.Thread(target=runThread, args=(self,))
self._thread = threading.Thread(target=self.run)
self._stepGate = threading.Event()
# Let us have a DB connection of our own
if (Config.getConfig().per_thread_db_connection): # type: ignore
# print("connector_type = {}".format(gConfig.connector_type))
# print("connector_type = {}".format(Config.getConfig().connector_type))
tInst = gContainer.defTdeInstance
if Config.getConfig().connector_type == 'native':
self._dbConn = DbConn.createNative(tInst.getDbTarget())
......@@ -963,7 +963,7 @@ class StateMechine:
# did not do this when openning connection, and this is NOT the worker
# thread, which does this on their own
dbc.use(dbName)
if not dbc.hasTables(): # no tables
if not dbc.hasTables(dbName): # no tables
Logging.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time()))
return StateDbOnly()
......@@ -1434,6 +1434,7 @@ class Task():
# TODO: refactor away, just provide the dbConn
def execWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread
""" Haha """
# print("thread %d runing sql is : %s " %(wt._tid , sql) )
return wt.execSql(sql)
def queryWtSql(self, wt: WorkerThread, sql): # execute an SQL on the worker thread
......@@ -1690,6 +1691,9 @@ class TdSuperTable:
def getName(self):
return self._stName
def getFullTableName(self):
return self._dbName + '.' + self._stName
def drop(self, dbc, skipCheck = False):
dbName = self._dbName
if self.exists(dbc) : # if myself exists
......@@ -1701,7 +1705,7 @@ class TdSuperTable:
def exists(self, dbc):
dbc.execute("USE " + self._dbName)
return dbc.existsSuperTable(self._stName)
return dbc.existsSuperTable(self._dbName, self._stName)
# TODO: odd semantic, create() method is usually static?
def create(self, dbc, cols: TdColumns, tags: TdTags, dropIfExists = False):
......@@ -1710,7 +1714,7 @@ class TdSuperTable:
dbName = self._dbName
dbc.execute("USE " + dbName)
fullTableName = dbName + '.' + self._stName
if dbc.existsSuperTable(self._stName):
if dbc.existsSuperTable(dbName, self._stName):
if dropIfExists:
dbc.execute("DROP TAbLE {}".format(fullTableName))
else: # error
......@@ -2491,7 +2495,7 @@ class MainExec:
action='store',
default='native',
type=str,
help='Connector type to use: native, rest, or mixed (default: 10)')
help='Connector type to use: native, rest, or mixed (default: native)')
parser.add_argument(
'-d',
'--debug',
......@@ -2552,7 +2556,7 @@ class MainExec:
'-r',
'--record-ops',
action='store_true',
help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)')
help='Use a pair of always-fsynced files to record operations performing + performed, for power-off tests (default: false)')
parser.add_argument(
'-s',
'--max-steps',
......
......@@ -164,6 +164,9 @@ quorum 2
def getExecFile(self): # .../taosd
return self._buildDir + "/build/bin/taosd"
def getAdapterFile(self): # .../taosadapter for restful
return self._buildDir + "/build/bin/taosadapter"
def getRunDir(self) -> DirPath : # TODO: rename to "root dir" ?!
if Config.getConfig().set_path =='': # use default path
......@@ -187,6 +190,31 @@ quorum 2
else:
# TODO: move "exec -c" into Popen(), we can both "use shell" and NOT fork so ask to lose kill control
return ["exec " + self.getExecFile(), '-c', self.getCfgDir()] # used in subproce.Popen()
def getAdapterCmdLine(self):
REST_PORT_INCREMENT = 11
Adapter_ports =str(self._port + REST_PORT_INCREMENT)
AdapterCmds = [self.getAdapterFile() + ' --port='+ Adapter_ports +
' --log.path='+ self.getLogDir() + ' --taosConfigDir='+self.getCfgDir()+
' --collectd.enable=false' +
' --influxdb.enable=false --node_exporter.enable=false' +
' --opentsdb.enable=false --statsd.enable=false' +
' --prometheus.enable=false --opentsdb_telnet.enable=false'] # get adapter cmd string
return AdapterCmds
def start_Adapter(self,cmdLine):
# print('nohup '+' '.join(cmdLine)+ '>>taosadapter.log 2>&1 &')
cmds = 'nohup '+' '.join(cmdLine)+ '>>taosadapter.log 2>&1 &'
ret = Popen(
cmds,
shell=True,
stdout=PIPE,
stderr=PIPE,
)
time.sleep(0.1) # very brief wait, then let's check if sub process started successfully.
if ret.poll():
raise CrashGenError("Sub process failed to start with command line: {}".format(cmdLine))
return ret
def _getDnodes(self, dbc):
dbc.query("show dnodes")
......@@ -230,6 +258,10 @@ quorum 2
# self._smThread.start(self.getServiceCmdLine(), self.getLogDir()) # May raise exceptions
self._subProcess = TdeSubProcess(self.getServiceCmdLine(), self.getLogDir())
# run taosadapter by subprocess ,taosadapter is stateless with TDengine ,so it don't need monitor
self.start_Adapter(self.getAdapterCmdLine())
print(' '.join(self.getAdapterCmdLine()))
def stop(self):
self._subProcess.stop()
self._subProcess = None
......
......@@ -100,13 +100,13 @@ class DbConn:
# print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName)))
return dbName in dbs # TODO: super weird type mangling seen, once here
def existsSuperTable(self, stName):
self.query("show stables")
def existsSuperTable(self, dbName, stName):
self.query("show {}.stables".format(dbName))
sts = [v[0] for v in self.getQueryResult()]
return stName in sts
def hasTables(self):
return self.query("show tables") > 0
def hasTables(self, dbName):
return self.query("show {}.tables".format(dbName)) > 0
def execute(self, sql):
''' Return the number of rows affected'''
......
......@@ -135,9 +135,9 @@ class TDTestCase:
tdSql.execute("insert into std3 values(now + 5s, 4);")
tdSql.execute("insert into std3 values(now + 6s, 8);")
tdSql.query("select stddev(col1) from stdtable group by loc;")
tdSql.checkData(0, 0, 2.0)
tdSql.checkData(2, 0, 2.0)
tdSql.checkData(1, 0, 0.5)
tdSql.checkData(2, 0, 0.5)
tdSql.checkData(0, 0, 0.5)
tdSql.execute("create table stdtableint(ts timestamp, col1 int) tags(num int)")
tdSql.execute("create table stdint1 using stdtableint tags(1)")
......
......@@ -49,13 +49,13 @@ class TDTestCase:
tdSql.query('select last(*) from mt0 group by c8')
tdSql.checkData(0,3,5)
tdSql.checkData(0,4,20)
tdSql.checkData(3,1,92)
tdSql.checkData(3,9,'涛思8')
tdSql.checkData(3,1,57)
tdSql.checkData(3,9,'涛思14')
tdSql.query('select last(*) from mt0 group by c9')
tdSql.checkData(0,3,0)
tdSql.checkData(0,8,'taos38')
tdSql.checkData(40,1,83)
tdSql.checkData(40,3,40)
tdSql.checkData(35,1,83)
tdSql.checkData(35,3,40)
def stop(self):
tdSql.close()
......
......@@ -51,19 +51,19 @@ class TDTestCase:
tdSql.checkRows(0)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 70 offset 3')
tdSql.checkRows(38)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset 2')
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset 12')
tdSql.checkData(0,0,91)
tdSql.checkData(0,1,2)
tdSql.checkData(0,2,2)
tdSql.checkData(0,3,91)
tdSql.checkData(1,0,92)
tdSql.checkData(2,1,4)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset 9')
tdSql.checkData(0,0,96)
tdSql.checkData(0,1,1)
tdSql.checkData(0,2,9)
tdSql.checkData(0,3,93)
tdSql.checkData(1,0,97)
tdSql.checkData(1,0,94)
tdSql.checkData(2,1,7)
tdSql.query('select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset 39')
tdSql.checkData(1,0,96)
tdSql.checkData(1,1,1)
tdSql.checkData(1,2,9)
tdSql.checkData(0,3,92)
tdSql.checkData(0,0,95)
def stop(self):
tdSql.close()
......
......@@ -303,11 +303,11 @@ class TDTestCase:
tdSql.checkRows(10)
# > for binary type on tag
tdSql.query("select * from st where tagcol3 > '表'")
tdSql.query("select * from st where tagcol3 < '表'")
tdSql.checkRows(10)
# >= for binary type on tag
tdSql.query("select * from st where tagcol3 >= '表'")
tdSql.query("select * from st where tagcol3 <= '表'")
tdSql.checkRows(10)
# = for binary type on tag
......
......@@ -198,6 +198,28 @@ class TDTestCase:
tdLog.info("case for TS-636")
self.escape_ascii()
# TS-1304
tdLog.info("case for JIRA TS-1304")
tdSql.execute("create stable devices (ts timestamp,tempature int,humity float,`1name` int ) tags (`1devid` int,devname binary(20))")
tdSql.execute("insert into devices_001 using devices tags (111,'zzm') values (now,10001,1,1)")
tdSql.execute("insert into devices_001 using devices tags (222,'cxd') values (now + 1s,10002,2,2)")
tdSql.execute("insert into devices_001 using devices tags (333,'cyt') values (now + 2s,10002,2,2)")
tdSql.error("select 1name from devices")
tdSql.error("select 1name from devices_001")
tdSql.error("select 1devid from devices")
tdSql.error("select 1devid from devices_001")
tdSql.query("select `1name` from devices_001")
tdSql.checkRows(3)
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 0, 2)
tdSql.checkData(2, 0, 2)
tdSql.query("select `1devid` from devices_001")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 111)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......
......@@ -18,6 +18,8 @@ from util.cases import *
from util.sql import *
import numpy as np
# constant define
WAITS = 5 # wait seconds
class TDTestCase:
def init(self, conn, logSql):
......@@ -67,9 +69,7 @@ class TDTestCase:
"%s failed: sql:%s, the order provided for col:%d is not correct" %
(callerFilename, tdSql.sql, col))
def run(self):
tdSql.prepare()
def test_base(self):
print("======= step 1: create table and insert data =========")
tdLog.debug(
''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double,
......@@ -183,6 +183,44 @@ class TDTestCase:
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
def create_insert_data(self):
sql = "create table sb(ts timestamp, i1 int) tags(t_b1 binary(32), t_n1 nchar(64));"
tdSql.execute(sql)
for i in range(20):
value = "%s%s%s" % (chr(64+i),chr(64+i),chr(65+i))
if i%10 == 5:
value += "_%s" % (chr(66+i))
if i%10 == 0:
value += "_%s" % (chr(67+i))
sql = "insert into b%d using sb tags('A%s', 'B%s') values(now, %d);"%(i, value, value, i+1000)
tdSql.execute(sql)
def test_groupby_order(self):
# create and insert data
print("======= group order step 1: create table and insert data =========")
self.create_insert_data()
# do query
print("======= group order step 2: do query =========")
# ASC
sql = "select count(*) from sb group by t_b1 order by t_b1 asc;"
tdSql.execute(sql)
tdSql.waitedQuery(sql, 20, WAITS)
tdSql.checkData(0, 1, "A@@A_C")
tdSql.checkData(5, 1, "AEEF_G")
tdSql.checkData(19, 1, "ASST")
#DESC
sql = "select count(*) from sb group by t_b1 order by t_b1 desc;"
tdSql.execute(sql)
tdSql.waitedQuery(sql, 20, WAITS)
tdSql.checkData(19, 1, "A@@A_C")
tdSql.checkData(4, 1, "AOOP_Q")
tdSql.checkData(0, 1, "ASST")
def run(self):
tdSql.prepare()
self.test_base()
self.test_groupby_order()
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -150,15 +150,22 @@ if __name__ == "__main__":
numOfNodes = ucase.updatecfgDict.get('numOfNodes')
cluster.init(numOfNodes, dataDir)
cluster.prepardBuild()
startArbitrator = False
arbitratorHost = "tdnode1"
for i in range(numOfNodes):
if ucase.updatecfgDict.get('%d' % (i + 1)) != None:
config = dict (ucase.updatecfgDict.get('%d' % (i + 1)))
print(config)
for key, value in config.items():
print(key, value, i + 1)
cluster.cfg(key, value, i + 1)
if key == "arbitrator":
startArbitrator = True
arbitratorHost = value
cluster.cfg(key, value, i + 1)
cluster.run()
if startArbitrator:
hostname=value.split(":")[0]
cluster.startArbitrator(hostname)
conn = cluster.conn
except Exception as e:
print(e.args)
......
......@@ -142,10 +142,8 @@ class BuildDockerCluser:
print("create dnode tdnode%d" % i)
self.cursor.execute("create dnode tdnode%d" % i)
def startArbitrator(self):
for i in range(1, self.numOfNodes + 1):
self.cfg("arbitrator", "tdnode1:6042", i)
cmd = "docker exec -d $(docker ps|grep tdnode1|awk '{print $1}') tarbitrator"
def startArbitrator(self, hostname = 'tdnode1'):
cmd = "docker exec -d $(docker ps|grep '%s'|awk '{print $1}') tarbitrator" % hostname
self.execCmd(cmd)
def prepardBuild(self):
......
......@@ -116,7 +116,7 @@ if $data00 != NULL then
return -1
endi
sql select count(*), a from mt_unsigned_1 group by a;
sql select count(*), a from mt_unsigned_1 group by a order by a desc;
if $rows != 2 then
return -1
endi
......@@ -137,7 +137,7 @@ if $data11 != 1 then
return -1
endi
sql select count(*), b from mt_unsigned_1 group by b;
sql select count(*), b from mt_unsigned_1 group by b order by b desc;
if $rows != 2 then
return -1
endi
......@@ -158,7 +158,7 @@ if $data11 != 2 then
return -1
endi
sql select count(*), c from mt_unsigned_1 group by c;
sql select count(*), c from mt_unsigned_1 group by c order by c desc;
if $rows != 2 then
return -1
endi
......@@ -179,7 +179,7 @@ if $data11 != 3 then
return -1
endi
sql select count(*), d from mt_unsigned_1 group by d;
sql select count(*), d from mt_unsigned_1 group by d order by d desc;
if $rows != 2 then
return -1
endi
......
......@@ -594,7 +594,8 @@ if $data10 != @{slop:0.000000, intercept:1.000000}@ then
return -1
endi
if $data90 != @{slop:0.000000, intercept:9.000000}@ then
if $data90 != @{slop:0.000000, intercept:17.000000}@ then
print " data90 expect: {slop:0.000000, intercept:17.000000} real:"$data90
return -1
endi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册