Commit e17fc729 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-15564: Fix bool/ibool type mismatch

dtype_is_string_type(), dtype_is_binary_string_type(),
dtype_is_non_binary_string_type(): Define as inline functions that
return bool, not ibool.
parent 10c05d4a
......@@ -79,67 +79,6 @@ dtype_get_at_most_n_mbchars(
return(data_len);
}
/*********************************************************************//**
Checks if a data main type is a string type. Also a BLOB is considered a
string type.
@return TRUE if string type */
ibool
dtype_is_string_type(
/*=================*/
ulint mtype) /*!< in: InnoDB main data type code: DATA_CHAR, ... */
{
if (mtype <= DATA_BLOB
|| mtype == DATA_MYSQL
|| mtype == DATA_VARMYSQL) {
return(TRUE);
}
return(FALSE);
}
/*********************************************************************//**
Checks if a type is a binary string type. Note that for tables created with
< 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For
those DATA_BLOB columns this function currently returns FALSE.
@return TRUE if binary string type */
ibool
dtype_is_binary_string_type(
/*========================*/
ulint mtype, /*!< in: main data type */
ulint prtype) /*!< in: precise type */
{
if ((mtype == DATA_FIXBINARY)
|| (mtype == DATA_BINARY)
|| (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) {
return(TRUE);
}
return(FALSE);
}
/*********************************************************************//**
Checks if a type is a non-binary string type. That is, dtype_is_string_type is
TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created
with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column.
For those DATA_BLOB columns this function currently returns TRUE.
@return TRUE if non-binary string type */
ibool
dtype_is_non_binary_string_type(
/*============================*/
ulint mtype, /*!< in: main data type */
ulint prtype) /*!< in: precise type */
{
if (dtype_is_string_type(mtype) == TRUE
&& dtype_is_binary_string_type(mtype, prtype) == FALSE) {
return(TRUE);
}
return(FALSE);
}
/*********************************************************************//**
Validates a data type structure.
@return TRUE if ok */
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -262,35 +262,31 @@ dtype_get_at_most_n_mbchars(
ulint data_len, /*!< in: length of str (in bytes) */
const char* str); /*!< in: the string whose prefix
length is being determined */
/*********************************************************************//**
Checks if a data main type is a string type. Also a BLOB is considered a
string type.
@return TRUE if string type */
ibool
dtype_is_string_type(
/*=================*/
ulint mtype); /*!< in: InnoDB main data type code: DATA_CHAR, ... */
/*********************************************************************//**
Checks if a type is a binary string type. Note that for tables created with
< 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For
those DATA_BLOB columns this function currently returns FALSE.
@return TRUE if binary string type */
ibool
dtype_is_binary_string_type(
/*========================*/
ulint mtype, /*!< in: main data type */
ulint prtype);/*!< in: precise type */
/*********************************************************************//**
Checks if a type is a non-binary string type. That is, dtype_is_string_type is
TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created
with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column.
For those DATA_BLOB columns this function currently returns TRUE.
@return TRUE if non-binary string type */
ibool
dtype_is_non_binary_string_type(
/*============================*/
ulint mtype, /*!< in: main data type */
ulint prtype);/*!< in: precise type */
/** @return whether main type is a string type */
inline bool dtype_is_string_type(ulint mtype)
{
return mtype <= DATA_BLOB
|| mtype == DATA_MYSQL || mtype == DATA_VARMYSQL;
}
/** @return whether a type is a binary string type */
inline bool dtype_is_binary_string_type(ulint mtype, ulint prtype)
{
/* Note that for tables created before MySQL 4.0.14,
we do not know if a DATA_BLOB column is a BLOB or a TEXT column.
For those DATA_BLOB columns we return false. */
return mtype == DATA_FIXBINARY || mtype == DATA_BINARY
|| (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE));
}
/** @return whether a type is a non-binary string type */
inline bool dtype_is_non_binary_string_type(ulint mtype, ulint prtype)
{
return dtype_is_string_type(mtype)
&& !dtype_is_binary_string_type(mtype, prtype);
}
/*********************************************************************//**
Sets a data type structure. */
UNIV_INLINE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment