Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
dd6f16ff
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dd6f16ff
编写于
9月 29, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-10396
上级
612e6771
d182e031
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
455 addition
and
205 deletion
+455
-205
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+37
-14
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+271
-145
tests/connectorTest/C#Test/nanosupport/nanotest.cs
tests/connectorTest/C#Test/nanosupport/nanotest.cs
+13
-46
tests/pytest/client/nettest.py
tests/pytest/client/nettest.py
+57
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+5
-0
tests/pytest/insert/schemaChangeTest.py
tests/pytest/insert/schemaChangeTest.py
+72
-0
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
dd6f16ff
...
@@ -986,36 +986,55 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -986,36 +986,55 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
performance_print
=
true
;
arguments
->
performance_print
=
true
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--port"
,
strlen
(
"--port"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--port"
,
strlen
(
"--port"
))))
{
uint64_t
port
;
char
strPort
[
BIGINT_BUFF_LEN
];
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg
(
argv
[
0
],
"P"
);
errorPrintReqArg
(
argv
[
0
],
"P"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
}
else
if
(
isStringNumber
(
argv
[
i
+
1
]))
{
tstrncpy
(
strPort
,
argv
[
++
i
],
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"P"
);
errorPrintReqArg2
(
argv
[
0
],
"P"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--port="
,
strlen
(
"--port="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--port="
,
strlen
(
"--port="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
))))
{
arguments
->
port
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
)));
tstrncpy
(
strPort
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
)),
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
))))
{
arguments
->
port
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
)));
tstrncpy
(
strPort
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
)),
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
strlen
(
"--port"
)
==
strlen
(
argv
[
i
]))
{
}
else
if
(
strlen
(
"--port"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--port"
);
errorPrintReqArg3
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
}
else
if
(
isStringNumber
(
argv
[
i
+
1
]))
{
tstrncpy
(
strPort
,
argv
[
++
i
],
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnrecognized
(
argv
[
0
],
argv
[
i
]);
errorUnrecognized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
port
=
atoi
(
strPort
);
if
(
port
>
65535
)
{
errorWrongValue
(
"taosdump"
,
"-P or --port"
,
strPort
);
exit
(
EXIT_FAILURE
);
}
arguments
->
port
=
(
uint16_t
)
port
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-I"
,
strlen
(
"-I"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-I"
,
strlen
(
"-I"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--interface"
,
strlen
(
"--interface"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--interface"
,
strlen
(
"--interface"
))))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
...
@@ -1581,7 +1600,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1581,7 +1600,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&&
strcasecmp
(
dataType
,
"BIGINT"
)
&&
strcasecmp
(
dataType
,
"BIGINT"
)
&&
strcasecmp
(
dataType
,
"DOUBLE"
)
&&
strcasecmp
(
dataType
,
"DOUBLE"
)
&&
strcasecmp
(
dataType
,
"TIMESTAMP"
)
&&
strcasecmp
(
dataType
,
"TIMESTAMP"
)
&&
!
regexMatch
(
dataType
,
"^(NCHAR|BINARY)(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
)
&&
!
regexMatch
(
dataType
,
"^(NCHAR|BINARY)(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
)
&&
strcasecmp
(
dataType
,
"UTINYINT"
)
&&
strcasecmp
(
dataType
,
"UTINYINT"
)
&&
strcasecmp
(
dataType
,
"USMALLINT"
)
&&
strcasecmp
(
dataType
,
"USMALLINT"
)
&&
strcasecmp
(
dataType
,
"UINT"
)
&&
strcasecmp
(
dataType
,
"UINT"
)
...
@@ -1603,11 +1624,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1603,11 +1624,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_FLOAT
;
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"DOUBLE"
))
{
}
else
if
(
0
==
strcasecmp
(
dataType
,
"DOUBLE"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_DOUBLE
;
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
1
==
regexMatch
(
dataType
,
"^BINARY(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
}
else
if
(
1
==
regexMatch
(
dataType
,
REG_EXTENDED
))
{
"^BINARY(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BINARY
;
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
1
==
regexMatch
(
dataType
,
"^NCHAR(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
}
else
if
(
1
==
regexMatch
(
dataType
,
REG_EXTENDED
))
{
"^NCHAR(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_NCHAR
;
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BOOL"
))
{
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BOOL"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BOOL
;
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BOOL
;
...
@@ -10280,7 +10303,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -10280,7 +10303,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&
stbInfo
->
childTblName
,
&
childTblCount
,
&
stbInfo
->
childTblName
,
&
childTblCount
,
limit
,
limit
,
offset
);
offset
);
ntables
=
childTblCount
;
// CBD
ntables
=
childTblCount
;
}
else
{
}
else
{
ntables
=
g_args
.
ntables
;
ntables
=
g_args
.
ntables
;
tableFrom
=
0
;
tableFrom
=
0
;
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
dd6f16ff
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <stdio.h>
#include <pthread.h>
#include <iconv.h>
#include <iconv.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/syscall.h>
...
@@ -26,6 +28,12 @@
...
@@ -26,6 +28,12 @@
#include "tsdb.h"
#include "tsdb.h"
#include "tutil.h"
#include "tutil.h"
#define AVRO_SUPPORT 0
#if AVRO_SUPPORT == 1
#include <avro.h>
#endif
#define TSDB_SUPPORT_NANOSECOND 1
#define TSDB_SUPPORT_NANOSECOND 1
#define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255
#define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255
...
@@ -128,19 +136,23 @@ enum _describe_table_index {
...
@@ -128,19 +136,23 @@ enum _describe_table_index {
TSDB_MAX_DESCRIBE_METRIC
TSDB_MAX_DESCRIBE_METRIC
};
};
#define COL_NOTE_LEN 128
#define COL_NOTE_LEN 4
#define COL_TYPEBUF_LEN 16
#define COL_VALUEBUF_LEN 32
typedef
struct
{
typedef
struct
{
char
field
[
TSDB_COL_NAME_LEN
+
1
];
char
field
[
TSDB_COL_NAME_LEN
];
char
type
[
16
];
char
type
[
COL_TYPEBUF_LEN
];
int
length
;
int
length
;
char
note
[
COL_NOTE_LEN
];
char
note
[
COL_NOTE_LEN
];
}
SColDes
;
char
value
[
COL_VALUEBUF_LEN
];
char
*
var_value
;
}
ColDes
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_NAME_LEN
];
char
name
[
TSDB_TABLE_NAME_LEN
];
S
ColDes
cols
[];
ColDes
cols
[];
}
S
TableDef
;
}
TableDef
;
extern
char
version
[];
extern
char
version
[];
...
@@ -334,21 +346,17 @@ static int dumpOut();
...
@@ -334,21 +346,17 @@ static int dumpOut();
static
int
dumpIn
();
static
int
dumpIn
();
static
void
dumpCreateDbClause
(
SDbInfo
*
dbInfo
,
bool
isDumpProperty
,
static
void
dumpCreateDbClause
(
SDbInfo
*
dbInfo
,
bool
isDumpProperty
,
FILE
*
fp
);
FILE
*
fp
);
//static int dumpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taos);
static
int
dumpCreateTableClause
(
TableDef
*
tableDes
,
int
numOfCols
,
static
int
dumpStableClasuse
(
SDbInfo
*
dbInfo
,
char
*
table
,
FILE
*
fp
);
static
int
dumpCreateTableClause
(
STableDef
*
tableDes
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
);
FILE
*
fp
,
char
*
dbName
);
static
void
dumpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
);
static
int
getTableDes
(
static
int
getTableDes
(
char
*
dbName
,
char
*
table
,
char
*
dbName
,
char
*
table
,
S
TableDef
*
stableDes
,
bool
isSuperTable
);
TableDef
*
stableDes
,
bool
isSuperTable
);
static
int64_t
dumpTableData
(
FILE
*
fp
,
char
*
tbName
,
static
int64_t
dumpTableData
(
FILE
*
fp
,
char
*
tbName
,
char
*
dbName
,
char
*
dbName
,
int
precision
,
int
precision
,
char
*
jsonAvroSchema
);
char
*
jsonAvroSchema
);
static
int
checkParam
();
static
int
checkParam
();
static
void
taosF
reeDbInfos
();
static
void
f
reeDbInfos
();
struct
arguments
g_args
=
{
struct
arguments
g_args
=
{
// connection option
// connection option
...
@@ -615,6 +623,17 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -615,6 +623,17 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
return
0
;
return
0
;
}
}
static
void
freeTbDes
(
TableDef
*
tableDes
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_COLUMNS
;
i
++
)
{
if
(
tableDes
->
cols
[
i
].
var_value
)
{
free
(
tableDes
->
cols
[
i
].
var_value
);
}
}
free
(
tableDes
);
}
static
int
queryDbImpl
(
TAOS
*
taos
,
char
*
command
)
{
static
int
queryDbImpl
(
TAOS
*
taos
,
char
*
command
)
{
TAOS_RES
*
res
=
NULL
;
TAOS_RES
*
res
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -773,7 +792,7 @@ static int getPrecisionByString(char *precision)
...
@@ -773,7 +792,7 @@ static int getPrecisionByString(char *precision)
return
-
1
;
return
-
1
;
}
}
static
void
taosF
reeDbInfos
()
{
static
void
f
reeDbInfos
()
{
if
(
g_dbInfos
==
NULL
)
return
;
if
(
g_dbInfos
==
NULL
)
return
;
for
(
int
i
=
0
;
i
<
g_args
.
dumpDbCount
;
i
++
)
for
(
int
i
=
0
;
i
<
g_args
.
dumpDbCount
;
i
++
)
tfree
(
g_dbInfos
[
i
]);
tfree
(
g_dbInfos
[
i
]);
...
@@ -899,7 +918,6 @@ static int inDatabasesSeq(
...
@@ -899,7 +918,6 @@ static int inDatabasesSeq(
dbname
=
strsep
(
&
running
,
","
);
dbname
=
strsep
(
&
running
,
","
);
}
}
}
}
return
-
1
;
return
-
1
;
...
@@ -965,10 +983,153 @@ static int getDumpDbCount()
...
@@ -965,10 +983,153 @@ static int getDumpDbCount()
return
count
;
return
count
;
}
}
static
int
convertSchemaToAvroSchema
(
STableDef
*
stableDes
,
char
**
avroSchema
)
static
void
dumpCreateMTableClause
(
char
*
dbName
,
char
*
stable
,
TableDef
*
tableDes
,
int
numOfCols
,
FILE
*
fp
)
{
int
counter
=
0
;
int
count_temp
=
0
;
char
*
tmpBuf
=
(
char
*
)
malloc
(
COMMAND_SIZE
);
if
(
tmpBuf
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to allocate %d memory
\n
"
,
__func__
,
__LINE__
,
COMMAND_SIZE
);
return
;
}
char
*
pstr
=
NULL
;
pstr
=
tmpBuf
;
pstr
+=
sprintf
(
tmpBuf
,
"CREATE TABLE IF NOT EXISTS %s.%s USING %s.%s TAGS ("
,
dbName
,
tableDes
->
name
,
dbName
,
stable
);
for
(;
counter
<
numOfCols
;
counter
++
)
{
if
(
tableDes
->
cols
[
counter
].
note
[
0
]
!=
'\0'
)
break
;
}
assert
(
counter
<
numOfCols
);
count_temp
=
counter
;
for
(;
counter
<
numOfCols
;
counter
++
)
{
if
(
counter
!=
count_temp
)
{
if
(
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"nchar"
)
==
0
)
{
//pstr += sprintf(pstr, ", \'%s\'", tableDes->cols[counter].note);
if
(
tableDes
->
cols
[
counter
].
var_value
)
{
pstr
+=
sprintf
(
pstr
,
", %s"
,
tableDes
->
cols
[
counter
].
var_value
);
}
else
{
pstr
+=
sprintf
(
pstr
,
", %s"
,
tableDes
->
cols
[
counter
].
value
);
}
}
else
{
pstr
+=
sprintf
(
pstr
,
", %s"
,
tableDes
->
cols
[
counter
].
value
);
}
}
else
{
if
(
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"nchar"
)
==
0
)
{
//pstr += sprintf(pstr, "\'%s\'", tableDes->cols[counter].note);
if
(
tableDes
->
cols
[
counter
].
var_value
)
{
pstr
+=
sprintf
(
pstr
,
"%s"
,
tableDes
->
cols
[
counter
].
var_value
);
}
else
{
pstr
+=
sprintf
(
pstr
,
"%s"
,
tableDes
->
cols
[
counter
].
value
);
}
}
else
{
pstr
+=
sprintf
(
pstr
,
"%s"
,
tableDes
->
cols
[
counter
].
value
);
}
/* pstr += sprintf(pstr, "%s", tableDes->cols[counter].note); */
}
/* if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 || strcasecmp(tableDes->cols[counter].type, "nchar")
* == 0) { */
/* pstr += sprintf(pstr, "(%d)", tableDes->cols[counter].length); */
/* } */
}
pstr
+=
sprintf
(
pstr
,
");"
);
fprintf
(
fp
,
"%s
\n
"
,
tmpBuf
);
free
(
tmpBuf
);
}
static
int
convertTbDesToAvroSchema
(
char
*
dbName
,
char
*
tbName
,
TableDef
*
tableDes
,
int
colCount
,
char
**
avroSchema
)
{
{
errorPrint
(
"%s() LN%d TODO: covert table schema to avro schema
\n
"
,
errorPrint
(
"%s() LN%d TODO: covert table schema to avro schema
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
// {
// "namesapce": "database name",
// "type": "record",
// "name": "table name",
// "fields": [
// {
// "name": "col0 name",
// "type": "long"
// },
// {
// "name": "col1 name",
// "type": ["int", "null"]
// },
// {
// "name": "col2 name",
// "type": ["float", "null"]
// },
// ...
// {
// "name": "coln name",
// "type": ["string", "null"]
// }
// ]
// }
*
avroSchema
=
(
char
*
)
calloc
(
1
,
17
+
TSDB_DB_NAME_LEN
/* dbname section */
+
17
/* type: record */
+
11
+
TSDB_TABLE_NAME_LEN
/* tbname section */
+
10
/* fields section */
+
(
TSDB_COL_NAME_LEN
+
11
+
16
)
*
colCount
+
4
);
/* fields section */
if
(
*
avroSchema
==
NULL
)
{
errorPrint
(
"%s() LN%d, memory allocation failed!
\n
"
,
__func__
,
__LINE__
);
return
-
1
;
}
char
*
pstr
=
*
avroSchema
;
pstr
+=
sprintf
(
pstr
,
"{
\"
namespace
\"
:
\"
%s
\"
,
\"
type
\"
:
\"
record
\"
,
\"
name
\"
:
\"
%s
\"
,
\"
fields
\"
: ["
,
dbName
,
tbName
);
for
(
int
i
=
0
;
i
<
colCount
;
i
++
)
{
if
(
0
==
i
)
{
pstr
+=
sprintf
(
pstr
,
"{
\"
name
\"
:
\"
%s
\"
,
\"
type
\"
:
\"
%s
\"
"
,
tableDes
->
cols
[
i
].
field
,
"long"
);
}
else
{
if
(
strcasecmp
(
tableDes
->
cols
[
i
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
i
].
type
,
"nchar"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
"{
\"
name
\"
:
\"
%s
\"
,
\"
type
\"
: [
\"
%s
\"
,
\"
null
\"
]"
,
tableDes
->
cols
[
i
].
field
,
"string"
);
}
else
{
pstr
+=
sprintf
(
pstr
,
"{
\"
name
\"
:
\"
%s
\"
,
\"
type
\"
: [
\"
%s
\"
,
\"
null
\"
]"
,
tableDes
->
cols
[
i
].
field
,
tableDes
->
cols
[
i
].
type
);
}
}
if
((
i
!=
(
colCount
-
1
))
&&
(
strcmp
(
tableDes
->
cols
[
i
+
1
].
note
,
"TAG"
)
!=
0
))
{
pstr
+=
sprintf
(
pstr
,
"},"
);
}
else
{
pstr
+=
sprintf
(
pstr
,
"}"
);
break
;
}
}
pstr
+=
sprintf
(
pstr
,
"]}"
);
debugPrint
(
"%s() LN%d, avroSchema: %s
\n
"
,
__func__
,
__LINE__
,
*
avroSchema
);
return
0
;
return
0
;
}
}
...
@@ -981,20 +1142,20 @@ static int64_t dumpNormalTable(
...
@@ -981,20 +1142,20 @@ static int64_t dumpNormalTable(
)
{
)
{
int
colCount
=
0
;
int
colCount
=
0
;
STableDef
*
tableDes
=
(
STableDef
*
)
calloc
(
1
,
sizeof
(
S
TableDef
)
TableDef
*
tableDes
=
(
TableDef
*
)
calloc
(
1
,
sizeof
(
TableDef
)
+
sizeof
(
S
ColDes
)
*
TSDB_MAX_COLUMNS
);
+
sizeof
(
ColDes
)
*
TSDB_MAX_COLUMNS
);
if
(
stable
!=
NULL
&&
stable
[
0
]
!=
'\0'
)
{
// dump table schema which is created by using super table
if
(
stable
!=
NULL
&&
stable
[
0
]
!=
'\0'
)
{
// dump table schema which is created by using super table
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
if
(
colCount
<
0
)
{
if
(
colCount
<
0
)
{
errorPrint
(
"%s"
,
"getTableDes() failed
\n
"
);
free
(
tableDes
);
free
(
tableDes
);
return
-
1
;
return
-
1
;
}
}
// create child-table using super-table
// create child-table using super-table
dumpCreateMTableClause
(
tableDes
,
stable
,
colCount
,
fp
,
dbName
);
dumpCreateMTableClause
(
dbName
,
stable
,
tableDes
,
colCount
,
fp
);
}
else
{
// dump table definition
}
else
{
// dump table definition
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
...
@@ -1009,7 +1170,11 @@ static int64_t dumpNormalTable(
...
@@ -1009,7 +1170,11 @@ static int64_t dumpNormalTable(
char
*
jsonAvroSchema
=
NULL
;
char
*
jsonAvroSchema
=
NULL
;
if
(
g_args
.
avro
)
{
if
(
g_args
.
avro
)
{
convertSchemaToAvroSchema
(
tableDes
,
&
jsonAvroSchema
);
if
(
0
!=
convertTbDesToAvroSchema
(
dbName
,
tbName
,
tableDes
,
colCount
,
&
jsonAvroSchema
))
{
freeTbDes
(
tableDes
);
return
-
1
;
}
}
}
free
(
tableDes
);
free
(
tableDes
);
...
@@ -1370,6 +1535,34 @@ static int64_t dumpNtbOfStbByThreads(
...
@@ -1370,6 +1535,34 @@ static int64_t dumpNtbOfStbByThreads(
return
records
;
return
records
;
}
}
static
int
dumpStableClasuse
(
SDbInfo
*
dbInfo
,
char
*
stbName
,
FILE
*
fp
)
{
uint64_t
sizeOfTableDes
=
(
uint64_t
)(
sizeof
(
TableDef
)
+
sizeof
(
ColDes
)
*
TSDB_MAX_COLUMNS
);
TableDef
*
tableDes
=
(
TableDef
*
)
calloc
(
1
,
sizeOfTableDes
);
if
(
NULL
==
tableDes
)
{
errorPrint
(
"%s() LN%d, failed to allocate %"
PRIu64
" memory
\n
"
,
__func__
,
__LINE__
,
sizeOfTableDes
);
exit
(
-
1
);
}
int
colCount
=
getTableDes
(
dbInfo
->
name
,
stbName
,
tableDes
,
true
);
if
(
colCount
<
0
)
{
free
(
tableDes
);
errorPrint
(
"%s() LN%d, failed to get stable[%s] schema
\n
"
,
__func__
,
__LINE__
,
stbName
);
exit
(
-
1
);
}
dumpCreateTableClause
(
tableDes
,
colCount
,
fp
,
dbInfo
->
name
);
free
(
tableDes
);
return
0
;
}
static
int64_t
dumpCreateSTableClauseOfDb
(
static
int64_t
dumpCreateSTableClauseOfDb
(
SDbInfo
*
dbInfo
,
FILE
*
fp
)
SDbInfo
*
dbInfo
,
FILE
*
fp
)
{
{
...
@@ -1714,7 +1907,7 @@ static int dumpOut() {
...
@@ -1714,7 +1907,7 @@ static int dumpOut() {
/* Close the handle and return */
/* Close the handle and return */
fclose
(
fp
);
fclose
(
fp
);
taos_free_result
(
result
);
taos_free_result
(
result
);
taosF
reeDbInfos
();
f
reeDbInfos
();
fprintf
(
stderr
,
"dump out rows: %"
PRId64
"
\n
"
,
g_totalDumpOutRows
);
fprintf
(
stderr
,
"dump out rows: %"
PRId64
"
\n
"
,
g_totalDumpOutRows
);
return
0
;
return
0
;
...
@@ -1722,14 +1915,14 @@ _exit_failure:
...
@@ -1722,14 +1915,14 @@ _exit_failure:
fclose
(
fp
);
fclose
(
fp
);
taos_close
(
taos
);
taos_close
(
taos
);
taos_free_result
(
result
);
taos_free_result
(
result
);
taosF
reeDbInfos
();
f
reeDbInfos
();
errorPrint
(
"dump out rows: %"
PRId64
"
\n
"
,
g_totalDumpOutRows
);
errorPrint
(
"dump out rows: %"
PRId64
"
\n
"
,
g_totalDumpOutRows
);
return
-
1
;
return
-
1
;
}
}
static
int
getTableDes
(
static
int
getTableDes
(
char
*
dbName
,
char
*
table
,
char
*
dbName
,
char
*
table
,
STableDef
*
s
tableDes
,
bool
isSuperTable
)
{
TableDef
*
tableDes
,
bool
isSuperTable
)
{
TAOS_ROW
row
=
NULL
;
TAOS_ROW
row
=
NULL
;
TAOS_RES
*
res
=
NULL
;
TAOS_RES
*
res
=
NULL
;
int
colCount
=
0
;
int
colCount
=
0
;
...
@@ -1758,22 +1951,21 @@ static int getTableDes(
...
@@ -1758,22 +1951,21 @@ static int getTableDes(
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
tstrncpy
(
s
tableDes
->
name
,
table
,
TSDB_TABLE_NAME_LEN
);
tstrncpy
(
tableDes
->
name
,
table
,
TSDB_TABLE_NAME_LEN
);
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
tstrncpy
(
s
tableDes
->
cols
[
colCount
].
field
,
tstrncpy
(
tableDes
->
cols
[
colCount
].
field
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
min
(
TSDB_COL_NAME_LEN
+
1
,
min
(
TSDB_COL_NAME_LEN
+
1
,
fields
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
].
bytes
+
1
));
fields
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
].
bytes
+
1
));
tstrncpy
(
s
tableDes
->
cols
[
colCount
].
type
,
tstrncpy
(
tableDes
->
cols
[
colCount
].
type
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
min
(
16
,
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
+
1
));
min
(
16
,
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
+
1
));
s
tableDes
->
cols
[
colCount
].
length
=
tableDes
->
cols
[
colCount
].
length
=
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
tstrncpy
(
s
tableDes
->
cols
[
colCount
].
note
,
tstrncpy
(
tableDes
->
cols
[
colCount
].
note
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
],
min
(
COL_NOTE_LEN
,
min
(
COL_NOTE_LEN
,
fields
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
].
bytes
+
1
));
fields
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
].
bytes
+
1
));
colCount
++
;
colCount
++
;
}
}
...
@@ -1786,10 +1978,10 @@ static int getTableDes(
...
@@ -1786,10 +1978,10 @@ static int getTableDes(
// if child-table have tag, using select tagName from table to get tagValue
// if child-table have tag, using select tagName from table to get tagValue
for
(
int
i
=
0
;
i
<
colCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
colCount
;
i
++
)
{
if
(
strcmp
(
s
tableDes
->
cols
[
i
].
note
,
"TAG"
)
!=
0
)
continue
;
if
(
strcmp
(
tableDes
->
cols
[
i
].
note
,
"TAG"
)
!=
0
)
continue
;
sprintf
(
sqlstr
,
"select %s from %s.%s"
,
sprintf
(
sqlstr
,
"select %s from %s.%s"
,
s
tableDes
->
cols
[
i
].
field
,
dbName
,
table
);
tableDes
->
cols
[
i
].
field
,
dbName
,
table
);
res
=
taos_query
(
taos
,
sqlstr
);
res
=
taos_query
(
taos
,
sqlstr
);
code
=
taos_errno
(
res
);
code
=
taos_errno
(
res
);
...
@@ -1813,7 +2005,7 @@ static int getTableDes(
...
@@ -1813,7 +2005,7 @@ static int getTableDes(
}
}
if
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]
==
NULL
)
{
if
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]
==
NULL
)
{
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%s"
,
"NUL
L"
);
sprintf
(
tableDes
->
cols
[
i
].
note
,
"%s"
,
"NU
L"
);
taos_free_result
(
res
);
taos_free_result
(
res
);
res
=
NULL
;
res
=
NULL
;
taos_close
(
taos
);
taos_close
(
taos
);
...
@@ -1825,58 +2017,82 @@ static int getTableDes(
...
@@ -1825,58 +2017,82 @@ static int getTableDes(
//int32_t* length = taos_fetch_lengths(tmpResult);
//int32_t* length = taos_fetch_lengths(tmpResult);
switch
(
fields
[
0
].
type
)
{
switch
(
fields
[
0
].
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
sprintf
(
stableDes
->
cols
[
i
].
not
e
,
"%d"
,
sprintf
(
tableDes
->
cols
[
i
].
valu
e
,
"%d"
,
((((
int32_t
)(
*
((
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
])))
==
1
)
?
1
:
0
));
((((
int32_t
)(
*
((
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
])))
==
1
)
?
1
:
0
));
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
sprintf
(
stableDes
->
cols
[
i
].
not
e
,
"%d"
,
sprintf
(
tableDes
->
cols
[
i
].
valu
e
,
"%d"
,
*
((
int8_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
*
((
int8_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%d"
,
*
((
int16_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
sprintf
(
tableDes
->
cols
[
i
].
value
,
"%d"
,
*
((
int16_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%d"
,
*
((
int32_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
sprintf
(
tableDes
->
cols
[
i
].
value
,
"%d"
,
*
((
int32_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%"
PRId64
""
,
*
((
int64_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
sprintf
(
tableDes
->
cols
[
i
].
value
,
"%"
PRId64
""
,
*
((
int64_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%f"
,
GET_FLOAT_VAL
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
sprintf
(
tableDes
->
cols
[
i
].
value
,
"%f"
,
GET_FLOAT_VAL
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
sprintf
(
stableDes
->
cols
[
i
].
note
,
"%f"
,
GET_DOUBLE_VAL
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
sprintf
(
tableDes
->
cols
[
i
].
value
,
"%f"
,
GET_DOUBLE_VAL
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]));
break
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
{
memset
(
tableDes
->
cols
[
i
].
value
,
0
,
memset
(
stableDes
->
cols
[
i
].
note
,
0
,
sizeof
(
stableDes
->
cols
[
i
].
note
));
sizeof
(
tableDes
->
cols
[
i
].
value
));
stableDes
->
cols
[
i
].
note
[
0
]
=
'\''
;
int
len
=
strlen
((
char
*
)
row
[
0
]);
char
tbuf
[
COL_NOTE_LEN
];
// FIXME for long value
converStringToReadable
((
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
length
[
0
],
tbuf
,
COL_NOTE_LEN
);
if
(
len
<
(
COL_VALUEBUF_LEN
-
2
))
{
char
*
pstr
=
stpcpy
(
&
(
stableDes
->
cols
[
i
].
note
[
1
]),
tbuf
);
tableDes
->
cols
[
i
].
value
[
0
]
=
'\''
;
*
(
pstr
++
)
=
'\''
;
converStringToReadable
(
break
;
(
char
*
)
row
[
0
],
length
[
0
],
tableDes
->
cols
[
i
].
value
+
1
,
len
);
tableDes
->
cols
[
i
].
value
[
len
+
1
]
=
'\''
;
}
else
{
tableDes
->
cols
[
i
].
var_value
=
calloc
(
1
,
len
+
2
);
if
(
tableDes
->
cols
[
i
].
var_value
==
NULL
)
{
errorPrint
(
"%s() LN%d, memory alalocation failed!
\n
"
,
__func__
,
__LINE__
);
taos_free_result
(
res
);
return
-
1
;
}
tableDes
->
cols
[
i
].
var_value
[
0
]
=
'\''
;
converStringToReadable
((
char
*
)
row
[
0
],
length
[
0
],
(
char
*
)(
tableDes
->
cols
[
i
].
var_value
+
1
),
len
);
tableDes
->
cols
[
i
].
var_value
[
len
+
1
]
=
'\''
;
}
}
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
{
{
memset
(
stableDes
->
cols
[
i
].
note
,
0
,
sizeof
(
s
tableDes
->
cols
[
i
].
note
));
memset
(
tableDes
->
cols
[
i
].
value
,
0
,
sizeof
(
tableDes
->
cols
[
i
].
note
));
char
tbuf
[
COL_NOTE_LEN
-
2
];
// need reserve 2 bytes for ' '
char
tbuf
[
COL_NOTE_LEN
-
2
];
// need reserve 2 bytes for ' '
convertNCharToReadable
((
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
length
[
0
],
tbuf
,
COL_NOTE_LEN
);
convertNCharToReadable
((
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
length
[
0
],
tbuf
,
COL_NOTE_LEN
);
sprintf
(
stableDes
->
cols
[
i
].
not
e
,
"
\'
%s
\'
"
,
tbuf
);
sprintf
(
tableDes
->
cols
[
i
].
valu
e
,
"
\'
%s
\'
"
,
tbuf
);
break
;
break
;
}
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
sprintf
(
stableDes
->
cols
[
i
].
not
e
,
"%"
PRId64
""
,
*
(
int64_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]);
sprintf
(
tableDes
->
cols
[
i
].
valu
e
,
"%"
PRId64
""
,
*
(
int64_t
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]);
#if 0
#if 0
if (!g_args.mysqlFlag) {
if (!g_args.mysqlFlag) {
sprintf(tableDes->cols[i].
not
e, "%" PRId64 "", *(int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]);
sprintf(tableDes->cols[i].
valu
e, "%" PRId64 "", *(int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]);
} else {
} else {
char buf[64] = "\0";
char buf[64] = "\0";
int64_t ts = *((int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]);
int64_t ts = *((int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]);
time_t tt = (time_t)(ts / 1000);
time_t tt = (time_t)(ts / 1000);
struct tm *ptm = localtime(&tt);
struct tm *ptm = localtime(&tt);
strftime(buf, 64, "%y-%m-%d %H:%M:%S", ptm);
strftime(buf, 64, "%y-%m-%d %H:%M:%S", ptm);
sprintf(tableDes->cols[i].
not
e, "\'%s.%03d\'", buf, (int)(ts % 1000));
sprintf(tableDes->cols[i].
valu
e, "\'%s.%03d\'", buf, (int)(ts % 1000));
}
}
#endif
#endif
break
;
break
;
...
@@ -1913,35 +2129,7 @@ static void dumpCreateDbClause(
...
@@ -1913,35 +2129,7 @@ static void dumpCreateDbClause(
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
}
}
static
int
dumpStableClasuse
(
SDbInfo
*
dbInfo
,
char
*
stbName
,
FILE
*
fp
)
static
int
dumpCreateTableClause
(
TableDef
*
tableDes
,
int
numOfCols
,
{
uint64_t
sizeOfTableDes
=
(
uint64_t
)(
sizeof
(
STableDef
)
+
sizeof
(
SColDes
)
*
TSDB_MAX_COLUMNS
);
STableDef
*
stableDes
=
(
STableDef
*
)
calloc
(
1
,
sizeOfTableDes
);
if
(
NULL
==
stableDes
)
{
errorPrint
(
"%s() LN%d, failed to allocate %"
PRIu64
" memory
\n
"
,
__func__
,
__LINE__
,
sizeOfTableDes
);
exit
(
-
1
);
}
int
colCount
=
getTableDes
(
dbInfo
->
name
,
stbName
,
stableDes
,
true
);
if
(
colCount
<
0
)
{
free
(
stableDes
);
errorPrint
(
"%s() LN%d, failed to get stable[%s] schema
\n
"
,
__func__
,
__LINE__
,
stbName
);
exit
(
-
1
);
}
dumpCreateTableClause
(
stableDes
,
colCount
,
fp
,
dbInfo
->
name
);
free
(
stableDes
);
return
0
;
}
static
int
dumpCreateTableClause
(
STableDef
*
tableDes
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
)
{
FILE
*
fp
,
char
*
dbName
)
{
int
counter
=
0
;
int
counter
=
0
;
int
count_temp
=
0
;
int
count_temp
=
0
;
...
@@ -1992,64 +2180,6 @@ static int dumpCreateTableClause(STableDef *tableDes, int numOfCols,
...
@@ -1992,64 +2180,6 @@ static int dumpCreateTableClause(STableDef *tableDes, int numOfCols,
return
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
return
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
}
}
static
void
dumpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
)
{
int
counter
=
0
;
int
count_temp
=
0
;
char
*
tmpBuf
=
(
char
*
)
malloc
(
COMMAND_SIZE
);
if
(
tmpBuf
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to allocate %d memory
\n
"
,
__func__
,
__LINE__
,
COMMAND_SIZE
);
return
;
}
char
*
pstr
=
NULL
;
pstr
=
tmpBuf
;
pstr
+=
sprintf
(
tmpBuf
,
"CREATE TABLE IF NOT EXISTS %s.%s USING %s.%s TAGS ("
,
dbName
,
tableDes
->
name
,
dbName
,
stable
);
for
(;
counter
<
numOfCols
;
counter
++
)
{
if
(
tableDes
->
cols
[
counter
].
note
[
0
]
!=
'\0'
)
break
;
}
assert
(
counter
<
numOfCols
);
count_temp
=
counter
;
for
(;
counter
<
numOfCols
;
counter
++
)
{
if
(
counter
!=
count_temp
)
{
if
(
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"nchar"
)
==
0
)
{
//pstr += sprintf(pstr, ", \'%s\'", tableDes->cols[counter].note);
pstr
+=
sprintf
(
pstr
,
", %s"
,
tableDes
->
cols
[
counter
].
note
);
}
else
{
pstr
+=
sprintf
(
pstr
,
", %s"
,
tableDes
->
cols
[
counter
].
note
);
}
}
else
{
if
(
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"nchar"
)
==
0
)
{
//pstr += sprintf(pstr, "\'%s\'", tableDes->cols[counter].note);
pstr
+=
sprintf
(
pstr
,
"%s"
,
tableDes
->
cols
[
counter
].
note
);
}
else
{
pstr
+=
sprintf
(
pstr
,
"%s"
,
tableDes
->
cols
[
counter
].
note
);
}
/* pstr += sprintf(pstr, "%s", tableDes->cols[counter].note); */
}
/* if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 || strcasecmp(tableDes->cols[counter].type, "nchar")
* == 0) { */
/* pstr += sprintf(pstr, "(%d)", tableDes->cols[counter].length); */
/* } */
}
pstr
+=
sprintf
(
pstr
,
");"
);
fprintf
(
fp
,
"%s
\n
"
,
tmpBuf
);
free
(
tmpBuf
);
}
static
int
writeSchemaToAvro
(
char
*
jsonAvroSchema
)
static
int
writeSchemaToAvro
(
char
*
jsonAvroSchema
)
{
{
errorPrint
(
"%s() LN%d, TODO: implement write schema to avro"
,
errorPrint
(
"%s() LN%d, TODO: implement write schema to avro"
,
...
@@ -2146,10 +2276,7 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN
...
@@ -2146,10 +2276,7 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
{
{
char
tbuf
[
COMMAND_SIZE
]
=
{
0
};
char
tbuf
[
COMMAND_SIZE
]
=
{
0
};
//*(pstr++) = '\'';
converStringToReadable
((
char
*
)
row
[
col
],
length
[
col
],
tbuf
,
COMMAND_SIZE
);
converStringToReadable
((
char
*
)
row
[
col
],
length
[
col
],
tbuf
,
COMMAND_SIZE
);
//pstr = stpcpy(pstr, tbuf);
//*(pstr++) = '\'';
curr_sqlstr_len
+=
sprintf
(
pstr
+
curr_sqlstr_len
,
"
\'
%s
\'
"
,
tbuf
);
curr_sqlstr_len
+=
sprintf
(
pstr
+
curr_sqlstr_len
,
"
\'
%s
\'
"
,
tbuf
);
break
;
break
;
}
}
...
@@ -2405,7 +2532,6 @@ static int converStringToReadable(char *str, int size, char *buf, int bufsize) {
...
@@ -2405,7 +2532,6 @@ static int converStringToReadable(char *str, int size, char *buf, int bufsize) {
static
int
convertNCharToReadable
(
char
*
str
,
int
size
,
char
*
buf
,
int
bufsize
)
{
static
int
convertNCharToReadable
(
char
*
str
,
int
size
,
char
*
buf
,
int
bufsize
)
{
char
*
pstr
=
str
;
char
*
pstr
=
str
;
char
*
pbuf
=
buf
;
char
*
pbuf
=
buf
;
// TODO
wchar_t
wc
;
wchar_t
wc
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
if
(
*
pstr
==
'\0'
)
break
;
if
(
*
pstr
==
'\0'
)
break
;
...
...
tests/connectorTest/C#Test/nanosupport/nanotest.cs
浏览文件 @
dd6f16ff
...
@@ -29,21 +29,7 @@ namespace TDengineDriver
...
@@ -29,21 +29,7 @@ namespace TDengineDriver
private
string
password
=
"taosdata"
;
private
string
password
=
"taosdata"
;
private
short
port
=
0
;
private
short
port
=
0
;
//sql parameters
private
string
dbName
;
private
string
tbName
;
private
string
precision
;
private
bool
isInsertData
;
private
bool
isQueryData
;
private
long
tableCount
;
private
long
totalRows
;
private
long
batchRows
;
private
long
beginTimestamp
=
1551369600000L
;
private
IntPtr
conn
=
IntPtr
.
Zero
;
private
IntPtr
conn
=
IntPtr
.
Zero
;
private
long
rowsInserted
=
0
;
static
void
Main
(
string
[]
args
)
static
void
Main
(
string
[]
args
)
{
{
...
@@ -73,15 +59,6 @@ namespace TDengineDriver
...
@@ -73,15 +59,6 @@ namespace TDengineDriver
tester
.
executeQuery
(
"select * from tb;"
);
tester
.
executeQuery
(
"select * from tb;"
);
// Console.WriteLine("expected is : {0}", width);
// tdSql.checkData(0,0,"2021-06-10 0:00:00.100000001");
// tdSql.checkData(1,0,"2021-06-10 0:00:00.150000000");
// tdSql.checkData(2,0,"2021-06-10 0:00:00.299999999");
// tdSql.checkData(3,1,3);
// tdSql.checkData(4,1,5);
// tdSql.checkData(5,1,7);
// tdSql.checkRows(6);
tester
.
executeQuery
(
"select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400100000002;"
);
tester
.
executeQuery
(
"select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400100000002;"
);
Console
.
WriteLine
(
"expected is : 1 "
);
Console
.
WriteLine
(
"expected is : 1 "
);
tester
.
executeQuery
(
"select count(*) from tb where ts > '2021-06-10 0:00:00.100000001' and ts < '2021-06-10 0:00:00.160000000';"
);
tester
.
executeQuery
(
"select count(*) from tb where ts > '2021-06-10 0:00:00.100000001' and ts < '2021-06-10 0:00:00.160000000';"
);
...
@@ -271,8 +248,8 @@ namespace TDengineDriver
...
@@ -271,8 +248,8 @@ namespace TDengineDriver
// tdSql.checkData(0,0,1623258000123456789);
// tdSql.checkData(0,0,1623258000123456789);
Console
.
WriteLine
(
"usdb"
);
Console
.
WriteLine
(
"usdb"
);
tester
.
execute
(
"drop database if exists usdb;"
);
tester
.
execute
(
"create database usdb precision 'us';"
);
tester
.
execute
(
"create database usdb precision 'us';"
);
tester
.
execute
(
"use usdb;"
);
tester
.
execute
(
"use usdb;"
);
tester
.
execute
(
"create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);"
);
tester
.
execute
(
"create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);"
);
...
@@ -290,12 +267,8 @@ namespace TDengineDriver
...
@@ -290,12 +267,8 @@ namespace TDengineDriver
tester
.
executeQuery
(
"select first(*) from tb1;"
);
tester
.
executeQuery
(
"select first(*) from tb1;"
);
Console
.
WriteLine
(
"expected is : 1623258000123 "
);
Console
.
WriteLine
(
"expected is : 1623258000123 "
);
tester
.
CloseConnection
();
tester
.
CloseConnection
();
tester
.
cleanup
();
tester
.
cleanup
();
}
}
public
void
InitTDengine
()
public
void
InitTDengine
()
...
@@ -321,13 +294,13 @@ namespace TDengineDriver
...
@@ -321,13 +294,13 @@ namespace TDengineDriver
Console
.
WriteLine
(
"[ OK ] Connection established."
);
Console
.
WriteLine
(
"[ OK ] Connection established."
);
}
}
}
}
//EXECUTE SQL
//EXECUTE SQL
public
void
execute
(
string
sql
)
public
void
execute
(
string
sql
)
{
{
DateTime
dt1
=
DateTime
.
Now
;
DateTime
dt1
=
DateTime
.
Now
;
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
DateTime
dt2
=
DateTime
.
Now
;
DateTime
dt2
=
DateTime
.
Now
;
TimeSpan
span
=
dt2
-
dt1
;
if
((
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
))
if
((
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
))
{
{
...
@@ -481,22 +454,16 @@ namespace TDengineDriver
...
@@ -481,22 +454,16 @@ namespace TDengineDriver
switch
(
psc
)
switch
(
psc
)
{
{
case
0
:
case
0
:
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
"
,
this
.
dbName
,
"
millisecond"
);
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
millisecond"
);
break
;
break
;
case
1
:
case
1
:
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
"
,
this
.
dbName
,
"
microsecond"
);
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
microsecond"
);
break
;
break
;
case
2
:
case
2
:
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
"
,
this
.
dbName
,
"
nanosecond"
);
Console
.
WriteLine
(
"db:[{0:G}]'s precision is {1:G}
nanosecond"
);
break
;
break
;
}
}
}
}
// public void checkData(int x ,int y , long ts ){
// }
}
}
}
}
tests/pytest/client/nettest.py
0 → 100644
浏览文件 @
dd6f16ff
###################################################################
# 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
taos
import
subprocess
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
try
:
str1
=
'taos -n speed -P 6030 -N 1000 -l 100000 -S tcp'
result1
=
subprocess
.
call
(
str1
)
except
Exception
as
result1
:
if
result1
==
1
:
tdLog
.
exit
(
"the shell 'taos -n speed -P 6030 -N 1000 -l 100000 -S tcp' is wrong"
)
try
:
str2
=
'taos -n speed -P 6030 -N 1000 -l 100000 -S udp'
result2
=
subprocess
.
call
(
str2
)
except
Exception
as
result2
:
if
result2
==
1
:
tdLog
.
exit
(
"the shell 'taos -n speed -P 6030 -N 1000 -l 100000 -S udp' is wrong"
)
try
:
str3
=
'taos -n fqdn'
result3
=
subprocess
.
call
(
str3
)
except
Exception
as
result3
:
if
result3
==
1
:
tdLog
.
exit
(
'the shell"taos -n fqdn" is wrong'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/fulltest.sh
浏览文件 @
dd6f16ff
...
@@ -398,7 +398,12 @@ python3 ./test.py -f query/queryWildcardLength.py
...
@@ -398,7 +398,12 @@ python3 ./test.py -f query/queryWildcardLength.py
python3 ./test.py
-f
query/queryTbnameUpperLower.py
python3 ./test.py
-f
query/queryTbnameUpperLower.py
python3 ./test.py
-f
query/query.py
python3 ./test.py
-f
query/query.py
python3 ./test.py
-f
query/queryDiffColsOr.py
python3 ./test.py
-f
query/queryDiffColsOr.py
python3 ./test.py
-f
client/nettest.py
python3 ./test.py
-f
query/queryRegex.py
python3 ./test.py
-f
query/queryRegex.py
#======================p4-end===============
#======================p4-end===============
...
...
tests/pytest/insert/schemaChangeTest.py
0 → 100644
浏览文件 @
dd6f16ff
###################################################################
# 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
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
import
multiprocessing
as
mp
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
ts
=
1609430400000
def
alterTableSchema
(
self
):
conn1
=
taos
.
connect
(
host
=
"127.0.0.1"
,
user
=
"root"
,
password
=
"taosdata"
,
config
=
tdDnodes
.
getSimCfgPath
())
c1
=
conn1
.
cursor
()
c1
.
execute
(
"use db"
)
c1
.
execute
(
"alter table st drop column c2"
)
c1
.
execute
(
"alter table st add column c2 double"
)
tdLog
.
sleep
(
1
)
c1
.
execute
(
"select * from st"
)
for
data
in
c1
:
print
(
"Process 1: c2 = %s"
%
data
[
2
])
def
insertData
(
self
):
conn2
=
taos
.
connect
(
host
=
"127.0.0.1"
,
user
=
"root"
,
password
=
"taosdata"
,
config
=
tdDnodes
.
getSimCfgPath
())
c2
=
conn2
.
cursor
()
tdLog
.
sleep
(
1
)
c2
.
execute
(
"use db"
)
c2
.
execute
(
"insert into t1 values(%d, 2, 2.22)"
%
(
self
.
ts
+
1
))
c2
.
execute
(
"select * from st"
)
for
data
in
c2
:
print
(
"Process 2: c2 = %f"
%
data
[
2
])
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
"create table st(ts timestamp, c1 int, c2 float) tags(t1 int)"
)
tdSql
.
execute
(
"create table t1 using st tags(1)"
)
tdSql
.
execute
(
"insert into t1 values(%d, 1, 1.11)"
%
self
.
ts
)
p1
=
mp
.
Process
(
target
=
self
.
alterTableSchema
,
args
=
())
p2
=
mp
.
Process
(
target
=
self
.
insertData
,
args
=
())
p1
.
start
()
p2
.
start
()
p1
.
join
()
p2
.
join
()
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录