@@ -4181,88 +4181,18 @@ int spider_db_mbase_util::open_item_func(
4181
4181
) {
4182
4182
/* no action */
4183
4183
break ;
4184
- } else if (func_name_length == 4 )
4185
- {
4186
- if (
4187
- !strncasecmp (" rand" , func_name, func_name_length) &&
4184
+ } else if (func_name_length == 4 &&
4185
+ !strncasecmp (" rand" , func_name, func_name_length) &&
4188
4186
#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED
4189
- !item_func->argument_count ()
4190
- #else
4191
- !item_func->arg_count
4192
- #endif
4193
- ) {
4194
- if (str)
4195
- str->length (str->length () - SPIDER_SQL_OPEN_PAREN_LEN);
4196
- DBUG_RETURN (spider_db_open_item_int (item_func, NULL , spider, str,
4197
- alias, alias_length, dbton_id, use_fields, fields));
4198
- } else if (
4199
- !strncasecmp (" case" , func_name, func_name_length)
4200
- ) {
4201
- #ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC
4202
- Item_func_case *item_func_case = (Item_func_case *) item_func;
4203
- if (str)
4204
- {
4205
- if (str->reserve (SPIDER_SQL_CASE_LEN))
4206
- DBUG_RETURN (HA_ERR_OUT_OF_MEM);
4207
- str->q_append (SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN);
4208
- }
4209
- if (item_func_case->first_expr_num != -1 )
4210
- {
4211
- if ((error_num = spider_db_print_item_type (
4212
- item_list[item_func_case->first_expr_num ], NULL , spider, str,
4213
- alias, alias_length, dbton_id, use_fields, fields)))
4214
- DBUG_RETURN (error_num);
4215
- }
4216
- for (roop_count = 0 ; roop_count < item_func_case->ncases ;
4217
- roop_count += 2 )
4218
- {
4219
- if (str)
4220
- {
4221
- if (str->reserve (SPIDER_SQL_WHEN_LEN))
4222
- DBUG_RETURN (HA_ERR_OUT_OF_MEM);
4223
- str->q_append (SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN);
4224
- }
4225
- if ((error_num = spider_db_print_item_type (
4226
- item_list[roop_count], NULL , spider, str,
4227
- alias, alias_length, dbton_id, use_fields, fields)))
4228
- DBUG_RETURN (error_num);
4229
- if (str)
4230
- {
4231
- if (str->reserve (SPIDER_SQL_THEN_LEN))
4232
- DBUG_RETURN (HA_ERR_OUT_OF_MEM);
4233
- str->q_append (SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN);
4234
- }
4235
- if ((error_num = spider_db_print_item_type (
4236
- item_list[roop_count + 1 ], NULL , spider, str,
4237
- alias, alias_length, dbton_id, use_fields, fields)))
4238
- DBUG_RETURN (error_num);
4239
- }
4240
- if (item_func_case->else_expr_num != -1 )
4241
- {
4242
- if (str)
4243
- {
4244
- if (str->reserve (SPIDER_SQL_ELSE_LEN))
4245
- DBUG_RETURN (HA_ERR_OUT_OF_MEM);
4246
- str->q_append (SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN);
4247
- }
4248
- if ((error_num = spider_db_print_item_type (
4249
- item_list[item_func_case->else_expr_num ], NULL , spider, str,
4250
- alias, alias_length, dbton_id, use_fields, fields)))
4251
- DBUG_RETURN (error_num);
4252
- }
4253
- if (str)
4254
- {
4255
- if (str->reserve (SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
4256
- DBUG_RETURN (HA_ERR_OUT_OF_MEM);
4257
- str->q_append (SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN);
4258
- str->q_append (SPIDER_SQL_CLOSE_PAREN_STR,
4259
- SPIDER_SQL_CLOSE_PAREN_LEN);
4260
- }
4261
- DBUG_RETURN (0 );
4187
+ !item_func->argument_count ()
4262
4188
#else
4263
- DBUG_RETURN (ER_SPIDER_COND_SKIP_NUM);
4189
+ !item_func-> arg_count
4264
4190
#endif
4265
- }
4191
+ ) {
4192
+ if (str)
4193
+ str->length (str->length () - SPIDER_SQL_OPEN_PAREN_LEN);
4194
+ DBUG_RETURN (spider_db_open_item_int (item_func, NULL , spider, str,
4195
+ alias, alias_length, dbton_id, use_fields, fields));
4266
4196
} else if (func_name_length == 6 &&
4267
4197
!strncasecmp (" istrue" , func_name, func_name_length)
4268
4198
) {
@@ -5088,6 +5018,72 @@ int spider_db_mbase_util::open_item_func(
5088
5018
}
5089
5019
}
5090
5020
break ;
5021
+ case Item_func::CASE_SEARCHED_FUNC:
5022
+ case Item_func::CASE_SIMPLE_FUNC:
5023
+ #ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC
5024
+ Item_func_case *item_func_case = (Item_func_case *) item_func;
5025
+ if (str)
5026
+ {
5027
+ if (str->reserve (SPIDER_SQL_CASE_LEN))
5028
+ DBUG_RETURN (HA_ERR_OUT_OF_MEM);
5029
+ str->q_append (SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN);
5030
+ }
5031
+ if (item_func_case->first_expr_num != -1 )
5032
+ {
5033
+ if ((error_num = spider_db_print_item_type (
5034
+ item_list[item_func_case->first_expr_num ], NULL , spider, str,
5035
+ alias, alias_length, dbton_id, use_fields, fields)))
5036
+ DBUG_RETURN (error_num);
5037
+ }
5038
+ for (roop_count = 0 ; roop_count < item_func_case->ncases ;
5039
+ roop_count += 2 )
5040
+ {
5041
+ if (str)
5042
+ {
5043
+ if (str->reserve (SPIDER_SQL_WHEN_LEN))
5044
+ DBUG_RETURN (HA_ERR_OUT_OF_MEM);
5045
+ str->q_append (SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN);
5046
+ }
5047
+ if ((error_num = spider_db_print_item_type (
5048
+ item_list[roop_count], NULL , spider, str,
5049
+ alias, alias_length, dbton_id, use_fields, fields)))
5050
+ DBUG_RETURN (error_num);
5051
+ if (str)
5052
+ {
5053
+ if (str->reserve (SPIDER_SQL_THEN_LEN))
5054
+ DBUG_RETURN (HA_ERR_OUT_OF_MEM);
5055
+ str->q_append (SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN);
5056
+ }
5057
+ if ((error_num = spider_db_print_item_type (
5058
+ item_list[roop_count + 1 ], NULL , spider, str,
5059
+ alias, alias_length, dbton_id, use_fields, fields)))
5060
+ DBUG_RETURN (error_num);
5061
+ }
5062
+ if (item_func_case->else_expr_num != -1 )
5063
+ {
5064
+ if (str)
5065
+ {
5066
+ if (str->reserve (SPIDER_SQL_ELSE_LEN))
5067
+ DBUG_RETURN (HA_ERR_OUT_OF_MEM);
5068
+ str->q_append (SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN);
5069
+ }
5070
+ if ((error_num = spider_db_print_item_type (
5071
+ item_list[item_func_case->else_expr_num ], NULL , spider, str,
5072
+ alias, alias_length, dbton_id, use_fields, fields)))
5073
+ DBUG_RETURN (error_num);
5074
+ }
5075
+ if (str)
5076
+ {
5077
+ if (str->reserve (SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
5078
+ DBUG_RETURN (HA_ERR_OUT_OF_MEM);
5079
+ str->q_append (SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN);
5080
+ str->q_append (SPIDER_SQL_CLOSE_PAREN_STR,
5081
+ SPIDER_SQL_CLOSE_PAREN_LEN);
5082
+ }
5083
+ DBUG_RETURN (0 );
5084
+ #else
5085
+ DBUG_RETURN (ER_SPIDER_COND_SKIP_NUM);
5086
+ #endif
5091
5087
default :
5092
5088
THD *thd = spider->trx ->thd ;
5093
5089
SPIDER_SHARE *share = spider->share ;
0 commit comments