fix json/gis/text/blob meta response inconsistent with mysql5.7 (master)
This commit is contained in:
parent
6267ac92d9
commit
4f162cdcc5
6
deps/oblib/src/common/ob_field.cpp
vendored
6
deps/oblib/src/common/ob_field.cpp
vendored
@ -359,7 +359,11 @@ int ObField::get_field_mb_length(const ObObjType type,
|
||||
if (OB_FAIL(common::ObCharset::get_mbmaxlen_by_coll(charsetnr, mbmaxlen))) {
|
||||
LOG_WARN("fail to get mbmaxlen", K(charsetnr), K(ret));
|
||||
} else {
|
||||
if (lib::is_mysql_mode() && tc == ObTextTC) {
|
||||
if (lib::is_mysql_mode() && (type == ObLongTextType || type == ObJsonType || type == ObGeometryType)) {
|
||||
// issue: 52728955, 52735855, 52731784, 52734963, 52729976
|
||||
// compat mysql .net driver 5.7, longblob, json, gis length is max u32
|
||||
length = UINT32_MAX;
|
||||
} else if (lib::is_mysql_mode() && tc == ObTextTC) {
|
||||
// compat mysql-jdbc 8.x for judge text type by length
|
||||
length = static_cast<uint32_t>(ObAccuracy::MAX_ACCURACY[type].get_length() - 1);
|
||||
} else {
|
||||
|
@ -85,8 +85,8 @@ static const ObMySQLTypeMap type_maps_[ObMaxType] =
|
||||
{EMySQLFieldType::MYSQL_TYPE_OB_NCHAR, 0, 0}, /* ObNCharType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_OB_UROWID, 0, 0},
|
||||
{EMySQLFieldType::MYSQL_TYPE_ORA_BLOB, 0, 0}, /* ObLobType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_JSON, BLOB_FLAG | NO_DEFAULT_VALUE_FLAG, 0}, /* ObJsonType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_GEOMETRY, BLOB_FLAG | NO_DEFAULT_VALUE_FLAG, 0}, /* ObGeometryType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_JSON, BLOB_FLAG | BINARY_FLAG, 0}, /* ObJsonType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_GEOMETRY, BLOB_FLAG | BINARY_FLAG, 0}, /* ObGeometryType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_COMPLEX, 0, 0}, /* ObUserDefinedSQLType */
|
||||
{EMySQLFieldType::MYSQL_TYPE_NEWDECIMAL, 0, 0}, /* ObDecimalIntType */
|
||||
/* ObMaxType */
|
||||
|
@ -1724,6 +1724,9 @@ void ObResultSet::replace_lob_type(const ObSQLSessionInfo &session,
|
||||
// for 5.x, always return MYSQL_TYPE_BLOB
|
||||
// for 8.x always return MYSQL_TYPE_BLOB, and do text type judge in mysql-jdbc by length
|
||||
mfield.type_ = obmysql::EMySQLFieldType::MYSQL_TYPE_BLOB;
|
||||
} else if (mfield.type_ == obmysql::EMySQLFieldType::MYSQL_TYPE_JSON) {
|
||||
// for mysql 5.x json response as plain text not binary, but the charset always binary
|
||||
mfield.charsetnr_ = common::CS_TYPE_BINARY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ def substr(v,1) 253 512 0 Y 0 0 45
|
||||
##cast test
|
||||
select substr(cast(date_c as char(1024)), 0) from build_in_func_test_table;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def substr(cast(date_c as char(1024)), 0) 252 536870910 0 Y 16 0 45
|
||||
def substr(cast(date_c as char(1024)), 0) 252 4294967295 0 Y 16 0 45
|
||||
+---------------------------------------+
|
||||
| substr(cast(date_c as char(1024)), 0) |
|
||||
+---------------------------------------+
|
||||
@ -273,7 +273,7 @@ def substr(cast(date_c as char(1024)), 0) 252 536870910 0 Y 16 0 45
|
||||
+---------------------------------------+
|
||||
select substr(cast(date_c as char(1024)), 10) from build_in_func_test_table;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def substr(cast(date_c as char(1024)), 10) 252 536870910 17 Y 16 0 45
|
||||
def substr(cast(date_c as char(1024)), 10) 252 4294967295 17 Y 16 0 45
|
||||
+----------------------------------------+
|
||||
| substr(cast(date_c as char(1024)), 10) |
|
||||
+----------------------------------------+
|
||||
@ -289,7 +289,7 @@ def substr(cast(1024 as char(1024)), 1, 2) 253 8 2 Y 0 0 45
|
||||
+----------------------------------------+
|
||||
select substr(cast(date_c as char(1024)) from 10) from build_in_func_test_table;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def substr(cast(date_c as char(1024)) from 10) 252 536870910 17 Y 16 0 45
|
||||
def substr(cast(date_c as char(1024)) from 10) 252 4294967295 17 Y 16 0 45
|
||||
+--------------------------------------------+
|
||||
| substr(cast(date_c as char(1024)) from 10) |
|
||||
+--------------------------------------------+
|
||||
@ -2771,7 +2771,7 @@ def unhex('123') 253 2 2 Y 128 0 63
|
||||
+--------------+
|
||||
select unhex(cast(repeat('123',5) as char(1024)));
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def unhex(cast(repeat('123',5) as char(1024))) 252 536870910 8 Y 144 0 63
|
||||
def unhex(cast(repeat('123',5) as char(1024))) 252 4294967295 8 Y 144 0 63
|
||||
+--------------------------------------------+
|
||||
| unhex(cast(repeat('123',5) as char(1024))) |
|
||||
+--------------------------------------------+
|
||||
|
Loading…
x
Reference in New Issue
Block a user