33
33
#include <drizzled/item/int_with_ref.h>
34
34
#include <drizzled/item/subselect.h>
35
35
#include <drizzled/session.h>
36
#include <drizzled/sql_lex.h>
36
37
#include <drizzled/sql_select.h>
38
#include <drizzled/system_variables.h>
37
39
#include <drizzled/temporal.h>
38
40
#include <drizzled/time_functions.h>
39
#include <drizzled/sql_lex.h>
42
43
#include <algorithm>
44
45
using namespace std;
49
49
extern const double log_10[309];
717
get_date_from_str(Session *session, String *str, type::timestamp_t warn_type,
718
char *warn_name, bool *error_arg)
718
get_date_from_str(Session *session, String *str, type::timestamp_t warn_type, const char *warn_name, bool *error_arg)
720
720
int64_t value= 0;
721
721
type::cut_t error= type::VALID;
744
744
if (error != type::VALID)
746
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
747
str->ptr(), str->length(),
748
warn_type, warn_name);
746
make_truncated_value_warning(*session, DRIZZLE_ERROR::WARN_LEVEL_WARN, *str, warn_type, warn_name);
2379
Item_func_if::fix_length_and_dec()
2374
void Item_func_if::fix_length_and_dec()
2381
2376
maybe_null= args[1]->maybe_null || args[2]->maybe_null;
2382
2377
decimals= max(args[1]->decimals, args[2]->decimals);
2404
agg_result_type(&cached_result_type, args+1, 2);
2399
agg_result_type(&cached_result_type, args +1, 2);
2405
2400
if (cached_result_type == STRING_RESULT)
2407
if (agg_arg_charsets(collation, args+1, 2, MY_COLL_ALLOW_CONV, 1))
2402
if (agg_arg_charsets(collation, args +1, 2, MY_COLL_ALLOW_CONV, 1))
2412
2407
collation.set(&my_charset_bin); // Number
2414
cached_field_type= agg_field_type(args + 1, 2);
2409
cached_field_type= agg_field_type(args +1, 2);
2417
if ((cached_result_type == DECIMAL_RESULT )
2418
|| (cached_result_type == INT_RESULT))
2412
switch (cached_result_type)
2420
int len1= args[1]->max_length - args[1]->decimals
2421
- (args[1]->unsigned_flag ? 0 : 1);
2423
int len2= args[2]->max_length - args[2]->decimals
2424
- (args[2]->unsigned_flag ? 0 : 1);
2426
max_length= max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
2414
case DECIMAL_RESULT:
2417
int len1= args[1]->max_length -args[1]->decimals -(args[1]->unsigned_flag ? 0 : 1);
2418
int len2= args[2]->max_length -args[2]->decimals -(args[2]->unsigned_flag ? 0 : 1);
2419
max_length= max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
2429
2424
max_length= max(args[1]->max_length, args[2]->max_length);
2454
2455
assert(fixed == 1);
2455
2456
Item *arg= args[0]->val_bool() ? args[1] : args[2];
2456
int64_t value=arg->val_int();
2457
null_value=arg->null_value;
2457
int64_t value= arg->val_int();
2458
null_value= arg->null_value;
2464
2465
assert(fixed == 1);
2465
2466
Item *arg= args[0]->val_bool() ? args[1] : args[2];
2466
String *res=arg->val_str(str);
2467
String *res= arg->val_str(str);
2468
2470
res->set_charset(collation.collation);
2469
null_value=arg->null_value;
2472
null_value= arg->null_value;
3127
3130
return (int) ((*compare)(collation, base+start*size, result) == 0);
3130
in_string::in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs)
3133
in_string::in_string(uint32_t elements,qsort2_cmp cmp_func, const charset_info_st * const cs)
3131
3134
:in_vector(elements, sizeof(String), cmp_func, cs),
3132
3135
tmp(buff, sizeof(buff), &my_charset_bin)
3572
static int srtcmp_in(const CHARSET_INFO * const cs, const String *x,const String *y)
3574
static int srtcmp_in(const charset_info_st * const cs, const String *x,const String *y)
3574
3576
return cs->coll->strnncollsp(cs,
3575
3577
(unsigned char *) x->ptr(),x->length(),
4291
4289
if (a == *org_item)
4293
4291
Item_cond *res;
4294
if ((res= new Item_cond_and(a, (Item*) b)))
4296
res->used_tables_cache= a->used_tables() | b->used_tables();
4297
res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables();
4292
res= new Item_cond_and(a, (Item*) b);
4293
res->used_tables_cache= a->used_tables() | b->used_tables();
4294
res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables();
4301
if (((Item_cond_and*) a)->add((Item*) b))
4297
((Item_cond_and*) a)->add((Item*) b);
4303
4298
((Item_cond_and*) a)->used_tables_cache|= b->used_tables();
4304
4299
((Item_cond_and*) a)->not_null_tables_cache|= b->not_null_tables();
4393
4388
return my_wildcmp(cmp.cmp_collation.collation,
4394
4389
res->ptr(),res->ptr()+res->length(),
4395
4390
res2->ptr(),res2->ptr()+res2->length(),
4396
make_escape_code(cmp.cmp_collation.collation, escape),
4397
internal::wild_one,internal::wild_many) ? 0 : 1;
4391
make_escape_code(cmp.cmp_collation.collation, escape), internal::wild_one,internal::wild_many) ? 0 : 1;
4454
4448
We could also do boyer-more for non-const items, but as we would have to
4455
4449
recompute the tables for each row it's not worth it.
4457
if (args[1]->const_item() && !use_strnxfrm(collation.collation))
4451
if (args[1]->const_item() && not collation.collation->use_strnxfrm())
4459
4453
String* res2 = args[1]->val_str(&tmp_value2);
4486
4480
pattern = first + 1;
4487
4481
pattern_len = (int) len - 2;
4488
int *suff = (int*) session->getMemRoot()->allocate((int) (sizeof(int)*
4489
((pattern_len + 1)*2+
4482
int *suff = (int*) session->mem.alloc(sizeof(int) * ((pattern_len + 1)*2+ alphabet_size));
4491
4483
bmGs = suff + pattern_len + 1;
4492
4484
bmBc = bmGs + pattern_len + 1;
4493
4485
turboBM_compute_good_suffix_shifts(suff);
4621
4613
int *end = bmBc + alphabet_size;
4623
4615
const int plm1 = pattern_len - 1;
4624
const CHARSET_INFO *const cs= cmp.cmp_collation.collation;
4616
const charset_info_st *const cs= cmp.cmp_collation.collation;
4626
4618
for (i = bmBc; i < end; i++)
4627
4619
*i = pattern_len;
5183
5175
void Item_equal::print(String *str)
5185
str->append(func_name());
5177
str->append(func_name(), strlen(func_name()));
5186
5178
str->append('(');
5187
5179
List<Item_field>::iterator it(fields.begin());