Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ed10d3a
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看板
提交
5ed10d3a
编写于
9月 13, 2020
作者:
Y
yihaoDeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
suppport cmd show-create-table and show-create-db
上级
f8bab293
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
717 addition
and
125 deletion
+717
-125
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+556
-26
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+33
-0
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+1
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+7
-0
src/client/src/tscSql.c
src/client/src/tscSql.c
+2
-0
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+1
-0
src/common/inc/tcmdtype.h
src/common/inc/tcmdtype.h
+3
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/inc/ttokendef.h
src/inc/ttokendef.h
+99
-99
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+3
-0
src/query/inc/sql.y
src/query/inc/sql.y
+10
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
5ed10d3a
...
...
@@ -98,6 +98,7 @@ typedef struct STableMeta {
uint8_t
tableType
;
int16_t
sversion
;
int16_t
tversion
;
char
sTableId
[
TSDB_TABLE_FNAME_LEN
];
SCMVgroupInfo
vgroupInfo
;
SCMCorVgroupInfo
corVgroupInfo
;
STableId
id
;
...
...
src/client/src/tscLocal.c
浏览文件 @
5ed10d3a
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
5ed10d3a
...
...
@@ -366,7 +366,40 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
}
case
TSDB_SQL_SHOW_CREATE_TABLE
:
{
SStrToken
*
pToken
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"table name is too long"
;
if
(
tscValidateName
(
pToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
!
tscValidateTableNameLength
(
pToken
->
n
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
tscSetTableFullName
(
pTableMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
return
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
}
case
TSDB_SQL_SHOW_CREATE_DATABASE
:
{
const
char
*
msg1
=
"invalid database name"
;
const
char
*
msg2
=
"table name is too long"
;
SStrToken
*
pToken
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
if
(
tscValidateName
(
pToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
pToken
->
n
>
TSDB_DB_NAME_LEN
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
tscSetTableFullName
(
pTableMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
return
TSDB_CODE_SUCCESS
;
}
case
TSDB_SQL_CFG_DNODE
:
{
const
char
*
msg2
=
"invalid configure options or values, such as resetlog / debugFlag 135 / balance 'vnode:2-dnode:2' / monitor 1 "
;
const
char
*
msg3
=
"invalid dnode ep"
;
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
5ed10d3a
...
...
@@ -170,6 +170,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
sversion
=
pTableMetaMsg
->
sversion
;
pTableMeta
->
tversion
=
pTableMetaMsg
->
tversion
;
tstrncpy
(
pTableMeta
->
sTableId
,
pTableMetaMsg
->
sTableId
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
...
...
src/client/src/tscServer.c
浏览文件 @
5ed10d3a
...
...
@@ -2072,6 +2072,9 @@ int tscProcessAlterDbMsgRsp(SSqlObj *pSql) {
UNUSED
(
pSql
);
return
0
;
}
int
tscProcessShowCreateRsp
(
SSqlObj
*
pSql
)
{
return
tscLocalResultCommonBuilder
(
pSql
,
1
);
}
int
tscProcessQueryRsp
(
SSqlObj
*
pSql
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -2343,6 +2346,10 @@ void tscInitMsgsFp() {
tscProcessMsgRsp
[
TSDB_SQL_ALTER_TABLE
]
=
tscProcessAlterTableMsgRsp
;
tscProcessMsgRsp
[
TSDB_SQL_ALTER_DB
]
=
tscProcessAlterDbMsgRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SHOW_CREATE_TABLE
]
=
tscProcessShowCreateRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SHOW_CREATE_DATABASE
]
=
tscProcessShowCreateRsp
;
tscKeepConn
[
TSDB_SQL_SHOW
]
=
1
;
tscKeepConn
[
TSDB_SQL_RETRIEVE
]
=
1
;
tscKeepConn
[
TSDB_SQL_SELECT
]
=
1
;
...
...
src/client/src/tscSql.c
浏览文件 @
5ed10d3a
...
...
@@ -451,6 +451,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
pCmd
->
command
==
TSDB_SQL_TABLE_JOIN_RETRIEVE
||
pCmd
->
command
==
TSDB_SQL_FETCH
||
pCmd
->
command
==
TSDB_SQL_SHOW
||
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_TABLE
||
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_DATABASE
||
pCmd
->
command
==
TSDB_SQL_SELECT
||
pCmd
->
command
==
TSDB_SQL_DESCRIBE_TABLE
||
pCmd
->
command
==
TSDB_SQL_SERV_STATUS
||
...
...
src/client/src/tscSubquery.c
浏览文件 @
5ed10d3a
...
...
@@ -23,6 +23,7 @@
#include "tscSubquery.h"
#include "tschemautil.h"
#include "tsclient.h"
#include "tscSubquery.h"
typedef
struct
SInsertSupporter
{
SSubqueryState
*
pState
;
...
...
src/common/inc/tcmdtype.h
浏览文件 @
5ed10d3a
...
...
@@ -78,6 +78,9 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_RETRIEVE_LOCALMERGE
,
"retrieve-localmerge"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_TABLE_JOIN_RETRIEVE
,
"join-retrieve"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SHOW_CREATE_TABLE
,
"show-create-table"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SHOW_CREATE_DATABASE
,
"show-create-database"
)
/*
* build empty result instead of accessing dnode to fetch result
* reset the client cache
...
...
src/inc/taosmsg.h
浏览文件 @
5ed10d3a
...
...
@@ -677,6 +677,7 @@ typedef struct {
typedef
struct
STableMetaMsg
{
int32_t
contLen
;
char
tableId
[
TSDB_TABLE_FNAME_LEN
];
// table id
char
sTableId
[
TSDB_TABLE_FNAME_LEN
];
uint8_t
numOfTags
;
uint8_t
precision
;
uint8_t
tableType
;
...
...
src/inc/ttokendef.h
浏览文件 @
5ed10d3a
...
...
@@ -16,105 +16,105 @@
#ifndef TDENGINE_TTOKENDEF_H
#define TDENGINE_TTOKENDEF_H
#define TK_ID
1
#define TK_BOOL
2
#define TK_TINYINT
3
#define TK_SMALLINT
4
#define TK_INTEGER
5
#define TK_BIGINT
6
#define TK_FLOAT
7
#define TK_DOUBLE
8
#define TK_STRING
9
#define TK_TIMESTAMP
10
#define TK_BINARY
11
#define TK_NCHAR
12
#define TK_OR
13
#define TK_AND
14
#define TK_NOT
15
#define TK_EQ
16
#define TK_NE
17
#define TK_ISNULL
18
#define TK_NOTNULL
19
#define TK_IS
20
#define TK_LIKE
21
#define TK_GLOB
22
#define TK_BETWEEN
23
#define TK_IN
24
#define TK_GT
25
#define TK_GE
26
#define TK_LT
27
#define TK_LE
28
#define TK_BITAND
29
#define TK_BITOR
30
#define TK_LSHIFT
31
#define TK_RSHIFT
32
#define TK_PLUS
33
#define TK_MINUS
34
#define TK_DIVIDE
35
#define TK_TIMES
36
#define TK_STAR
37
#define TK_SLASH
38
#define TK_REM
39
#define TK_CONCAT
40
#define TK_UMINUS
41
#define TK_UPLUS
42
#define TK_BITNOT
43
#define TK_SHOW
44
#define TK_DATABASES
45
#define TK_MNODES
46
#define TK_DNODES
47
#define TK_ACCOUNTS
48
#define TK_USERS
49
#define TK_MODULES
50
#define TK_QUERIES
51
#define TK_CONNECTIONS
52
#define TK_STREAMS
53
#define TK_VARIABLES
54
#define TK_SCORES
55
#define TK_GRANTS
56
#define TK_VNODES
57
#define TK_IPTOKEN
58
#define TK_DOT
59
#define TK_
TABLES
60
#define TK_
STABLES
61
#define TK_
VGROUPS
62
#define TK_
DROP
63
#define TK_
TABLE
64
#define TK_
DATABASE
65
#define TK_D
NODE
66
#define TK_
USER
67
#define TK_
ACCOUNT
68
#define TK_
USE
69
#define TK_
DESCRIBE
70
#define TK_
ALTER
71
#define TK_
PASS
72
#define TK_P
RIVILEGE
73
#define TK_
LOCAL
74
#define TK_
IF
75
#define TK_
EXISTS
76
#define TK_
CREATE
77
#define TK_PPS
78
#define TK_TSERIES
79
#define TK_DBS
80
#define TK_STORAGE
81
#define TK_QTIME
82
#define TK_CONNS
83
#define TK_STATE
84
#define TK_KEEP
85
#define TK_CACHE
86
#define TK_REPLICA
87
#define TK_QUORUM
88
#define TK_DAYS
89
#define TK_MINROWS
90
#define TK_MAXROWS
91
#define TK_BLOCKS
92
#define TK_CTIME
93
#define TK_WAL
94
#define TK_FSYNC
95
#define TK_COMP
96
#define TK_PRECISION
97
#define TK_LP
98
#define TK_RP
99
#define TK_ID 1
#define TK_BOOL 2
#define TK_TINYINT 3
#define TK_SMALLINT 4
#define TK_INTEGER 5
#define TK_BIGINT 6
#define TK_FLOAT 7
#define TK_DOUBLE 8
#define TK_STRING 9
#define TK_TIMESTAMP 10
#define TK_BINARY 11
#define TK_NCHAR 12
#define TK_OR 13
#define TK_AND 14
#define TK_NOT 15
#define TK_EQ 16
#define TK_NE 17
#define TK_ISNULL 18
#define TK_NOTNULL 19
#define TK_IS 20
#define TK_LIKE 21
#define TK_GLOB 22
#define TK_BETWEEN 23
#define TK_IN 24
#define TK_GT 25
#define TK_GE 26
#define TK_LT 27
#define TK_LE 28
#define TK_BITAND 29
#define TK_BITOR 30
#define TK_LSHIFT 31
#define TK_RSHIFT 32
#define TK_PLUS 33
#define TK_MINUS 34
#define TK_DIVIDE 35
#define TK_TIMES 36
#define TK_STAR 37
#define TK_SLASH 38
#define TK_REM 39
#define TK_CONCAT 40
#define TK_UMINUS 41
#define TK_UPLUS 42
#define TK_BITNOT 43
#define TK_SHOW 44
#define TK_DATABASES 45
#define TK_MNODES 46
#define TK_DNODES 47
#define TK_ACCOUNTS 48
#define TK_USERS 49
#define TK_MODULES 50
#define TK_QUERIES 51
#define TK_CONNECTIONS 52
#define TK_STREAMS 53
#define TK_VARIABLES 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_
CREATE
60
#define TK_
TABLE
61
#define TK_
DATABASE
62
#define TK_
TABLES
63
#define TK_
STABLES
64
#define TK_
VGROUPS
65
#define TK_D
ROP
66
#define TK_
DNODE
67
#define TK_
USER
68
#define TK_
ACCOUNT
69
#define TK_
USE
70
#define TK_
DESCRIBE
71
#define TK_
ALTER
72
#define TK_P
ASS
73
#define TK_
PRIVILEGE
74
#define TK_
LOCAL
75
#define TK_
IF
76
#define TK_
EXISTS
77
#define TK_PPS 78
#define TK_TSERIES 79
#define TK_DBS 80
#define TK_STORAGE 81
#define TK_QTIME 82
#define TK_CONNS 83
#define TK_STATE 84
#define TK_KEEP 85
#define TK_CACHE 86
#define TK_REPLICA 87
#define TK_QUORUM 88
#define TK_DAYS 89
#define TK_MINROWS 90
#define TK_MAXROWS 91
#define TK_BLOCKS 92
#define TK_CTIME 93
#define TK_WAL 94
#define TK_FSYNC 95
#define TK_COMP 96
#define TK_PRECISION 97
#define TK_LP 98
#define TK_RP 99
#define TK_TAGS 100
#define TK_USING 101
#define TK_AS 102
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
5ed10d3a
...
...
@@ -2090,6 +2090,9 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
tableType
=
pTable
->
info
.
type
;
tstrncpy
(
pMeta
->
tableId
,
pTable
->
info
.
tableId
,
TSDB_TABLE_FNAME_LEN
);
if
(
pTable
->
superTable
)
{
tstrncpy
(
pMeta
->
sTableId
,
pTable
->
superTable
->
info
.
tableId
,
TSDB_TABLE_FNAME_LEN
);
}
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
pMeta
->
sversion
=
htons
(
pTable
->
superTable
->
sversion
);
...
...
src/query/inc/sql.y
浏览文件 @
5ed10d3a
...
...
@@ -80,6 +80,7 @@ cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0);
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
%type dbPrefix {SStrToken}
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
dbPrefix(A) ::= ids(X) DOT. {A = X; }
...
...
@@ -88,6 +89,15 @@ dbPrefix(A) ::= ids(X) DOT. {A = X; }
cpxName(A) ::= . {A.n = 0; }
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
cmd ::= SHOW CREATE TABLE ids(X) cpxName(Y). {
X.n += Y.n;
setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &X);
}
cmd ::= SHOW CREATE DATABASE ids(X). {
setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &X);
}
cmd ::= SHOW dbPrefix(X) TABLES. {
setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &X, 0);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录