Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8424e83e
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看板
提交
8424e83e
编写于
8月 26, 2021
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6285]<enhance>: set cloneCurrentDBName as a public util function
上级
28d689f4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
57 deletion
+34
-57
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+0
-30
src/client/src/tscServer.c
src/client/src/tscServer.c
+3
-27
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+29
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
8424e83e
...
...
@@ -364,6 +364,8 @@ STblCond* tsGetTableFilter(SArray* filters, uint64_t uid, int16_t idx);
void
tscRemoveCachedTableMeta
(
STableMetaInfo
*
pTableMetaInfo
,
uint64_t
id
);
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
);
#ifdef __cplusplus
}
#endif
...
...
src/client/src/tscSQLParser.c
浏览文件 @
8424e83e
...
...
@@ -40,7 +40,6 @@
#include "qScript.h"
#include "ttype.h"
#include "qFilter.h"
#include "httpInt.h"
#define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0"
...
...
@@ -72,7 +71,6 @@ static int convertTimestampStrToInt64(tVariant *pVar, int32_t precision);
static
bool
serializeExprListToVariant
(
SArray
*
pList
,
tVariant
**
dst
,
int16_t
colType
,
uint8_t
precision
);
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIdx
,
const
char
*
name
);
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
);
static
int32_t
getDelimiterIndex
(
SStrToken
*
pTableName
);
static
bool
validateTableColumnInfo
(
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
static
bool
validateTagParams
(
SArray
*
pTagsList
,
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
...
...
@@ -1687,34 +1685,6 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
char
*
p
=
NULL
;
HttpContext
*
pCtx
=
NULL
;
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
STscObj
*
pTscObj
=
pSql
->
pTscObj
;
switch
(
pTscObj
->
from
)
{
case
TAOS_REQ_FROM_HTTP
:
pCtx
=
pSql
->
param
;
if
(
pCtx
&&
pCtx
->
db
[
0
]
!=
'\0'
)
{
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
]
=
{
0
};
int32_t
len
=
sprintf
(
db
,
"%s%s%s"
,
pTscObj
->
acctId
,
TS_PATH_DELIMITER
,
pCtx
->
db
);
assert
(
len
<=
sizeof
(
db
));
p
=
strdup
(
db
);
}
break
;
default:
break
;
}
if
(
p
==
NULL
)
{
p
=
strdup
(
pSql
->
pTscObj
->
db
);
}
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
return
p
;
}
/* length limitation, strstr cannot be applied */
static
int32_t
getDelimiterIndex
(
SStrToken
*
pTableName
)
{
for
(
uint32_t
i
=
0
;
i
<
pTableName
->
n
;
++
i
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
8424e83e
...
...
@@ -26,7 +26,6 @@
#include "tscUtil.h"
#include "tsclient.h"
#include "ttimer.h"
#include "httpInt.h"
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
=
{
0
};
...
...
@@ -1430,14 +1429,10 @@ int32_t tscBuildSyncDbReplicaMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildShowMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_SHOW
;
pCmd
->
payloadLen
=
sizeof
(
SShowMsg
)
+
100
;
char
*
p
=
NULL
;
HttpContext
*
pCtx
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -1456,28 +1451,9 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
if
(
tNameIsEmpty
(
&
pTableMetaInfo
->
name
))
{
pthread_mutex_lock
(
&
pObj
->
mutex
);
STscObj
*
pTscObj
=
pSql
->
pTscObj
;
switch
(
pTscObj
->
from
)
{
case
TAOS_REQ_FROM_HTTP
:
pCtx
=
pSql
->
param
;
if
(
pCtx
&&
pCtx
->
db
[
0
]
!=
'\0'
)
{
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
]
=
{
0
};
int32_t
len
=
sprintf
(
db
,
"%s%s%s"
,
pTscObj
->
acctId
,
TS_PATH_DELIMITER
,
pCtx
->
db
);
assert
(
len
<=
sizeof
(
db
));
p
=
db
;
}
break
;
default:
break
;
}
if
(
p
==
NULL
)
{
tstrncpy
(
pShowMsg
->
db
,
pObj
->
db
,
sizeof
(
pShowMsg
->
db
));
}
else
{
tstrncpy
(
pShowMsg
->
db
,
p
,
strlen
(
p
)
+
1
);
}
pthread_mutex_unlock
(
&
pObj
->
mutex
);
char
*
p
=
cloneCurrentDBName
(
pSql
);
tstrncpy
(
pShowMsg
->
db
,
p
,
sizeof
(
pShowMsg
->
db
));
tfree
(
p
);
}
else
{
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pShowMsg
->
db
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
8424e83e
...
...
@@ -29,6 +29,7 @@
#include "tsclient.h"
#include "ttimer.h"
#include "ttokendef.h"
#include "httpInt.h"
static
void
freeQueryInfoImpl
(
SQueryInfo
*
pQueryInfo
);
...
...
@@ -5065,3 +5066,31 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id) {
taosHashRemove
(
tscTableMetaMap
,
fname
,
len
);
tscDebug
(
"0x%"
PRIx64
" remove table meta %s, numOfRemain:%d"
,
id
,
fname
,
(
int32_t
)
taosHashGetSize
(
tscTableMetaMap
));
}
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
char
*
p
=
NULL
;
HttpContext
*
pCtx
=
NULL
;
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
STscObj
*
pTscObj
=
pSql
->
pTscObj
;
switch
(
pTscObj
->
from
)
{
case
TAOS_REQ_FROM_HTTP
:
pCtx
=
pSql
->
param
;
if
(
pCtx
&&
pCtx
->
db
[
0
]
!=
'\0'
)
{
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
]
=
{
0
};
int32_t
len
=
sprintf
(
db
,
"%s%s%s"
,
pTscObj
->
acctId
,
TS_PATH_DELIMITER
,
pCtx
->
db
);
assert
(
len
<=
sizeof
(
db
));
p
=
strdup
(
db
);
}
break
;
default:
break
;
}
if
(
p
==
NULL
)
{
p
=
strdup
(
pSql
->
pTscObj
->
db
);
}
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
return
p
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录