Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
23cbcfe0
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看板
提交
23cbcfe0
编写于
7月 11, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parameters can be out of order when creating a database
上级
139af8e4
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
563 addition
and
590 deletion
+563
-590
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+2
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+73
-52
src/client/src/tscSQLParserImpl.c
src/client/src/tscSQLParserImpl.c
+21
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+0
-33
src/inc/sql.y
src/inc/sql.y
+44
-76
src/inc/tsql.h
src/inc/tsql.h
+15
-13
src/inc/tsqldef.h
src/inc/tsqldef.h
+4
-4
src/util/src/sql.c
src/util/src/sql.c
+404
-410
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
23cbcfe0
...
...
@@ -2331,7 +2331,8 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) {
tMemBucketDestroy
((
tMemBucket
**
)
&
(
pCtx
->
intermediateBuf
[
1
].
pz
));
tOrderDescDestroy
(
pCtx
->
intermediateBuf
[
2
].
pz
);
assert
(
pCtx
->
intermediateBuf
[
1
].
pz
==
NULL
);
pCtx
->
intermediateBuf
[
1
].
pz
=
NULL
;
pCtx
->
intermediateBuf
[
2
].
pz
=
NULL
;
}
static
bool
apercentile_function
(
SQLFunctionCtx
*
pCtx
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
23cbcfe0
...
...
@@ -110,6 +110,7 @@ static bool hasTimestampForPointInterpQuery(SSqlCmd* pCmd);
static
void
updateTagColumnIndex
(
SSqlCmd
*
pCmd
);
static
int32_t
setLimitOffsetValueInfo
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
);
static
void
addRequiredTagColumn
(
SSqlCmd
*
pCmd
,
int32_t
tagColIndex
);
static
int32_t
parseCreateDBOptions
(
SCreateDBInfo
*
pCreateDbSql
,
SSqlCmd
*
pCmd
);
static
int32_t
tscQueryOnlyMetricTags
(
SSqlCmd
*
pCmd
,
bool
*
queryOnMetricTags
)
{
assert
(
pCmd
->
metricQuery
==
1
);
...
...
@@ -240,8 +241,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
CREATE_DATABASE
:
{
char
msg2
[]
=
"name too long"
;
char
msg3
[]
=
"invalid db name"
;
char
msg4
[]
=
"invalid time precision"
;
int32_t
STORAGE_LEVEL
=
3
;
if
(
pInfo
->
sqlType
==
ALTER_DATABASE
)
{
pCmd
->
command
=
TSDB_SQL_ALTER_DB
;
...
...
@@ -250,7 +249,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd
->
existsCheck
=
(
pInfo
->
pDCLInfo
->
a
[
0
].
n
==
1
);
}
SCreateDB
SQL
*
pCreateDB
=
&
(
pInfo
->
pDCLInfo
->
dbOpt
);
SCreateDB
Info
*
pCreateDB
=
&
(
pInfo
->
pDCLInfo
->
dbOpt
);
if
(
tscValidateName
(
&
pCreateDB
->
dbname
)
!=
TSDB_CODE_SUCCESS
)
{
setErrMsg
(
pCmd
,
msg3
,
tListLen
(
msg3
));
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -262,57 +261,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
ret
;
}
/* in case of TSDB_SQL_ALTER_DB, other parameters will be ignore by mnode.*/
pCmd
->
defaultVal
[
0
]
=
pCreateDB
->
nReplica
;
pCmd
->
defaultVal
[
1
]
=
pCreateDB
->
nDays
;
pCmd
->
defaultVal
[
3
]
=
pCreateDB
->
nRowsInFileBlock
;
pCmd
->
defaultVal
[
4
]
=
pCreateDB
->
nCacheBlockSize
;
pCmd
->
defaultVal
[
5
]
=
pCreateDB
->
numOfBlocksPerTable
;
pCmd
->
defaultVal
[
6
]
=
pCreateDB
->
nTablesPerVnode
;
pCmd
->
defaultVal
[
7
]
=
pCreateDB
->
commitTime
;
pCmd
->
defaultVal
[
8
]
=
pCreateDB
->
commitLog
;
pCmd
->
defaultVal
[
9
]
=
pCreateDB
->
compressionLevel
;
*
(
double
*
)
&
(
pCmd
->
defaultVal
[
10
])
=
pCreateDB
->
nCacheNumOfBlocks
;
if
(
pCreateDB
->
keep
!=
NULL
)
{
pCmd
->
defaultVal
[
11
]
=
pCreateDB
->
keep
->
nExpr
;
for
(
int32_t
i
=
0
;
i
<
STORAGE_LEVEL
;
++
i
)
{
if
(
i
<
pCreateDB
->
keep
->
nExpr
)
{
pCmd
->
defaultVal
[
12
+
i
]
=
pCreateDB
->
keep
->
a
[
i
].
pVar
.
i64Key
;
}
else
{
pCmd
->
defaultVal
[
12
+
i
]
=
pCreateDB
->
keep
->
a
[
0
].
pVar
.
i64Key
;
}
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
STORAGE_LEVEL
;
++
i
)
{
pCmd
->
defaultVal
[
12
+
i
]
=
-
1
;
}
}
/* force to set 3 */
pCmd
->
defaultVal
[
11
]
=
3
;
const
int32_t
TIME_PRECISION_INDEX
=
15
;
if
(
pCreateDB
->
precision
.
n
>
0
)
{
if
(
strncmp
(
pCreateDB
->
precision
.
z
,
TSDB_TIME_PRECISION_MILLI_STR
,
pCreateDB
->
precision
.
n
)
==
0
&&
strlen
(
TSDB_TIME_PRECISION_MILLI_STR
)
==
pCreateDB
->
precision
.
n
)
{
/*time precision for this db: million second */
pCmd
->
defaultVal
[
TIME_PRECISION_INDEX
]
=
TSDB_TIME_PRECISION_MILLI
;
}
else
if
(
strncmp
(
pCreateDB
->
precision
.
z
,
TSDB_TIME_PRECISION_MICRO_STR
,
pCreateDB
->
precision
.
n
)
==
0
&&
strlen
(
TSDB_TIME_PRECISION_MICRO_STR
)
==
pCreateDB
->
precision
.
n
)
{
pCmd
->
defaultVal
[
TIME_PRECISION_INDEX
]
=
TSDB_TIME_PRECISION_MICRO
;
}
else
{
setErrMsg
(
pCmd
,
msg4
,
tListLen
(
msg4
));
if
(
parseCreateDBOptions
(
pCreateDB
,
pCmd
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
}
}
else
{
// millisecond by default
pCmd
->
defaultVal
[
TIME_PRECISION_INDEX
]
=
TSDB_TIME_PRECISION_MILLI
;
}
break
;
}
...
...
@@ -3967,3 +3919,72 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
return
TSDB_CODE_SUCCESS
;
}
static
void
setCreateDBOption
(
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond by default
pMsg
->
daysToKeep
=
htonl
(
-
1
);
pMsg
->
daysToKeep1
=
htonl
(
-
1
);
pMsg
->
daysToKeep2
=
htonl
(
-
1
);
pMsg
->
blocksPerMeter
=
(
pCreateDb
->
numOfBlocksPerTable
==
0
)
?
htons
(
-
1
)
:
htons
(
pCreateDb
->
numOfBlocksPerTable
);
pMsg
->
compression
=
(
pCreateDb
->
compressionLevel
==
0
)
?
-
1
:
pCreateDb
->
numOfAvgCacheBlocks
;
pMsg
->
commitLog
=
(
pCreateDb
->
commitLog
==
0
)
?
-
1
:
pCreateDb
->
numOfAvgCacheBlocks
;
pMsg
->
commitTime
=
(
pCreateDb
->
commitTime
==
0
)
?
htonl
(
-
1
)
:
htonl
(
pCreateDb
->
commitTime
);
pMsg
->
maxSessions
=
(
pCreateDb
->
tablesPerVnode
==
0
)
?
htonl
(
-
1
)
:
htonl
(
pCreateDb
->
tablesPerVnode
);
pMsg
->
cacheNumOfBlocks
.
fraction
=
(
pCreateDb
->
numOfAvgCacheBlocks
==
0
)
?
-
1
:
pCreateDb
->
numOfAvgCacheBlocks
;
pMsg
->
cacheBlockSize
=
(
pCreateDb
->
cacheBlockSize
==
0
)
?
htonl
(
-
1
)
:
htonl
(
pCreateDb
->
cacheBlockSize
);
pMsg
->
rowsInFileBlock
=
(
pCreateDb
->
rowPerFileBlock
==
0
)
?
htonl
(
-
1
)
:
htonl
(
pCreateDb
->
rowPerFileBlock
);
pMsg
->
daysPerFile
=
(
pCreateDb
->
daysPerFile
==
0
)
?
htonl
(
-
1
)
:
htonl
(
pCreateDb
->
daysPerFile
);
pMsg
->
replications
=
(
pCreateDb
->
replica
==
0
)
?
-
1
:
pCreateDb
->
replica
;
}
int32_t
parseCreateDBOptions
(
SCreateDBInfo
*
pCreateDbSql
,
SSqlCmd
*
pCmd
)
{
char
msg0
[]
=
"invalid number of options"
;
char
msg1
[]
=
"invalid time precision"
;
SCreateDbMsg
*
pMsg
=
(
SCreateDbMsg
*
)
(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
setCreateDBOption
(
pMsg
,
pCreateDbSql
);
if
(
pCreateDbSql
->
keep
!=
NULL
)
{
switch
(
pCreateDbSql
->
keep
->
nExpr
)
{
case
1
:
pMsg
->
daysToKeep
=
htonl
(
pCreateDbSql
->
keep
->
a
[
0
].
pVar
.
i64Key
);
break
;
case
2
:
{
pMsg
->
daysToKeep
=
htonl
(
pCreateDbSql
->
keep
->
a
[
0
].
pVar
.
i64Key
);
pMsg
->
daysToKeep1
=
htonl
(
pCreateDbSql
->
keep
->
a
[
1
].
pVar
.
i64Key
);
break
;
}
case
3
:
{
pMsg
->
daysToKeep
=
htonl
(
pCreateDbSql
->
keep
->
a
[
0
].
pVar
.
i64Key
);
pMsg
->
daysToKeep1
=
htonl
(
pCreateDbSql
->
keep
->
a
[
1
].
pVar
.
i64Key
);
pMsg
->
daysToKeep2
=
htonl
(
pCreateDbSql
->
keep
->
a
[
2
].
pVar
.
i64Key
);
break
;
}
default:
{
setErrMsg
(
pCmd
,
msg0
,
tListLen
(
msg0
));
return
TSDB_CODE_INVALID_SQL
;
}
}
}
SSQLToken
*
pToken
=
&
pCreateDbSql
->
precision
;
if
(
pToken
->
n
>
0
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
if
(
strncmp
(
pToken
->
z
,
TSDB_TIME_PRECISION_MILLI_STR
,
pToken
->
n
)
==
0
&&
strlen
(
TSDB_TIME_PRECISION_MILLI_STR
)
==
pToken
->
n
)
{
// time precision for this db: million second
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
}
else
if
(
strncmp
(
pToken
->
z
,
TSDB_TIME_PRECISION_MICRO_STR
,
pToken
->
n
)
==
0
&&
strlen
(
TSDB_TIME_PRECISION_MICRO_STR
)
==
pToken
->
n
)
{
pMsg
->
precision
=
TSDB_TIME_PRECISION_MICRO
;
}
else
{
setErrMsg
(
pCmd
,
msg1
,
tListLen
(
msg1
));
return
TSDB_CODE_INVALID_SQL
;
}
}
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
src/client/src/tscSQLParserImpl.c
浏览文件 @
23cbcfe0
...
...
@@ -369,6 +369,26 @@ void tVariantListDestroy(tVariantList *pList) {
free
(
pList
);
}
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SSQLToken
*
pAliasToken
,
uint8_t
sortOrder
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tVariantList
));
}
if
(
tVariantListExpand
(
pList
)
==
NULL
)
{
return
pList
;
}
if
(
pAliasToken
)
{
tVariant
t
=
{
0
};
tVariantCreate
(
&
t
,
pAliasToken
);
tVariantListItem
*
pItem
=
&
pList
->
a
[
pList
->
nExpr
++
];
memcpy
(
pItem
,
&
t
,
sizeof
(
tVariant
));
pItem
->
sortOrder
=
sortOrder
;
}
return
pList
;
}
tFieldList
*
tFieldListAppend
(
tFieldList
*
pList
,
TAOS_FIELD
*
pField
)
{
if
(
pList
==
NULL
)
pList
=
calloc
(
1
,
sizeof
(
tFieldList
));
...
...
@@ -650,7 +670,7 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_end
(
va
);
}
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDB
SQL
*
pDB
,
SSQLToken
*
pIgExists
)
{
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDB
Info
*
pDB
,
SSQLToken
*
pIgExists
)
{
pInfo
->
sqlType
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
src/client/src/tscServer.c
浏览文件 @
23cbcfe0
...
...
@@ -1362,39 +1362,6 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) {
pCreateDbMsg
=
(
SCreateDbMsg
*
)
pMsg
;
strcpy
(
pCreateDbMsg
->
db
,
pCmd
->
name
);
pCreateDbMsg
->
replications
=
pCmd
->
defaultVal
[
0
];
pCreateDbMsg
->
daysPerFile
=
htonl
(
pCmd
->
defaultVal
[
1
]);
pCreateDbMsg
->
rowsInFileBlock
=
htonl
(
pCmd
->
defaultVal
[
3
]);
pCreateDbMsg
->
cacheBlockSize
=
htonl
(
pCmd
->
defaultVal
[
4
]);
pCreateDbMsg
->
blocksPerMeter
=
htons
(
pCmd
->
defaultVal
[
5
]);
pCreateDbMsg
->
maxSessions
=
htonl
(
pCmd
->
defaultVal
[
6
]);
pCreateDbMsg
->
commitTime
=
htonl
(
pCmd
->
defaultVal
[
7
]);
pCreateDbMsg
->
commitLog
=
pCmd
->
defaultVal
[
8
];
pCreateDbMsg
->
compression
=
pCmd
->
defaultVal
[
9
];
pCreateDbMsg
->
cacheNumOfBlocks
.
fraction
=
*
(
double
*
)
&
(
pCmd
->
defaultVal
[
10
]);
int32_t
n
=
pCmd
->
defaultVal
[
11
];
switch
(
n
)
{
case
1
:
pCreateDbMsg
->
daysToKeep
=
htonl
(
pCmd
->
defaultVal
[
12
]);
break
;
case
2
:
{
pCreateDbMsg
->
daysToKeep
=
htonl
(
pCmd
->
defaultVal
[
12
]);
pCreateDbMsg
->
daysToKeep1
=
htonl
(
pCmd
->
defaultVal
[
13
]);
break
;
}
case
3
:
{
pCreateDbMsg
->
daysToKeep
=
htonl
(
pCmd
->
defaultVal
[
12
]);
pCreateDbMsg
->
daysToKeep1
=
htonl
(
pCmd
->
defaultVal
[
13
]);
pCreateDbMsg
->
daysToKeep2
=
htonl
(
pCmd
->
defaultVal
[
14
]);
break
;
}
}
pCreateDbMsg
->
precision
=
pCmd
->
defaultVal
[
15
];
pMsg
+=
sizeof
(
SCreateDbMsg
);
msgLen
=
pMsg
-
pStart
;
...
...
src/inc/sql.y
浏览文件 @
23cbcfe0
...
...
@@ -152,56 +152,39 @@ cmd ::= CREATE USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, CREATE_USER,
%type keep {tVariantList*}
%destructor keep {tVariantListDestroy($$);}
keep(Y) ::= . {Y = 0; }
keep(Y) ::= KEEP tagitemlist(X). {Y = X; }
replica(Y) ::= . {Y.n = 0; }
replica(Y) ::= REPLICA INTEGER(X). {Y = X; }
day(Y) ::= . {Y.n = 0; }
day(Y) ::= DAYS INTEGER(X). {Y = X; }
rows(Y) ::= ROWS INTEGER(X). {Y = X; }
rows(Y) ::= . {Y.n = 0; }
cache(Y) ::= CACHE INTEGER(X). {Y = X; }
cache(Y) ::= . {Y.n = 0; }
ablocks(Y) ::= ABLOCKS ID(X). {Y = X; }
ablocks(Y) ::= . {Y.n = 0; }
tblocks(Y) ::= TBLOCKS INTEGER(X). {Y = X; }
tblocks(Y) ::= . {Y.n = 0; }
tables(Y) ::= TABLES INTEGER(X). {Y = X; }
tables(Y) ::= . {Y.n = 0; }
ctime(Y) ::= CTIME INTEGER(X). {Y = X; }
ctime(Y) ::= . {Y.n = 0; }
clog(Y) ::= CLOG INTEGER(X). {Y = X; }
clog(Y) ::= . {Y.n = 0; }
comp(Y) ::= COMP INTEGER(X). {Y = X; }
comp(Y) ::= . {Y.n = 0; }
prec(Y) ::= PRECISION ids(X). {Y = X; }
prec(Y) ::= . {Y.n = 0; }
%type db_optr {SCreateDBSQL}
db_optr(Y) ::= replica(A) day(B) keep(C) rows(D) cache(E) ablocks(F) tblocks(K) tables(G) ctime(H) clog(I) comp(J) prec(L). {
Y.nReplica = (A.n > 0)? atoi(A.z):-1;
Y.nDays = (B.n > 0)? atoi(B.z):-1;
Y.nRowsInFileBlock = (D.n > 0)? atoi(D.z):-1;
Y.nCacheBlockSize = (E.n > 0)? atoi(E.z):-1;
Y.nCacheNumOfBlocks = (F.n > 0)? strtod(F.z, NULL):-1;
Y.numOfBlocksPerTable = (K.n > 0)? atoi(K.z):-1;
Y.nTablesPerVnode = (G.n > 0)? atoi(G.z):-1;
Y.commitTime = (H.n > 0)? atoi(H.z):-1;
Y.commitLog = (I.n > 0)? atoi(I.z):-1;
Y.compressionLevel = (J.n > 0)? atoi(J.z):-1;
Y.keep = C;
Y.precision = L;
}
%type alter_db_optr {SCreateDBSQL}
alter_db_optr(Y) ::= replica(A). {
Y.nReplica = (A.n > 0)? atoi(A.z):0;
keep(Y) ::= KEEP tagitemlist(X). { Y = X; }
tables(Y) ::= TABLES INTEGER(X). { Y = X; }
cache(Y) ::= CACHE INTEGER(X). { Y = X; }
replica(Y) ::= REPLICA INTEGER(X). { Y = X; }
days(Y) ::= DAYS INTEGER(X). { Y = X; }
rows(Y) ::= ROWS INTEGER(X). { Y = X; }
ablocks(Y) ::= ABLOCKS ID(X). { Y = X; }
tblocks(Y) ::= TBLOCKS INTEGER(X). { Y = X; }
ctime(Y) ::= CTIME INTEGER(X). { Y = X; }
clog(Y) ::= CLOG INTEGER(X). { Y = X; }
comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; }
%type db_optr {SCreateDBInfo}
db_optr ::= . {}
db_optr(Y) ::= db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) days(X). { Y = Z; Y.daysPerFile = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) rows(X). { Y = Z; Y.rowPerFileBlock = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) ablocks(X). { Y = Z; Y.numOfAvgCacheBlocks = strtod(X.z, NULL); }
db_optr(Y) ::= db_optr(Z) tblocks(X). { Y = Z; Y.numOfBlocksPerTable = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) ctime(X). { Y = Z; Y.commitTime = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) clog(X). { Y = Z; Y.commitLog = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
%type alter_db_optr {SCreateDBInfo}
alter_db_optr(Y) ::= REPLICA tagitem(A). {
Y.replica = A.i64Key;
}
%type typename {TAOS_FIELD}
...
...
@@ -359,11 +342,8 @@ fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. {
}
fill_opt(N) ::= FILL LP ID(Y) RP. {
tVariant A = {0};
toTSDBType(Y.type);
tVariantCreate(&A, &Y);
N = tVariantListAppend(NULL, &A, -1);
N = tVariantListAppendToken(NULL, &Y, -1);
}
%type sliding_opt {SSQLToken}
...
...
@@ -386,13 +366,15 @@ sortlist(A) ::= sortlist(X) COMMA item(Y) sortorder(Z). {
A = tVariantListAppend(X, &Y, Z);
}
%type item {tVariant}
sortlist(A) ::= item(Y) sortorder(Z). {
A = tVariantListAppend(NULL, &Y, Z);
}
item(A) ::= ids(X). {
%type item {tVariant}
item(A) ::= ids(X) cpxName(Y). {
toTSDBType(X.type);
X.n += Y.n;
tVariantCreate(&A, &X);
}
...
...
@@ -456,6 +438,7 @@ expr(A) ::= LP expr(X) RP. {A = X; }
expr(A) ::= ID(X). {A = tSQLExprIdValueCreate(&X, TK_ID);}
expr(A) ::= ID(X) DOT ID(Y). {X.n += (1+Y.n); A = tSQLExprIdValueCreate(&X, TK_ID);}
expr(A) ::= ID(X) DOT STAR(Y). {X.n += (1+Y.n); A = tSQLExprIdValueCreate(&X, TK_ALL);}
expr(A) ::= INTEGER(X). {A = tSQLExprIdValueCreate(&X, TK_INTEGER);}
expr(A) ::= MINUS(X) INTEGER(Y). {X.n += Y.n; X.type = TK_INTEGER; A = tSQLExprIdValueCreate(&X, TK_INTEGER);}
...
...
@@ -547,11 +530,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
X.n += F.n;
toTSDBType(A.type);
tVariant V;
tVariantCreate(&V, &A);
tVariantList* K = tVariantListAppend(NULL, &V, -1);
tVariantList* K = tVariantListAppendToken(NULL, &A, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, K, ALTER_TABLE_DROP_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_DROP_COLUMN);
...
...
@@ -567,11 +546,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
X.n += Z.n;
toTSDBType(Y.type);
tVariant V;
tVariantCreate(&V, &Y);
tVariantList* A = tVariantListAppend(NULL, &V, -1);
tVariantList* A = tVariantListAppendToken(NULL, &Y, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_DROP);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_DROP);
...
...
@@ -580,15 +555,11 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
X.n += F.n;
tVariant V;
toTSDBType(Y.type);
tVariantCreate(&V, &Y);
tVariantList* A = tVariantListAppend(NULL, &V, -1);
tVariantList* A = tVariantListAppendToken(NULL, &Y, -1);
toTSDBType(Z.type);
tVariantCreate(&V, &Z);
A = tVariantListAppend(A, &V, -1);
A = tVariantListAppendToken(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_CHG);
setSQLInfo(pInfo, pAlterTable, NULL, ALTER_TABLE_TAGS_CHG);
...
...
@@ -597,11 +568,8 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
cmd ::= ALTER TABLE ids(X) cpxName(F) SET ids(Y) EQ tagitem(Z). {
X.n += F.n;
tVariant V;
toTSDBType(Y.type);
tVariantCreate(&V, &Y);
tVariantList* A = tVariantListAppend(NULL, &V, -1);
tVariantList* A = tVariantListAppendToken(NULL, &Y, -1);
A = tVariantListAppend(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&X, NULL, A, ALTER_TABLE_TAGS_SET);
...
...
src/inc/tsql.h
浏览文件 @
23cbcfe0
...
...
@@ -197,23 +197,24 @@ typedef struct SInsertSQL {
struct
tSQLExprListList
*
pValue
;
}
SInsertSQL
;
typedef
struct
SCreateDB
SQL
{
typedef
struct
SCreateDB
Info
{
SSQLToken
dbname
;
int32_t
nReplica
;
int32_t
nDays
;
int32_t
replica
;
int32_t
cacheBlockSize
;
int32_t
tablesPerVnode
;
int32_t
daysPerFile
;
int32_t
rowPerFileBlock
;
tVariantList
*
keep
;
int32_t
nRowsInFileBlock
;
int32_t
nCacheBlockSize
;
float
nCacheNumOfBlocks
;
float
numOfAvgCacheBlocks
;
int32_t
numOfBlocksPerTable
;
int32_t
nTablesPerVnode
;
int64_t
commitTime
;
int32_t
commitLog
;
int32_t
compressionLevel
;
SSQLToken
precision
;
// time precision[ms by default/us]
}
SCreateDBSQL
;
SSQLToken
precision
;
tVariantList
*
keep
;
}
SCreateDBInfo
;
typedef
struct
SCreateAcctSQL
{
int32_t
users
;
...
...
@@ -233,7 +234,7 @@ typedef struct tDCLSQL {
SSQLToken
*
a
;
/* one entry for element */
union
{
SCreateDB
SQL
dbOpt
;
SCreateDB
Info
dbOpt
;
SCreateAcctSQL
acctOpt
;
};
}
tDCLSQL
;
...
...
@@ -326,6 +327,7 @@ void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor, SSqlInfo *);
*/
void
ParseFree
(
void
*
p
,
void
(
*
freeProc
)(
void
*
));
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SSQLToken
*
pAliasToken
,
uint8_t
sortOrder
);
tVariantList
*
tVariantListAppend
(
tVariantList
*
pList
,
tVariant
*
pVar
,
uint8_t
sortOrder
);
tVariantList
*
tVariantListInsert
(
tVariantList
*
pList
,
tVariant
*
pVar
,
uint8_t
sortOrder
,
int32_t
index
);
...
...
@@ -371,7 +373,7 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SSQLToken
*
pToken
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDB
SQL
*
pDB
,
SSQLToken
*
pIgExists
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pToken
,
SCreateDB
Info
*
pDB
,
SSQLToken
*
pIgExists
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SSQLToken
*
pName
,
SSQLToken
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
...
...
src/inc/tsqldef.h
浏览文件 @
23cbcfe0
...
...
@@ -91,10 +91,10 @@
#define TK_EXISTS 73
#define TK_CREATE 74
#define TK_KEEP 75
#define TK_
REPLICA
76
#define TK_
DAYS
77
#define TK_
ROW
S 78
#define TK_
CACHE
79
#define TK_
CACHE
76
#define TK_
REPLICA
77
#define TK_
DAY
S 78
#define TK_
ROWS
79
#define TK_ABLOCKS 80
#define TK_TBLOCKS 81
#define TK_CTIME 82
...
...
src/util/src/sql.c
浏览文件 @
23cbcfe0
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录