30 #include "eval0eval.ic"
38 static ulint eval_rnd = 128367121;
43 static byte eval_dummy;
49 que_node_get_like_node(
81 data =
static_cast<byte*
>(dfield_get_data(dfield));
83 if (data && data != &eval_dummy) {
90 data =
static_cast<byte*
>(mem_alloc(size));
118 data =
static_cast<byte*
>(dfield_get_data(dfield));
145 arg3 = que_node_get_like_node(arg2);
151 dtype = dfield_get_type(dfield);
154 op =
static_cast<ib_like_t
>(
mach_read_from_4(static_cast<const unsigned char*>(dfield_get_data(dfield))));
160 res = cmp_dfield_dfield_like_prefix(
168 res = cmp_dfield_dfield_like_suffix(
176 res = cmp_dfield_dfield_like_substr(
214 arg1 = cmp_node->
args;
217 func = cmp_node->
func;
219 if (func == PARS_LIKE_TOKEN_EXACT
220 || func == PARS_LIKE_TOKEN_PREFIX
221 || func == PARS_LIKE_TOKEN_SUFFIX
222 || func == PARS_LIKE_TOKEN_SUBSTR) {
224 val = eval_cmp_like(arg1, arg2);
233 }
else if (func ==
'<') {
237 }
else if (func == PARS_LE_TOKEN) {
241 }
else if (func == PARS_NE_TOKEN) {
245 }
else if (func == PARS_GE_TOKEN) {
258 eval_node_set_ibool_val(cmp_node, val);
280 arg1 = logical_node->
args;
289 func = logical_node->
func;
291 if (func == PARS_AND_TOKEN) {
293 }
else if (func == PARS_OR_TOKEN) {
295 }
else if (func == PARS_NOT_TOKEN) {
301 eval_node_set_ibool_val(logical_node, val);
321 arg1 = arith_node->
args;
330 func = arith_node->
func;
334 }
else if ((func ==
'-') && arg2) {
336 }
else if (func ==
'-') {
338 }
else if (func ==
'*') {
367 if (func == PARS_COUNT_TOKEN) {
371 ut_ad(func == PARS_SUM_TOKEN);
393 que_node_t* arg2 = 0;
403 arg1 = func_node->
args;
409 func = func_node->
func;
411 if (func == PARS_PRINTF_TOKEN) {
423 }
else if (func == PARS_ASSERT_TOKEN) {
426 fputs(
"SQL assertion fails in a stored procedure!\n",
435 }
else if (func == PARS_RND_TOKEN) {
443 int_val = (lint) (len1
444 + (eval_rnd % (len2 - len1 + 1)));
446 int_val = (lint) len1;
453 }
else if (func == PARS_RND_STR_TOKEN) {
457 data = eval_node_ensure_val_buf(func_node, len1);
459 for (i = 0; i < len1; i++) {
460 data[
i] = (byte)(97 + (eval_rnd % 3));
481 ut_ad(func_node->
func == PARS_NOTFOUND_TOKEN);
503 eval_node_set_ibool_val(func_node, ibool_val);
522 arg1 = func_node->
args;
525 ut_ad(func_node->
func == PARS_SUBSTR_TOKEN);
556 arg1 = func_node->
args;
600 arg1 = func_node->
args;
606 str1 =
static_cast<byte*
>(dfield_get_data(dfield1));
607 str2 =
static_cast<byte*
>(dfield_get_data(dfield2));
616 match_char = str2[0];
618 for (i = 0; i < len1; i++) {
621 if (str1[i] == match_char) {
623 if (i + len2 > len1) {
637 if (str1[i + j] != str2[j]) {
666 arg1 = func_node->
args;
670 str1 =
static_cast<byte*
>(dfield_get_data(dfield));
681 str2 = (byte*) &int_val;
683 ut_memcpy(str2 + (4 - len1), str1, len1);
703 arg = func_node->
args;
714 data = eval_node_ensure_val_buf(func_node, len);
716 arg = func_node->
args;
723 ut_memcpy(data + len, dfield_get_data(dfield), len1);
750 arg1 = func_node->
args;
792 func = func_node->
func;
794 arg1 = func_node->
args;
796 if (func == PARS_LENGTH_TOKEN) {
800 }
else if (func == PARS_TO_CHAR_TOKEN) {
817 uint_val = ((ulint) -int_val - 1) + 1;
820 uint_val = (ulint) int_val;
822 for (; uint_val > 0; int_len++) {
828 data = eval_node_ensure_val_buf(func_node, int_len + 1);
841 uint_val = ((ulint) -int_val - 1) + 1;
843 uint_val = (ulint) int_val;
845 for (tmp = int_len; uint_val > 0; uint_val /= 10) {
847 (
'0' + (byte)(uint_val % 10));
855 }
else if (func == PARS_TO_NUMBER_TOKEN) {
857 int_val = atoi((
char*)
860 }
else if (func == PARS_SYSDATE_TOKEN) {
863 eval_predefined_2(func_node);
885 fclass = func_node->
fclass;
886 func = func_node->
func;
888 arg = func_node->
args;
899 && (func != PARS_NOTFOUND_TOKEN)
900 && (func != PARS_PRINTF_TOKEN)) {
919 case PARS_NOTFOUND_TOKEN:
922 case PARS_SUBSTR_TOKEN:
925 case PARS_REPLSTR_TOKEN:
926 eval_replstr(func_node);
928 case PARS_INSTR_TOKEN:
929 eval_instr(func_node);
931 case PARS_BINARY_TO_NUMBER_TOKEN:
934 case PARS_CONCAT_TOKEN:
935 eval_concat(func_node);
937 case PARS_TO_BINARY_TOKEN: