在看到ob的底层数据类型实现时,有点懵了,在ObObjType
中定义了以下类型:
enum ObObjType
{
ObNullType = 0, // 空类型
ObTinyIntType = 1, // int8, aka mysql boolean type
ObSmallIntType = 2, // int16
ObMediumIntType = 3, // int24
ObInt32Type = 4, // int32
ObIntType = 5, // int64, aka bigint
ObUTinyIntType = 6, // uint8
ObUSmallIntType = 7, // uint16
ObUMediumIntType = 8, // uint24
ObUInt32Type = 9, // uint32
ObUInt64Type = 10, // uint64
ObFloatType = 11, // single-precision floating point
ObDoubleType = 12, // double-precision floating point
ObUFloatType = 13, // unsigned single-precision floating point
ObUDoubleType = 14, // unsigned double-precision floating point
ObNumberType = 15, // aka decimal/numeric
ObUNumberType = 16,
ObDateTimeType = 17,
ObTimestampType = 18,
ObDateType = 19,
ObTimeType = 20,
ObYearType = 21,
ObVarcharType = 22, // charset: utf8mb4 or binary
ObCharType = 23, // charset: utf8mb4 or binary
ObHexStringType = 24, // hexadecimal literal, e.g. X’42’, 0x42, b’1001’, 0b1001
ObExtendType = 25, // Min, Max, NOP etc.
ObUnknownType = 26, // For question mark(?) in prepared statement, no need to serialize
// @note future new types to be defined here !!!
ObTinyTextType = 27,
ObTextType = 28,
ObMediumTextType = 29,
ObLongTextType = 30,
ObBitType = 31,
ObEnumType = 32,
ObSetType = 33,
ObEnumInnerType = 34,
ObSetInnerType = 35,
ObTimestampTZType = 36, // timestamp with time zone for oracle
ObTimestampLTZType = 37, // timestamp with local time zone for oracle
ObTimestampNanoType = 38, // timestamp nanosecond for oracle
ObRawType = 39, // raw type for oracle
ObIntervalYMType = 40, // interval year to month
ObIntervalDSType = 41, // interval day to second
ObNumberFloatType = 42, // oracle float, subtype of NUMBER
ObNVarchar2Type = 43, // nvarchar2
ObNCharType = 44, // nchar
ObURowIDType = 45, // UROWID
ObLobType = 46, // Oracle Lob
ObJsonType = 47, // Json Type
ObGeometryType = 48, // Geometry type
ObUserDefinedSQLType = 49, // User defined type in SQL
ObMaxType // invalid type, or count of obj type
};
然后又在ObObjOType
中定义了以下类型:
//Oracle type
enum ObObjOType
{
ObONotSupport = 0,
ObONullType = 1, // 空类型
ObOSmallIntType = 2,
ObOIntType = 3,
ObONumberFloatType = 4, //float
ObOBinFloatType = 5, //binary float
ObOBinDoubleType = 6, //binary double
ObONumberType = 7,
ObOCharType = 8,
ObOVarcharType = 9,
ObODateType = 10,
ObOTimestampTZType = 11, //timestamp with time zone
ObOTimestampLTZType = 12, //timestamp with local time zone
ObOTimestampType = 13, //timestamp
ObOIntervalYMType = 14, //TODO
ObOIntervalDSType = 15, //TODO
ObOLobType = 16, //blob
ObOExtendType = 17, //not sure
ObOUnknownType = 18, //not sure
ObORawType = 19,
ObONVarchar2Type = 20,
ObONCharType = 21,
ObOURowIDType = 22,
ObOLobLocatorType = 23,
ObOJsonType = 24,
ObOGeometryType = 25,
ObOUDTSqlType = 26,
ObOMaxType //invalid type, or count of ObObjOType
};
ob是兼容mysql和oracle的所以这些数据类型也是为了兼容mysql和oracle,令我疑惑的是在ObObjType
中含有相关的时间+时区的类型,例如:
ObTimestampTZType = 36, // timestamp with time zone for oracle
ObTimestampLTZType = 37, // timestamp with local time zone for oracle
ObTimestampNanoType = 38, // timestamp nanosecond for oracle
在ObObjOType
也含有相关的时间+时区的类型,例如:
ObOTimestampTZType = 11, //timestamp with time zone
ObOTimestampLTZType = 12, //timestamp with local time zone
通过查阅资料,猜测时间带时区的类型是为了兼容oracle的timestamp with time zone
以及timestamp with local time zone
这两种数据类型。既然这样,为什么这种类型多次定义了啊?难道是因为之前考虑把兼容mysql的类型和oracle都实现在ObObjType
中,后来发现有点混乱,有单独把oracle的数据类型提出来,但是由于历史的原因改动ObObjType的代价过高,索性也就放那先不管了?
小弟才疏学浅,勿喷,求大神解答。