Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
96c4e414
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看板
提交
96c4e414
编写于
4月 23, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-171] suppress create if not exists dbname return error msg
上级
d78d7886
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
89 addition
and
28 deletion
+89
-28
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+13
-6
src/inc/taosmsg.h
src/inc/taosmsg.h
+4
-4
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+27
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+39
-10
src/query/inc/qsqlparser.h
src/query/inc/qsqlparser.h
+3
-4
src/query/src/qparserImpl.c
src/query/src/qparserImpl.c
+1
-2
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+1
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
96c4e414
...
...
@@ -4784,6 +4784,7 @@ static void setCreateDBOption(SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
pMsg
->
rowsInFileBlock
=
htonl
(
pCreateDb
->
rowPerFileBlock
);
pMsg
->
daysPerFile
=
htonl
(
pCreateDb
->
daysPerFile
);
pMsg
->
replications
=
pCreateDb
->
replica
;
pMsg
->
ignoreExist
=
pCreateDb
->
ignoreExists
;
}
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDBInfo
*
pCreateDbSql
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
96c4e414
...
...
@@ -380,7 +380,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
int
doProcessSql
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pCmd
->
command
==
TSDB_SQL_SELECT
||
pCmd
->
command
==
TSDB_SQL_FETCH
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE
||
...
...
@@ -389,10 +390,15 @@ int doProcessSql(SSqlObj *pSql) {
pCmd
->
command
==
TSDB_SQL_HB
||
pCmd
->
command
==
TSDB_SQL_META
||
pCmd
->
command
==
TSDB_SQL_STABLEVGROUP
)
{
tscBuildMsg
[
pCmd
->
command
](
pSql
,
NULL
);
pRes
->
code
=
tscBuildMsg
[
pCmd
->
command
](
pSql
,
NULL
);
}
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
tscQueueAsyncRes
(
pSql
);
return
pRes
->
code
;
}
int32_t
code
=
tscSendMsgToServer
(
pSql
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRes
->
code
=
code
;
tscQueueAsyncRes
(
pSql
);
...
...
@@ -701,18 +707,19 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
size_t
numOfCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
numOfCols
*
sizeof
(
SColumnInfo
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
int32_t
total
=
tscGetNumOfColumns
(
pTableMeta
)
+
tscGetNumOfTags
(
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
pQueryInfo
->
colList
,
i
);
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
(
pCol
->
colIndex
.
columnIndex
>=
t
scGetNumOfColumns
(
pTableMeta
)
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
if
(
pCol
->
colIndex
.
columnIndex
>=
t
otal
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
tscError
(
"%p sid:%d uid:%"
PRIu64
" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s"
,
pSql
,
pTableMeta
->
sid
,
pTableMeta
->
uid
,
pTableMetaInfo
->
name
,
tscGetNumOfColumns
(
pTableMeta
),
pCol
->
colIndex
,
pColSchema
->
name
);
return
-
1
;
// 0 means build msg failed
return
TSDB_CODE_INVALID_SQL
;
}
pQueryMsg
->
colList
[
i
].
colId
=
htons
(
pColSchema
->
colId
);
...
...
src/inc/taosmsg.h
浏览文件 @
96c4e414
...
...
@@ -515,8 +515,8 @@ typedef struct {
}
SVnodeLoad
;
typedef
struct
{
char
acct
[
TSDB_USER_LEN
+
1
];
char
db
[
TSDB_DB_NAME_LEN
+
1
];
char
acct
[
TSDB_USER_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
uint32_t
vgId
;
int32_t
maxSessions
;
int32_t
cacheBlockSize
;
...
...
@@ -537,8 +537,8 @@ typedef struct {
int8_t
repStrategy
;
int8_t
loadLatest
;
// load into mem or not
uint8_t
precision
;
// time resolution
int8_t
reserved
[
16
]
;
}
S
DbCfg
,
S
CMCreateDbMsg
,
SCMAlterDbMsg
;
int8_t
ignoreExist
;
}
SCMCreateDbMsg
,
SCMAlterDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_ID_LEN
+
1
];
...
...
src/mnode/inc/mgmtDef.h
浏览文件 @
96c4e414
...
...
@@ -29,6 +29,32 @@ struct SAcctObj;
struct
SUserObj
;
struct
SMnodeObj
;
typedef
struct
{
char
acct
[
TSDB_USER_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
uint32_t
vgId
;
int32_t
maxSessions
;
int32_t
cacheBlockSize
;
union
{
int32_t
totalBlocks
;
float
fraction
;
}
cacheNumOfBlocks
;
int32_t
daysPerFile
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
daysToKeep
;
int32_t
commitTime
;
int32_t
rowsInFileBlock
;
int16_t
blocksPerTable
;
int8_t
compression
;
int8_t
commitLog
;
int8_t
replications
;
int8_t
repStrategy
;
int8_t
loadLatest
;
// load into mem or not
uint8_t
precision
;
// time resolution
int8_t
reserved
[
16
];
}
SDbCfg
;
typedef
struct
SDnodeObj
{
int32_t
dnodeId
;
uint32_t
privateIp
;
...
...
@@ -53,7 +79,7 @@ typedef struct SDnodeObj {
int32_t
refCount
;
uint32_t
moduleStatus
;
uint32_t
lastReboot
;
// time stamp for last reboot
float
score
;
// calc in balance function
float
score
;
// calc in balance function
float
diskAvailable
;
// from dnode status msg
int16_t
diskAvgUsage
;
// calc from sys.disk
int16_t
cpuAvgUsage
;
// calc from sys.cpu
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
96c4e414
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tutil.h"
#include "tgrant.h"
...
...
@@ -300,7 +301,12 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
SDbObj
*
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mgmtDecDbRef
(
pDb
);
return
TSDB_CODE_DB_ALREADY_EXIST
;
if
(
pCreate
->
ignoreExist
)
{
return
TSDB_CODE_SUCCESS
;
}
else
{
return
TSDB_CODE_DB_ALREADY_EXIST
;
}
}
code
=
mgmtCheckDbParams
(
pCreate
);
...
...
@@ -313,18 +319,41 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
return
code
;
}
pDb
=
malloc
(
sizeof
(
SDbObj
));
memset
(
pDb
,
0
,
sizeof
(
SDbObj
));
strcpy
(
pDb
->
name
,
pCreate
->
db
);
strcpy
(
pCreate
->
acct
,
pAcct
->
user
);
pDb
=
calloc
(
1
,
sizeof
(
SDbObj
));
strncpy
(
pDb
->
name
,
pCreate
->
db
,
TSDB_DB_NAME_LEN
);
strncpy
(
pCreate
->
acct
,
pAcct
->
user
,
TSDB_USER_LEN
);
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
*
pCreate
;
pDb
->
cfg
=
(
SDbCfg
)
{
.
vgId
=
pCreate
->
vgId
,
.
precision
=
pCreate
->
precision
,
.
maxSessions
=
pCreate
->
maxSessions
,
.
cacheNumOfBlocks
.
totalBlocks
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
,
.
rowsInFileBlock
=
pCreate
->
rowsInFileBlock
,
.
commitLog
=
pCreate
->
commitLog
,
.
replications
=
pCreate
->
replications
,
.
daysPerFile
=
pCreate
->
daysPerFile
,
.
cacheBlockSize
=
pCreate
->
cacheBlockSize
,
.
commitTime
=
pCreate
->
commitTime
,
.
blocksPerTable
=
pCreate
->
blocksPerTable
,
.
compression
=
pCreate
->
compression
,
.
daysToKeep
=
pCreate
->
daysToKeep
,
.
daysToKeep1
=
pCreate
->
daysToKeep1
,
.
daysToKeep2
=
pCreate
->
daysToKeep2
,
.
loadLatest
=
pCreate
->
loadLatest
,
.
repStrategy
=
pCreate
->
repStrategy
,
};
strncpy
(
pDb
->
cfg
.
db
,
pCreate
->
db
,
TSDB_DB_NAME_LEN
);
strncpy
(
pDb
->
cfg
.
acct
,
pCreate
->
acct
,
TSDB_USER_LEN
);
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDbSdb
,
.
pObj
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
)
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDbSdb
,
.
pObj
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
)
,
};
code
=
sdbInsertRow
(
&
oper
);
...
...
src/query/inc/qsqlparser.h
浏览文件 @
96c4e414
...
...
@@ -114,14 +114,13 @@ typedef struct SCreateDBInfo {
int32_t
tablesPerVnode
;
int32_t
daysPerFile
;
int32_t
rowPerFileBlock
;
float
numOfAvgCacheBlocks
;
int32_t
numOfBlocksPerTable
;
float
numOfAvgCacheBlocks
;
int32_t
numOfBlocksPerTable
;
int64_t
commitTime
;
int32_t
commitLog
;
int32_t
compressionLevel
;
SSQLToken
precision
;
bool
ignoreExists
;
tVariantList
*
keep
;
}
SCreateDBInfo
;
...
...
src/query/src/qparserImpl.c
浏览文件 @
96c4e414
...
...
@@ -815,8 +815,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
pInfo
->
pDCLInfo
->
dbOpt
=
*
pDB
;
pInfo
->
pDCLInfo
->
dbOpt
.
dbname
=
*
pToken
;
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pIgExists
);
pInfo
->
pDCLInfo
->
dbOpt
.
ignoreExists
=
(
pIgExists
!=
NULL
);
}
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
...
...
src/query/src/queryExecutor.c
浏览文件 @
96c4e414
...
...
@@ -3555,7 +3555,7 @@ static void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *
int32_t
setAdditionalInfo
(
SQInfo
*
pQInfo
,
STable
*
pTable
,
STableQueryInfo
*
pTableQueryInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
assert
(
pTableQueryInfo
->
lastKey
>
0
);
assert
(
pTableQueryInfo
->
lastKey
>
=
0
);
setTagVal
(
pRuntimeEnv
,
pTable
->
tableId
,
pQInfo
->
tsdb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录