Commit 095630bf authored by marko's avatar marko

branches/zip: Relax the string type check of some built-in functions

of the InnoDB SQL parser.

pars_is_string_type(): New function.  Returns TRUE iff mtype equals
DATA_VARCHAR, DATA_CHAR, DATA_FIXBINARY, or DATA_BINARY.

pars_resolve_func_data_type(): Replace checks for DATA_VARCHAR with
pars_is_string_type().  For example, the NAME column of SYS_INDEXES,
SYS_TABLES, and SYS_COLUMNS is of DATA_BINARY type, although it
contains a UTF-8 character string.  This affects the functions
TO_NUMBER, BINARY_TO_NUMBER, LENGTH, INSTR, and SUBSTR.
parent 666c6377
......@@ -217,6 +217,25 @@ pars_order_by(
return(node);
}
/*************************************************************************
Determine if a data type is a built-in string data type of the InnoDB
SQL parser. */
static
ibool
pars_is_string_type(
/*================*/
/* out: TRUE if string data type */
ulint mtype) /* in: main data type */
{
switch (mtype) {
case DATA_VARCHAR: case DATA_CHAR:
case DATA_FIXBINARY: case DATA_BINARY:
return(TRUE);
}
return(FALSE);
}
/*************************************************************************
Resolves the data type of a function in an expression. The argument data
types must already be resolved. */
......@@ -271,8 +290,7 @@ pars_resolve_func_data_type(
case PARS_BINARY_TO_NUMBER_TOKEN:
case PARS_LENGTH_TOKEN:
case PARS_INSTR_TOKEN:
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
ut_a(pars_is_string_type(que_node_get_data_type(arg)->mtype));
dtype_set(que_node_get_data_type(node), DATA_INT, 0, 4);
break;
......@@ -283,8 +301,7 @@ pars_resolve_func_data_type(
case PARS_SUBSTR_TOKEN:
case PARS_CONCAT_TOKEN:
ut_a(dtype_get_mtype(que_node_get_data_type(arg))
== DATA_VARCHAR);
ut_a(pars_is_string_type(que_node_get_data_type(arg)->mtype));
dtype_set(que_node_get_data_type(node), DATA_VARCHAR,
DATA_ENGLISH, 0);
break;
......
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