Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cd7821f9
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cd7821f9
编写于
8月 24, 2021
作者:
D
dapan1121
提交者:
GitHub
8月 24, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7518 from taosdata/feature/TD-6001
[TD-6001]<enhance>: use db_name in url if exists
上级
c294053e
95b1135e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
53 addition
and
9 deletion
+53
-9
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+2
-0
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+6
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+22
-2
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+1
-0
src/plugins/http/inc/httpRestHandle.h
src/plugins/http/inc/httpRestHandle.h
+5
-5
src/plugins/http/src/httpRestHandle.c
src/plugins/http/src/httpRestHandle.c
+12
-2
src/plugins/http/src/httpSql.c
src/plugins/http/src/httpSql.c
+5
-0
未找到文件。
src/client/CMakeLists.txt
浏览文件 @
cd7821f9
...
@@ -4,6 +4,8 @@ PROJECT(TDengine)
...
@@ -4,6 +4,8 @@ PROJECT(TDengine)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
jni
)
INCLUDE_DIRECTORIES
(
jni
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/zlib-1.2.11/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/plugins/http/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
IF
(
TD_LINUX
)
IF
(
TD_LINUX
)
...
...
src/client/inc/tsclient.h
浏览文件 @
cd7821f9
...
@@ -38,6 +38,11 @@ extern "C" {
...
@@ -38,6 +38,11 @@ extern "C" {
#include "qUtil.h"
#include "qUtil.h"
#include "tcmdtype.h"
#include "tcmdtype.h"
typedef
enum
{
TAOS_REQ_FROM_SHELL
,
TAOS_REQ_FROM_HTTP
}
SReqOrigin
;
// forward declaration
// forward declaration
struct
SSqlInfo
;
struct
SSqlInfo
;
...
@@ -340,6 +345,7 @@ typedef struct STscObj {
...
@@ -340,6 +345,7 @@ typedef struct STscObj {
SRpcCorEpSet
*
tscCorMgmtEpSet
;
SRpcCorEpSet
*
tscCorMgmtEpSet
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
int32_t
numOfObj
;
// number of sqlObj from this tscObj
int32_t
numOfObj
;
// number of sqlObj from this tscObj
SReqOrigin
from
;
}
STscObj
;
}
STscObj
;
typedef
struct
SSubqueryState
{
typedef
struct
SSubqueryState
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
cd7821f9
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "qScript.h"
#include "qScript.h"
#include "ttype.h"
#include "ttype.h"
#include "qFilter.h"
#include "qFilter.h"
#include "httpInt.h"
#define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0"
#define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0"
...
@@ -1687,8 +1688,28 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
...
@@ -1687,8 +1688,28 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
char
*
p
=
NULL
;
HttpContext
*
pCtx
=
NULL
;
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
char
*
p
=
strdup
(
pSql
->
pTscObj
->
db
);
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
);
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
return
p
;
return
p
;
...
@@ -8687,7 +8708,6 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) {
...
@@ -8687,7 +8708,6 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) {
n
+=
1
;
n
+=
1
;
}
}
info
->
numOfColumns
=
n
;
info
->
numOfColumns
=
n
;
return
meta
;
return
meta
;
}
}
...
...
src/plugins/http/inc/httpInt.h
浏览文件 @
cd7821f9
...
@@ -150,6 +150,7 @@ typedef struct HttpContext {
...
@@ -150,6 +150,7 @@ typedef struct HttpContext {
char
ipstr
[
22
];
char
ipstr
[
22
];
char
user
[
TSDB_USER_LEN
];
// parsed from auth token or login message
char
user
[
TSDB_USER_LEN
];
// parsed from auth token or login message
char
pass
[
HTTP_PASSWORD_LEN
];
char
pass
[
HTTP_PASSWORD_LEN
];
char
db
[
/*TSDB_ACCT_ID_LEN + */
TSDB_DB_NAME_LEN
];
TAOS
*
taos
;
TAOS
*
taos
;
void
*
ppContext
;
void
*
ppContext
;
HttpSession
*
session
;
HttpSession
*
session
;
...
...
src/plugins/http/inc/httpRestHandle.h
浏览文件 @
cd7821f9
...
@@ -22,12 +22,12 @@
...
@@ -22,12 +22,12 @@
#include "httpResp.h"
#include "httpResp.h"
#include "httpSql.h"
#include "httpSql.h"
#define REST_ROOT_URL_POS 0
#define REST_ROOT_URL_POS
0
#define REST_ACTION_URL_POS 1
#define REST_ACTION_URL_POS
1
#define REST_USER_URL_POS 2
#define REST_USER_U
SEDB_U
RL_POS 2
#define REST_PASS_URL_POS 3
#define REST_PASS_URL_POS
3
void
restInitHandle
(
HttpServer
*
pServer
);
void
restInitHandle
(
HttpServer
*
pServer
);
bool
restProcessRequest
(
struct
HttpContext
*
pContext
);
bool
restProcessRequest
(
struct
HttpContext
*
pContext
);
#endif
#endif
\ No newline at end of file
src/plugins/http/src/httpRestHandle.c
浏览文件 @
cd7821f9
...
@@ -62,11 +62,11 @@ void restInitHandle(HttpServer* pServer) {
...
@@ -62,11 +62,11 @@ void restInitHandle(HttpServer* pServer) {
bool
restGetUserFromUrl
(
HttpContext
*
pContext
)
{
bool
restGetUserFromUrl
(
HttpContext
*
pContext
)
{
HttpParser
*
pParser
=
pContext
->
parser
;
HttpParser
*
pParser
=
pContext
->
parser
;
if
(
pParser
->
path
[
REST_USER_U
RL_POS
].
pos
>=
TSDB_USER_LEN
||
pParser
->
path
[
REST_USER
_URL_POS
].
pos
<=
0
)
{
if
(
pParser
->
path
[
REST_USER_U
SEDB_URL_POS
].
pos
>=
TSDB_USER_LEN
||
pParser
->
path
[
REST_USER_USEDB
_URL_POS
].
pos
<=
0
)
{
return
false
;
return
false
;
}
}
tstrncpy
(
pContext
->
user
,
pParser
->
path
[
REST_USER_URL_POS
].
str
,
TSDB_USER_LEN
);
tstrncpy
(
pContext
->
user
,
pParser
->
path
[
REST_USER_U
SEDB_U
RL_POS
].
str
,
TSDB_USER_LEN
);
return
true
;
return
true
;
}
}
...
@@ -107,6 +107,16 @@ bool restProcessSqlRequest(HttpContext* pContext, int32_t timestampFmt) {
...
@@ -107,6 +107,16 @@ bool restProcessSqlRequest(HttpContext* pContext, int32_t timestampFmt) {
HttpSqlCmd
*
cmd
=
&
(
pContext
->
singleCmd
);
HttpSqlCmd
*
cmd
=
&
(
pContext
->
singleCmd
);
cmd
->
nativSql
=
sql
;
cmd
->
nativSql
=
sql
;
/* find if there is db_name in url */
pContext
->
db
[
0
]
=
'\0'
;
HttpString
*
path
=
&
pContext
->
parser
->
path
[
REST_USER_USEDB_URL_POS
];
if
(
path
->
pos
>
0
&&
!
(
strlen
(
sql
)
>
4
&&
(
sql
[
0
]
==
'u'
||
sql
[
0
]
==
'U'
)
&&
(
sql
[
1
]
==
's'
||
sql
[
1
]
==
'S'
)
&&
(
sql
[
2
]
==
'e'
||
sql
[
2
]
==
'E'
)
&&
sql
[
3
]
==
' '
))
{
snprintf
(
pContext
->
db
,
/*TSDB_ACCT_ID_LEN + */
TSDB_DB_NAME_LEN
,
"%s"
,
path
->
str
);
}
pContext
->
reqType
=
HTTP_REQTYPE_SINGLE_SQL
;
pContext
->
reqType
=
HTTP_REQTYPE_SINGLE_SQL
;
if
(
timestampFmt
==
REST_TIMESTAMP_FMT_LOCAL_STRING
)
{
if
(
timestampFmt
==
REST_TIMESTAMP_FMT_LOCAL_STRING
)
{
pContext
->
encodeMethod
=
&
restEncodeSqlLocalTimeStringMethod
;
pContext
->
encodeMethod
=
&
restEncodeSqlLocalTimeStringMethod
;
...
...
src/plugins/http/src/httpSql.c
浏览文件 @
cd7821f9
...
@@ -419,6 +419,11 @@ void httpProcessRequest(HttpContext *pContext) {
...
@@ -419,6 +419,11 @@ void httpProcessRequest(HttpContext *pContext) {
&
(
pContext
->
taos
));
&
(
pContext
->
taos
));
httpDebug
(
"context:%p, fd:%d, user:%s, try connect tdengine, taos:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
httpDebug
(
"context:%p, fd:%d, user:%s, try connect tdengine, taos:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
user
,
pContext
->
taos
);
pContext
->
taos
);
if
(
pContext
->
taos
!=
NULL
)
{
STscObj
*
pObj
=
pContext
->
taos
;
pObj
->
from
=
TAOS_REQ_FROM_HTTP
;
}
}
else
{
}
else
{
httpExecCmd
(
pContext
);
httpExecCmd
(
pContext
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录