~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/item_timefunc.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-11-08 11:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20111108113113-3ulw01fvi4vn8m25
Tags: upstream-5.5.17
ImportĀ upstreamĀ versionĀ 5.5.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef ITEM_TIMEFUNC_INCLUDED
 
2
#define ITEM_TIMEFUNC_INCLUDED
 
3
 
 
4
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
5
 
 
6
   This program is free software; you can redistribute it and/or modify
 
7
   it under the terms of the GNU General Public License as published by
 
8
   the Free Software Foundation; version 2 of the License.
 
9
 
 
10
   This program is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
   GNU General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU General Public License
 
16
   along with this program; if not, write to the Free Software
 
17
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
18
 
 
19
 
 
20
/* Function items used by mysql */
 
21
 
 
22
#ifdef USE_PRAGMA_INTERFACE
 
23
#pragma interface                       /* gcc class implementation */
 
24
#endif
 
25
 
 
26
class MY_LOCALE;
 
27
 
 
28
enum date_time_format_types 
 
29
 
30
  TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
 
31
};
 
32
 
 
33
bool get_interval_value(Item *args,interval_type int_type,
 
34
                               String *str_value, INTERVAL *interval);
 
35
 
 
36
class Item_func_period_add :public Item_int_func
 
37
{
 
38
public:
 
39
  Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {}
 
40
  longlong val_int();
 
41
  const char *func_name() const { return "period_add"; }
 
42
  void fix_length_and_dec() 
 
43
  { 
 
44
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
 
45
  }
 
46
};
 
47
 
 
48
 
 
49
class Item_func_period_diff :public Item_int_func
 
50
{
 
51
public:
 
52
  Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {}
 
53
  longlong val_int();
 
54
  const char *func_name() const { return "period_diff"; }
 
55
  void fix_length_and_dec()
 
56
  { 
 
57
    decimals=0;
 
58
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
 
59
  }
 
60
};
 
61
 
 
62
 
 
63
class Item_func_to_days :public Item_int_func
 
64
{
 
65
public:
 
66
  Item_func_to_days(Item *a) :Item_int_func(a) {}
 
67
  longlong val_int();
 
68
  const char *func_name() const { return "to_days"; }
 
69
  void fix_length_and_dec() 
 
70
  { 
 
71
    decimals=0; 
 
72
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
 
73
    maybe_null=1; 
 
74
  }
 
75
  enum_monotonicity_info get_monotonicity_info() const;
 
76
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
 
77
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
78
  bool check_valid_arguments_processor(uchar *int_arg)
 
79
  {
 
80
    return !has_date_args();
 
81
  }
 
82
};
 
83
 
 
84
 
 
85
class Item_func_to_seconds :public Item_int_func
 
86
{
 
87
public:
 
88
  Item_func_to_seconds(Item *a) :Item_int_func(a) {}
 
89
  longlong val_int();
 
90
  const char *func_name() const { return "to_seconds"; }
 
91
  void fix_length_and_dec() 
 
92
  { 
 
93
    decimals=0; 
 
94
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
 
95
    maybe_null=1; 
 
96
  }
 
97
  enum_monotonicity_info get_monotonicity_info() const;
 
98
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
 
99
  bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
 
100
 
 
101
  bool intro_version(uchar *int_arg)
 
102
  {
 
103
    int *input_version= (int*)int_arg;
 
104
    /* This function was introduced in 5.5 */
 
105
    int output_version= max(*input_version, 50500);
 
106
    *input_version= output_version;
 
107
    return 0;
 
108
  }
 
109
 
 
110
  /* Only meaningful with date part and optional time part */
 
111
  bool check_valid_arguments_processor(uchar *int_arg)
 
112
  {
 
113
    return !has_date_args();
 
114
  }
 
115
};
 
116
 
 
117
 
 
118
class Item_func_dayofmonth :public Item_int_func
 
119
{
 
120
public:
 
121
  Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
 
122
  longlong val_int();
 
123
  const char *func_name() const { return "dayofmonth"; }
 
124
  void fix_length_and_dec() 
 
125
  { 
 
126
    decimals=0; 
 
127
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
 
128
    maybe_null=1; 
 
129
  }
 
130
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
131
  bool check_valid_arguments_processor(uchar *int_arg)
 
132
  {
 
133
    return !has_date_args();
 
134
  }
 
135
};
 
136
 
 
137
 
 
138
class Item_func_month :public Item_func
 
139
{
 
140
public:
 
141
  Item_func_month(Item *a) :Item_func(a) { collation.set_numeric(); }
 
142
  longlong val_int();
 
143
  double val_real()
 
144
  { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
 
145
  String *val_str(String *str) 
 
146
  {
 
147
    longlong nr= val_int();
 
148
    if (null_value)
 
149
      return 0;
 
150
    str->set(nr, collation.collation);
 
151
    return str;
 
152
  }
 
153
  const char *func_name() const { return "month"; }
 
154
  enum Item_result result_type () const { return INT_RESULT; }
 
155
  void fix_length_and_dec() 
 
156
  { 
 
157
    decimals= 0;
 
158
    fix_char_length(2);
 
159
    maybe_null= 1;
 
160
  }
 
161
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
162
  bool check_valid_arguments_processor(uchar *int_arg)
 
163
  {
 
164
    return !has_date_args();
 
165
  }
 
166
};
 
167
 
 
168
 
 
169
class Item_func_monthname :public Item_str_func
 
170
{
 
171
  MY_LOCALE *locale;
 
172
public:
 
173
  Item_func_monthname(Item *a) :Item_str_func(a) {}
 
174
  const char *func_name() const { return "monthname"; }
 
175
  String *val_str(String *str);
 
176
  void fix_length_and_dec();
 
177
  bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
 
178
  bool check_valid_arguments_processor(uchar *int_arg)
 
179
  {
 
180
    return !has_date_args();
 
181
  }
 
182
};
 
183
 
 
184
 
 
185
class Item_func_dayofyear :public Item_int_func
 
186
{
 
187
public:
 
188
  Item_func_dayofyear(Item *a) :Item_int_func(a) {}
 
189
  longlong val_int();
 
190
  const char *func_name() const { return "dayofyear"; }
 
191
  void fix_length_and_dec() 
 
192
  { 
 
193
    decimals= 0;
 
194
    fix_char_length(3);
 
195
    maybe_null= 1;
 
196
  }
 
197
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
198
  bool check_valid_arguments_processor(uchar *int_arg)
 
199
  {
 
200
    return !has_date_args();
 
201
  }
 
202
};
 
203
 
 
204
 
 
205
class Item_func_hour :public Item_int_func
 
206
{
 
207
public:
 
208
  Item_func_hour(Item *a) :Item_int_func(a) {}
 
209
  longlong val_int();
 
210
  const char *func_name() const { return "hour"; }
 
211
  void fix_length_and_dec()
 
212
  {
 
213
    decimals=0;
 
214
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
 
215
    maybe_null=1;
 
216
  }
 
217
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
218
  bool check_valid_arguments_processor(uchar *int_arg)
 
219
  {
 
220
    return !has_time_args();
 
221
  }
 
222
};
 
223
 
 
224
 
 
225
class Item_func_minute :public Item_int_func
 
226
{
 
227
public:
 
228
  Item_func_minute(Item *a) :Item_int_func(a) {}
 
229
  longlong val_int();
 
230
  const char *func_name() const { return "minute"; }
 
231
  void fix_length_and_dec()
 
232
  {
 
233
    decimals=0;
 
234
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
 
235
    maybe_null=1;
 
236
  }
 
237
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
238
  bool check_valid_arguments_processor(uchar *int_arg)
 
239
  {
 
240
    return !has_time_args();
 
241
  }
 
242
};
 
243
 
 
244
 
 
245
class Item_func_quarter :public Item_int_func
 
246
{
 
247
public:
 
248
  Item_func_quarter(Item *a) :Item_int_func(a) {}
 
249
  longlong val_int();
 
250
  const char *func_name() const { return "quarter"; }
 
251
  void fix_length_and_dec()
 
252
  { 
 
253
     decimals=0;
 
254
     max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
 
255
     maybe_null=1;
 
256
  }
 
257
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
258
  bool check_valid_arguments_processor(uchar *int_arg)
 
259
  {
 
260
    return !has_date_args();
 
261
  }
 
262
};
 
263
 
 
264
 
 
265
class Item_func_second :public Item_int_func
 
266
{
 
267
public:
 
268
  Item_func_second(Item *a) :Item_int_func(a) {}
 
269
  longlong val_int();
 
270
  const char *func_name() const { return "second"; }
 
271
  void fix_length_and_dec() 
 
272
  { 
 
273
    decimals=0;
 
274
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
 
275
    maybe_null=1;
 
276
  }
 
277
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
278
  bool check_valid_arguments_processor(uchar *int_arg)
 
279
  {
 
280
    return !has_time_args();
 
281
  }
 
282
};
 
283
 
 
284
 
 
285
class Item_func_week :public Item_int_func
 
286
{
 
287
public:
 
288
  Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
 
289
  longlong val_int();
 
290
  const char *func_name() const { return "week"; }
 
291
  void fix_length_and_dec()
 
292
  { 
 
293
    decimals=0;
 
294
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
 
295
    maybe_null=1;
 
296
  }
 
297
};
 
298
 
 
299
class Item_func_yearweek :public Item_int_func
 
300
{
 
301
public:
 
302
  Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
 
303
  longlong val_int();
 
304
  const char *func_name() const { return "yearweek"; }
 
305
  void fix_length_and_dec()
 
306
  { 
 
307
    decimals=0;
 
308
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
 
309
    maybe_null=1;
 
310
  }
 
311
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
312
  bool check_valid_arguments_processor(uchar *int_arg)
 
313
  {
 
314
    return !has_date_args();
 
315
  }
 
316
};
 
317
 
 
318
 
 
319
class Item_func_year :public Item_int_func
 
320
{
 
321
public:
 
322
  Item_func_year(Item *a) :Item_int_func(a) {}
 
323
  longlong val_int();
 
324
  const char *func_name() const { return "year"; }
 
325
  enum_monotonicity_info get_monotonicity_info() const;
 
326
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
 
327
  void fix_length_and_dec()
 
328
  { 
 
329
    decimals=0;
 
330
    max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
 
331
    maybe_null=1;
 
332
  }
 
333
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
334
  bool check_valid_arguments_processor(uchar *int_arg)
 
335
  {
 
336
    return !has_date_args();
 
337
  }
 
338
};
 
339
 
 
340
 
 
341
class Item_func_weekday :public Item_func
 
342
{
 
343
  bool odbc_type;
 
344
public:
 
345
  Item_func_weekday(Item *a,bool type_arg)
 
346
    :Item_func(a), odbc_type(type_arg) { collation.set_numeric(); }
 
347
  longlong val_int();
 
348
  double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
 
349
  String *val_str(String *str)
 
350
  {
 
351
    DBUG_ASSERT(fixed == 1);
 
352
    str->set(val_int(), &my_charset_bin);
 
353
    return null_value ? 0 : str;
 
354
  }
 
355
  const char *func_name() const
 
356
  {
 
357
     return (odbc_type ? "dayofweek" : "weekday");
 
358
  }
 
359
  enum Item_result result_type () const { return INT_RESULT; }
 
360
  void fix_length_and_dec()
 
361
  {
 
362
    decimals= 0;
 
363
    fix_char_length(1);
 
364
    maybe_null= 1;
 
365
  }
 
366
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
367
  bool check_valid_arguments_processor(uchar *int_arg)
 
368
  {
 
369
    return !has_date_args();
 
370
  }
 
371
};
 
372
 
 
373
class Item_func_dayname :public Item_func_weekday
 
374
{
 
375
  MY_LOCALE *locale;
 
376
 public:
 
377
  Item_func_dayname(Item *a) :Item_func_weekday(a,0) {}
 
378
  const char *func_name() const { return "dayname"; }
 
379
  String *val_str(String *str);
 
380
  enum Item_result result_type () const { return STRING_RESULT; }
 
381
  void fix_length_and_dec();
 
382
  bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
 
383
};
 
384
 
 
385
 
 
386
class Item_func_unix_timestamp :public Item_int_func
 
387
{
 
388
  String value;
 
389
public:
 
390
  Item_func_unix_timestamp() :Item_int_func() {}
 
391
  Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
 
392
  longlong val_int();
 
393
  const char *func_name() const { return "unix_timestamp"; }
 
394
  enum_monotonicity_info get_monotonicity_info() const;
 
395
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
 
396
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
397
  /*
 
398
    UNIX_TIMESTAMP() depends on the current timezone
 
399
    (and thus may not be used as a partitioning function)
 
400
    when its argument is NOT of the TIMESTAMP type.
 
401
  */
 
402
  bool check_valid_arguments_processor(uchar *int_arg)
 
403
  {
 
404
    return !has_timestamp_args();
 
405
  }
 
406
  void fix_length_and_dec()
 
407
  {
 
408
    decimals=0;
 
409
    max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
 
410
  }
 
411
};
 
412
 
 
413
 
 
414
class Item_func_time_to_sec :public Item_int_func
 
415
{
 
416
public:
 
417
  Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
 
418
  longlong val_int();
 
419
  const char *func_name() const { return "time_to_sec"; }
 
420
  void fix_length_and_dec()
 
421
  {
 
422
    maybe_null= TRUE;
 
423
    decimals=0;
 
424
    max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
 
425
  }
 
426
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
427
  bool check_valid_arguments_processor(uchar *int_arg)
 
428
  {
 
429
    return !has_time_args();
 
430
  }
 
431
};
 
432
 
 
433
 
 
434
/*
 
435
  This can't be a Item_str_func, because the val_real() functions are special
 
436
*/
 
437
 
 
438
class Item_date :public Item_func
 
439
{
 
440
public:
 
441
  Item_date() :Item_func() {}
 
442
  Item_date(Item *a) :Item_func(a) {}
 
443
  enum Item_result result_type () const { return STRING_RESULT; }
 
444
  enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
 
445
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
446
  String *val_str(String *str);
 
447
  longlong val_int();
 
448
  double val_real() { return val_real_from_decimal(); }
 
449
  const char *func_name() const { return "date"; }
 
450
  void fix_length_and_dec()
 
451
  { 
 
452
    decimals= 0;
 
453
    fix_length_and_charset_datetime(MAX_DATE_WIDTH);
 
454
  }
 
455
  Field *tmp_table_field(TABLE *table)
 
456
  {
 
457
    return tmp_table_field_from_field_type(table, 0);
 
458
  }
 
459
  bool result_as_longlong() { return TRUE; }
 
460
  my_decimal *val_decimal(my_decimal *decimal_value)
 
461
  {
 
462
    DBUG_ASSERT(fixed == 1);
 
463
    return  val_decimal_from_date(decimal_value);
 
464
  }
 
465
  int save_in_field(Field *field, bool no_conversions)
 
466
  {
 
467
    return save_date_in_field(field);
 
468
  }
 
469
};
 
470
 
 
471
 
 
472
class Item_date_func :public Item_str_func
 
473
{
 
474
public:
 
475
  Item_date_func() :Item_str_func() {}
 
476
  Item_date_func(Item *a) :Item_str_func(a) {}
 
477
  Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
 
478
  Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
 
479
  enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
 
480
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
481
  Field *tmp_table_field(TABLE *table)
 
482
  {
 
483
    return tmp_table_field_from_field_type(table, 0);
 
484
  }
 
485
  bool result_as_longlong() { return TRUE; }
 
486
  double val_real() { return (double) val_int(); }
 
487
  my_decimal *val_decimal(my_decimal *decimal_value)
 
488
  {
 
489
    DBUG_ASSERT(fixed == 1);
 
490
    return  val_decimal_from_date(decimal_value);
 
491
  }
 
492
  int save_in_field(Field *field, bool no_conversions)
 
493
  {
 
494
    return save_date_in_field(field);
 
495
  }
 
496
};
 
497
 
 
498
 
 
499
class Item_str_timefunc :public Item_str_func
 
500
{
 
501
public:
 
502
  Item_str_timefunc() :Item_str_func() {}
 
503
  Item_str_timefunc(Item *a) :Item_str_func(a) {}
 
504
  Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
 
505
  Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
 
506
  enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
 
507
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
508
  void fix_length_and_dec()
 
509
  {
 
510
    decimals= DATETIME_DEC;
 
511
    fix_length_and_charset_datetime(MAX_TIME_WIDTH);
 
512
  }
 
513
  Field *tmp_table_field(TABLE *table)
 
514
  {
 
515
    return tmp_table_field_from_field_type(table, 0);
 
516
  }
 
517
  double val_real() { return val_real_from_decimal(); }
 
518
  my_decimal *val_decimal(my_decimal *decimal_value)
 
519
  {
 
520
    DBUG_ASSERT(fixed == 1);
 
521
    return  val_decimal_from_time(decimal_value);
 
522
  }
 
523
  int save_in_field(Field *field, bool no_conversions)
 
524
  {
 
525
    return save_time_in_field(field);
 
526
  }
 
527
  longlong val_int() { return val_int_from_decimal(); }
 
528
  bool result_as_longlong() { return TRUE; }
 
529
};
 
530
 
 
531
 
 
532
/* Abstract CURTIME function. Children should define what time zone is used */
 
533
 
 
534
class Item_func_curtime :public Item_str_timefunc
 
535
{
 
536
  longlong value;
 
537
  char buff[9*2+32];
 
538
  uint buff_length;
 
539
public:
 
540
  Item_func_curtime() :Item_str_timefunc() {}
 
541
  Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
 
542
  double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
 
543
  longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
 
544
  String *val_str(String *str);
 
545
  void fix_length_and_dec();
 
546
  /* 
 
547
    Abstract method that defines which time zone is used for conversion.
 
548
    Converts time current time in my_time_t representation to broken-down
 
549
    MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
 
550
  */
 
551
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
 
552
  bool result_as_longlong() { return TRUE; }
 
553
};
 
554
 
 
555
 
 
556
class Item_func_curtime_local :public Item_func_curtime
 
557
{
 
558
public:
 
559
  Item_func_curtime_local() :Item_func_curtime() {}
 
560
  Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
 
561
  const char *func_name() const { return "curtime"; }
 
562
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
 
563
};
 
564
 
 
565
 
 
566
class Item_func_curtime_utc :public Item_func_curtime
 
567
{
 
568
public:
 
569
  Item_func_curtime_utc() :Item_func_curtime() {}
 
570
  Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
 
571
  const char *func_name() const { return "utc_time"; }
 
572
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
 
573
};
 
574
 
 
575
 
 
576
/* Abstract CURDATE function. See also Item_func_curtime. */
 
577
 
 
578
class Item_func_curdate :public Item_date
 
579
{
 
580
  longlong value;
 
581
  MYSQL_TIME ltime;
 
582
public:
 
583
  Item_func_curdate() :Item_date() {}
 
584
  longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
 
585
  String *val_str(String *str);
 
586
  void fix_length_and_dec();
 
587
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
588
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
 
589
};
 
590
 
 
591
 
 
592
class Item_func_curdate_local :public Item_func_curdate
 
593
{
 
594
public:
 
595
  Item_func_curdate_local() :Item_func_curdate() {}
 
596
  const char *func_name() const { return "curdate"; }
 
597
  void store_now_in_TIME(MYSQL_TIME *now_time);
 
598
};
 
599
 
 
600
 
 
601
class Item_func_curdate_utc :public Item_func_curdate
 
602
{
 
603
public:
 
604
  Item_func_curdate_utc() :Item_func_curdate() {}
 
605
  const char *func_name() const { return "utc_date"; }
 
606
  void store_now_in_TIME(MYSQL_TIME *now_time);
 
607
};
 
608
 
 
609
 
 
610
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
 
611
 
 
612
class Item_func_now :public Item_date_func
 
613
{
 
614
protected:
 
615
  longlong value;
 
616
  char buff[20*2+32];   // +32 to make my_snprintf_{8bit|ucs2} happy
 
617
  uint buff_length;
 
618
  MYSQL_TIME ltime;
 
619
public:
 
620
  Item_func_now() :Item_date_func() {}
 
621
  Item_func_now(Item *a) :Item_date_func(a) {}
 
622
  enum Item_result result_type () const { return STRING_RESULT; }
 
623
  longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
 
624
  int save_in_field(Field *to, bool no_conversions);
 
625
  String *val_str(String *str);
 
626
  void fix_length_and_dec();
 
627
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
628
  virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
 
629
};
 
630
 
 
631
 
 
632
class Item_func_now_local :public Item_func_now
 
633
{
 
634
public:
 
635
  Item_func_now_local() :Item_func_now() {}
 
636
  Item_func_now_local(Item *a) :Item_func_now(a) {}
 
637
  const char *func_name() const { return "now"; }
 
638
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
 
639
  virtual enum Functype functype() const { return NOW_FUNC; }
 
640
};
 
641
 
 
642
 
 
643
class Item_func_now_utc :public Item_func_now
 
644
{
 
645
public:
 
646
  Item_func_now_utc() :Item_func_now() {}
 
647
  Item_func_now_utc(Item *a) :Item_func_now(a) {}
 
648
  const char *func_name() const { return "utc_timestamp"; }
 
649
  virtual void store_now_in_TIME(MYSQL_TIME *now_time);
 
650
};
 
651
 
 
652
 
 
653
/*
 
654
  This is like NOW(), but always uses the real current time, not the
 
655
  query_start(). This matches the Oracle behavior.
 
656
*/
 
657
class Item_func_sysdate_local :public Item_func_now
 
658
{
 
659
public:
 
660
  Item_func_sysdate_local() :Item_func_now() {}
 
661
  Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
 
662
  bool const_item() const { return 0; }
 
663
  const char *func_name() const { return "sysdate"; }
 
664
  void store_now_in_TIME(MYSQL_TIME *now_time);
 
665
  double val_real();
 
666
  longlong val_int();
 
667
  int save_in_field(Field *to, bool no_conversions);
 
668
  String *val_str(String *str);
 
669
  void fix_length_and_dec();
 
670
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
671
  void update_used_tables()
 
672
  {
 
673
    Item_func_now::update_used_tables();
 
674
    used_tables_cache|= RAND_TABLE_BIT;
 
675
  }
 
676
};
 
677
 
 
678
 
 
679
class Item_func_from_days :public Item_date
 
680
{
 
681
public:
 
682
  Item_func_from_days(Item *a) :Item_date(a) {}
 
683
  const char *func_name() const { return "from_days"; }
 
684
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
685
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
686
  bool check_valid_arguments_processor(uchar *int_arg)
 
687
  {
 
688
    return has_date_args() || has_time_args();
 
689
  }
 
690
};
 
691
 
 
692
 
 
693
class Item_func_date_format :public Item_str_func
 
694
{
 
695
  int fixed_length;
 
696
  const bool is_time_format;
 
697
  String value;
 
698
public:
 
699
  Item_func_date_format(Item *a,Item *b,bool is_time_format_arg)
 
700
    :Item_str_func(a,b),is_time_format(is_time_format_arg) {}
 
701
  String *val_str(String *str);
 
702
  const char *func_name() const
 
703
    { return is_time_format ? "time_format" : "date_format"; }
 
704
  void fix_length_and_dec();
 
705
  uint format_length(const String *format);
 
706
  bool eq(const Item *item, bool binary_cmp) const;
 
707
};
 
708
 
 
709
 
 
710
class Item_func_from_unixtime :public Item_date_func
 
711
{
 
712
  THD *thd;
 
713
 public:
 
714
  Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
 
715
  longlong val_int();
 
716
  String *val_str(String *str);
 
717
  const char *func_name() const { return "from_unixtime"; }
 
718
  void fix_length_and_dec();
 
719
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
720
};
 
721
 
 
722
 
 
723
/* 
 
724
  We need Time_zone class declaration for storing pointers in
 
725
  Item_func_convert_tz.
 
726
*/
 
727
class Time_zone;
 
728
 
 
729
/*
 
730
  This class represents CONVERT_TZ() function.
 
731
  The important fact about this function that it is handled in special way.
 
732
  When such function is met in expression time_zone system tables are added
 
733
  to global list of tables to open, so later those already opened and locked
 
734
  tables can be used during this function calculation for loading time zone
 
735
  descriptions.
 
736
*/
 
737
class Item_func_convert_tz :public Item_date_func
 
738
{
 
739
  /*
 
740
    If time zone parameters are constants we are caching objects that
 
741
    represent them (we use separate from_tz_cached/to_tz_cached members
 
742
    to indicate this fact, since NULL is legal value for from_tz/to_tz
 
743
    members.
 
744
  */
 
745
  bool from_tz_cached, to_tz_cached;
 
746
  Time_zone *from_tz, *to_tz;
 
747
 public:
 
748
  Item_func_convert_tz(Item *a, Item *b, Item *c):
 
749
    Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
 
750
  longlong val_int();
 
751
  String *val_str(String *str);
 
752
  const char *func_name() const { return "convert_tz"; }
 
753
  void fix_length_and_dec();
 
754
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
755
  void cleanup();
 
756
};
 
757
 
 
758
 
 
759
class Item_func_sec_to_time :public Item_str_timefunc
 
760
{
 
761
public:
 
762
  Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
 
763
  double val_real()
 
764
  {
 
765
    DBUG_ASSERT(fixed == 1);
 
766
    return (double) Item_func_sec_to_time::val_int();
 
767
  }
 
768
  longlong val_int();
 
769
  String *val_str(String *);
 
770
  void fix_length_and_dec()
 
771
  { 
 
772
    Item_str_timefunc::fix_length_and_dec();
 
773
    maybe_null=1;
 
774
  }
 
775
  const char *func_name() const { return "sec_to_time"; }
 
776
  bool result_as_longlong() { return TRUE; }
 
777
};
 
778
 
 
779
 
 
780
class Item_date_add_interval :public Item_date_func
 
781
{
 
782
  String value;
 
783
  enum_field_types cached_field_type;
 
784
  String ascii_buf;
 
785
public:
 
786
  const interval_type int_type; // keep it public
 
787
  const bool date_sub_interval; // keep it public
 
788
  Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
 
789
    :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
 
790
  String *val_str_ascii(String *str);
 
791
  String *val_str(String *str)
 
792
  {
 
793
    return val_str_from_val_str_ascii(str, &ascii_buf);
 
794
  }
 
795
  const char *func_name() const { return "date_add_interval"; }
 
796
  void fix_length_and_dec();
 
797
  enum_field_types field_type() const { return cached_field_type; }
 
798
  CHARSET_INFO *charset_for_protocol(void) const
 
799
  {
 
800
    /*
 
801
      DATE_ADD() can return DATE, DATETIME or VARCHAR depending on arguments.
 
802
      Send using "binary" when DATE or DATETIME,
 
803
      or using collation.collation when VARCHAR
 
804
      (which was fixed from @collation_connection in fix_length_and_dec).
 
805
    */
 
806
    DBUG_ASSERT(fixed == 1);
 
807
    return cached_field_type == MYSQL_TYPE_STRING ?
 
808
                                collation.collation : &my_charset_bin;
 
809
  }
 
810
  longlong val_int();
 
811
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
812
  bool eq(const Item *item, bool binary_cmp) const;
 
813
  virtual void print(String *str, enum_query_type query_type);
 
814
};
 
815
 
 
816
 
 
817
class Item_extract :public Item_int_func
 
818
{
 
819
  bool date_value;
 
820
 public:
 
821
  const interval_type int_type; // keep it public
 
822
  Item_extract(interval_type type_arg, Item *a)
 
823
    :Item_int_func(a), int_type(type_arg) {}
 
824
  longlong val_int();
 
825
  enum Functype functype() const { return EXTRACT_FUNC; }
 
826
  const char *func_name() const { return "extract"; }
 
827
  void fix_length_and_dec();
 
828
  bool eq(const Item *item, bool binary_cmp) const;
 
829
  virtual void print(String *str, enum_query_type query_type);
 
830
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
831
  bool check_valid_arguments_processor(uchar *int_arg)
 
832
  {
 
833
    switch (int_type) {
 
834
    case INTERVAL_YEAR:
 
835
    case INTERVAL_YEAR_MONTH:
 
836
    case INTERVAL_QUARTER:
 
837
    case INTERVAL_MONTH:
 
838
    /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */
 
839
    case INTERVAL_DAY:
 
840
      return !has_date_args();
 
841
    case INTERVAL_DAY_HOUR:
 
842
    case INTERVAL_DAY_MINUTE:
 
843
    case INTERVAL_DAY_SECOND:
 
844
    case INTERVAL_DAY_MICROSECOND:
 
845
      return !has_datetime_args();
 
846
    case INTERVAL_HOUR:
 
847
    case INTERVAL_HOUR_MINUTE:
 
848
    case INTERVAL_HOUR_SECOND:
 
849
    case INTERVAL_MINUTE:
 
850
    case INTERVAL_MINUTE_SECOND:
 
851
    case INTERVAL_SECOND:
 
852
    case INTERVAL_MICROSECOND:
 
853
    case INTERVAL_HOUR_MICROSECOND:
 
854
    case INTERVAL_MINUTE_MICROSECOND:
 
855
    case INTERVAL_SECOND_MICROSECOND:
 
856
      return !has_time_args();
 
857
    default:
 
858
      /*
 
859
        INTERVAL_LAST is only an end marker,
 
860
        INTERVAL_WEEK depends on default_week_format which is a session
 
861
        variable and cannot be used for partitioning. See bug#57071.
 
862
      */
 
863
      break;
 
864
    }
 
865
    return true;
 
866
  }
 
867
};
 
868
 
 
869
 
 
870
class Item_typecast :public Item_str_func
 
871
{
 
872
public:
 
873
  Item_typecast(Item *a) :Item_str_func(a) {}
 
874
  String *val_str(String *a)
 
875
  {
 
876
    DBUG_ASSERT(fixed == 1);
 
877
    String *tmp=args[0]->val_str(a);
 
878
    null_value=args[0]->null_value;
 
879
    if (tmp)
 
880
      tmp->set_charset(collation.collation);
 
881
    return tmp;
 
882
  }
 
883
  void fix_length_and_dec()
 
884
  {
 
885
    collation.set(&my_charset_bin);
 
886
    max_length=args[0]->max_length;
 
887
  }
 
888
  virtual const char* cast_type() const= 0;
 
889
  virtual void print(String *str, enum_query_type query_type);
 
890
};
 
891
 
 
892
 
 
893
class Item_typecast_maybe_null :public Item_typecast
 
894
{
 
895
public:
 
896
  Item_typecast_maybe_null(Item *a) :Item_typecast(a) { maybe_null= 1; }
 
897
};
 
898
 
 
899
 
 
900
class Item_char_typecast :public Item_typecast
 
901
{
 
902
  int cast_length;
 
903
  CHARSET_INFO *cast_cs, *from_cs;
 
904
  bool charset_conversion;
 
905
  String tmp_value;
 
906
public:
 
907
  Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
 
908
    :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
 
909
  enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
 
910
  bool eq(const Item *item, bool binary_cmp) const;
 
911
  const char *func_name() const { return "cast_as_char"; }
 
912
  const char* cast_type() const { return "char"; };
 
913
  String *val_str(String *a);
 
914
  void fix_length_and_dec();
 
915
  virtual void print(String *str, enum_query_type query_type);
 
916
};
 
917
 
 
918
 
 
919
class Item_date_typecast :public Item_typecast_maybe_null
 
920
{
 
921
public:
 
922
  Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
 
923
  const char *func_name() const { return "cast_as_date"; }
 
924
  String *val_str(String *str);
 
925
  bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
 
926
  bool get_time(MYSQL_TIME *ltime);
 
927
  const char *cast_type() const { return "date"; }
 
928
  enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
 
929
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
930
  Field *tmp_table_field(TABLE *table)
 
931
  {
 
932
    return tmp_table_field_from_field_type(table, 0);
 
933
  }
 
934
  void fix_length_and_dec() { fix_length_and_charset_datetime(10); }
 
935
  bool result_as_longlong() { return TRUE; }
 
936
  longlong val_int();
 
937
  double val_real() { return (double) val_int(); }
 
938
  my_decimal *val_decimal(my_decimal *decimal_value)
 
939
  {
 
940
    DBUG_ASSERT(fixed == 1);
 
941
    return  val_decimal_from_date(decimal_value);
 
942
  }
 
943
  int save_in_field(Field *field, bool no_conversions)
 
944
  {
 
945
    return save_date_in_field(field);
 
946
  }
 
947
};
 
948
 
 
949
 
 
950
class Item_time_typecast :public Item_typecast_maybe_null
 
951
{
 
952
public:
 
953
  Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
 
954
  const char *func_name() const { return "cast_as_time"; }
 
955
  String *val_str(String *str);
 
956
  bool get_time(MYSQL_TIME *ltime);
 
957
  const char *cast_type() const { return "time"; }
 
958
  enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
 
959
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
960
  Field *tmp_table_field(TABLE *table)
 
961
  {
 
962
    return tmp_table_field_from_field_type(table, 0);
 
963
  }
 
964
  bool result_as_longlong() { return TRUE; }
 
965
  longlong val_int();
 
966
  double val_real() { return val_real_from_decimal(); }
 
967
  my_decimal *val_decimal(my_decimal *decimal_value)
 
968
  {
 
969
    DBUG_ASSERT(fixed == 1);
 
970
    return  val_decimal_from_time(decimal_value);
 
971
  }
 
972
  int save_in_field(Field *field, bool no_conversions)
 
973
  {
 
974
    return save_time_in_field(field);
 
975
  }
 
976
  void fix_length_and_dec()
 
977
  { fix_length_and_charset_datetime(args[0]->max_char_length()); }
 
978
};
 
979
 
 
980
 
 
981
class Item_datetime_typecast :public Item_typecast_maybe_null
 
982
{
 
983
public:
 
984
  Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
 
985
  const char *func_name() const { return "cast_as_datetime"; }
 
986
  String *val_str(String *str);
 
987
  const char *cast_type() const { return "datetime"; }
 
988
  enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
 
989
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
990
  Field *tmp_table_field(TABLE *table)
 
991
  {
 
992
    return tmp_table_field_from_field_type(table, 0);
 
993
  }
 
994
  void fix_length_and_dec()
 
995
  {
 
996
    fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH);
 
997
    decimals= DATETIME_DEC;
 
998
  }
 
999
  bool result_as_longlong() { return TRUE; }
 
1000
  longlong val_int();
 
1001
  double val_real() { return val_real_from_decimal(); }
 
1002
  double val() { return (double) val_int(); }
 
1003
  my_decimal *val_decimal(my_decimal *decimal_value)
 
1004
  {
 
1005
    DBUG_ASSERT(fixed == 1);
 
1006
    return  val_decimal_from_date(decimal_value);
 
1007
  }
 
1008
  int save_in_field(Field *field, bool no_conversions)
 
1009
  {
 
1010
    return save_date_in_field(field);
 
1011
  }
 
1012
};
 
1013
 
 
1014
class Item_func_makedate :public Item_date_func
 
1015
{
 
1016
public:
 
1017
  Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
 
1018
  String *val_str(String *str);
 
1019
  const char *func_name() const { return "makedate"; }
 
1020
  enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
 
1021
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
1022
  void fix_length_and_dec()
 
1023
  { 
 
1024
    decimals=0;
 
1025
    fix_length_and_charset_datetime(MAX_DATE_WIDTH);
 
1026
    maybe_null= 1;
 
1027
  }
 
1028
  longlong val_int();
 
1029
};
 
1030
 
 
1031
 
 
1032
class Item_func_add_time :public Item_str_func
 
1033
{
 
1034
  const bool is_date;
 
1035
  int sign;
 
1036
  enum_field_types cached_field_type;
 
1037
 
 
1038
public:
 
1039
  Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
 
1040
    :Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
 
1041
  String *val_str(String *str);
 
1042
  enum_field_types field_type() const { return cached_field_type; }
 
1043
  void fix_length_and_dec();
 
1044
  CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; }
 
1045
 
 
1046
  Field *tmp_table_field(TABLE *table)
 
1047
  {
 
1048
    return tmp_table_field_from_field_type(table, 0);
 
1049
  }
 
1050
  virtual void print(String *str, enum_query_type query_type);
 
1051
  const char *func_name() const { return "add_time"; }
 
1052
  double val_real() { return val_real_from_decimal(); }
 
1053
  my_decimal *val_decimal(my_decimal *decimal_value)
 
1054
  {
 
1055
    DBUG_ASSERT(fixed == 1);
 
1056
    if (cached_field_type == MYSQL_TYPE_TIME)
 
1057
      return  val_decimal_from_time(decimal_value);
 
1058
    if (cached_field_type == MYSQL_TYPE_DATETIME)
 
1059
      return  val_decimal_from_date(decimal_value);
 
1060
    return Item_str_func::val_decimal(decimal_value);
 
1061
  }
 
1062
  int save_in_field(Field *field, bool no_conversions)
 
1063
  {
 
1064
    if (cached_field_type == MYSQL_TYPE_TIME)
 
1065
      return save_time_in_field(field);
 
1066
    if (cached_field_type == MYSQL_TYPE_DATETIME)
 
1067
      return save_date_in_field(field);
 
1068
    return Item_str_func::save_in_field(field, no_conversions);
 
1069
  }
 
1070
  longlong val_int();
 
1071
  MYSQL_TIME *val_datetime(MYSQL_TIME *time, date_time_format_types *format);
 
1072
};
 
1073
 
 
1074
class Item_func_timediff :public Item_str_timefunc
 
1075
{
 
1076
public:
 
1077
  Item_func_timediff(Item *a, Item *b)
 
1078
    :Item_str_timefunc(a, b) {}
 
1079
  String *val_str(String *str);
 
1080
  const char *func_name() const { return "timediff"; }
 
1081
  void fix_length_and_dec()
 
1082
  {
 
1083
    Item_str_timefunc::fix_length_and_dec();
 
1084
    maybe_null= 1;
 
1085
  }
 
1086
};
 
1087
 
 
1088
class Item_func_maketime :public Item_str_timefunc
 
1089
{
 
1090
public:
 
1091
  Item_func_maketime(Item *a, Item *b, Item *c)
 
1092
    :Item_str_timefunc(a, b, c) 
 
1093
  {
 
1094
    maybe_null= TRUE;
 
1095
  }
 
1096
  String *val_str(String *str);
 
1097
  const char *func_name() const { return "maketime"; }
 
1098
};
 
1099
 
 
1100
class Item_func_microsecond :public Item_int_func
 
1101
{
 
1102
public:
 
1103
  Item_func_microsecond(Item *a) :Item_int_func(a) {}
 
1104
  longlong val_int();
 
1105
  const char *func_name() const { return "microsecond"; }
 
1106
  void fix_length_and_dec() 
 
1107
  { 
 
1108
    decimals=0;
 
1109
    maybe_null=1;
 
1110
  }
 
1111
  bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
 
1112
  bool check_valid_arguments_processor(uchar *int_arg)
 
1113
  {
 
1114
    return !has_time_args();
 
1115
  }
 
1116
};
 
1117
 
 
1118
 
 
1119
class Item_func_timestamp_diff :public Item_int_func
 
1120
{
 
1121
  const interval_type int_type;
 
1122
public:
 
1123
  Item_func_timestamp_diff(Item *a,Item *b,interval_type type_arg)
 
1124
    :Item_int_func(a,b), int_type(type_arg) {}
 
1125
  const char *func_name() const { return "timestampdiff"; }
 
1126
  longlong val_int();
 
1127
  void fix_length_and_dec()
 
1128
  {
 
1129
    decimals=0;
 
1130
    maybe_null=1;
 
1131
  }
 
1132
  virtual void print(String *str, enum_query_type query_type);
 
1133
};
 
1134
 
 
1135
 
 
1136
enum date_time_format
 
1137
{
 
1138
  USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT
 
1139
};
 
1140
 
 
1141
class Item_func_get_format :public Item_str_ascii_func
 
1142
{
 
1143
public:
 
1144
  const timestamp_type type; // keep it public
 
1145
  Item_func_get_format(timestamp_type type_arg, Item *a)
 
1146
    :Item_str_ascii_func(a), type(type_arg)
 
1147
  {}
 
1148
  String *val_str_ascii(String *str);
 
1149
  const char *func_name() const { return "get_format"; }
 
1150
  void fix_length_and_dec()
 
1151
  {
 
1152
    maybe_null= 1;
 
1153
    decimals=0;
 
1154
    fix_length_and_charset(17, default_charset());
 
1155
  }
 
1156
  virtual void print(String *str, enum_query_type query_type);
 
1157
};
 
1158
 
 
1159
 
 
1160
class Item_func_str_to_date :public Item_str_func
 
1161
{
 
1162
  enum_field_types cached_field_type;
 
1163
  date_time_format_types cached_format_type;
 
1164
  timestamp_type cached_timestamp_type;
 
1165
  bool const_item;
 
1166
  ulonglong sql_mode;
 
1167
public:
 
1168
  Item_func_str_to_date(Item *a, Item *b)
 
1169
    :Item_str_func(a, b), const_item(false)
 
1170
  {}
 
1171
  String *val_str(String *str);
 
1172
  bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
 
1173
  const char *func_name() const { return "str_to_date"; }
 
1174
  enum_field_types field_type() const { return cached_field_type; }
 
1175
  void fix_length_and_dec();
 
1176
  Field *tmp_table_field(TABLE *table)
 
1177
  {
 
1178
    return tmp_table_field_from_field_type(table, 1);
 
1179
  }
 
1180
  longlong val_int();
 
1181
  bool result_as_longlong() { return TRUE; }
 
1182
};
 
1183
 
 
1184
 
 
1185
class Item_func_last_day :public Item_date
 
1186
{
 
1187
public:
 
1188
  Item_func_last_day(Item *a) :Item_date(a) {}
 
1189
  const char *func_name() const { return "last_day"; }
 
1190
  bool get_date(MYSQL_TIME *res, uint fuzzy_date);
 
1191
  void fix_length_and_dec()
 
1192
  { 
 
1193
    Item_date::fix_length_and_dec();
 
1194
    maybe_null= 1;
 
1195
  }
 
1196
};
 
1197
 
 
1198
 
 
1199
/* Function prototypes */
 
1200
 
 
1201
bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
 
1202
                    timestamp_type type, String *str);
 
1203
 
 
1204
#endif /* ITEM_TIMEFUNC_INCLUDED */