Add new type default string length

This commit is contained in:
br0
2021-11-02 14:31:00 +08:00
committed by LINxiansheng
parent 22d5eee21f
commit 0121cc45a8
2 changed files with 43 additions and 4 deletions

View File

@ -13,13 +13,14 @@
#ifndef _OB_EXPR_CAST_H_
#define _OB_EXPR_CAST_H_
#include "common/object/ob_obj_type.h"
#include "sql/engine/expr/ob_expr_operator.h"
namespace oceanbase {
namespace sql {
// TODO::only support 26??
static const int32_t CAST_STRING_DEFUALT_LENGTH[26] = {
// The length of array need to be equal to the number of types defined at ObObjType
static const int32_t CAST_STRING_DEFUALT_LENGTH[48] = {
0, // null
4, // tinyint
6, // smallint
@ -45,9 +46,34 @@ static const int32_t CAST_STRING_DEFUALT_LENGTH[26] = {
1, // varchar
1, // char
1, // binary
0 // extend
0, // extend
0, // unknown
1, // tinytext text share default length with varchar
1, // text
1, // mediumtext
1, // longtext
64, // bit
1, // enum
1, // set
1, // enuminner
1, // setinner
25, // timestampTZ timestamp + time zone('+00:00')
25, // timestampLTZ
19, // timestampNano timestamp + nanosecond scale
1, // raw
7, // intervalYM yyyy-mm
19, // intervalDS ddd hh:mm:ss.fractionsecond(6)
12, // numberfloat same with float
1, // nvarchar2 share default length with varchar
1, // nchar share default length with char
1, // urowid
1, // lob
0 // max, invalid type, or count of obj type
};
static_assert(common::ObMaxType + 1 == sizeof(CAST_STRING_DEFUALT_LENGTH) / sizeof(int32_t),
"Please keep the length of CAST_STRING_DEFUALT_LENGTH must equal to the number of types");
class ObExprCast : public ObFuncExprOperator {
OB_UNIS_VERSION_V(1);
const static int32_t OB_LITERAL_MAX_INT_LEN = 21;