Fix binary flag not compatible with MySQL
This commit is contained in:
@ -206,11 +206,32 @@ inline uint16_t ObIRawExpr::get_subschema_id() const
|
||||
|
||||
inline uint32_t ObIRawExpr::get_result_flag() const
|
||||
{
|
||||
return (result_type_.get_collation_type() == common::CS_TYPE_UTF8MB4_BIN ||
|
||||
result_type_.get_collation_type() == common::CS_TYPE_BINARY) ?
|
||||
result_type_.get_result_flag() | BINARY_FLAG :
|
||||
result_type_.get_result_flag();
|
||||
uint32_t flag = result_type_.get_result_flag();
|
||||
bool is_oracle_lob = false;
|
||||
ObObjType obj_type = result_type_.get_type();
|
||||
if (ObLongTextType == obj_type && lib::is_oracle_mode()) { // was ObLobType
|
||||
is_oracle_lob = true;
|
||||
}
|
||||
if (ObCharset::is_bin_sort(result_type_.get_collation_type())) {
|
||||
if (!is_column_ref_expr() ||
|
||||
(!ob_is_numeric_type(result_type_.get_type()) &&
|
||||
!ob_is_year_tc(result_type_.get_type()) &&
|
||||
!is_oracle_lob)) {
|
||||
flag |= BINARY_FLAG;
|
||||
}
|
||||
}
|
||||
if (is_oracle_lob) {
|
||||
flag &= (~BLOB_FLAG); // was ObLobType
|
||||
}
|
||||
if (ob_is_bit_tc(obj_type) && get_accuracy().get_precision() > 1) {
|
||||
//
|
||||
// bit(1) flags -> UNSIGNED
|
||||
// bit(2) flags -> BINARY_FLAG | UNSIGNED
|
||||
flag |= BINARY_FLAG;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
inline int ObIRawExpr::get_length_for_meta_in_bytes(common::ObLength &length) const
|
||||
{
|
||||
return result_type_.get_length_for_meta_in_bytes(length);
|
||||
|
||||
@ -42,18 +42,6 @@ int ObMySQLResultSet::to_mysql_field(const ObField &field, ObMySQLField &mfield)
|
||||
mfield.charsetnr_ = field.charsetnr_;
|
||||
mfield.flags_ = field.flags_;
|
||||
mfield.length_ = field.length_;
|
||||
// 对于Varchar类,检查charset:
|
||||
mfield.flags_ &= (~BINARY_FLAG);
|
||||
bool is_oracle_lob = false;
|
||||
if (ObLongTextType == field.type_.get_type() && lib::is_oracle_mode()) { // was ObLobType
|
||||
is_oracle_lob = true;
|
||||
}
|
||||
if (ob_is_string_type(field.type_.get_type())
|
||||
&& ObCharset::is_valid_collation(static_cast<ObCollationType>(field.charsetnr_))
|
||||
&& ObCharset::is_bin_sort(static_cast<ObCollationType>(field.charsetnr_))
|
||||
&& !is_oracle_lob) {
|
||||
mfield.flags_ |= BINARY_FLAG;
|
||||
}
|
||||
|
||||
ObScale decimals = mfield.accuracy_.get_scale();
|
||||
ObPrecision pre = mfield.accuracy_.get_precision();
|
||||
@ -63,9 +51,6 @@ int ObMySQLResultSet::to_mysql_field(const ObField &field, ObMySQLField &mfield)
|
||||
} else {
|
||||
ret = ObSMUtils::get_mysql_type(field.type_.get_type(), mfield.type_, mfield.flags_, decimals);
|
||||
}
|
||||
if (OB_SUCC(ret) && is_oracle_lob) {
|
||||
mfield.flags_ &= (~BLOB_FLAG); // was ObLobType
|
||||
}
|
||||
|
||||
mfield.type_owner_ = field.type_owner_;
|
||||
mfield.type_name_ = field.type_name_;
|
||||
@ -90,14 +75,6 @@ int ObMySQLResultSet::to_mysql_field(const ObField &field, ObMySQLField &mfield)
|
||||
ret = ObSMUtils::get_mysql_type(
|
||||
field.default_value_.get_type(), mfield.default_value_, flags, num_decimals);
|
||||
}
|
||||
if (OB_SUCC(ret)
|
||||
&& EMySQLFieldType::MYSQL_TYPE_BIT == mfield.type_
|
||||
&& 1 != mfield.accuracy_.get_precision()) {
|
||||
// bit(1) flags -> UNSIGNED
|
||||
// bit(2) flags -> BINARY_FLAG | BLOB_FLAG | UNSIGNED
|
||||
mfield.flags_ |= BINARY_FLAG;
|
||||
mfield.flags_ |= BLOB_FLAG;
|
||||
}
|
||||
if (field.is_hidden_rowid_) {
|
||||
mfield.inout_mode_ |= 0x04;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user