Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5b2ef2a6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5b2ef2a6
编写于
5月 13, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
other: merge main and remove invalid return data for poll.
上级
181f9063
0c744e86
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
169 addition
and
72 deletion
+169
-72
README-CN.md
README-CN.md
+1
-1
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+1
-0
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+1
-0
source/dnode/vnode/src/tq/tqUtil.c
source/dnode/vnode/src/tq/tqUtil.c
+57
-53
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+2
-2
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+10
-1
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+3
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+12
-1
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+8
-0
tests/script/tsim/alter/table.sim
tests/script/tsim/alter/table.sim
+20
-1
tests/script/tsim/parser/alter_column.sim
tests/script/tsim/parser/alter_column.sim
+1
-1
tests/script/tsim/query/unionall_as_table.sim
tests/script/tsim/query/unionall_as_table.sim
+17
-0
tests/system-test/0-others/user_privilege.py
tests/system-test/0-others/user_privilege.py
+36
-12
未找到文件。
README-CN.md
浏览文件 @
5b2ef2a6
...
...
@@ -352,4 +352,4 @@ TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java
# 加入技术交流群
TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小 T 为好友,即可入群。
TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine
1
",加小 T 为好友,即可入群。
source/dnode/vnode/src/inc/tq.h
浏览文件 @
5b2ef2a6
...
...
@@ -102,6 +102,7 @@ typedef struct {
STqExecHandle
execHandle
;
// exec
SRpcMsg
*
msg
;
int32_t
noDataPollCnt
;
int8_t
exec
;
}
STqHandle
;
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
5b2ef2a6
...
...
@@ -55,6 +55,7 @@ int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
memcpy
(
pHandle
->
msg
,
pMsg
,
sizeof
(
SRpcMsg
));
pHandle
->
msg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
}
else
{
tqPushDataRsp
(
pHandle
,
vgId
);
void
*
tmp
=
pHandle
->
msg
->
pCont
;
memcpy
(
pHandle
->
msg
,
pMsg
,
sizeof
(
SRpcMsg
));
pHandle
->
msg
->
pCont
=
tmp
;
...
...
source/dnode/vnode/src/tq/tqUtil.c
浏览文件 @
5b2ef2a6
...
...
@@ -162,6 +162,10 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
return
0
;
}
static
bool
isHandleExecuting
(
STqHandle
*
pHandle
){
return
1
==
atomic_load_8
(
&
pHandle
->
exec
);
}
static
int32_t
extractDataAndRspForNormalSubscribe
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
pOffset
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
...
...
@@ -170,13 +174,20 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
SMqDataRsp
dataRsp
=
{
0
};
tqInitDataRsp
(
&
dataRsp
,
pRequest
);
qTaskInfo_t
task
=
pHandle
->
execHandle
.
task
;
if
(
qTaskIsExecuting
(
task
))
{
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
,
vgId
);
tDeleteMqDataRsp
(
&
dataRsp
);
return
code
;
// qTaskInfo_t task = pHandle->execHandle.task;
// if (qTaskIsExecuting(task)) {
// code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_RSP, vgId);
// tDeleteMqDataRsp(&dataRsp);
// return code;
// }
while
(
isHandleExecuting
(
pHandle
)){
tqInfo
(
"sub is executing, pHandle:%p"
,
pHandle
);
taosMsleep
(
5
);
}
atomic_store_8
(
&
pHandle
->
exec
,
1
);
qSetTaskId
(
pHandle
->
execHandle
.
task
,
consumerId
,
pRequest
->
reqId
);
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
if
(
code
!=
0
)
{
...
...
@@ -193,6 +204,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
code
=
tqRegisterPushHandle
(
pTq
,
pHandle
,
pMsg
);
taosWUnLockLatch
(
&
pTq
->
lock
);
tDeleteMqDataRsp
(
&
dataRsp
);
atomic_store_8
(
&
pHandle
->
exec
,
0
);
return
code
;
}
else
{
pHandle
->
noDataPollCnt
++
;
...
...
@@ -202,36 +214,43 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
// NOTE: this pHandle->consumerId may have been changed already.
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
,
vgId
);
end
:
{
char
buf
[
80
]
=
{
0
};
tFormatOffset
(
buf
,
80
,
&
dataRsp
.
rspOffset
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%"
PRIx64
" code:%d"
,
consumerId
,
pHandle
->
subKey
,
vgId
,
dataRsp
.
blockNum
,
buf
,
pRequest
->
reqId
,
code
);
// taosWUnLockLatch(&pTq->lock);
tDeleteMqDataRsp
(
&
dataRsp
);
}
end:
{
char
buf
[
80
]
=
{
0
};
tFormatOffset
(
buf
,
80
,
&
dataRsp
.
rspOffset
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%"
PRIx64
" code:%d"
,
consumerId
,
pHandle
->
subKey
,
vgId
,
dataRsp
.
blockNum
,
buf
,
pRequest
->
reqId
,
code
);
tDeleteMqDataRsp
(
&
dataRsp
);
}
atomic_store_8
(
&
pHandle
->
exec
,
0
);
return
code
;
}
static
int32_t
extractDataAndRspForDbStbSubscribe
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
offset
)
{
int
code
=
0
;
int
code
=
0
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
SWalCkHead
*
pCkHead
=
NULL
;
SMqMetaRsp
metaRsp
=
{
0
};
STaosxRsp
taosxRsp
=
{
0
};
tqInitTaosxRsp
(
&
taosxRsp
,
pRequest
);
qTaskInfo_t
task
=
pHandle
->
execHandle
.
task
;
if
(
qTaskIsExecuting
(
task
)){
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
,
vgId
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
// qTaskInfo_t task = pHandle->execHandle.task;
// if(qTaskIsExecuting(task)){
// code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP, vgId);
// tDeleteSTaosxRsp(&taosxRsp);
// return code;
// }
while
(
isHandleExecuting
(
pHandle
)){
tqInfo
(
"sub is executing, pHandle:%p"
,
pHandle
);
taosMsleep
(
5
);
}
atomic_store_8
(
&
pHandle
->
exec
,
1
);
if
(
offset
->
type
!=
TMQ_OFFSET__LOG
)
{
if
(
tqScanTaosx
(
pTq
,
pHandle
,
&
taosxRsp
,
&
metaRsp
,
offset
)
<
0
)
{
tDeleteSTaosxRsp
(
&
taosxRsp
)
;
return
-
1
;
code
=
-
1
;
goto
end
;
}
if
(
metaRsp
.
metaRspLen
>
0
)
{
...
...
@@ -239,8 +258,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send meta offset type:%d,uid:%"
PRId64
",ts:%"
PRId64
,
pRequest
->
consumerId
,
pHandle
->
subKey
,
vgId
,
metaRsp
.
rspOffset
.
type
,
metaRsp
.
rspOffset
.
uid
,
metaRsp
.
rspOffset
.
ts
);
taosMemoryFree
(
metaRsp
.
metaRsp
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
goto
end
;
}
tqDebug
(
"taosx poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%"
PRId64
...
...
@@ -259,9 +277,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
int64_t
fetchVer
=
offset
->
version
+
1
;
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
if
(
pCkHead
==
NULL
)
{
tDeleteSTaosxRsp
(
&
taosxRsp
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
code
=
-
1
;
goto
end
;
}
walSetReaderCapacity
(
pHandle
->
pWalReader
,
2048
);
int
totalRows
=
0
;
...
...
@@ -277,9 +295,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
if
(
tqFetchLog
(
pTq
,
pHandle
,
&
fetchVer
,
&
pCkHead
,
pRequest
->
reqId
)
<
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
);
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
,
vgId
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
SWalCont
*
pHead
=
&
pCkHead
->
head
;
...
...
@@ -291,9 +307,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
if
(
totalRows
>
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
-
1
);
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
,
vgId
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%s"
,
pHead
->
version
,
TMSG_INFO
(
pHead
->
msgType
));
...
...
@@ -301,17 +315,8 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
metaRspLen
=
pHead
->
bodyLen
;
metaRsp
.
metaRsp
=
pHead
->
body
;
if
(
tqSendMetaPollRsp
(
pHandle
,
pMsg
,
pRequest
,
&
metaRsp
,
vgId
)
<
0
)
{
code
=
-
1
;
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
}
code
=
0
;
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
code
=
tqSendMetaPollRsp
(
pHandle
,
pMsg
,
pRequest
,
&
metaRsp
,
vgId
);
goto
end
;
}
// process data
...
...
@@ -321,29 +326,28 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
.
ver
=
pHead
->
version
,
};
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
)
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
pRequest
->
consumerId
,
vgId
,
pRequest
->
subKey
);
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
-
1
;
code
=
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
);
if
(
code
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
pRequest
->
consumerId
,
vgId
,
pRequest
->
subKey
);
goto
end
;
}
if
(
totalRows
>=
4096
||
taosxRsp
.
createTableNum
>
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
);
code
=
tqSendDataRsp
(
pHandle
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
,
vgId
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
else
{
fetchVer
++
;
}
}
}
end:
atomic_store_8
(
&
pHandle
->
exec
,
0
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
0
;
return
code
;
}
int32_t
tqExtractDataForMq
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
)
{
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
5b2ef2a6
...
...
@@ -1437,12 +1437,12 @@ _return:
SMetaRes
*
pRes
=
taosArrayGet
(
ctx
->
pResList
,
pFetch
->
resIdx
);
pRes
->
code
=
code
;
pRes
->
pRes
=
NULL
;
ctgTaskError
(
"Get table %d.%s.%s meta failed with error %s"
,
pName
->
acctId
,
pName
->
dbname
,
pName
->
tname
,
tstrerror
(
code
));
if
(
0
==
atomic_sub_fetch_32
(
&
ctx
->
fetchNum
,
1
))
{
TSWAP
(
pTask
->
res
,
ctx
->
pResList
);
taskDone
=
true
;
}
ctgTaskError
(
"Get table %d.%s.%s meta failed with error %s"
,
pName
->
acctId
,
pName
->
dbname
,
pName
->
tname
,
tstrerror
(
code
));
}
if
(
pTask
->
res
&&
taskDone
)
{
...
...
source/libs/executor/src/executil.c
浏览文件 @
5b2ef2a6
...
...
@@ -1484,14 +1484,23 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SHashObj
*
pSelectFuncs
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
const
char
*
pName
=
pCtx
[
i
].
pExpr
->
pExpr
->
_function
.
functionName
;
if
((
strcmp
(
pName
,
"_select_value"
)
==
0
)
||
(
strcmp
(
pName
,
"_group_key"
)
==
0
))
{
pValCtx
[
num
++
]
=
&
pCtx
[
i
];
}
else
if
(
fmIsSelectFunc
(
pCtx
[
i
].
functionId
))
{
p
=
&
pCtx
[
i
];
void
*
data
=
taosHashGet
(
pSelectFuncs
,
pName
,
strlen
(
pName
));
if
(
taosHashGetSize
(
pSelectFuncs
)
!=
0
&&
data
==
NULL
)
{
p
=
NULL
;
break
;
}
else
{
taosHashPut
(
pSelectFuncs
,
pName
,
strlen
(
pName
),
&
num
,
sizeof
(
num
));
p
=
&
pCtx
[
i
];
}
}
}
taosHashCleanup
(
pSelectFuncs
);
if
(
p
!=
NULL
)
{
p
->
subsidiaries
.
pCtx
=
pValCtx
;
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
5b2ef2a6
...
...
@@ -388,6 +388,9 @@ static bool isSetUselessCol(SSetOperator* pSetOp, int32_t index, SExprNode* pPro
}
static
int32_t
calcConstSetOpProjections
(
SCalcConstContext
*
pCxt
,
SSetOperator
*
pSetOp
,
bool
subquery
)
{
if
(
subquery
&&
pSetOp
->
opType
==
SET_OP_TYPE_UNION
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
index
=
0
;
SNode
*
pProj
=
NULL
;
WHERE_EACH
(
pProj
,
pSetOp
->
pProjectionList
)
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
5b2ef2a6
...
...
@@ -5349,7 +5349,8 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
}
if
(
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
==
pStmt
->
alterType
)
{
if
(
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_FIELD_LEN
)
{
if
((
TSDB_DATA_TYPE_VARCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BINARY_LEN
)
||
(
TSDB_DATA_TYPE_NCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_NCHAR_LEN
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
);
}
...
...
@@ -5374,6 +5375,11 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
}
if
((
TSDB_DATA_TYPE_VARCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BINARY_LEN
)
||
(
TSDB_DATA_TYPE_NCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_NCHAR_LEN
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
);
}
if
(
pTableMeta
->
tableInfo
.
rowSize
+
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
...
...
@@ -8382,6 +8388,11 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
if
((
TSDB_DATA_TYPE_VARCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_BINARY_LEN
)
||
(
TSDB_DATA_TYPE_NCHAR
==
pStmt
->
dataType
.
type
&&
calcTypeBytes
(
pStmt
->
dataType
)
>
TSDB_MAX_NCHAR_LEN
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
);
}
if
(
pTableMeta
->
tableInfo
.
rowSize
+
pReq
->
colModBytes
-
pSchema
->
bytes
>
TSDB_MAX_BYTES_PER_ROW
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROW_LENGTH
,
TSDB_MAX_BYTES_PER_ROW
);
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
5b2ef2a6
...
...
@@ -19,6 +19,14 @@
#include "scalar.h"
#include "tglobal.h"
static
void
debugPrintNode
(
SNode
*
pNode
)
{
char
*
pStr
=
NULL
;
nodesNodeToString
(
pNode
,
false
,
&
pStr
,
NULL
);
printf
(
"%s
\n
"
,
pStr
);
taosMemoryFree
(
pStr
);
return
;
}
static
void
dumpQueryPlan
(
SQueryPlan
*
pPlan
)
{
if
(
!
tsQueryPlannerTrace
)
{
return
;
...
...
tests/script/tsim/alter/table.sim
浏览文件 @
5b2ef2a6
...
...
@@ -657,17 +657,36 @@ if $data20 != null then
return -1
endi
print =============== error
print =============== error
for normal table
sql create table tb2023(ts timestamp, f int);
sql_error alter table tb2023 add column v varchar(65535);
sql_error alter table tb2023 add column v varchar(65535);
sql_error alter table tb2023 add column v varchar(65530);
sql alter table tb2023 add column v varchar(16374);
sql_error alter table tb2023 modify column v varchar(16375);
sql desc tb2023
sql alter table tb2023 drop column v
sql_error alter table tb2023 add column v nchar(4094);
sql alter table tb2023 add column v nchar(4093);
sql_error alter table tb2023 modify column v nchar(4094);
sql_error alter table tb2023 add column v nchar(16384);
sql alter table tb2023 add column v nchar(16374);
sql desc tb2023
print =============== error for super table
sql create table stb2023(ts timestamp, f int) tags(t1 int);
sql_error alter table stb2023 add column v varchar(16375);
sql_error alter table stb2023 add column v varchar(16385);
sql_error alter table stb2023 add column v varchar(33100);
sql alter table stb2023 add column v varchar(16374);
sql_error alter table stb2023 modify column v varchar(16375);
sql desc stb2023
sql alter table stb2023 drop column v
sql_error alter table stb2023 add column v nchar(4094);
sql alter table stb2023 add column v nchar(4093);
sql_error alter table stb2023 modify column v nchar(4094);
sql desc stb2023
print ======= over
sql drop database d1
sql select * from information_schema.ins_databases
...
...
tests/script/tsim/parser/alter_column.sim
浏览文件 @
5b2ef2a6
...
...
@@ -48,7 +48,7 @@ sql_error alter table tb modify column c2 binary(10);
sql_error alter table tb modify column c2 binary(9);
sql_error alter table tb modify column c2 binary(-9);
sql_error alter table tb modify column c2 binary(0);
sql alter table tb modify column c2 binary(17000);
sql
_error
alter table tb modify column c2 binary(17000);
sql_error alter table tb modify column c2 nchar(30);
sql_error alter table tb modify column c3 double;
sql_error alter table tb modify column c3 nchar(10);
...
...
tests/script/tsim/query/unionall_as_table.sim
浏览文件 @
5b2ef2a6
...
...
@@ -25,4 +25,21 @@ if $data05 != @0021001@ then
return -1
endi
sql create table st (ts timestamp, f int) tags (t int);
sql insert into ct1 using st tags(1) values(now, 1)(now+1s, 2)
sql insert into ct2 using st tags(2) values(now+2s, 3)(now+3s, 4)
sql select count(*) from (select * from ct1 union all select * from ct2)
if $rows != 1 then
return -1
endi
if $data00 != 4 then
return -1
endi
sql select count(*) from (select * from ct1 union select * from ct2)
if $rows != 1 then
return -1
endi
if $data00 != 4 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/system-test/0-others/user_privilege.py
浏览文件 @
5b2ef2a6
...
...
@@ -29,6 +29,7 @@ class TDTestCase:
self
.
stbname
=
'stb'
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
dbnames
=
[
'db1'
,
'db2'
]
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'float'
,
...
...
@@ -57,21 +58,25 @@ class TDTestCase:
def
create_user
(
self
):
user_name
=
'test'
tdSql
.
execute
(
f
'create user
{
user_name
}
pass "test"'
)
tdSql
.
execute
(
f
'grant read on db.stb with t2 = "Beijing" to
{
user_name
}
'
)
tdSql
.
execute
(
f
'grant read on
{
self
.
dbnames
[
0
]
}
.
{
self
.
stbname
}
with t2 = "Beijing" to
{
user_name
}
'
)
tdSql
.
execute
(
f
'grant write on
{
self
.
dbnames
[
1
]
}
.
{
self
.
stbname
}
with t1 = 2 to
{
user_name
}
'
)
def
prepare_data
(
self
):
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
for
db
in
self
.
dbnames
:
tdSql
.
execute
(
f
"create database
{
db
}
"
)
tdSql
.
execute
(
f
"use
{
db
}
"
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
def
user_
privilege_check
(
self
):
def
user_
read_privilege_check
(
self
,
dbname
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
try
:
sql
=
"select count(*) from db
.stb where t2 = 'Beijing'"
sql
=
f
"select count(*) from
{
dbname
}
.stb where t2 = 'Beijing'"
res
=
testconn
.
query
(
sql
)
data
=
res
.
fetch_all
()
count
=
data
[
0
][
0
]
...
...
@@ -85,11 +90,30 @@ class TDTestCase:
tdLog
.
exit
(
f
"
{
sql
}
, expect result doesn't match"
)
pass
def
user_write_privilege_check
(
self
,
dbname
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
try
:
sql
=
f
"insert into
{
dbname
}
.stb_1 values(now, 1.1, 200, 0.3)"
testconn
.
execute
(
sql
)
except
BaseException
:
expectErrNotOccured
=
True
if
expectErrNotOccured
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
else
:
pass
def
user_privilege_error_check
(
self
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
sql_list
=
[
"alter talbe db.stb_1 set t2 = 'Wuhan'"
,
"drop table db.stb_1"
]
sql_list
=
[
f
"alter talbe
{
self
.
dbnames
[
0
]
}
.stb_1 set t2 = 'Wuhan'"
,
f
"insert into
{
self
.
dbnames
[
0
]
}
.stb_1 values(now, 1.1, 200, 0.3)"
,
f
"drop table
{
self
.
dbnames
[
0
]
}
.stb_1"
,
f
"select count(*) from
{
self
.
dbnames
[
1
]
}
.stb"
]
for
sql
in
sql_list
:
try
:
...
...
@@ -104,11 +128,11 @@ class TDTestCase:
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
pass
def
run
(
self
):
tdSql
.
prepare
()
def
run
(
self
):
self
.
prepare_data
()
self
.
create_user
()
self
.
user_privilege_check
()
self
.
user_read_privilege_check
(
self
.
dbnames
[
0
])
self
.
user_write_privilege_check
(
self
.
dbnames
[
1
])
self
.
user_privilege_error_check
()
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录