Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
TDengine
提交
d87a5251
T
TDengine
项目概览
jobily
/
TDengine
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d87a5251
编写于
8月 30, 2023
作者:
H
Haojun Liao
提交者:
GitHub
8月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22639 from taosdata/fix/TD-26025
fix create tag error
上级
718f97e5
cf98414d
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
540 addition
and
510 deletion
+540
-510
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+34
-18
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+5
-6
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+483
-483
tests/script/tsim/tagindex/add_index.sim
tests/script/tsim/tagindex/add_index.sim
+16
-1
未找到文件。
source/libs/parser/inc/sql.y
浏览文件 @
d87a5251
...
...
@@ -506,9 +506,9 @@ tag_item(A) ::= column_name(B) AS column_alias(C).
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX not_exists_opt(D)
full_index
_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
col
_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
cmd ::= CREATE INDEX not_exists_opt(D)
full_index
_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); }
col
_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); }
cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
d87a5251
...
...
@@ -348,7 +348,8 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
return
(
SNode
*
)
val
;
}
bool
addHintNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
**
ppHintList
,
EHintOption
opt
,
SToken
*
paramList
,
int32_t
paramNum
)
{
bool
addHintNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
**
ppHintList
,
EHintOption
opt
,
SToken
*
paramList
,
int32_t
paramNum
)
{
void
*
value
=
NULL
;
switch
(
opt
)
{
case
HINT_BATCH_SCAN
:
...
...
@@ -361,7 +362,7 @@ bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOpt
default:
return
true
;
}
SHintNode
*
hint
=
(
SHintNode
*
)
nodesMakeNode
(
QUERY_NODE_HINT
);
CHECK_OUT_OF_MEM
(
hint
);
hint
->
option
=
opt
;
...
...
@@ -385,15 +386,15 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
if
(
NULL
==
pLiteral
||
pLiteral
->
n
<=
5
)
{
return
NULL
;
}
SNodeList
*
pHintList
=
NULL
;
char
*
hint
=
strndup
(
pLiteral
->
z
+
3
,
pLiteral
->
n
-
5
);
int32_t
i
=
0
;
bool
quit
=
false
;
bool
inParamList
=
false
;
bool
lastComma
=
false
;
SNodeList
*
pHintList
=
NULL
;
char
*
hint
=
strndup
(
pLiteral
->
z
+
3
,
pLiteral
->
n
-
5
);
int32_t
i
=
0
;
bool
quit
=
false
;
bool
inParamList
=
false
;
bool
lastComma
=
false
;
EHintOption
opt
=
0
;
int32_t
paramNum
=
0
;
SToken
paramList
[
10
];
int32_t
paramNum
=
0
;
SToken
paramList
[
10
];
while
(
!
quit
)
{
SToken
t0
=
{
0
};
if
(
hint
[
i
]
==
0
)
{
...
...
@@ -412,7 +413,7 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
}
opt
=
HINT_BATCH_SCAN
;
break
;
case
TK_NO_BATCH_SCAN
:
case
TK_NO_BATCH_SCAN
:
lastComma
=
false
;
if
(
0
!=
opt
||
inParamList
)
{
quit
=
true
;
...
...
@@ -446,7 +447,7 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) {
paramList
[
paramNum
++
]
=
t0
;
}
break
;
case
TK_NK_COMMA
:
case
TK_NK_COMMA
:
if
(
lastComma
)
{
quit
=
true
;
}
...
...
@@ -962,11 +963,12 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
return
pStmt
;
}
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
)
{
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SNode
*
select
=
createSelectStmtImpl
(
isDistinct
,
pProjectionList
,
pTable
,
pHint
);
CHECK_OUT_OF_MEM
(
select
);
return
select
;
return
select
;
}
SNode
*
setSelectStmtTagMode
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
bool
bSelectTags
)
{
...
...
@@ -1766,8 +1768,23 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
indexType
=
type
;
pStmt
->
ignoreExists
=
ignoreExists
;
snprintf
(
pStmt
->
indexDbName
,
sizeof
(
pStmt
->
indexDbName
),
"%s"
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
dbName
);
snprintf
(
pStmt
->
indexName
,
sizeof
(
pStmt
->
indexName
),
"%s"
,
((
SRealTableNode
*
)
pIndexName
)
->
table
.
tableName
);
SRealTableNode
*
pFullTable
=
(
SRealTableNode
*
)
pRealTable
;
if
(
strlen
(
pFullTable
->
table
.
dbName
)
==
0
)
{
// no db specified,
if
(
pCxt
->
pQueryCxt
->
db
==
NULL
)
{
pCxt
->
errCode
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_DB_NOT_SPECIFIED
);
nodesDestroyNode
(
pIndexName
);
nodesDestroyNode
(
pRealTable
);
nodesDestroyNode
(
pOptions
);
return
NULL
;
}
else
{
snprintf
(
pStmt
->
indexDbName
,
sizeof
(
pStmt
->
indexDbName
),
"%s"
,
pCxt
->
pQueryCxt
->
db
);
}
}
else
{
snprintf
(
pStmt
->
indexDbName
,
sizeof
(
pStmt
->
indexDbName
),
"%s"
,
pFullTable
->
table
.
dbName
);
}
snprintf
(
pStmt
->
indexName
,
sizeof
(
pStmt
->
indexName
),
"%s"
,
((
SColumnNode
*
)
pIndexName
)
->
colName
);
snprintf
(
pStmt
->
dbName
,
sizeof
(
pStmt
->
dbName
),
"%s"
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
dbName
);
snprintf
(
pStmt
->
tableName
,
sizeof
(
pStmt
->
tableName
),
"%s"
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
tableName
);
nodesDestroyNode
(
pIndexName
);
...
...
@@ -1884,8 +1901,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropCGroupStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pCGroupId
,
SToken
*
pTopicName
)
{
SNode
*
createDropCGroupStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pCGroupId
,
SToken
*
pTopicName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkTopicName
(
pCxt
,
pTopicName
))
{
return
NULL
;
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
d87a5251
...
...
@@ -336,7 +336,7 @@ 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
)
{
if
(
INDEX_TYPE_SMA
==
pStmt
->
indexType
||
INDEX_TYPE_NORMAL
==
pStmt
->
indexType
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
...
...
@@ -356,8 +356,7 @@ static int32_t collectMetaKeyFromCreateTopic(SCollectMetaKeyCxt* pCxt, SCreateTo
return
collectMetaKeyFromQuery
(
pCxt
,
pStmt
->
pQuery
);
}
if
(
NULL
!=
pStmt
->
pWhere
)
{
int32_t
code
=
collectMetaKeyFromRealTableImpl
(
pCxt
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
AUTH_TYPE_READ
);
int32_t
code
=
collectMetaKeyFromRealTableImpl
(
pCxt
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
AUTH_TYPE_READ
);
return
code
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -387,7 +386,7 @@ static int32_t collectMetaKeyFromCreateStream(SCollectMetaKeyCxt* pCxt, SCreateS
if
(
TSDB_CODE_SUCCESS
==
code
&&
pStmt
->
pOptions
->
fillHistory
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
->
pQuery
;
code
=
reserveDbCfgForLastRow
(
pCxt
,
pSelect
->
pFromTable
);
}
}
return
code
;
}
...
...
@@ -590,8 +589,8 @@ static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShow
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_READ
,
pCxt
->
pMetaCache
);
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_READ
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
d87a5251
此差异已折叠。
点击以展开。
tests/script/tsim/tagindex/add_index.sim
浏览文件 @
d87a5251
...
...
@@ -18,6 +18,20 @@ sql use $dbPrefix
print =============== create super table and register tag index
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2 int, t3 int, t4 int, t5 int)
sql use information_schema;
sql create index t2i on ta_3_db.ta_3_mt(t2)
sql_error create index t3i on ta_3_mt(t3)
sql_error drop index t2i
sql drop index ta_3_db.t2i
sql use $dbPrefix
sql show stables
if $rows != 1 then
return -1
...
...
@@ -310,4 +324,5 @@ sql_error create index ti2 on $mtPrefix (t1)
sql_error create index t2i on ta_3_tb17 (t2)
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录