Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f33959bd
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看板
提交
f33959bd
编写于
8月 02, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: some problems of parser
上级
5f18be15
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
1962 addition
and
1908 deletion
+1962
-1908
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+4
-1
source/libs/command/src/command.c
source/libs/command/src/command.c
+38
-17
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-6
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+8
-10
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+9
-7
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+28
-12
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1850
-1843
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+4
-2
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+7
-7
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+2
-0
source/libs/planner/test/planSubqueryTest.cpp
source/libs/planner/test/planSubqueryTest.cpp
+6
-0
未找到文件。
include/libs/nodes/cmdnodes.h
浏览文件 @
f33959bd
...
...
@@ -253,7 +253,8 @@ typedef struct SShowCreateTableStmt {
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
void
*
pCfg
;
// STableCfg
void
*
pDbCfg
;
// SDbCfgInfo
void
*
pTableCfg
;
// STableCfg
}
SShowCreateTableStmt
;
typedef
struct
SShowTableDistributedStmt
{
...
...
@@ -282,6 +283,7 @@ typedef struct SCreateIndexStmt {
ENodeType
type
;
EIndexType
indexType
;
bool
ignoreExists
;
char
indexDbName
[
TSDB_DB_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
...
...
@@ -292,6 +294,7 @@ typedef struct SCreateIndexStmt {
typedef
struct
SDropIndexStmt
{
ENodeType
type
;
bool
ignoreNotExists
;
char
indexDbName
[
TSDB_DB_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
}
SDropIndexStmt
;
...
...
source/libs/command/src/command.c
浏览文件 @
f33959bd
...
...
@@ -192,6 +192,26 @@ char* buildRetension(SArray* pRetension) {
return
p1
;
}
static
const
char
*
cacheModelStr
(
int8_t
cacheModel
)
{
switch
(
cacheModel
)
{
case
TSDB_CACHE_MODEL_NONE
:
return
TSDB_CACHE_MODEL_NONE_STR
;
case
TSDB_CACHE_MODEL_LAST_ROW
:
return
TSDB_CACHE_MODEL_LAST_ROW_STR
;
case
TSDB_CACHE_MODEL_LAST_VALUE
:
return
TSDB_CACHE_MODEL_LAST_VALUE_STR
;
case
TSDB_CACHE_MODEL_BOTH
:
return
TSDB_CACHE_MODEL_BOTH_STR
;
default:
break
;
}
return
TSDB_CACHE_MODEL_NONE_STR
;
}
static
const
char
*
strictStr
(
int8_t
strict
)
{
return
TSDB_DB_STRICT_ON
==
strict
?
TSDB_DB_STRICT_ON_STR
:
TSDB_DB_STRICT_OFF_STR
;
}
static
void
setCreateDBResultIntoDataBlock
(
SSDataBlock
*
pBlock
,
char
*
dbFName
,
SDbCfgInfo
*
pCfg
)
{
blockDataEnsureCapacity
(
pBlock
,
1
);
pBlock
->
info
.
rows
=
1
;
...
...
@@ -222,14 +242,15 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
char
*
retentions
=
buildRetension
(
pCfg
->
pRetensions
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE DATABASE `%s` BUFFER %d CACHEMODEL %d COMP %d DURATION %dm "
"FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
"STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d"
,
dbFName
,
pCfg
->
buffer
,
pCfg
->
cacheLast
,
pCfg
->
compression
,
pCfg
->
daysPerFile
,
pCfg
->
walFsyncPeriod
,
pCfg
->
maxRows
,
pCfg
->
minRows
,
pCfg
->
daysToKeep0
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
pCfg
->
pages
,
pCfg
->
pageSize
,
prec
,
pCfg
->
replications
,
pCfg
->
strict
,
pCfg
->
walLevel
,
pCfg
->
numOfVgroups
,
1
==
pCfg
->
numOfStables
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE DATABASE `%s` BUFFER %d CACHEMODEL '%s' COMP %d DURATION %dm "
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
"STRICT '%s' WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d"
,
dbFName
,
pCfg
->
buffer
,
cacheModelStr
(
pCfg
->
cacheLast
),
pCfg
->
compression
,
pCfg
->
daysPerFile
,
pCfg
->
walFsyncPeriod
,
pCfg
->
maxRows
,
pCfg
->
minRows
,
pCfg
->
daysToKeep0
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
pCfg
->
pages
,
pCfg
->
pageSize
,
prec
,
pCfg
->
replications
,
strictStr
(
pCfg
->
strict
),
pCfg
->
walLevel
,
pCfg
->
numOfVgroups
,
1
==
pCfg
->
numOfStables
);
if
(
retentions
)
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
" RETENTIONS %s"
,
retentions
);
...
...
@@ -383,21 +404,21 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
return
TSDB_CODE_SUCCESS
;
}
void
appendTableOptions
(
char
*
buf
,
int32_t
*
len
,
STableCfg
*
pCfg
)
{
void
appendTableOptions
(
char
*
buf
,
int32_t
*
len
,
S
DbCfgInfo
*
pDbCfg
,
S
TableCfg
*
pCfg
)
{
if
(
pCfg
->
commentLen
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" COMMENT '%s'"
,
pCfg
->
pComment
);
}
else
if
(
0
==
pCfg
->
commentLen
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" COMMENT ''"
);
}
if
(
pCfg
->
watermark1
>
0
)
{
if
(
NULL
!=
pDbCfg
->
pRetensions
&&
pCfg
->
watermark1
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" WATERMARK %"
PRId64
"a"
,
pCfg
->
watermark1
);
if
(
pCfg
->
watermark2
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
", %"
PRId64
"a"
,
pCfg
->
watermark2
);
}
}
if
(
pCfg
->
delay1
>
0
)
{
if
(
NULL
!=
pDbCfg
->
pRetensions
&&
pCfg
->
delay1
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" MAX_DELAY %"
PRId64
"a"
,
pCfg
->
delay1
);
if
(
pCfg
->
delay2
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
", %"
PRId64
"a"
,
pCfg
->
delay2
);
...
...
@@ -405,7 +426,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) {
}
int32_t
funcNum
=
taosArrayGetSize
(
pCfg
->
pFuncs
);
if
(
funcNum
>
0
)
{
if
(
NULL
!=
pDbCfg
->
pRetensions
&&
funcNum
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" ROLLUP("
);
for
(
int32_t
i
=
0
;
i
<
funcNum
;
++
i
)
{
char
*
pFunc
=
taosArrayGet
(
pCfg
->
pFuncs
,
i
);
...
...
@@ -419,7 +440,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) {
}
}
static
int32_t
setCreateTBResultIntoDataBlock
(
SSDataBlock
*
pBlock
,
char
*
tbName
,
STableCfg
*
pCfg
)
{
static
int32_t
setCreateTBResultIntoDataBlock
(
SSDataBlock
*
pBlock
,
SDbCfgInfo
*
pDbCfg
,
char
*
tbName
,
STableCfg
*
pCfg
)
{
int32_t
code
=
0
;
blockDataEnsureCapacity
(
pBlock
,
1
);
pBlock
->
info
.
rows
=
1
;
...
...
@@ -439,7 +460,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
") TAGS ("
);
appendTagFields
(
buf2
,
&
len
,
pCfg
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
")"
);
appendTableOptions
(
buf2
,
&
len
,
pCfg
);
appendTableOptions
(
buf2
,
&
len
,
p
DbCfg
,
p
Cfg
);
}
else
if
(
TSDB_CHILD_TABLE
==
pCfg
->
tableType
)
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE TABLE `%s` USING `%s` ("
,
tbName
,
pCfg
->
stbName
);
appendTagNameFields
(
buf2
,
&
len
,
pCfg
);
...
...
@@ -449,7 +470,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
return
code
;
}
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
")"
);
appendTableOptions
(
buf2
,
&
len
,
pCfg
);
appendTableOptions
(
buf2
,
&
len
,
p
DbCfg
,
p
Cfg
);
}
else
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE TABLE `%s` ("
,
tbName
);
appendColumnFields
(
buf2
,
&
len
,
pCfg
);
...
...
@@ -465,7 +486,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName,
static
int32_t
execShowCreateTable
(
SShowCreateTableStmt
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
SSDataBlock
*
pBlock
=
buildCreateTbResultDataBlock
();
int32_t
code
=
setCreateTBResultIntoDataBlock
(
pBlock
,
pStmt
->
tableName
,
pStmt
->
p
Cfg
);
int32_t
code
=
setCreateTBResultIntoDataBlock
(
pBlock
,
pStmt
->
pDbCfg
,
pStmt
->
tableName
,
pStmt
->
pTable
Cfg
);
if
(
code
)
{
return
code
;
}
...
...
@@ -473,7 +494,7 @@ static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRs
}
static
int32_t
execShowCreateSTable
(
SShowCreateTableStmt
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
STableCfg
*
pCfg
=
(
STableCfg
*
)
pStmt
->
pCfg
;
STableCfg
*
pCfg
=
(
STableCfg
*
)
pStmt
->
p
Table
Cfg
;
if
(
TSDB_SUPER_TABLE
!=
pCfg
->
tableType
)
{
terrno
=
TSDB_CODE_TSC_NOT_STABLE_ERROR
;
return
terrno
;
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
f33959bd
...
...
@@ -713,7 +713,8 @@ void nodesDestroyNode(SNode* pNode) {
break
;
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
destroyTableCfg
((
STableCfg
*
)(((
SShowCreateTableStmt
*
)
pNode
)
->
pCfg
));
taosMemoryFreeClear
(((
SShowCreateTableStmt
*
)
pNode
)
->
pDbCfg
);
destroyTableCfg
((
STableCfg
*
)(((
SShowCreateTableStmt
*
)
pNode
)
->
pTableCfg
));
break
;
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
// no pointer field
case
QUERY_NODE_KILL_CONNECTION_STMT
:
// no pointer field
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
f33959bd
...
...
@@ -176,11 +176,11 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
S
Token
*
pIndexName
,
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
S
Node
*
pIndexName
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pStreamOptions
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
S
Token
*
pIndexName
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
S
Node
*
pIndexName
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
...
...
source/libs/parser/inc/sql.y
浏览文件 @
f33959bd
...
...
@@ -424,8 +424,8 @@ from_db_opt(A) ::= FROM db_name(B).
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX not_exists_opt(D)
index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &
A, B, NULL, C); }
cmd ::= DROP INDEX exists_opt(B)
index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &
A); }
full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D,
A, B, NULL, C); }
cmd ::= DROP INDEX exists_opt(B)
full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B,
A); }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
...
...
@@ -608,10 +608,6 @@ column_alias(A) ::= NK_ID(B).
%destructor user_name { }
user_name(A) ::= NK_ID(B). { A = B; }
%type index_name { SToken }
%destructor index_name { }
index_name(A) ::= NK_ID(B). { A = B; }
%type topic_name { SToken }
%destructor topic_name { }
topic_name(A) ::= NK_ID(B). { A = B; }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
f33959bd
...
...
@@ -1402,19 +1402,18 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
S
Token
*
pIndexName
,
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
S
Node
*
pIndexName
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkIndexName
(
pCxt
,
pIndexName
))
{
return
NULL
;
}
SCreateIndexStmt
*
pStmt
=
(
SCreateIndexStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_INDEX_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
indexType
=
type
;
pStmt
->
ignoreExists
=
ignoreExists
;
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
indexName
,
pIndexName
);
strcpy
(
pStmt
->
indexDbName
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
dbName
);
strcpy
(
pStmt
->
indexName
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
tableName
);
strcpy
(
pStmt
->
dbName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
dbName
);
strcpy
(
pStmt
->
tableName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
tableName
);
nodesDestroyNode
(
pIndexName
);
nodesDestroyNode
(
pRealTable
);
pStmt
->
pCols
=
pCols
;
pStmt
->
pOptions
=
(
SIndexOptions
*
)
pOptions
;
...
...
@@ -1434,15 +1433,14 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
return
(
SNode
*
)
pOptions
;
}
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
S
Token
*
pIndexName
)
{
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
S
Node
*
pIndexName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
NULL
,
true
)
||
!
checkIndexName
(
pCxt
,
pIndexName
))
{
return
NULL
;
}
SDropIndexStmt
*
pStmt
=
(
SDropIndexStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_INDEX_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
ignoreNotExists
=
ignoreNotExists
;
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
indexName
,
pIndexName
);
strcpy
(
pStmt
->
indexDbName
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
dbName
);
strcpy
(
pStmt
->
indexName
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
tableName
);
nodesDestroyNode
(
pIndexName
);
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
f33959bd
...
...
@@ -269,16 +269,15 @@ static int32_t collectMetaKeyFromUseDatabase(SCollectMetaKeyCxt* pCxt, SUseDatab
static
int32_t
collectMetaKeyFromCreateIndex
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
INDEX_TYPE_SMA
==
pStmt
->
indexType
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Cxt
->
pParseCxt
->
db
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Stmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Cxt
->
pParseCxt
->
db
,
pCxt
->
pMetaCache
);
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Stmt
->
dbName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Cxt
->
pParseCxt
->
db
,
pCxt
->
pMetaCache
);
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
p
Stmt
->
dbName
,
pCxt
->
pMetaCache
);
}
}
return
code
;
...
...
@@ -366,8 +365,8 @@ static int32_t collectMetaKeyFromShowStreams(SCollectMetaKeyCxt* pCxt, SShowStmt
}
static
int32_t
collectMetaKeyFromShowTables
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_TABLES
,
pCxt
->
pMetaCache
);
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_TABLES
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
!=
pStmt
->
pDbName
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
...
...
@@ -457,6 +456,9 @@ static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShow
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
f33959bd
...
...
@@ -1751,8 +1751,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) {
static
bool
sysTableFromVnode
(
const
char
*
pTable
)
{
return
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLES
))
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLE_DISTRIBUTED
)
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
)));
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TABLE_DISTRIBUTED
)
||
(
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_TAGS
)));
}
static
bool
sysTableFromDnode
(
const
char
*
pTable
)
{
return
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_DNODE_VARIABLES
);
}
...
...
@@ -3705,6 +3704,11 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
}
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
,
bool
createStable
)
{
if
(
NULL
!=
strchr
(
pStmt
->
tableName
,
'.'
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
"The table name cannot contain '.'"
);
}
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
createStable
&&
NULL
!=
dbCfg
.
pRetensions
)
{
...
...
@@ -4282,9 +4286,10 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt
return
buildCmdMsg
(
pCxt
,
TDMT_MND_CONFIG_DNODE
,
(
FSerializeFunc
)
tSerializeSMCfgDnodeReq
,
&
cfgReq
);
}
static
int32_t
getSmaIndexDstVgId
(
STranslateContext
*
pCxt
,
char
*
pTableName
,
int32_t
*
pVgId
)
{
static
int32_t
getSmaIndexDstVgId
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
int32_t
*
pVgId
)
{
SVgroupInfo
vg
=
{
0
};
int32_t
code
=
getTableHashVgroup
(
pCxt
,
p
Cxt
->
pParseCxt
->
db
,
pTableName
,
&
vg
);
int32_t
code
=
getTableHashVgroup
(
pCxt
,
p
DbName
,
pTableName
,
&
vg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pVgId
=
vg
.
vgId
;
}
...
...
@@ -4301,7 +4306,7 @@ static int32_t getSmaIndexSql(STranslateContext* pCxt, char** pSql, int32_t* pLe
}
static
int32_t
buildSampleAstInfoByIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SSampleAstInfo
*
pInfo
)
{
pInfo
->
pDbName
=
p
Cxt
->
pParseCxt
->
db
;
pInfo
->
pDbName
=
p
Stmt
->
dbName
;
pInfo
->
pTableName
=
pStmt
->
tableName
;
pInfo
->
pFuncs
=
nodesCloneList
(
pStmt
->
pOptions
->
pFuncs
);
pInfo
->
pInterval
=
nodesCloneNode
(
pStmt
->
pOptions
->
pInterval
);
...
...
@@ -4328,7 +4333,7 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
SName
name
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
p
Cxt
->
pParseCxt
->
db
,
pStmt
->
indexName
,
&
name
),
pReq
->
name
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
p
Stmt
->
indexDbName
,
pStmt
->
indexName
,
&
name
),
pReq
->
name
);
memset
(
&
name
,
0
,
sizeof
(
SName
));
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
name
),
pReq
->
stb
);
pReq
->
igExists
=
pStmt
->
ignoreExists
;
...
...
@@ -4352,7 +4357,7 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
}
}
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getSmaIndexSql
(
pCxt
,
&
pReq
->
sql
,
&
pReq
->
sqlLen
);
}
...
...
@@ -4365,7 +4370,7 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
static
int32_t
checkCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
p
Cxt
->
pParseCxt
->
db
,
&
dbCfg
);
int32_t
code
=
getDBCfg
(
pCxt
,
p
Stmt
->
dbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
dbCfg
.
pRetensions
)
{
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_SMA_INDEX
,
"Tables configured with the 'ROLLUP' option do not support creating sma index"
);
...
...
@@ -4883,10 +4888,17 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD
}
static
int32_t
translateShowCreateTable
(
STranslateContext
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
SName
name
;
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
name
);
return
getTableCfg
(
pCxt
,
&
name
,
(
STableCfg
**
)
&
pStmt
->
pCfg
);
pStmt
->
pDbCfg
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgInfo
));
if
(
NULL
==
pStmt
->
pDbCfg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
(
SDbCfgInfo
*
)
pStmt
->
pDbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SName
name
;
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
name
);
code
=
getTableCfg
(
pCxt
,
&
name
,
(
STableCfg
**
)
&
pStmt
->
pTableCfg
);
}
return
code
;
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
...
...
@@ -5917,6 +5929,10 @@ static int32_t checkCreateSubTable(STranslateContext* pCxt, SCreateSubTableClaus
if
(
0
!=
strcmp
(
pStmt
->
dbName
,
pStmt
->
useDbName
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR
);
}
if
(
NULL
!=
strchr
(
pStmt
->
tableName
,
'.'
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
"The table name cannot contain '.'"
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
rewriteCreateSubTable
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
SHashObj
*
pVgroupHashmap
)
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
f33959bd
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
f33959bd
...
...
@@ -54,7 +54,8 @@ TEST_F(ParserShowToUseTest, showCreateSTable) {
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_STABLE_STMT
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pCfg
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pDbCfg
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pTableCfg
,
nullptr
);
});
run
(
"SHOW CREATE STABLE st1"
);
...
...
@@ -67,7 +68,8 @@ TEST_F(ParserShowToUseTest, showCreateTable) {
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_TABLE_STMT
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pCfg
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pDbCfg
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pTableCfg
,
nullptr
);
});
run
(
"SHOW CREATE TABLE t1"
);
...
...
source/libs/planner/inc/planInt.h
浏览文件 @
f33959bd
...
...
@@ -23,13 +23,13 @@ extern "C" {
#include "planner.h"
#include "taoserror.h"
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
#define planInfo(param, ...) qInfo("PLAN: " param, __VA_ARGS__)
#define planDebug(param, ...) qDebug("PLAN: " param, __VA_ARGS__)
#define planDebugL(param, ...) qDebugL("PLAN: " param, __VA_ARGS__)
#define planTrace(param, ...) qTrace("PLAN: " param, __VA_ARGS__)
#define planFatal(param, ...) qFatal("PLAN: " param,
##
__VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param,
##
__VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param,
##
__VA_ARGS__)
#define planInfo(param, ...) qInfo("PLAN: " param,
##
__VA_ARGS__)
#define planDebug(param, ...) qDebug("PLAN: " param,
##
__VA_ARGS__)
#define planDebugL(param, ...) qDebugL("PLAN: " param,
##
__VA_ARGS__)
#define planTrace(param, ...) qTrace("PLAN: " param,
##
__VA_ARGS__)
int32_t
generateUsageErrMsg
(
char
*
pBuf
,
int32_t
len
,
int32_t
errCode
,
...);
int32_t
createColumnByRewriteExprs
(
SNodeList
*
pExprs
,
SNodeList
**
pList
);
...
...
source/libs/planner/src/planUtil.c
浏览文件 @
f33959bd
...
...
@@ -159,6 +159,7 @@ static bool isKeepOrderAggFunc(SNodeList* pFuncs) {
static
int32_t
adjustAggDataRequirement
(
SAggLogicNode
*
pAgg
,
EDataOrderLevel
requirement
)
{
// The sort level of agg with group by output data can only be DATA_ORDER_LEVEL_NONE
if
(
requirement
>
DATA_ORDER_LEVEL_NONE
&&
(
NULL
!=
pAgg
->
pGroupKeys
||
!
isKeepOrderAggFunc
(
pAgg
->
pAggFuncs
)))
{
planError
(
"Illegal statement, should be intercepted in parser"
);
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
pAgg
->
node
.
resultDataOrder
=
requirement
;
...
...
@@ -231,6 +232,7 @@ static int32_t adjustSortDataRequirement(SSortLogicNode* pSort, EDataOrderLevel
static
int32_t
adjustPartitionDataRequirement
(
SPartitionLogicNode
*
pPart
,
EDataOrderLevel
requirement
)
{
if
(
DATA_ORDER_LEVEL_GLOBAL
==
requirement
)
{
planError
(
"Illegal statement, should be intercepted in parser"
);
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
pPart
->
node
.
resultDataOrder
=
requirement
;
...
...
source/libs/planner/test/planSubqueryTest.cpp
浏览文件 @
f33959bd
...
...
@@ -85,3 +85,9 @@ TEST_F(PlanSubqeuryTest, outerPartition) {
run
(
"SELECT c1, COUNT(*) FROM (SELECT ts, c1 FROM st1) PARTITION BY c1"
);
}
TEST_F
(
PlanSubqeuryTest
,
outerApercentile
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT APERCENTILE(c1, 54) FROM (SELECT SUM(c1) AS c1 FROM t1)"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录