Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
03a6ba65
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
03a6ba65
编写于
3月 12, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support udf
上级
a1f747a8
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
121 addition
and
1 deletion
+121
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+83
-0
src/common/inc/tcmdtype.h
src/common/inc/tcmdtype.h
+2
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-0
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+7
-0
src/query/inc/sql.y
src/query/inc/sql.y
+0
-1
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+23
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
03a6ba65
...
...
@@ -241,6 +241,80 @@ static int32_t handlePassword(SSqlCmd* pCmd, SStrToken* pPwd) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
readFromFile
(
char
*
name
,
uint32_t
*
len
,
void
**
buf
)
{
struct
stat
fileStat
;
if
(
stat
(
name
,
&
fileStat
)
<
0
)
{
tscError
(
"stat file %s failed, error:%s"
,
name
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
}
*
len
=
fileStat
.
st_size
;
*
buf
=
calloc
(
1
,
*
len
);
if
(
*
buf
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
int
fd
=
open
(
name
,
O_RDONLY
);
if
(
fd
<
0
)
{
tscError
(
"open file %s failed, error:%s"
,
name
,
strerror
(
errno
));
tfree
(
*
buf
);
return
TAOS_SYSTEM_ERROR
(
errno
);
}
int64_t
s
=
taosReadImp
(
fd
,
*
buf
,
*
len
);
if
(
s
!=
*
len
)
{
tscError
(
"read file %s failed, error:%s"
,
name
,
strerror
(
errno
));
close
(
fd
);
tfree
(
*
buf
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
handleCreateFunc
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
switch
(
pInfo
->
type
)
{
case
TSDB_SQL_CREATE_FUNCTION
:
SCreateFuncInfo
*
createInfo
=
&
pInfo
->
pMiscInfo
->
funcOpt
;
SCreateFuncMsg
*
pMsg
=
(
SCreateFuncMsg
*
)
pSql
->
cmd
.
payload
;
int32_t
len
=
0
;
void
*
buf
=
NULL
;
createInfo
->
path
.
z
[
createInfo
->
path
.
n
]
=
0
;
strdequote
(
createInfo
->
path
.
z
);
int32_t
ret
=
readFromFile
(
createInfo
->
path
.
z
,
&
len
,
&
buf
);
if
(
ret
)
{
return
ret
;
}
//TODO CHECK CODE
if
(
len
+
sizeof
(
SCreateFuncMsg
)
>
pSql
->
cmd
.
allocSize
)
{
ret
=
tscAllocPayload
(
&
pSql
->
cmd
,
len
+
sizeof
(
SCreateFuncMsg
));
if
(
ret
)
{
return
ret
;
}
}
pMsg
->
codeLen
=
htonl
(
len
);
memcpy
(
pMsg
->
code
,
*
buf
,
len
);
break
;
case
TSDB_SQL_DROP_FUNCTION
:
default:
return
TSDB_CODE_TSC_APP_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
||
pSql
==
NULL
)
{
return
TSDB_CODE_TSC_APP_ERROR
;
...
...
@@ -352,6 +426,15 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
break
;
}
case
TSDB_SQL_CREATE_FUNCTION
:
case
TSDB_SQL_DROP_FUNCTION
:
{
if
(
handleCreateFunc
(
pSql
,
pInfo
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
break
;
}
case
TSDB_SQL_ALTER_DB
:
case
TSDB_SQL_CREATE_DB
:
{
const
char
*
msg1
=
"invalid db name"
;
...
...
src/common/inc/tcmdtype.h
浏览文件 @
03a6ba65
...
...
@@ -41,8 +41,10 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_MGMT
,
"mgmt"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_DB
,
"create-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_TABLE
,
"create-table"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_FUNCTION
,
"create-function"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_DB
,
"drop-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_TABLE
,
"drop-table"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_FUNCTION
,
"drop-function"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_ACCT
,
"create-acct"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_USER
,
"create-user"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_ACCT
,
"drop-acct"
)
...
...
src/inc/taosmsg.h
浏览文件 @
03a6ba65
...
...
@@ -148,6 +148,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_STREAMTABLES
,
TSDB_MGMT_TABLE_CLUSTER
,
TSDB_MGMT_TABLE_TP
,
TSDB_MGMT_TABLE_FUNCTION
,
TSDB_MGMT_TABLE_MAX
,
};
...
...
@@ -567,6 +568,11 @@ typedef struct {
int8_t
reserve
[
5
];
}
SCreateDbMsg
,
SAlterDbMsg
;
typedef
struct
{
int32_t
codeLen
;
char
code
[];
}
SCreateFuncMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
uint8_t
ignoreNotExists
;
...
...
src/query/inc/qSqlparser.h
浏览文件 @
03a6ba65
...
...
@@ -129,6 +129,12 @@ typedef struct SCreateDbInfo {
int16_t
partitions
;
}
SCreateDbInfo
;
typedef
struct
SCreateFuncInfo
{
SStrToken
name
;
SStrToken
path
;
}
SCreateFuncInfo
;
typedef
struct
SCreateAcctInfo
{
int32_t
maxUsers
;
int32_t
maxDbs
;
...
...
@@ -163,6 +169,7 @@ typedef struct SMiscInfo {
union
{
SCreateDbInfo
dbOpt
;
SCreateAcctInfo
acctOpt
;
SCreateFuncInfo
funcOpt
;
SShowInfo
showOpt
;
SStrToken
id
;
};
...
...
src/query/inc/sql.y
浏览文件 @
03a6ba65
无法预览此类型文件
src/query/src/qParserImpl.c
浏览文件 @
03a6ba65
...
...
@@ -820,6 +820,18 @@ void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrTo
pInfo
->
pMiscInfo
->
tableType
=
tableType
;
}
void
setDropFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pMiscInfo
==
NULL
)
{
pInfo
->
pMiscInfo
=
(
SMiscInfo
*
)
calloc
(
1
,
sizeof
(
SMiscInfo
));
pInfo
->
pMiscInfo
->
a
=
taosArrayInit
(
4
,
sizeof
(
SStrToken
));
}
taosArrayPush
(
pInfo
->
pMiscInfo
->
a
,
pToken
);
}
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
prefix
,
SStrToken
*
pPatterns
)
{
if
(
pInfo
->
pMiscInfo
==
NULL
)
{
pInfo
->
pMiscInfo
=
calloc
(
1
,
sizeof
(
SMiscInfo
));
...
...
@@ -854,6 +866,17 @@ void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDb
pInfo
->
pMiscInfo
->
dbOpt
.
ignoreExists
=
pIgExists
->
n
;
// sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
}
void
setCreateFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pName
,
SStrToken
*
pPath
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pMiscInfo
==
NULL
)
{
pInfo
->
pMiscInfo
=
calloc
(
1
,
sizeof
(
SMiscInfo
));
}
pInfo
->
pMiscInfo
->
funcOpt
.
name
=
*
pName
;
pInfo
->
pMiscInfo
->
funcOpt
.
path
=
*
pPath
;
}
void
setCreateAcctSql
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pName
,
SStrToken
*
pPwd
,
SCreateAcctInfo
*
pAcctInfo
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pMiscInfo
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录