Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0b335b07
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0b335b07
编写于
3月 31, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 31, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11160 from taosdata/feature/3.0_wxy
TD-14431 bugfix
上级
c80f3239
ee1b47b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
25 deletion
+29
-25
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+28
-24
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-1
未找到文件。
source/libs/parser/src/parInsert.c
浏览文件 @
0b335b07
...
...
@@ -65,7 +65,7 @@ typedef struct SInsertParseContext {
SVnodeModifOpStmt
*
pOutput
;
}
SInsertParseContext
;
typedef
int32_t
(
*
_row_append_fn_t
)(
const
void
*
value
,
int32_t
len
,
void
*
param
);
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
static
uint8_t
TRUE_VALUE
=
(
uint8_t
)
TSDB_TRUE
;
static
uint8_t
FALSE_VALUE
=
(
uint8_t
)
TSDB_FALSE
;
...
...
@@ -444,26 +444,26 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
if
(
isNullStr
(
pToken
))
{
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pSchema
->
type
&&
PRIMARYKEY_TIMESTAMP_COL_ID
==
pSchema
->
colId
)
{
int64_t
tmpVal
=
0
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
return
func
(
NULL
,
0
,
param
);
return
func
(
pMsgBuf
,
NULL
,
0
,
param
);
}
switch
(
pSchema
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
if
((
pToken
->
type
==
TK_NK_BOOL
||
pToken
->
type
==
TK_NK_STRING
)
&&
(
pToken
->
n
!=
0
))
{
if
(
strncmp
(
pToken
->
z
,
"true"
,
pToken
->
n
)
==
0
)
{
return
func
(
&
TRUE_VALUE
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
TRUE_VALUE
,
pSchema
->
bytes
,
param
);
}
else
if
(
strncmp
(
pToken
->
z
,
"false"
,
pToken
->
n
)
==
0
)
{
return
func
(
&
FALSE_VALUE
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
FALSE_VALUE
,
pSchema
->
bytes
,
param
);
}
else
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid bool data"
,
pToken
->
z
);
}
}
else
if
(
pToken
->
type
==
TK_NK_INTEGER
)
{
return
func
(((
strtoll
(
pToken
->
z
,
NULL
,
10
)
==
0
)
?
&
FALSE_VALUE
:
&
TRUE_VALUE
),
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
((
strtoll
(
pToken
->
z
,
NULL
,
10
)
==
0
)
?
&
FALSE_VALUE
:
&
TRUE_VALUE
),
pSchema
->
bytes
,
param
);
}
else
if
(
pToken
->
type
==
TK_NK_FLOAT
)
{
return
func
(((
strtod
(
pToken
->
z
,
NULL
)
==
0
)
?
&
FALSE_VALUE
:
&
TRUE_VALUE
),
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
((
strtod
(
pToken
->
z
,
NULL
)
==
0
)
?
&
FALSE_VALUE
:
&
TRUE_VALUE
),
pSchema
->
bytes
,
param
);
}
else
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid bool data"
,
pToken
->
z
);
}
...
...
@@ -477,7 +477,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
}
uint8_t
tmpVal
=
(
uint8_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_UTINYINT
:{
...
...
@@ -487,7 +487,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"unsigned tinyint data overflow"
,
pToken
->
z
);
}
uint8_t
tmpVal
=
(
uint8_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
...
...
@@ -497,7 +497,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"smallint data overflow"
,
pToken
->
z
);
}
int16_t
tmpVal
=
(
int16_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
...
...
@@ -507,7 +507,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"unsigned smallint data overflow"
,
pToken
->
z
);
}
uint16_t
tmpVal
=
(
uint16_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_INT
:
{
...
...
@@ -517,7 +517,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"int data overflow"
,
pToken
->
z
);
}
int32_t
tmpVal
=
(
int32_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_UINT
:
{
...
...
@@ -527,7 +527,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"unsigned int data overflow"
,
pToken
->
z
);
}
uint32_t
tmpVal
=
(
uint32_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_BIGINT
:
{
...
...
@@ -536,7 +536,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
}
else
if
(
!
IS_VALID_BIGINT
(
iv
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"bigint data overflow"
,
pToken
->
z
);
}
return
func
(
&
iv
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
iv
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
...
...
@@ -546,7 +546,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"unsigned bigint data overflow"
,
pToken
->
z
);
}
uint64_t
tmpVal
=
(
uint64_t
)
iv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_FLOAT
:
{
...
...
@@ -558,7 +558,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal float data"
,
pToken
->
z
);
}
float
tmpVal
=
(
float
)
dv
;
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
...
...
@@ -569,7 +569,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
isinf
(
dv
)
||
isnan
(
dv
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal double data"
,
pToken
->
z
);
}
return
func
(
&
dv
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
dv
,
pSchema
->
bytes
,
param
);
}
case
TSDB_DATA_TYPE_BINARY
:
{
...
...
@@ -578,11 +578,11 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"string data overflow"
,
pToken
->
z
);
}
return
func
(
pToken
->
z
,
pToken
->
n
,
param
);
return
func
(
p
MsgBuf
,
p
Token
->
z
,
pToken
->
n
,
param
);
}
case
TSDB_DATA_TYPE_NCHAR
:
{
return
func
(
pToken
->
z
,
pToken
->
n
,
param
);
return
func
(
p
MsgBuf
,
p
Token
->
z
,
pToken
->
n
,
param
);
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
...
...
@@ -591,7 +591,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid timestamp"
,
pToken
->
z
);
}
return
func
(
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
}
...
...
@@ -605,7 +605,7 @@ typedef struct SMemParam {
col_id_t
colIdx
;
}
SMemParam
;
static
FORCE_INLINE
int32_t
MemRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
static
FORCE_INLINE
int32_t
MemRowAppend
(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
SMemParam
*
pa
=
(
SMemParam
*
)
param
;
SRowBuilder
*
rb
=
pa
->
rb
;
if
(
TSDB_DATA_TYPE_BINARY
==
pa
->
schema
->
type
)
{
...
...
@@ -617,7 +617,9 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p
int32_t
output
=
0
;
const
char
*
rowEnd
=
tdRowEnd
(
rb
->
pBuf
);
if
(
!
taosMbsToUcs4
(
value
,
len
,
(
TdUcs4
*
)
varDataVal
(
rowEnd
),
pa
->
schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);
}
varDataSetLen
(
rowEnd
,
output
);
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NORM
,
rowEnd
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
...
...
@@ -714,7 +716,7 @@ typedef struct SKvParam {
char
buf
[
TSDB_MAX_TAGS_LEN
];
}
SKvParam
;
static
int32_t
KvRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
static
int32_t
KvRowAppend
(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
SKvParam
*
pa
=
(
SKvParam
*
)
param
;
int8_t
type
=
pa
->
schema
->
type
;
...
...
@@ -727,7 +729,9 @@ static int32_t KvRowAppend(const void *value, int32_t len, void *param) {
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
int32_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
value
,
len
,
(
TdUcs4
*
)
varDataVal
(
pa
->
buf
),
pa
->
schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);;
}
varDataSetLen
(
pa
->
buf
,
output
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
0b335b07
...
...
@@ -2167,7 +2167,7 @@ typedef struct SVgroupTablesBatch {
static
void
toSchema
(
const
SColumnDefNode
*
pCol
,
col_id_t
colId
,
SSchema
*
pSchema
)
{
pSchema
->
colId
=
colId
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
bytes
=
pCol
->
dataType
.
bytes
;
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
)
;
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录