-
Yuchen Pei authored
During spider query construction of certain cast functions, it locates the last occurrence of a keyword in the output of the Item::print() function and append from there to the constructed query so far. For example, consider the following query SELECT * FROM t2 ORDER BY CAST(c AS INET6); It constructs the following query and executes it at the data node (assuming the data node table is called t0). select cast(t0.`c` as inet6) ``,t0.`c` `c` from `test`.`t1` t0 order by `` When the construction has completed the initial part select cast(t0.`c` It then attempts to construct the " as inet6" part. To that end, it calls print() on the Item_typecast_fbt corresponding to the cast item, and obtains cast(`test`.`t2`.`c` as inet6) It then looks for " as ", and places cursor there for appending: cast(`test`.`t2`.`c` as inet6) ^ In this patch, if the search fails, i.e. there's no " as ...", we make sure that the cursor is not placed before the beginning of the string (out of bound). We also relax the search from " as char" to " as " in the case of CHAR_TYPECAST_FUNC, since there is more than one Item type with this func type. For example, "AS INET6" is an Item_typecast_fbt which has this func type.
454b8106