Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
aa063917
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa063917
编写于
3月 12, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
[td-2895] merge develop.
上级
709d045c
776c80a7
变更
45
展开全部
显示空白变更内容
内联
并排
Showing
45 changed file
with
3480 addition
and
1939 deletion
+3480
-1939
CMakeLists.txt
CMakeLists.txt
+1
-0
cmake/define.inc
cmake/define.inc
+4
-0
cmake/input.inc
cmake/input.inc
+8
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+12
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+6
-3
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+5
-1
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+12
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
.../jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
+0
-64
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
.../jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
+10
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
.../jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
+3
-4
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+0
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+6
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+26
-31
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+5
-5
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
...src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
+50
-91
src/dnode/CMakeLists.txt
src/dnode/CMakeLists.txt
+4
-0
src/dnode/src/dnodeMWrite.c
src/dnode/src/dnodeMWrite.c
+2
-2
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+5
-0
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+3
-0
src/inc/taosdef.h
src/inc/taosdef.h
+7
-0
src/inc/taoserror.h
src/inc/taoserror.h
+3
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+12
-2
src/inc/tp.h
src/inc/tp.h
+31
-0
src/inc/ttokendef.h
src/inc/ttokendef.h
+141
-139
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+140
-53
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+3
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+46
-8
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+1
-0
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+15
-0
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+5
-1
src/query/inc/sql.y
src/query/inc/sql.y
+22
-5
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+14
-2
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+3
-0
src/query/src/sql.c
src/query/src/sql.c
+1569
-1517
src/util/src/terror.c
src/util/src/terror.c
+3
-0
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+2
-1
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+13
-3
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+5
-0
tests/script/general/db/topic1.sim
tests/script/general/db/topic1.sim
+856
-0
tests/script/general/db/topic2.sim
tests/script/general/db/topic2.sim
+321
-0
tests/script/general/parser/last_groupby.sim
tests/script/general/parser/last_groupby.sim
+99
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-0
tests/script/jenkins/basic_7.txt
tests/script/jenkins/basic_7.txt
+2
-0
tests/test-all.sh
tests/test-all.sh
+2
-0
未找到文件。
CMakeLists.txt
浏览文件 @
aa063917
...
...
@@ -16,6 +16,7 @@ SET(TD_GRANT FALSE)
SET
(
TD_MQTT FALSE
)
SET
(
TD_TSDB_PLUGINS FALSE
)
SET
(
TD_STORAGE FALSE
)
SET
(
TD_TOPIC FALSE
)
SET
(
TD_COVER FALSE
)
SET
(
TD_MEM_CHECK FALSE
)
...
...
cmake/define.inc
浏览文件 @
aa063917
...
...
@@ -25,6 +25,10 @@ IF (TD_STORAGE)
ADD_DEFINITIONS
(
-
D_STORAGE
)
ENDIF
()
IF
(
TD_TOPIC
)
ADD_DEFINITIONS
(
-
D_TOPIC
)
ENDIF
()
IF
(
TD_GODLL
)
ADD_DEFINITIONS
(
-
D_TD_GO_DLL_
)
ENDIF
()
...
...
cmake/input.inc
浏览文件 @
aa063917
...
...
@@ -9,6 +9,14 @@ ELSEIF (${ACCOUNT} MATCHES "false")
MESSAGE
(
STATUS
"Build without account plugins"
)
ENDIF
()
IF
(
$
{
TOPIC
}
MATCHES
"true"
)
SET
(
TD_TOPIC
TRUE
)
MESSAGE
(
STATUS
"Build with topic plugins"
)
ELSEIF
(
$
{
TOPIC
}
MATCHES
"false"
)
SET
(
TD_TOPIC
FALSE
)
MESSAGE
(
STATUS
"Build without topic plugins"
)
ENDIF
()
IF
(
$
{
COVER
}
MATCHES
"true"
)
SET
(
TD_COVER
TRUE
)
MESSAGE
(
STATUS
"Build with test coverage"
)
...
...
src/client/src/tscSQLParser.c
浏览文件 @
aa063917
...
...
@@ -5538,6 +5538,8 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) {
pMsg
->
ignoreExist
=
pCreateDb
->
ignoreExists
;
pMsg
->
update
=
pCreateDb
->
update
;
pMsg
->
cacheLastRow
=
pCreateDb
->
cachelast
;
pMsg
->
dbType
=
pCreateDb
->
dbType
;
pMsg
->
partitions
=
htons
(
pCreateDb
->
partitions
);
}
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDbInfo
*
pCreateDbSql
)
{
...
...
@@ -6168,6 +6170,15 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
val
=
(
int16_t
)
htons
(
pCreate
->
partitions
);
if
(
val
!=
-
1
&&
(
val
<
TSDB_MIN_DB_PARTITON_OPTION
||
val
>
TSDB_MAX_DB_PARTITON_OPTION
))
{
snprintf
(
msg
,
tListLen
(
msg
),
"invalid topic option partition: %d valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_PARTITON_OPTION
,
TSDB_MAX_DB_PARTITON_OPTION
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
aa063917
...
...
@@ -1071,7 +1071,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildCreateDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateDbMsg
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_CREATE_DB
;
pCmd
->
msgType
=
(
pInfo
->
pMiscInfo
->
dbOpt
.
dbType
==
TSDB_DB_TYPE_DEFAULT
)
?
TSDB_MSG_TYPE_CM_CREATE_DB
:
TSDB_MSG_TYPE_CM_CREATE_TP
;
SCreateDbMsg
*
pCreateDbMsg
=
(
SCreateDbMsg
*
)
pCmd
->
payload
;
...
...
@@ -1203,7 +1204,7 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pDropDbMsg
->
ignoreNotExists
=
pInfo
->
pMiscInfo
->
existsCheck
?
1
:
0
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_DB
;
pCmd
->
msgType
=
(
pInfo
->
pMiscInfo
->
dbType
==
TSDB_DB_TYPE_DEFAULT
)
?
TSDB_MSG_TYPE_CM_DROP_DB
:
TSDB_MSG_TYPE_CM_DROP_TP
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1530,9 +1531,11 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SAlterDbMsg
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_ALTER_DB
;
pCmd
->
msgType
=
(
pInfo
->
pMiscInfo
->
dbOpt
.
dbType
==
TSDB_DB_TYPE_DEFAULT
)
?
TSDB_MSG_TYPE_CM_ALTER_DB
:
TSDB_MSG_TYPE_CM_ALTER_TP
;
SAlterDbMsg
*
pAlterDbMsg
=
(
SAlterDbMsg
*
)
pCmd
->
payload
;
pAlterDbMsg
->
dbType
=
-
1
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
pAlterDbMsg
->
db
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
aa063917
...
...
@@ -1944,7 +1944,11 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
// tag or group by column
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
)
||
pExpr
->
functionId
==
TSDB_FUNC_PRJ
)
{
if
(
row
[
i
]
==
NULL
)
{
setNull
(
p
+
offset
,
pExpr
->
resType
,
pExpr
->
resBytes
);
}
else
{
memcpy
(
p
+
offset
,
row
[
i
],
length
[
i
]);
}
offset
+=
pExpr
->
resBytes
;
}
}
...
...
src/common/inc/tglobal.h
浏览文件 @
aa063917
...
...
@@ -95,6 +95,7 @@ extern int8_t tsCompression;
extern
int8_t
tsWAL
;
extern
int32_t
tsFsyncPeriod
;
extern
int32_t
tsReplications
;
extern
int16_t
tsPartitons
;
extern
int32_t
tsQuorum
;
extern
int8_t
tsUpdate
;
extern
int8_t
tsCacheLastRow
;
...
...
src/common/src/tglobal.c
浏览文件 @
aa063917
...
...
@@ -126,8 +126,9 @@ int8_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
int32_t
tsFsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
int32_t
tsReplications
=
TSDB_DEFAULT_DB_REPLICA_OPTION
;
int32_t
tsQuorum
=
TSDB_DEFAULT_DB_QUORUM_OPTION
;
int16_t
tsPartitons
=
TSDB_DEFAULT_DB_PARTITON_OPTION
;
int8_t
tsUpdate
=
TSDB_DEFAULT_DB_UPDATE_OPTION
;
int8_t
tsCacheLastRow
=
TSDB_DEFAULT_CACHE_
BLOCK_SIZE
;
int8_t
tsCacheLastRow
=
TSDB_DEFAULT_CACHE_
LAST_ROW
;
int32_t
tsMaxVgroupsPerDb
=
0
;
int32_t
tsMinTablePerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsMaxTablePerVnode
=
TSDB_DEFAULT_TABLES
;
...
...
@@ -853,6 +854,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"partitions"
;
cfg
.
ptr
=
&
tsPartitons
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT16
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_DB_PARTITON_OPTION
;
cfg
.
maxValue
=
TSDB_MAX_DB_PARTITON_OPTION
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"quorum"
;
cfg
.
ptr
=
&
tsQuorum
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
浏览文件 @
aa063917
package
com.taosdata.jdbc
;
import
java.io.*
;
import
java.sql.Driver
;
import
java.sql.DriverPropertyInfo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.StringTokenizer
;
public
abstract
class
AbstractDriver
implements
Driver
{
private
static
final
String
TAOS_CFG_FILENAME
=
"taos.cfg"
;
/**
* @param cfgDirPath
* @return return the config dir
**/
protected
File
loadConfigDir
(
String
cfgDirPath
)
{
if
(
cfgDirPath
==
null
)
return
loadDefaultConfigDir
();
File
cfgDir
=
new
File
(
cfgDirPath
);
if
(!
cfgDir
.
exists
())
return
loadDefaultConfigDir
();
return
cfgDir
;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
*/
protected
File
loadDefaultConfigDir
()
{
File
cfgDir
;
File
cfgDir_linux
=
new
File
(
"/etc/taos"
);
cfgDir
=
cfgDir_linux
.
exists
()
?
cfgDir_linux
:
null
;
File
cfgDir_windows
=
new
File
(
"C:\\TDengine\\cfg"
);
cfgDir
=
(
cfgDir
==
null
&&
cfgDir_windows
.
exists
())
?
cfgDir_windows
:
cfgDir
;
return
cfgDir
;
}
protected
List
<
String
>
loadConfigEndpoints
(
File
cfgFile
)
{
List
<
String
>
endpoints
=
new
ArrayList
<>();
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
cfgFile
)))
{
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
trim
().
startsWith
(
"firstEp"
)
||
line
.
trim
().
startsWith
(
"secondEp"
))
{
endpoints
.
add
(
line
.
substring
(
line
.
indexOf
(
'p'
)
+
1
).
trim
());
}
if
(
endpoints
.
size
()
>
1
)
break
;
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
endpoints
;
}
protected
void
loadTaosConfig
(
Properties
info
)
{
if
((
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
)
==
null
||
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
).
isEmpty
())
&&
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
)
==
null
||
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
).
isEmpty
()))
{
File
cfgDir
=
loadConfigDir
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_CONFIG_DIR
));
File
cfgFile
=
cfgDir
.
listFiles
((
dir
,
name
)
->
TAOS_CFG_FILENAME
.
equalsIgnoreCase
(
name
))[
0
];
List
<
String
>
endpoints
=
loadConfigEndpoints
(
cfgFile
);
if
(!
endpoints
.
isEmpty
())
{
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
endpoints
.
get
(
0
).
split
(
":"
)[
0
]);
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
endpoints
.
get
(
0
).
split
(
":"
)[
1
]);
}
}
}
protected
DriverPropertyInfo
[]
getPropertyInfo
(
Properties
info
)
{
DriverPropertyInfo
hostProp
=
new
DriverPropertyInfo
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
));
hostProp
.
required
=
false
;
...
...
@@ -154,6 +92,4 @@ public abstract class AbstractDriver implements Driver {
return
urlProps
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
浏览文件 @
aa063917
...
...
@@ -52,4 +52,14 @@ public class ColumnMetaData {
public
void
setColIndex
(
int
colIndex
)
{
this
.
colIndex
=
colIndex
;
}
@Override
public
String
toString
()
{
return
"ColumnMetaData{"
+
"colType="
+
colType
+
", colName='"
+
colName
+
'\''
+
", colSize="
+
colSize
+
", colIndex="
+
colIndex
+
'}'
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
浏览文件 @
aa063917
...
...
@@ -87,11 +87,10 @@ public class TSDBConnection extends AbstractConnection {
}
public
void
close
()
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
}
this
.
isClosed
=
true
;
if
(
isClosed
)
return
;
this
.
connector
.
closeConnection
();
this
.
isClosed
=
true
;
}
public
boolean
isClosed
()
throws
SQLException
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
aa063917
...
...
@@ -112,8 +112,6 @@ public class TSDBDriver extends AbstractDriver {
if
((
props
=
parseURL
(
url
,
info
))
==
null
)
{
return
null
;
}
//load taos.cfg start
loadTaosConfig
(
info
);
try
{
TSDBJNIConnector
.
init
((
String
)
props
.
get
(
PROPERTY_KEY_CONFIG_DIR
),
(
String
)
props
.
get
(
PROPERTY_KEY_LOCALE
),
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
aa063917
/***************************************************************************
/**
* *************************************************************************
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
...
...
@@ -11,7 +12,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
****************************************************************************
*/
package
com.taosdata.jdbc
;
import
com.taosdata.jdbc.utils.TaosInfo
;
...
...
@@ -20,6 +21,9 @@ import java.sql.SQLException;
import
java.sql.SQLWarning
;
import
java.util.List
;
/**
* JNI connector
* */
public
class
TSDBJNIConnector
{
private
static
volatile
Boolean
isInitialized
=
false
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
浏览文件 @
aa063917
...
...
@@ -20,18 +20,16 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
TSDBResultSet
extends
AbstractResultSet
implements
ResultSet
{
private
TSDBJNIConnector
jniConnector
;
private
final
TSDBJNIConnector
jniConnector
;
private
final
TSDBStatement
statement
;
private
long
resultSetPointer
=
0L
;
private
final
long
resultSetPointer
;
private
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>();
private
TSDBResultSetRowData
rowData
;
private
TSDBResultSetBlockData
blockData
;
private
final
TSDBResultSetRowData
rowData
;
private
final
TSDBResultSetBlockData
blockData
;
private
boolean
batchFetch
=
false
;
private
boolean
lastWasNull
=
false
;
private
final
int
COLUMN_INDEX_START_VALUE
=
1
;
private
boolean
isClosed
;
public
void
setBatchFetch
(
boolean
batchFetch
)
{
this
.
batchFetch
=
batchFetch
;
...
...
@@ -56,13 +54,13 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
int
code
=
this
.
jniConnector
.
getSchemaMetaData
(
this
.
resultSetPointer
,
this
.
columnMetaDataList
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_RESULT_SET_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
if
(
code
==
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
);
}
this
.
rowData
=
new
TSDBResultSetRowData
(
this
.
columnMetaDataList
.
size
());
this
.
blockData
=
new
TSDBResultSetBlockData
(
this
.
columnMetaDataList
,
this
.
columnMetaDataList
.
size
());
...
...
@@ -78,16 +76,12 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
this
.
blockData
.
reset
();
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_RESULT_SET_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
));
}
else
if
(
code
==
TSDBConstants
.
JNI_FETCH_END
)
{
return
false
;
}
return
true
;
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
);
}
else
return
code
!=
TSDBConstants
.
JNI_FETCH_END
;
}
else
{
if
(
rowData
!=
null
)
{
this
.
rowData
.
clear
();
...
...
@@ -95,11 +89,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
int
code
=
this
.
jniConnector
.
fetchRow
(
this
.
resultSetPointer
,
this
.
rowData
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_RESULT_SET_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
);
}
else
if
(
code
==
TSDBConstants
.
JNI_FETCH_END
)
{
return
false
;
}
else
{
...
...
@@ -109,14 +103,17 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
}
public
void
close
()
throws
SQLException
{
if
(
isClosed
)
return
;
if
(
this
.
jniConnector
!=
null
)
{
int
code
=
this
.
jniConnector
.
freeResultSet
(
this
.
resultSetPointer
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_RESULT_SET_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
}
isClosed
=
true
;
}
public
boolean
wasNull
()
throws
SQLException
{
...
...
@@ -415,8 +412,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
}
public
boolean
isClosed
()
throws
SQLException
{
//TODO: check if need release resources
boolean
isClosed
=
true
;
if
(
isClosed
)
return
true
;
if
(
jniConnector
!=
null
)
{
isClosed
=
jniConnector
.
isResultsetClosed
();
}
...
...
@@ -429,14 +426,12 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
}
private
int
getTrueColumnIndex
(
int
columnIndex
)
throws
SQLException
{
if
(
columnIndex
<
this
.
COLUMN_INDEX_START_VALUE
)
{
throw
new
SQLException
(
"Column Index out of range, "
+
columnIndex
+
" < "
+
this
.
COLUMN_INDEX_START_VALUE
);
}
if
(
columnIndex
<
1
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_PARAMETER_INDEX_OUT_RANGE
,
"columnIndex("
+
columnIndex
+
"): < 1"
);
int
numOfCols
=
this
.
columnMetaDataList
.
size
();
if
(
columnIndex
>
numOfCols
)
{
throw
new
SQLException
(
"Column Index out of range, "
+
columnIndex
+
" > "
+
numOfCols
);
}
if
(
columnIndex
>
numOfCols
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_PARAMETER_INDEX_OUT_RANGE
,
"columnIndex: "
+
columnIndex
);
return
columnIndex
-
1
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
aa063917
...
...
@@ -73,12 +73,12 @@ public class TSDBStatement extends AbstractStatement {
}
public
void
close
()
throws
SQLException
{
if
(!
isClosed
)
{
if
(
this
.
resultSet
!=
null
)
if
(
isClosed
)
return
;
if
(
this
.
resultSet
!=
null
&&
!
this
.
resultSet
.
isClosed
())
this
.
resultSet
.
close
();
isClosed
=
true
;
}
}
public
boolean
execute
(
String
sql
)
throws
SQLException
{
// check if closed
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
浏览文件 @
aa063917
...
...
@@ -7,24 +7,26 @@ import java.sql.SQLWarning;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.*;
public
class
TSDBJNIConnectorTest
{
public
static
void
main
(
String
[]
args
)
{
private
static
TSDBResultSetRowData
rowData
;
@Test
public
void
test
()
{
try
{
TSDBJNIConnector
.
init
(
"/etc/taos/taos.cfg"
,
"en_US.UTF-8"
,
""
,
""
);
// init
TSDBJNIConnector
.
init
(
null
,
null
,
null
,
null
);
// connect
TSDBJNIConnector
connector
=
new
TSDBJNIConnector
();
connector
.
connect
(
"127.0.0.1"
,
6030
,
"test"
,
"root"
,
"taosdata"
);
long
pSql
=
connector
.
executeQuery
(
"show dnodes"
);
// if pSql is create/insert/update/delete/alter SQL
connector
.
connect
(
"127.0.0.1"
,
6030
,
null
,
"root"
,
"taosdata"
);
// executeQuery
long
pSql
=
connector
.
executeQuery
(
"show variables"
);
if
(
connector
.
isUpdateQuery
(
pSql
))
{
connector
.
freeResultSet
(
pSql
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEQUERY
);
}
// get schema
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>();
int
code
=
connector
.
getSchemaMetaData
(
pSql
,
columnMetaDataList
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
...
...
@@ -35,96 +37,53 @@ public class TSDBJNIConnectorTest {
if
(
code
==
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
));
}
}
catch
(
SQLWarning
throwables
)
{
throwables
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
isClosed
()
{
}
@Test
public
void
isResultsetClosed
()
{
}
@Test
public
void
init
()
{
}
@Test
public
void
initImp
()
{
}
@Test
public
void
setOptions
()
{
}
@Test
public
void
getTsCharset
()
{
}
@Test
public
void
connect
()
{
}
@Test
public
void
executeQuery
()
{
}
@Test
public
void
getErrCode
()
{
}
@Test
public
void
getErrMsg
()
{
}
@Test
public
void
isUpdateQuery
()
{
int
columnSize
=
columnMetaDataList
.
size
();
// print metadata
for
(
int
i
=
0
;
i
<
columnSize
;
i
++)
{
System
.
out
.
println
(
columnMetaDataList
.
get
(
i
));
}
@Test
public
void
freeResultSet
()
{
rowData
=
new
TSDBResultSetRowData
(
columnSize
);
// iterate resultSet
for
(
int
i
=
0
;
next
(
connector
,
pSql
);
i
++)
{
System
.
out
.
println
(
"col["
+
i
+
"] size: "
+
rowData
.
getColSize
());
rowData
.
getData
().
stream
().
forEach
(
col
->
System
.
out
.
print
(
col
+
"\t"
));
System
.
out
.
println
();
}
@Test
public
void
getAffectedRows
()
{
// close resultSet
code
=
connector
.
freeResultSet
(
pSql
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
// close statement
@Test
public
void
getSchemaMetaData
()
{
}
// close connection
connector
.
closeConnection
();
@Test
public
void
fetchRow
()
{
}
catch
(
SQLWarning
throwables
)
{
throwables
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
@Test
public
void
fetchBlock
()
{
}
@Test
public
void
closeConnection
()
{
}
private
static
boolean
next
(
TSDBJNIConnector
connector
,
long
pSql
)
throws
SQLException
{
if
(
rowData
!=
null
)
rowData
.
clear
();
@Test
public
void
subscribe
()
{
}
@Test
public
void
consume
()
{
int
code
=
connector
.
fetchRow
(
pSql
,
rowData
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_RESULT_SET_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
else
if
(
code
==
TSDBConstants
.
JNI_NUM_OF_FIELDS_0
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
);
}
else
if
(
code
==
TSDBConstants
.
JNI_FETCH_END
)
{
return
false
;
}
else
{
return
true
;
}
@Test
public
void
unsubscribe
()
{
}
@Test
public
void
validateCreateTableSql
()
{
}
}
\ No newline at end of file
src/dnode/CMakeLists.txt
浏览文件 @
aa063917
...
...
@@ -31,6 +31,10 @@ IF (TD_MQTT)
TARGET_LINK_LIBRARIES
(
taosd mqtt
)
ENDIF
()
IF
(
TD_TOPIC
)
TARGET_LINK_LIBRARIES
(
taosd topic
)
ENDIF
()
SET
(
PREPARE_ENV_CMD
"prepare_env_cmd"
)
SET
(
PREPARE_ENV_TARGET
"prepare_env_target"
)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
PREPARE_ENV_CMD
}
...
...
src/dnode/src/dnodeMWrite.c
浏览文件 @
aa063917
src/dnode/src/dnodeMain.c
浏览文件 @
aa063917
...
...
@@ -189,6 +189,11 @@ static void dnodeCheckDataDirOpenned(char *dir) {
}
static
int32_t
dnodeInitStorage
()
{
if
(
tsDiskCfgNum
==
1
&&
dnodeCreateDir
(
tsDataDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsDataDir
,
strerror
(
errno
));
return
-
1
;
}
if
(
tfsInit
(
tsDiskCfg
,
tsDiskCfgNum
)
<
0
)
{
dError
(
"failed to init TFS since %s"
,
tstrerror
(
terrno
));
return
-
1
;
...
...
src/dnode/src/dnodeShell.c
浏览文件 @
aa063917
...
...
@@ -47,8 +47,11 @@ int32_t dnodeInitShell() {
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DNODE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DNODE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_TP
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_TP
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_TP
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_TABLE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_TABLE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_TABLE
]
=
dnodeDispatchToMWriteQueue
;
...
...
src/inc/taosdef.h
浏览文件 @
aa063917
...
...
@@ -222,6 +222,9 @@ do { \
#define TSDB_MQTT_TOPIC_LEN 64
#define TSDB_MQTT_CLIENT_ID_LEN 32
#define TSDB_DB_TYPE_DEFAULT 0
#define TSDB_DB_TYPE_TOPIC 1
#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
...
...
@@ -306,6 +309,10 @@ do { \
#define TSDB_MAX_DB_REPLICA_OPTION 3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
#define TSDB_MIN_DB_PARTITON_OPTION 0
#define TSDB_MAX_DB_PARTITON_OPTION 1000
#define TSDB_DEFAULT_DB_PARTITON_OPTION 4
#define TSDB_MIN_DB_QUORUM_OPTION 1
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
...
...
src/inc/taoserror.h
浏览文件 @
aa063917
...
...
@@ -185,6 +185,9 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) //"Invalid database option: days out of range")
#define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) //"Invalid database option: keep >= keep1 >= keep0 >= days")
#define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) //"Invalid topic name)
#define TSDB_CODE_MND_INVALID_TOPIC_OPTION TAOS_DEF_ERROR_CODE(0, 0x0393) //"Invalid topic option)
// dnode
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
...
...
src/inc/taosmsg.h
浏览文件 @
aa063917
...
...
@@ -107,6 +107,12 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY14
,
"dummy14"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_NETWORK_TEST
,
"nettest"
)
// message for topic
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_CREATE_TP
,
"create-tp"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_DROP_TP
,
"drop-tp"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_USE_TP
,
"use-tp"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_ALTER_TP
,
"alter-tp"
)
#ifndef TAOS_MESSAGE_C
TSDB_MSG_TYPE_MAX
// 105
#endif
...
...
@@ -141,6 +147,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_STREAMTABLES
,
TSDB_MGMT_TABLE_CLUSTER
,
TSDB_MGMT_TABLE_TP
,
TSDB_MGMT_TABLE_MAX
,
};
...
...
@@ -558,7 +565,9 @@ typedef struct {
int8_t
ignoreExist
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
reserve
[
8
];
int8_t
dbType
;
int16_t
partitions
;
int8_t
reserve
[
5
];
}
SCreateDbMsg
,
SAlterDbMsg
;
typedef
struct
{
...
...
@@ -677,7 +686,8 @@ typedef struct {
int8_t
cacheLastRow
;
int32_t
vgCfgVersion
;
int8_t
dbReplica
;
int8_t
reserved
[
9
];
int8_t
dbType
;
int8_t
reserved
[
8
];
}
SVnodeCfg
;
typedef
struct
{
...
...
src/inc/tp.h
0 → 100644
浏览文件 @
aa063917
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TP
#define TDENGINE_TP
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
tpInit
();
void
tpCleanUp
();
void
tpUpdateTs
(
int32_t
*
seq
,
void
*
pMsg
);
#ifdef __cplusplus
}
#endif
#endif
src/inc/ttokendef.h
浏览文件 @
aa063917
...
...
@@ -62,144 +62,147 @@
#define TK_BITNOT 43
#define TK_SHOW 44
#define TK_DATABASES 45
#define TK_MNODES 46
#define TK_DNODES 47
#define TK_ACCOUNTS 48
#define TK_USERS 49
#define TK_MODULES 50
#define TK_QUERIES 51
#define TK_CONNECTIONS 52
#define TK_STREAMS 53
#define TK_VARIABLES 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_CREATE 60
#define TK_TABLE 61
#define TK_DATABASE 62
#define TK_TABLES 63
#define TK_STABLES 64
#define TK_VGROUPS 65
#define TK_DROP 66
#define TK_STABLE 67
#define TK_DNODE 68
#define TK_USER 69
#define TK_ACCOUNT 70
#define TK_USE 71
#define TK_DESCRIBE 72
#define TK_ALTER 73
#define TK_PASS 74
#define TK_PRIVILEGE 75
#define TK_LOCAL 76
#define TK_IF 77
#define TK_EXISTS 78
#define TK_PPS 79
#define TK_TSERIES 80
#define TK_DBS 81
#define TK_STORAGE 82
#define TK_QTIME 83
#define TK_CONNS 84
#define TK_STATE 85
#define TK_KEEP 86
#define TK_CACHE 87
#define TK_REPLICA 88
#define TK_QUORUM 89
#define TK_DAYS 90
#define TK_MINROWS 91
#define TK_MAXROWS 92
#define TK_BLOCKS 93
#define TK_CTIME 94
#define TK_WAL 95
#define TK_FSYNC 96
#define TK_COMP 97
#define TK_PRECISION 98
#define TK_UPDATE 99
#define TK_CACHELAST 100
#define TK_LP 101
#define TK_RP 102
#define TK_UNSIGNED 103
#define TK_TAGS 104
#define TK_USING 105
#define TK_COMMA 106
#define TK_AS 107
#define TK_NULL 108
#define TK_SELECT 109
#define TK_UNION 110
#define TK_ALL 111
#define TK_DISTINCT 112
#define TK_FROM 113
#define TK_VARIABLE 114
#define TK_INTERVAL 115
#define TK_FILL 116
#define TK_SLIDING 117
#define TK_ORDER 118
#define TK_BY 119
#define TK_ASC 120
#define TK_DESC 121
#define TK_GROUP 122
#define TK_HAVING 123
#define TK_LIMIT 124
#define TK_OFFSET 125
#define TK_SLIMIT 126
#define TK_SOFFSET 127
#define TK_WHERE 128
#define TK_NOW 129
#define TK_RESET 130
#define TK_QUERY 131
#define TK_ADD 132
#define TK_COLUMN 133
#define TK_TAG 134
#define TK_CHANGE 135
#define TK_SET 136
#define TK_KILL 137
#define TK_CONNECTION 138
#define TK_STREAM 139
#define TK_COLON 140
#define TK_ABORT 141
#define TK_AFTER 142
#define TK_ATTACH 143
#define TK_BEFORE 144
#define TK_BEGIN 145
#define TK_CASCADE 146
#define TK_CLUSTER 147
#define TK_CONFLICT 148
#define TK_COPY 149
#define TK_DEFERRED 150
#define TK_DELIMITERS 151
#define TK_DETACH 152
#define TK_EACH 153
#define TK_END 154
#define TK_EXPLAIN 155
#define TK_FAIL 156
#define TK_FOR 157
#define TK_IGNORE 158
#define TK_IMMEDIATE 159
#define TK_INITIALLY 160
#define TK_INSTEAD 161
#define TK_MATCH 162
#define TK_KEY 163
#define TK_OF 164
#define TK_RAISE 165
#define TK_REPLACE 166
#define TK_RESTRICT 167
#define TK_ROW 168
#define TK_STATEMENT 169
#define TK_TRIGGER 170
#define TK_VIEW 171
#define TK_SEMI 172
#define TK_NONE 173
#define TK_PREV 174
#define TK_LINEAR 175
#define TK_IMPORT 176
#define TK_METRIC 177
#define TK_TBNAME 178
#define TK_JOIN 179
#define TK_METRICS 180
#define TK_INSERT 181
#define TK_INTO 182
#define TK_VALUES 183
#define TK_TOPICS 46
#define TK_MNODES 47
#define TK_DNODES 48
#define TK_ACCOUNTS 49
#define TK_USERS 50
#define TK_MODULES 51
#define TK_QUERIES 52
#define TK_CONNECTIONS 53
#define TK_STREAMS 54
#define TK_VARIABLES 55
#define TK_SCORES 56
#define TK_GRANTS 57
#define TK_VNODES 58
#define TK_IPTOKEN 59
#define TK_DOT 60
#define TK_CREATE 61
#define TK_TABLE 62
#define TK_DATABASE 63
#define TK_TABLES 64
#define TK_STABLES 65
#define TK_VGROUPS 66
#define TK_DROP 67
#define TK_STABLE 68
#define TK_TOPIC 69
#define TK_DNODE 70
#define TK_USER 71
#define TK_ACCOUNT 72
#define TK_USE 73
#define TK_DESCRIBE 74
#define TK_ALTER 75
#define TK_PASS 76
#define TK_PRIVILEGE 77
#define TK_LOCAL 78
#define TK_IF 79
#define TK_EXISTS 80
#define TK_PPS 81
#define TK_TSERIES 82
#define TK_DBS 83
#define TK_STORAGE 84
#define TK_QTIME 85
#define TK_CONNS 86
#define TK_STATE 87
#define TK_KEEP 88
#define TK_CACHE 89
#define TK_REPLICA 90
#define TK_QUORUM 91
#define TK_DAYS 92
#define TK_MINROWS 93
#define TK_MAXROWS 94
#define TK_BLOCKS 95
#define TK_CTIME 96
#define TK_WAL 97
#define TK_FSYNC 98
#define TK_COMP 99
#define TK_PRECISION 100
#define TK_UPDATE 101
#define TK_CACHELAST 102
#define TK_PARTITIONS 103
#define TK_LP 104
#define TK_RP 105
#define TK_UNSIGNED 106
#define TK_TAGS 107
#define TK_USING 108
#define TK_COMMA 109
#define TK_AS 110
#define TK_NULL 111
#define TK_SELECT 112
#define TK_UNION 113
#define TK_ALL 114
#define TK_DISTINCT 115
#define TK_FROM 116
#define TK_VARIABLE 117
#define TK_INTERVAL 118
#define TK_FILL 119
#define TK_SLIDING 120
#define TK_ORDER 121
#define TK_BY 122
#define TK_ASC 123
#define TK_DESC 124
#define TK_GROUP 125
#define TK_HAVING 126
#define TK_LIMIT 127
#define TK_OFFSET 128
#define TK_SLIMIT 129
#define TK_SOFFSET 130
#define TK_WHERE 131
#define TK_NOW 132
#define TK_RESET 133
#define TK_QUERY 134
#define TK_ADD 135
#define TK_COLUMN 136
#define TK_TAG 137
#define TK_CHANGE 138
#define TK_SET 139
#define TK_KILL 140
#define TK_CONNECTION 141
#define TK_STREAM 142
#define TK_COLON 143
#define TK_ABORT 144
#define TK_AFTER 145
#define TK_ATTACH 146
#define TK_BEFORE 147
#define TK_BEGIN 148
#define TK_CASCADE 149
#define TK_CLUSTER 150
#define TK_CONFLICT 151
#define TK_COPY 152
#define TK_DEFERRED 153
#define TK_DELIMITERS 154
#define TK_DETACH 155
#define TK_EACH 156
#define TK_END 157
#define TK_EXPLAIN 158
#define TK_FAIL 159
#define TK_FOR 160
#define TK_IGNORE 161
#define TK_IMMEDIATE 162
#define TK_INITIALLY 163
#define TK_INSTEAD 164
#define TK_MATCH 165
#define TK_KEY 166
#define TK_OF 167
#define TK_RAISE 168
#define TK_REPLACE 169
#define TK_RESTRICT 170
#define TK_ROW 171
#define TK_STATEMENT 172
#define TK_TRIGGER 173
#define TK_VIEW 174
#define TK_SEMI 175
#define TK_NONE 176
#define TK_PREV 177
#define TK_LINEAR 178
#define TK_IMPORT 179
#define TK_METRIC 180
#define TK_TBNAME 181
#define TK_JOIN 182
#define TK_METRICS 183
#define TK_INSERT 184
#define TK_INTO 185
#define TK_VALUES 186
#define TK_SPACE 300
...
...
@@ -210,7 +213,6 @@
#define TK_BIN 305 // bin format data 0b111
#define TK_FILE 306
#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query
#define TK_FUNCTION 308
#endif
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
aa063917
...
...
@@ -46,10 +46,11 @@
#include <stdio.h>
#include "os.h"
#ifdef TD_WINDOWS
#ifdef WINDOWS
#include <winsock2.h>
typedef
unsigned
__int32
uint32_t
;
#pragma comment ( lib, "ws2_32.lib" )
#pragma comment ( lib, "winmm.lib" )
#pragma comment ( lib, "wldap32.lib" )
#endif
#endif
...
...
@@ -95,6 +96,7 @@ extern char configDir[];
#define MAX_QUERY_SQL_LENGTH 256
#define MAX_DATABASE_COUNT 256
#define INPUT_BUF_LEN 256
typedef
enum
CREATE_SUB_TALBE_MOD_EN
{
PRE_CREATE_SUBTBL
,
...
...
@@ -1595,18 +1597,17 @@ static void printfQuerySystemInfo(TAOS * taos) {
}
void
ERROR_EXIT
(
const
char
*
msg
)
{
perror
(
msg
);
exit
(
0
);
}
void
ERROR_EXIT
(
const
char
*
msg
)
{
perror
(
msg
);
exit
(
-
1
);
}
int
postProceSql
(
char
*
host
,
uint16_t
port
,
char
*
sqlstr
)
{
char
*
req_fmt
=
"POST %s HTTP/1.1
\r\n
Host: %s:%d
\r\n
Accept: */*
\r\n
%s
\r\n
Content-Length: %d
\r\n
Content-Type: application/x-www-form-urlencoded
\r\n\r\n
%s"
;
char
*
req_fmt
=
"POST %s HTTP/1.1
\r\n
Host: %s:%d
\r\n
Accept: */*
\r\n
Authorization: Basic
%s
\r\n
Content-Length: %d
\r\n
Content-Type: application/x-www-form-urlencoded
\r\n\r\n
%s"
;
char
*
url
=
"/rest/sql"
;
char
*
auth
=
"Authorization: Basic cm9vdDp0YW9zZGF0YQ=="
;
struct
hostent
*
server
;
struct
sockaddr_in
serv_addr
;
int
sockfd
,
bytes
,
sent
,
received
,
req_str_len
,
resp_len
;
int
bytes
,
sent
,
received
,
req_str_len
,
resp_len
;
char
*
request_buf
;
char
response_buf
[
RESP_BUF_LEN
];
uint16_t
rest_port
=
port
+
TSDB_PORT_HTTP
;
...
...
@@ -1617,18 +1618,37 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
if
(
NULL
==
request_buf
)
ERROR_EXIT
(
"ERROR, cannot allocate memory."
);
int
r
=
snprintf
(
request_buf
,
req_buf_len
,
req_fmt
,
url
,
host
,
rest_port
,
auth
,
strlen
(
sqlstr
),
sqlstr
);
if
(
r
>=
req_buf_len
)
{
free
(
request_buf
);
ERROR_EXIT
(
"ERROR too long request"
);
}
printf
(
"Request:
\n
%s
\n
"
,
request_buf
);
char
userpass_buf
[
INPUT_BUF_LEN
];
int
mod_table
[]
=
{
0
,
2
,
1
};
static
char
base64
[]
=
{
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'+'
,
'/'
};
snprintf
(
userpass_buf
,
INPUT_BUF_LEN
,
"%s:%s"
,
g_Dbs
.
user
,
g_Dbs
.
password
);
size_t
userpass_buf_len
=
strlen
(
userpass_buf
);
size_t
encoded_len
=
4
*
((
userpass_buf_len
+
2
)
/
3
);
char
base64_buf
[
INPUT_BUF_LEN
];
#ifdef WINDOWS
WSADATA
wsaData
;
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
SOCKET
sockfd
;
#else
int
sockfd
;
#endif
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sockfd
<
0
)
{
#ifdef WINDOWS
fprintf
(
stderr
,
"Could not create socket : %d"
,
WSAGetLastError
());
#endif
debugPrint
(
"%s() LN%d sockfd=%d
\n
"
,
__func__
,
__LINE__
,
sockfd
);
free
(
request_buf
);
ERROR_EXIT
(
"ERROR opening socket"
);
}
...
...
@@ -1639,20 +1659,68 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
ERROR_EXIT
(
"ERROR, no such host"
);
}
debugPrint
(
"h_name: %s
\n
h_addretype: %s
\n
h_length: %d
\n
"
,
server
->
h_name
,
(
server
->
h_addrtype
==
AF_INET
)
?
"ipv4"
:
"ipv6"
,
server
->
h_length
);
memset
(
&
serv_addr
,
0
,
sizeof
(
serv_addr
));
serv_addr
.
sin_family
=
AF_INET
;
serv_addr
.
sin_port
=
htons
(
rest_port
);
#ifdef WINDOWS
serv_addr
.
sin_addr
.
s_addr
=
inet_addr
(
host
);
#else
memcpy
(
&
serv_addr
.
sin_addr
.
s_addr
,
server
->
h_addr
,
server
->
h_length
);
#endif
if
(
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
<
0
)
{
int
retConn
=
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
debugPrint
(
"%s() LN%d connect() return %d
\n
"
,
__func__
,
__LINE__
,
retConn
);
if
(
retConn
<
0
)
{
free
(
request_buf
);
ERROR_EXIT
(
"ERROR connecting"
);
}
memset
(
base64_buf
,
0
,
INPUT_BUF_LEN
);
for
(
int
n
=
0
,
m
=
0
;
n
<
userpass_buf_len
;)
{
uint32_t
oct_a
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_b
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_c
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
triple
=
(
oct_a
<<
0x10
)
+
(
oct_b
<<
0x08
)
+
oct_c
;
base64_buf
[
m
++
]
=
base64
[(
triple
>>
3
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
2
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
1
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
0
*
6
)
&
0x3f
];
}
for
(
int
l
=
0
;
l
<
mod_table
[
userpass_buf_len
%
3
];
l
++
)
base64_buf
[
encoded_len
-
1
-
l
]
=
'='
;
debugPrint
(
"%s() LN%d: auth string base64 encoded: %s
\n
"
,
__func__
,
__LINE__
,
base64_buf
);
char
*
auth
=
base64_buf
;
int
r
=
snprintf
(
request_buf
,
req_buf_len
,
req_fmt
,
url
,
host
,
rest_port
,
auth
,
strlen
(
sqlstr
),
sqlstr
);
if
(
r
>=
req_buf_len
)
{
free
(
request_buf
);
ERROR_EXIT
(
"ERROR too long request"
);
}
verbosePrint
(
"%s() LN%d: Request:
\n
%s
\n
"
,
__func__
,
__LINE__
,
request_buf
);
req_str_len
=
strlen
(
request_buf
);
sent
=
0
;
do
{
#ifdef WINDOWS
bytes
=
send
(
sockfd
,
request_buf
+
sent
,
req_str_len
-
sent
,
0
);
#else
bytes
=
write
(
sockfd
,
request_buf
+
sent
,
req_str_len
-
sent
);
#endif
if
(
bytes
<
0
)
ERROR_EXIT
(
"ERROR writing message to socket"
);
if
(
bytes
==
0
)
...
...
@@ -1664,7 +1732,11 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
resp_len
=
sizeof
(
response_buf
)
-
1
;
received
=
0
;
do
{
#ifdef WINDOWS
bytes
=
recv
(
sockfd
,
response_buf
+
received
,
resp_len
-
received
,
0
);
#else
bytes
=
read
(
sockfd
,
response_buf
+
received
,
resp_len
-
received
);
#endif
if
(
bytes
<
0
)
{
free
(
request_buf
);
ERROR_EXIT
(
"ERROR reading response from socket"
);
...
...
@@ -1683,7 +1755,12 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
printf
(
"Response:
\n
%s
\n
"
,
response_buf
);
free
(
request_buf
);
#ifdef WINDOWS
closesocket
(
sockfd
);
WSACleanup
();
#else
close
(
sockfd
);
#endif
return
0
;
}
...
...
@@ -2143,7 +2220,7 @@ static int createDatabases() {
debugPrint
(
"%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
))
{
taos_close
(
taos
);
printf
(
"
\n
create database %s failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
fprintf
(
stderr
,
"
\n
create database %s failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
return
-
1
;
}
printf
(
"
\n
create database %s success!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
...
...
@@ -2242,6 +2319,7 @@ static void* createTable(void *sarg)
len
=
0
;
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
if
(
0
!=
queryDbExec
(
winfo
->
taos
,
buffer
,
NO_INSERT_TYPE
)){
fprintf
(
stderr
,
"queryDbExec() failed. buffer:
\n
%s
\n
"
,
buffer
);
free
(
buffer
);
return
NULL
;
}
...
...
@@ -2256,7 +2334,9 @@ static void* createTable(void *sarg)
if
(
0
!=
len
)
{
verbosePrint
(
"%s() %d buffer: %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
(
void
)
queryDbExec
(
winfo
->
taos
,
buffer
,
NO_INSERT_TYPE
);
if
(
0
!=
queryDbExec
(
winfo
->
taos
,
buffer
,
NO_INSERT_TYPE
))
{
fprintf
(
stderr
,
"queryDbExec() failed. buffer:
\n
%s
\n
"
,
buffer
);
}
}
free
(
buffer
);
...
...
@@ -3949,9 +4029,7 @@ send_to_server:
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
if
(
0
>
affectedRows
)
{
goto
free_and_statistics
;
}
else
{
if
(
0
<
affectedRows
)
{
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
if
(
delay
>
winfo
->
maxDelay
)
winfo
->
maxDelay
=
delay
;
...
...
@@ -3960,6 +4038,9 @@ send_to_server:
winfo
->
totalDelay
+=
delay
;
winfo
->
avgDelay
=
(
double
)
winfo
->
totalDelay
/
winfo
->
cntDelay
;
winfo
->
totalAffectedRows
+=
affectedRows
;
}
else
{
fprintf
(
stderr
,
"queryDbExec() buffer:
\n
%s
\n
affected rows is %d"
,
buffer
,
affectedRows
);
goto
free_and_statistics
;
}
int64_t
currentPrintTime
=
taosGetTimestampMs
();
...
...
@@ -4102,10 +4183,11 @@ static void* syncWrite(void *sarg) {
winfo
->
totalAffectedRows
=
0
;
for
(
int
tID
=
winfo
->
start_table_id
;
tID
<=
winfo
->
end_table_id
;
tID
++
)
{
int64_t
tmp_time
=
time_counter
;
for
(
int
i
=
0
;
i
<
g_args
.
num_of_DPT
;)
{
int
tblInserted
=
i
;
int64_t
tmp_time
=
time_counter
;
char
*
pstr
=
buffer
;
pstr
+=
sprintf
(
pstr
,
...
...
@@ -4160,8 +4242,7 @@ static void* syncWrite(void *sarg) {
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
verbosePrint
(
"%s() LN%d: affectedRows:%d
\n
"
,
__func__
,
__LINE__
,
affectedRows
);
if
(
0
<=
affectedRows
){
if
(
0
<
affectedRows
){
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
if
(
delay
>
winfo
->
maxDelay
)
...
...
@@ -4172,9 +4253,11 @@ static void* syncWrite(void *sarg) {
winfo
->
totalDelay
+=
delay
;
winfo
->
totalAffectedRows
+=
affectedRows
;
winfo
->
avgDelay
=
(
double
)
winfo
->
totalDelay
/
winfo
->
cntDelay
;
}
else
{
fprintf
(
stderr
,
"queryDbExec() buffer:
\n
%s
\n
affected rows is %d"
,
buffer
,
affectedRows
);
}
verbosePrint
(
"%s() LN%d: totalaffectedRows:%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
winfo
->
totalAffectedRows
);
verbosePrint
(
"%s() LN%d: totalaffectedRows:%"
PRId64
"
tblInserted=%d
\n
"
,
__func__
,
__LINE__
,
winfo
->
totalAffectedRows
,
tblInserted
);
if
(
g_args
.
insert_interval
)
{
et
=
taosGetTimestampMs
();
}
...
...
@@ -4258,7 +4341,7 @@ static void* syncWriteWithStb(void *sarg) {
int
sampleUsePos
;
debug
Print
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
superTblInfo
->
insertRows
);
verbose
Print
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
superTblInfo
->
insertRows
);
for
(
uint32_t
tID
=
winfo
->
start_table_id
;
tID
<=
winfo
->
end_table_id
;
tID
++
)
{
...
...
@@ -4364,7 +4447,7 @@ static void* syncWriteWithStb(void *sarg) {
}
len
+=
retLen
;
verbosePrint
(
"%s() LN%d retLen=%d len=%d k=%d buffer=%s
\n
"
,
__func__
,
__LINE__
,
retLen
,
len
,
k
,
buffer
);
verbosePrint
(
"%s() LN%d retLen=%d len=%d k=%d
\n
buffer=%s
\n
"
,
__func__
,
__LINE__
,
retLen
,
len
,
k
,
buffer
);
tblInserted
++
;
k
++
;
...
...
@@ -4376,24 +4459,35 @@ static void* syncWriteWithStb(void *sarg) {
winfo
->
totalRowsInserted
+=
k
;
if
(
0
==
strncasecmp
(
superTblInfo
->
insertMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
int64_t
startTs
;
int64_t
startTs
=
taosGetTimestampUs
();
int64_t
endTs
;
startTs
=
taosGetTimestampUs
()
;
int
affectedRows
;
if
(
0
==
strncasecmp
(
superTblInfo
->
insertMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
if
(
0
>
affectedRows
){
goto
free_and_statistics_2
;
}
}
else
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
retCode
=
postProceSql
(
g_Dbs
.
host
,
g_Dbs
.
port
,
buffer
);
if
(
0
!=
retCode
)
{
printf
(
"========restful return fail, threadID[%d]
\n
"
,
winfo
->
threadID
);
goto
free_and_statistics_2
;
}
affectedRows
=
k
;
}
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
if
(
delay
>
winfo
->
maxDelay
)
winfo
->
maxDelay
=
delay
;
if
(
delay
<
winfo
->
minDelay
)
winfo
->
minDelay
=
delay
;
winfo
->
cntDelay
++
;
winfo
->
totalDelay
+=
delay
;
}
winfo
->
totalAffectedRows
+=
affectedRows
;
int64_t
currentPrintTime
=
taosGetTimestampMs
();
...
...
@@ -4404,14 +4498,7 @@ static void* syncWriteWithStb(void *sarg) {
winfo
->
totalAffectedRows
);
lastPrintTime
=
currentPrintTime
;
}
}
else
{
int
retCode
=
postProceSql
(
g_Dbs
.
host
,
g_Dbs
.
port
,
buffer
);
if
(
0
!=
retCode
)
{
printf
(
"========restful return fail, threadID[%d]
\n
"
,
winfo
->
threadID
);
goto
free_and_statistics_2
;
}
}
if
(
g_args
.
insert_interval
)
{
et
=
taosGetTimestampMs
();
}
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
aa063917
...
...
@@ -175,7 +175,9 @@ typedef struct {
int8_t
quorum
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
reserved
[
10
];
int8_t
dbType
;
int16_t
partitions
;
int8_t
reserved
[
7
];
}
SDbCfg
;
typedef
struct
SDbObj
{
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
aa063917
...
...
@@ -22,6 +22,7 @@
#include "tname.h"
#include "tbn.h"
#include "tdataformat.h"
#include "tp.h"
#include "mnode.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
...
...
@@ -39,7 +40,7 @@
#define VG_LIST_SIZE 8
int64_t
tsDbRid
=
-
1
;
static
void
*
tsDbSdb
=
NULL
;
void
*
tsDbSdb
=
NULL
;
static
int32_t
tsDbUpdateSize
;
static
int32_t
mnodeCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
,
SMnodeMsg
*
pMsg
);
...
...
@@ -48,8 +49,14 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb);
static
int32_t
mnodeGetDbMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeProcessCreateDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropDbMsg
(
SMnodeMsg
*
pMsg
);
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
);
#ifndef _TOPIC
int32_t
tpInit
()
{
return
0
;
}
void
tpCleanUp
()
{}
void
tpUpdateTs
(
int32_t
*
seq
,
void
*
pMsg
)
{}
#endif
static
void
mnodeDestroyDb
(
SDbObj
*
pDb
)
{
pthread_mutex_destroy
(
&
pDb
->
mutex
);
...
...
@@ -176,7 +183,7 @@ int32_t mnodeInitDbs() {
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
mDebug
(
"table:dbs table is created"
);
return
0
;
return
tpInit
()
;
}
void
*
mnodeGetNextDb
(
void
*
pIter
,
SDbObj
**
pDb
)
{
...
...
@@ -332,6 +339,17 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
if
(
pCfg
->
dbType
<
0
||
pCfg
->
dbType
>
1
)
{
mError
(
"invalid db option dbType:%d valid range: [%d, %d]"
,
pCfg
->
dbType
,
0
,
1
);
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
if
(
pCfg
->
partitions
<
TSDB_MIN_DB_PARTITON_OPTION
||
pCfg
->
partitions
>
TSDB_MAX_DB_PARTITON_OPTION
)
{
mError
(
"invalid db option partitions:%d valid range: [%d, %d]"
,
pCfg
->
partitions
,
TSDB_MIN_DB_PARTITON_OPTION
,
TSDB_MAX_DB_PARTITON_OPTION
);
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -354,6 +372,8 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
quorum
<
0
)
pCfg
->
quorum
=
tsQuorum
;
if
(
pCfg
->
update
<
0
)
pCfg
->
update
=
tsUpdate
;
if
(
pCfg
->
cacheLastRow
<
0
)
pCfg
->
cacheLastRow
=
tsCacheLastRow
;
if
(
pCfg
->
dbType
<
0
)
pCfg
->
dbType
=
0
;
if
(
pCfg
->
partitions
<
0
)
pCfg
->
partitions
=
tsPartitons
;
}
static
int32_t
mnodeCreateDbCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
...
...
@@ -408,7 +428,9 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
.
replications
=
pCreate
->
replications
,
.
quorum
=
pCreate
->
quorum
,
.
update
=
pCreate
->
update
,
.
cacheLastRow
=
pCreate
->
cacheLastRow
.
cacheLastRow
=
pCreate
->
cacheLastRow
,
.
dbType
=
pCreate
->
dbType
,
.
partitions
=
pCreate
->
partitions
};
mnodeSetDefaultDbCfg
(
&
pDb
->
cfg
);
...
...
@@ -501,6 +523,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
}
void
mnodeCleanupDbs
()
{
tpCleanUp
();
sdbCloseTable
(
tsDbRid
);
tsDbSdb
=
NULL
;
}
...
...
@@ -660,7 +683,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
return
0
;
}
static
char
*
mnodeGetDbStr
(
char
*
src
)
{
char
*
mnodeGetDbStr
(
char
*
src
)
{
char
*
pos
=
strstr
(
src
,
TS_PATH_DELIMITER
);
if
(
pos
!=
NULL
)
++
pos
;
...
...
@@ -852,6 +875,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
pCreate
->
daysToKeep2
=
htonl
(
pCreate
->
daysToKeep2
);
pCreate
->
commitTime
=
htonl
(
pCreate
->
commitTime
);
pCreate
->
fsyncPeriod
=
htonl
(
pCreate
->
fsyncPeriod
);
pCreate
->
partitions
=
htons
(
pCreate
->
partitions
);
pCreate
->
minRowsPerFileBlock
=
htonl
(
pCreate
->
minRowsPerFileBlock
);
pCreate
->
maxRowsPerFileBlock
=
htonl
(
pCreate
->
maxRowsPerFileBlock
);
...
...
@@ -887,6 +911,8 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
int8_t
precision
=
pAlter
->
precision
;
int8_t
update
=
pAlter
->
update
;
int8_t
cacheLastRow
=
pAlter
->
cacheLastRow
;
int8_t
dbType
=
pAlter
->
dbType
;
int16_t
partitions
=
htons
(
pAlter
->
partitions
);
terrno
=
TSDB_CODE_SUCCESS
;
...
...
@@ -1004,6 +1030,16 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
newCfg
.
cacheLastRow
=
cacheLastRow
;
}
if
(
dbType
>=
0
&&
dbType
!=
pDb
->
cfg
.
dbType
)
{
mDebug
(
"db:%s, dbType:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
dbType
,
dbType
);
newCfg
.
dbType
=
dbType
;
}
if
(
partitions
>=
0
&&
partitions
!=
pDb
->
cfg
.
partitions
)
{
mDebug
(
"db:%s, partitions:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
partitions
,
partitions
);
newCfg
.
partitions
=
partitions
;
}
return
newCfg
;
}
...
...
@@ -1031,6 +1067,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
}
static
int32_t
mnodeAlterDb
(
SDbObj
*
pDb
,
SAlterDbMsg
*
pAlter
,
void
*
pMsg
)
{
mDebug
(
"db:%s, type:%d do alter operation"
,
pDb
->
name
,
pDb
->
cfg
.
dbType
);
SDbCfg
newCfg
=
mnodeGetAlterDbOption
(
pDb
,
pAlter
);
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
return
terrno
;
...
...
@@ -1061,9 +1099,9 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
return
code
;
}
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
SAlterDbMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"db:%s, alter db msg is received from thandle:%p
"
,
pAlter
->
db
,
pMsg
->
rpcMsg
.
handl
e
);
mDebug
(
"db:%s, alter db msg is received from thandle:%p
, dbType:%d"
,
pAlter
->
db
,
pMsg
->
rpcMsg
.
handle
,
pAlter
->
dbTyp
e
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDb
(
pAlter
->
db
);
if
(
pMsg
->
pDb
==
NULL
)
{
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
aa063917
...
...
@@ -109,6 +109,7 @@ static char *mnodeGetShowType(int32_t showType) {
case
TSDB_MGMT_TABLE_VNODES
:
return
"show vnodes"
;
case
TSDB_MGMT_TABLE_CLUSTER
:
return
"show clusters"
;
case
TSDB_MGMT_TABLE_STREAMTABLES
:
return
"show streamtables"
;
case
TSDB_MGMT_TABLE_TP
:
return
"show topics"
;
default:
return
"undefined"
;
}
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
aa063917
...
...
@@ -367,6 +367,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
maxIdPoolSize
=
MAX
(
maxIdPoolSize
,
idPoolSize
);
}
// create one table each vnode
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
)
{
maxIdPoolSize
=
1
;
}
// new vgroup
if
(
pInputVgroup
->
idPool
==
NULL
)
{
pInputVgroup
->
idPool
=
taosInitIdPool
(
maxIdPoolSize
);
...
...
@@ -379,6 +384,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
}
}
// create one table each vnode
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
)
{
return
TSDB_CODE_SUCCESS
;
}
// realloc all vgroups in db
int32_t
newIdPoolSize
;
if
(
minIdPoolSize
*
4
<
tsTableIncStepPerVnode
)
{
...
...
@@ -449,6 +459,10 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
maxVgroupsPerDb
=
MIN
(
maxVgroupsPerDb
,
TSDB_MAX_VNODES_PER_DB
);
}
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
)
{
maxVgroupsPerDb
=
TSDB_MAX_DB_PARTITON_OPTION
;
}
int32_t
code
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
if
(
pDb
->
numOfVgroups
<
maxVgroupsPerDb
)
{
mDebug
(
"msg:%p, app:%p db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d"
,
pMsg
,
...
...
@@ -881,6 +895,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
pCfg
->
update
=
pDb
->
cfg
.
update
;
pCfg
->
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
pCfg
->
dbReplica
=
pDb
->
cfg
.
replications
;
pCfg
->
dbType
=
pDb
->
cfg
.
dbType
;
SVnodeDesc
*
pNodes
=
pVnode
->
nodes
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
...
...
src/query/inc/qSqlparser.h
浏览文件 @
aa063917
...
...
@@ -125,6 +125,8 @@ typedef struct SCreateDbInfo {
int8_t
update
;
int8_t
cachelast
;
SArray
*
keep
;
int8_t
dbType
;
int16_t
partitions
;
}
SCreateDbInfo
;
typedef
struct
SCreateAcctInfo
{
...
...
@@ -155,6 +157,7 @@ typedef struct SUserInfo {
typedef
struct
SMiscInfo
{
SArray
*
a
;
// SArray<SStrToken>
bool
existsCheck
;
int16_t
dbType
;
int16_t
tableType
;
SUserInfo
user
;
union
{
...
...
@@ -278,7 +281,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
dbType
,
int16_t
tableType
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
prefix
,
SStrToken
*
pPatterns
);
void
setCreateDbInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SCreateDbInfo
*
pDB
,
SStrToken
*
pIgExists
);
...
...
@@ -289,6 +292,7 @@ void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
void
setAlterUserSql
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SStrToken
*
pName
,
SStrToken
*
pPwd
,
SStrToken
*
pPrivilege
);
void
setDefaultCreateDbOption
(
SCreateDbInfo
*
pDBInfo
);
void
setDefaultCreateTopicOption
(
SCreateDbInfo
*
pDBInfo
);
// prefix show db.tables;
void
setDbName
(
SStrToken
*
pCpxName
,
SStrToken
*
pDb
);
...
...
src/query/inc/sql.y
浏览文件 @
aa063917
无法预览此类型文件
src/query/src/qParserImpl.c
浏览文件 @
aa063917
...
...
@@ -817,7 +817,7 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_end
(
va
);
}
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
)
{
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
dbType
,
int16_t
tableType
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pMiscInfo
==
NULL
)
{
...
...
@@ -828,6 +828,7 @@ void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrTo
taosArrayPush
(
pInfo
->
pMiscInfo
->
a
,
pToken
);
pInfo
->
pMiscInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
pInfo
->
pMiscInfo
->
dbType
=
dbType
;
pInfo
->
pMiscInfo
->
tableType
=
tableType
;
}
...
...
@@ -947,6 +948,17 @@ void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) {
pDBInfo
->
keep
=
NULL
;
pDBInfo
->
update
=
-
1
;
pDBInfo
->
cachelast
=
0
;
pDBInfo
->
cachelast
=
-
1
;
pDBInfo
->
dbType
=
-
1
;
pDBInfo
->
partitions
=
-
1
;
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SStrToken
));
}
void
setDefaultCreateTopicOption
(
SCreateDbInfo
*
pDBInfo
)
{
setDefaultCreateDbOption
(
pDBInfo
);
pDBInfo
->
dbType
=
TSDB_DB_TYPE_TOPIC
;
pDBInfo
->
partitions
=
TSDB_DEFAULT_DB_PARTITON_OPTION
;
}
src/query/src/qTokenizer.c
浏览文件 @
aa063917
...
...
@@ -215,6 +215,9 @@ static SKeyword keywordTable[] = {
{
"UNION"
,
TK_UNION
},
{
"CACHELAST"
,
TK_CACHELAST
},
{
"DISTINCT"
,
TK_DISTINCT
},
{
"PARTITIONS"
,
TK_PARTITIONS
},
{
"TOPIC"
,
TK_TOPIC
},
{
"TOPICS"
,
TK_TOPICS
}
};
static
const
char
isIdChar
[]
=
{
...
...
src/query/src/sql.c
浏览文件 @
aa063917
此差异已折叠。
点击以展开。
src/util/src/terror.c
浏览文件 @
aa063917
...
...
@@ -197,6 +197,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_READY, "Database unsynced")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_DB_OPTION_DAYS
,
"Invalid database option: days out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_DB_OPTION_KEEP
,
"Invalid database option: keep >= keep1 >= keep0 >= days"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TOPIC
,
"Invalid topic name"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TOPIC_OPTION
,
"Invalid topic option"
)
// dnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MSG_NOT_PROCESSED
,
"Message not processed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_OUT_OF_MEMORY
,
"Dnode out of memory"
)
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
aa063917
...
...
@@ -40,6 +40,7 @@ typedef struct {
int32_t
queuedWMsg
;
int32_t
queuedRMsg
;
int32_t
flowctrlLevel
;
int32_t
sequence
;
// for topic
int8_t
status
;
int8_t
role
;
int8_t
accessState
;
...
...
@@ -47,7 +48,7 @@ typedef struct {
int8_t
isCommiting
;
int8_t
dbReplica
;
int8_t
dropped
;
int8_t
reserved
;
int8_t
dbType
;
uint64_t
version
;
// current version
uint64_t
cversion
;
// version while commit start
uint64_t
fversion
;
// version on saved data file
...
...
src/vnode/src/vnodeCfg.c
浏览文件 @
aa063917
...
...
@@ -42,6 +42,7 @@ static void vnodeLoadCfg(SVnodeObj *pVnode, SCreateVnodeMsg* vnodeMsg) {
pVnode
->
syncCfg
.
replica
=
vnodeMsg
->
cfg
.
vgReplica
;
pVnode
->
syncCfg
.
quorum
=
vnodeMsg
->
cfg
.
quorum
;
pVnode
->
dbReplica
=
vnodeMsg
->
cfg
.
dbReplica
;
pVnode
->
dbType
=
vnodeMsg
->
cfg
.
dbType
;
for
(
int
i
=
0
;
i
<
pVnode
->
syncCfg
.
replica
;
++
i
)
{
SVnodeDesc
*
node
=
&
vnodeMsg
->
nodes
[
i
];
...
...
@@ -214,7 +215,7 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
dbReplica
=
cJSON_GetObjectItem
(
root
,
"dbReplica"
);
if
(
!
dbReplica
||
dbReplica
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId:%d, failed to read %s, dbReplica not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId:%d, failed to read %s, dbReplica not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
dbReplica
=
vnodeMsg
.
cfg
.
vgReplica
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
...
...
@@ -230,7 +231,7 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
update
=
cJSON_GetObjectItem
(
root
,
"update"
);
if
(
!
update
||
update
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId: %d, failed to read %s, update not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId: %d, failed to read %s, update not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
update
=
0
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
...
...
@@ -239,13 +240,21 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
cacheLastRow
=
cJSON_GetObjectItem
(
root
,
"cacheLastRow"
);
if
(
!
cacheLastRow
||
cacheLastRow
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId: %d, failed to read %s, cacheLastRow not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId: %d, failed to read %s, cacheLastRow not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
cacheLastRow
=
0
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
vnodeMsg
.
cfg
.
cacheLastRow
=
(
int8_t
)
cacheLastRow
->
valueint
;
}
cJSON
*
dbType
=
cJSON_GetObjectItem
(
root
,
"dbType"
);
if
(
!
dbType
||
dbType
->
type
!=
cJSON_Number
)
{
vWarn
(
"vgId: %d, failed to read %s, dbType not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
dbType
=
0
;
}
else
{
vnodeMsg
.
cfg
.
dbType
=
(
int8_t
)
dbType
->
valueint
;
}
cJSON
*
nodeInfos
=
cJSON_GetObjectItem
(
root
,
"nodeInfos"
);
if
(
!
nodeInfos
||
nodeInfos
->
type
!=
cJSON_Array
)
{
vError
(
"vgId:%d, failed to read %s, nodeInfos not found"
,
pVnode
->
vgId
,
file
);
...
...
@@ -337,6 +346,7 @@ int32_t vnodeWriteCfg(SCreateVnodeMsg *pMsg) {
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
quorum
\"
: %d,
\n
"
,
pMsg
->
cfg
.
quorum
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
update
\"
: %d,
\n
"
,
pMsg
->
cfg
.
update
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
cacheLastRow
\"
: %d,
\n
"
,
pMsg
->
cfg
.
cacheLastRow
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dbType
\"
: %d,
\n
"
,
pMsg
->
cfg
.
dbType
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeInfos
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
pMsg
->
cfg
.
vgReplica
;
i
++
)
{
SVnodeDesc
*
node
=
&
pMsg
->
nodes
[
i
];
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
aa063917
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tp.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "tglobal.h"
...
...
@@ -139,6 +140,10 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
vTrace
(
"vgId:%d, submit msg is processed"
,
pVnode
->
vgId
);
if
(
pVnode
->
dbType
==
TSDB_DB_TYPE_TOPIC
&&
pVnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
tpUpdateTs
(
&
pVnode
->
sequence
,
pCont
);
}
// save insert result into item
SShellSubmitRspMsg
*
pRsp
=
NULL
;
if
(
pRet
)
{
...
...
tests/script/general/db/topic1.sim
0 → 100644
浏览文件 @
aa063917
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 100
system sh/cfg.sh -n dnode1 -c partitions -v 4
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ====step1 create with default para
sql create topic t1;
sql use t1;
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
if $data02 != 4 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 < 1 then
return -1
endi
#numofvgroups
if $data03 < 1 then
return -1
endi
sql show t1.vgroups;
if $rows < 1 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
if $data04 < 1 then
return -1
endi
sql show t1.tables;
if $rows < 1 then
return -1
endi
sql drop topic t1
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
sql_error use t1;
sql_error show t1.vgroups;
sql_error show t1.stables;
sql_error show t1.tables;
print ====step2 create with giving para
sql create topic t1 partitions 6;
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
if $data02 != 6 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 != 6 then
return -1
endi
#numofvgroups
if $data03 != 6 then
return -1
endi
sql show t1.vgroups;
if $rows != 6 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
if $data00 != ps then
return -1
endi
if $data04 != 6 then
return -1
endi
sql show t1.tables;
if $rows != 6 then
return -1
endi
sql describe t1.ps;
if $data00 != off then
return -1
endi
if $data10 != ts then
return -1
endi
if $data20 != content then
return -1
endi
if $data30 != pid then
return -1
endi
sql describe t1.p1;
if $data00 != off then
return -1
endi
if $data10 != ts then
return -1
endi
if $data20 != content then
return -1
endi
if $data30 != pid then
return -1
endi
sql drop topic t1
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
sql_error show t1.vgroups;
sql_error show t1.stables;
sql_error show t1.tables;
sql_error create topic t1 partitions -1;
sql_error create topic t1 partitions 0;
sql_error create topic t1 partitions 10001;
print =============step3 create with db para
sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1
sql show databases
if $data00 != db then
return -1
endi
if $data02 != 4 then
return -1
endi
if $data03 != 4 then
return -1
endi
if $data04 != 1 then
return -1
endi
if $data06 != 10 then
return -1
endi
if $data07 != 20,20,20 then
return -1
endi
if $data08 != 2 then
return -1
endi
if $data09 != 4 then
return -1
endi
sql drop topic db;
sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 partitions 7
sql show databases
if $data00 != db then
return -1
endi
if $data02 != 7 then
return -1
endi
if $data03 != 7 then
return -1
endi
if $data04 != 1 then
return -1
endi
if $data06 != 10 then
return -1
endi
if $data07 != 20,20,20 then
return -1
endi
if $data08 != 2 then
return -1
endi
if $data09 != 4 then
return -1
endi
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != db then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != db then
return -1
endi
#tables
if $data02 != 7 then
return -1
endi
#numofvgroups
sql show db.vgroups;
if $rows != 7 then
return -1
endi
sql show db.stables;
if $rows != 1 then
return -1
endi
sql show db.tables;
if $rows != 7 then
return -1
endi
print ============== step name
sql_error alter database db name d1
sql_error alter database db name d2
sql_error alter topic db name d1
sql_error alter topic db name d2
print ============== step ntables
sql_error alter database db ntables -1
sql_error alter database db ntables 0
sql_error alter database db ntables 1
sql_error alter database db ntables 10
sql_error alter topic db ntables -1
sql_error alter topic db ntables 0
sql_error alter topic db ntables 1
sql_error alter topic db ntables 10
print ============== step vgroups
sql_error alter database db vgroups -1
sql_error alter database db vgroups 0
sql_error alter database db vgroups 1
sql_error alter database db vgroups 10
sql_error alter topic db vgroups -1
sql_error alter topic db vgroups 0
sql_error alter topic db vgroups 1
sql_error alter topic db vgroups 10
print ============== step replica
sql_error alter database db replica 2
sql_error alter database db replica 3
sql_error alter database db replica 0
sql_error alter topic db replica 2
sql_error alter topic db replica 3
sql_error alter topic db replica 0
sql alter database db replica 1
sql show databases
print replica $data4_db
if $data4_db != 1 then
return -1
endi
sql show topics
if $rows != 1 then
return -1
endi
print ============== step quorum
sql show databases
print quorum $data5_db
if $data5_db != 1 then
return -1
endi
sql_error alter topic db quorum 1
sql alter database db quorum 1
sql show databases
print quorum $data5_db
if $data5_db != 1 then
return -1
endi
sql_error alter database db quorum 2
sql_error alter database db quorum 3
sql_error alter topic db quorum 2
sql_error alter topic db quorum 3
sql_error alter database db quorum 0
sql_error alter database db quorum 4
sql_error alter database db quorum 5
sql_error alter database db quorum -1
sql_error alter topic db quorum 0
sql_error alter topic db quorum 4
sql_error alter topic db quorum 5
sql_error alter topic db quorum -1
print ============== step days
sql_error alter database db days 0
sql_error alter database db days 1
sql_error alter database db days 2
sql_error alter database db days 10
sql_error alter database db days 50
sql_error alter database db days 100
sql_error alter topic db days 0
sql_error alter topic db days 1
sql_error alter topic db days 2
sql_error alter topic db days 10
sql_error alter topic db days 50
sql_error alter topic db days 100
print ============== step keep
sql show databases
print keep $data7_db
if $data7_db != 20,20,20 then
return -1
endi
sql_error topic db keep 20
sql alter database db keep 20
sql show databases
print keep $data7_db
if $data7_db != 20,20,20 then
return -1
endi
sql_error topic db keep 30
sql alter database db keep 30
sql show databases
print keep $data7_db
if $data7_db != 20,20,30 then
return -1
endi
sql_error alter topic db keep 40
sql alter database db keep 40
sql show databases
print keep $data7_db
if $data7_db != 20,20,40 then
return -1
endi
sql alter database db keep 40
sql alter database db keep 30
sql alter database db keep 20
sql_error alter database db keep 10
sql_error alter database db keep 9
sql_error alter database db keep 1
sql alter database db keep 0
sql alter database db keep -1
sql_error alter database db keep 365001
sql_error alter topic db keep 40
sql_error alter topic db keep 30
sql_error alter topic db keep 20
sql_error alter topic db keep 10
sql_error alter topic db keep 9
sql_error alter topic db keep 1
sql_error alter topic db keep 0
sql_error alter topic db keep -1
sql_error alter topic db keep 365001
print ============== step cache
sql_error alter database db cache 60
sql_error alter database db cache 50
sql_error alter database db cache 20
sql_error alter database db cache 3
sql_error alter database db cache 129
sql_error alter database db cache 300
sql_error alter database db cache 0
sql_error alter database db cache -1
sql_error alter topic db cache 60
sql_error alter topic db cache 50
sql_error alter topic db cache 20
sql_error alter topic db cache 3
sql_error alter topic db cache 129
sql_error alter topic db cache 300
sql_error alter topic db cache 0
sql_error alter topic db cache -1
print ============== step blocks
sql show databases
print blocks $data9_db
if $data9_db != 4 then
return -1
endi
sql_error alter topic db blocks 10
sql alter database db blocks 10
sql show databases
print blocks $data9_db
if $data9_db != 10 then
return -1
endi
sql_error alter topic db blocks 20
sql alter database db blocks 20
sql show databases
print blocks $data9_db
if $data9_db != 20 then
return -1
endi
sql_error alter topic db blocks 20
sql alter database db blocks 30
sql show databases
print blocks $data9_db
if $data9_db != 30 then
return -1
endi
sql alter database db blocks 40
sql alter database db blocks 30
sql alter database db blocks 20
sql alter database db blocks 10
sql_error alter database db blocks 2
sql_error alter database db blocks 1
sql alter database db blocks 0
sql_error alter database db blocks -1
sql_error alter database db blocks 10001
sql_error alter topic db blocks 40
sql_error alter topic db blocks 30
sql_error alter topic db blocks 20
sql_error alter topic db blocks 10
sql_error alter topic db blocks 2
sql_error alter topic db blocks 1
sql_error alter topic db blocks 0
sql_error alter topic db blocks -1
sql_error alter topic db blocks 10001
print ============== step minrows
sql_error alter database db minrows 1
sql_error alter database db minrows 100
sql_error alter database db minrows 1000
sql_error alter topic db minrows 1
sql_error alter topic db minrows 100
sql_error alter topic db minrows 1000
print ============== step maxrows
sql_error alter database db maxrows 1
sql_error alter database db maxrows 100
sql_error alter database db maxrows 1000
sql_error alter topic db maxrows 1
sql_error alter topic db maxrows 100
sql_error alter topic db maxrows 1000
print ============== step wallevel
sql show databases
print wallevel $data12_db
if $data12_db != 1 then
return -1
endi
sql_error alter topic db wal 1
sql alter database db wal 1
sql show databases
print wal $data12_db
if $data12_db != 1 then
return -1
endi
sql alter database db wal 1
sql alter database db wal 2
sql alter database db wal 1
sql alter database db wal 2
sql alter database db wal 0
sql_error alter database db wal 3
sql_error alter database db wal 4
sql_error alter database db wal -1
sql_error alter database db wal 1000
sql_error alter topic db wal 1
sql_error alter topic db wal 2
sql_error alter topic db wal 1
sql_error alter topic db wal 2
sql_error alter topic db wal 0
sql_error alter topic db wal 3
sql_error alter topic db wal 4
sql_error alter topic db wal -1
sql_error alter topic db wal 1000
print ============== step fsync
sql alter database db fsync 0
sql alter database db fsync 1
sql alter database db fsync 3600
sql alter database db fsync 18000
sql alter database db fsync 180000
sql_error alter database db fsync 180001
sql_error alter database db fsync -1
sql_error alter topic db fsync 0
sql_error alter topic db fsync 1
sql_error alter topic db fsync 3600
sql_error alter topic db fsync 18000
sql_error alter topic db fsync 180000
sql_error alter topic db fsync 180001
sql_error alter topic db fsync -1
print ============== step comp
sql show databases
print comp $data14_db
if $data14_db != 2 then
return -1
endi
sql_error alter topic db comp 1
sql alter database db comp 1
sql show databases
print comp $data14_db
if $data14_db != 1 then
return -1
endi
sql_error alter topic db comp 2
sql alter database db comp 2
sql show databases
print comp $data14_db
if $data14_db != 2 then
return -1
endi
sql_error alter topic db comp 0
sql alter database db comp 0
sql show databases
print comp $data14_db
if $data14_db != 0 then
return -1
endi
sql_error alter database db comp 3
sql_error alter database db comp 4
sql_error alter database db comp 5
sql_error alter database db comp -1
sql_error alter topic db comp 3
sql_error alter topic db comp 4
sql_error alter topic db comp 5
sql_error alter topic db comp -1
print ============== step precision
sql_error alter database db prec 'us'
sql_error alter topic db prec 'us'
print ============== step status
sql_error alter database db status 'delete'
sql_error alter topic db status 'delete'
print ============== step drop
sql drop database db
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
print ============== step db1
sql create database d1
sql_error alter database d1 partitions 2
sql_error alter topic d1 partitions 2
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql alter database d1 fsync 0
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql drop database d1
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
print ============== step db2
sql create topic d1
sql show topics;
if $rows != 1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql alter database d1 fsync 0
sql show topics;
if $rows != 1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql drop database d1
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
print ============== step db3
sql create topic d1
sql show topics;
if $rows != 1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql alter topic d1 partitions 2
sql show topics;
if $rows != 1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql drop database d1
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 0 then
return -1
endi
print ============== step partitions
sql create topic t1 partitions 5
sql_error alter database t1 partitions -1
sql_error alter database t1 partitions 0
sql_error alter database t1 partitions 1
sql_error alter database t1 partitions 2
sql_error alter database t1 partitions 3
sql_error alter database t1 partitions 100
sql_error alter database t1 partitions 1000
sql_error alter database t1 partitions 10000
sql_error alter topic t1 partitions -1
sql_error alter topic t1 partitions 0
sql_error alter database t1 partitions 10000
sql alter topic t1 partitions 1
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 != 1 then
return -1
endi
#numofvgroups
sql show t1.vgroups;
if $rows != 1 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
sql show t1.tables;
if $rows != 1 then
return -1
endi
sql alter topic t1 partitions 2
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 != 2 then
return -1
endi
#numofvgroups
sql show t1.vgroups;
if $rows != 2 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
sql show t1.tables;
if $rows != 2 then
return -1
endi
sql alter topic t1 partitions 3
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 != 3 then
return -1
endi
#numofvgroups
sql show t1.vgroups;
if $rows != 3 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
sql show t1.tables;
if $rows != 3 then
return -1
endi
sql alter topic t1 partitions 10
sql show topics;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
if $data00 != t1 then
return -1
endi
#tables
if $data02 != 10 then
return -1
endi
#numofvgroups
sql show t1.vgroups;
if $rows != 10 then
return -1
endi
sql show t1.stables;
if $rows != 1 then
return -1
endi
sql show t1.tables;
if $rows != 10 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/general/db/topic2.sim
0 → 100644
浏览文件 @
aa063917
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ==== step1
sql create topic t1 partitions 2;
sql show t1.tables
if $rows != 2 then
return -1
endi
sql show t1.vgroups
if $rows != 2 then
return -1
endi
sql insert into t1.p1 values(1, now, '1');
sql insert into t1.p1 values(1, now, '2');
sql insert into t1.p1 values(1, now, '3');
sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p2 values(1, now, '1');
sql insert into t1.p2 values(1, now, '2');
sql insert into t1.p2 values(1, now, '3');
sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p3 values(1, now, '1');
sql_error insert into t1.p3 values(1, now, '2');
sql_error insert into t1.p3 values(1, now, '3');
sql_error insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql select * from t1.p1 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p2 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
print ==== step2
sql alter topic t1 partitions 4;
sql show t1.tables
if $rows != 4 then
return -1
endi
sql show t1.vgroups
if $rows != 4 then
return -1
endi
sql insert into t1.p1 values(1, now, '1');
sql insert into t1.p1 values(1, now, '2');
sql insert into t1.p1 values(1, now, '3');
sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p2 values(1, now, '1');
sql insert into t1.p2 values(1, now, '2');
sql insert into t1.p2 values(1, now, '3');
sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p3 values(1, now, '1');
sql insert into t1.p3 values(1, now, '2');
sql insert into t1.p3 values(1, now, '3');
sql insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p4 values(1, now, '1');
sql insert into t1.p4 values(1, now, '2');
sql insert into t1.p4 values(1, now, '3');
sql insert into t1.p4 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p4 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p4 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p5 values(1, now, '1');
sql_error insert into t1.p5 values(1, now, '2');
sql_error insert into t1.p5 values(1, now, '3');
sql_error insert into t1.p5 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p5 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p5 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql select * from t1.p1 order by off asc
if $rows != 66 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p2 order by off asc
if $rows != 66 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p3 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p4 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
print ==== step3
sql alter topic t1 partitions 1;
sql show t1.tables
if $rows != 1 then
return -1
endi
sql show t1.vgroups
if $rows != 1 then
return -1
endi
sql insert into t1.p1 values(1, now, '1');
sql insert into t1.p1 values(1, now, '2');
sql insert into t1.p1 values(1, now, '3');
sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p2 values(1, now, '1');
sql_error insert into t1.p2 values(1, now, '2');
sql_error insert into t1.p2 values(1, now, '3');
sql_error insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p3 values(1, now, '1');
sql_error insert into t1.p3 values(1, now, '2');
sql_error insert into t1.p3 values(1, now, '3');
sql_error insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p4 values(1, now, '1');
sql_error insert into t1.p4 values(1, now, '2');
sql_error insert into t1.p4 values(1, now, '3');
sql_error insert into t1.p4 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p4 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p4 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p5 values(1, now, '1');
sql_error insert into t1.p5 values(1, now, '2');
sql_error insert into t1.p5 values(1, now, '3');
sql_error insert into t1.p5 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql_error insert into t1.p5 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql_error insert into t1.p5 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql select * from t1.p1 order by off asc
if $rows != 99 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql_error select * from t1.p2 order by off asc
sql_error select * from t1.p3 order by off asc
sql_error select * from t1.p4 order by off asc
print ==== step4
sql alter topic t1 partitions 3;
sql show t1.tables
if $rows != 3 then
return -1
endi
sql show t1.vgroups
if $rows != 3 then
return -1
endi
sql insert into t1.p1 values(1, now, '1');
sql insert into t1.p1 values(1, now, '2');
sql insert into t1.p1 values(1, now, '3');
sql insert into t1.p1 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p1 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p1 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p2 values(1, now, '1');
sql insert into t1.p2 values(1, now, '2');
sql insert into t1.p2 values(1, now, '3');
sql insert into t1.p2 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p2 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p2 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql insert into t1.p3 values(1, now, '1');
sql insert into t1.p3 values(1, now, '2');
sql insert into t1.p3 values(1, now, '3');
sql insert into t1.p3 values(1, now, '4')(2, now, '5')(3, now, '6')(4, now, '7')(5, now, '8')(6, now, '9');
sql insert into t1.p3 values(1, now, '10')(2, now, '11')(3, now, '12')(4, now, '13')(5, now, '14')(6, now, '15');
sql insert into t1.p3 values(1, now, '16')(2, now,'17')(3, now,'18')(4, now,'19')(5, now,'20')(6, now,'21')(7, now,'22')(8, now,'23')(9, now,'24')(10, now,'25')(11, now,'26')(12, now,'27')(13, now,'28')(14, now,'29')(15, now,'30')(16, now,'31')(17, now,'32')(18, now,'33');
sql_error insert into t1.p4 values(1, now, '1');
sql_error insert into t1.p5 values(1, now, '1');
sql_error insert into t1.p6 values(1, now, '1');
sql_error select * from t1.p4 order by off asc
sql_error select * from t1.p5 order by off asc
sql_error select * from t1.p6 order by off asc
sql select * from t1.p1 order by off asc
if $rows != 132 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p2 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.p3 order by off asc
if $rows != 33 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 2 then
return -1
endi
if $data22 != 3 then
return -1
endi
sql select * from t1.ps order by off asc
if $rows != 198 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/general/parser/last_groupby.sim
0 → 100644
浏览文件 @
aa063917
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2
system sh/exec.sh -n dnode1 -s start
sleep 100
sql connect
print ======================== dnode1 start
$db = testdb
sql create database $db
sql use $db
sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10))
sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1");
sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1")
sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2")
sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3")
sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4")
sql select f1,last(*) from st2 group by f1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data02 != 1 then
print $data02
return -1
endi
if $data03 != 1.00000 then
return -1
endi
if $data04 != 1.000000000 then
return -1
endi
if $data05 != 1 then
return -1
endi
if $data06 != 1 then
return -1
endi
if $data07 != 1 then
return -1
endi
if $data08 != 1 then
return -1
endi
if $data09 != 1 then
return -1
endi
sql select f1,last(f1,st2.*) from st2 group by f1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data03 != 1 then
return -1
endi
if $data04 != 1.00000 then
return -1
endi
if $data05 != 1.000000000 then
return -1
endi
if $data06 != 1 then
return -1
endi
if $data07 != 1 then
return -1
endi
if $data08 != 1 then
return -1
endi
if $data09 != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/jenkins/basic.txt
浏览文件 @
aa063917
...
...
@@ -68,6 +68,8 @@ cd ../../../debug; make
./test.sh -f general/db/repeat.sim
./test.sh -f general/db/tables.sim
./test.sh -f general/db/vnodes.sim
./test.sh -f general/db/topic1.sim
./test.sh -f general/db/topic2.sim
./test.sh -f general/db/nosuchfile.sim
./test.sh -f general/field/2.sim
...
...
tests/script/jenkins/basic_7.txt
浏览文件 @
aa063917
...
...
@@ -38,6 +38,8 @@
./test.sh -f general/db/repeat.sim
./test.sh -f general/db/tables.sim
./test.sh -f general/db/vnodes.sim
./test.sh -f general/db/topic1.sim
./test.sh -f general/db/topic2.sim
./test.sh -f general/table/autocreate.sim
./test.sh -f general/table/basic1.sim
./test.sh -f general/table/basic2.sim
...
...
tests/test-all.sh
浏览文件 @
aa063917
...
...
@@ -316,6 +316,7 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "unit" ] && [ "$1" ==
cd
debug/
stopTaosd
rm
-rf
/var/lib/taos/
*
nohup
build/bin/taosd
-c
/etc/taos/
>
/dev/null 2>&1 &
sleep
30
...
...
@@ -358,6 +359,7 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$1" ==
pwd
cd
debug/build/bin
rm
-rf
/var/lib/taos/
*
nohup
./taosd
-c
/etc/taos/
>
/dev/null 2>&1 &
sleep
30
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录