271
271
# Test types from + INTERVAL
274
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date);
274
CREATE TABLE t1 (datetime_arg datetime, timestamp_arg timestamp, date_arg date);
275
275
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02");
276
276
SELECT * from t1;
277
277
select date_add("1997-12-31",INTERVAL 1 SECOND);
278
278
select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
280
select date_add(datetime, INTERVAL 1 SECOND) from t1;
281
select date_add(datetime, INTERVAL 1 YEAR) from t1;
280
select date_add(datetime_arg, INTERVAL 1 SECOND) from t1;
281
select date_add(datetime_arg, INTERVAL 1 YEAR) from t1;
283
select date_add(date,INTERVAL 1 SECOND) from t1;
284
select date_add(date,INTERVAL 1 MINUTE) from t1;
285
select date_add(date,INTERVAL 1 HOUR) from t1;
286
select date_add(date,INTERVAL 1 DAY) from t1;
287
select date_add(date,INTERVAL 1 MONTH) from t1;
288
select date_add(date,INTERVAL 1 YEAR) from t1;
289
select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
290
select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
291
select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
292
select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
293
select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
294
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
295
select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
296
select date_add(date,INTERVAL "1" WEEK) from t1;
297
select date_add(date,INTERVAL "1" QUARTER) from t1;
298
select timestampadd(MINUTE, 1, date) from t1;
299
select timestampadd(WEEK, 1, date) from t1;
300
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
283
select date_add(date_arg, INTERVAL 1 SECOND) from t1;
284
select date_add(date_arg, INTERVAL 1 MINUTE) from t1;
285
select date_add(date_arg, INTERVAL 1 HOUR) from t1;
286
select date_add(date_arg, INTERVAL 1 DAY) from t1;
287
select date_add(date_arg, INTERVAL 1 MONTH) from t1;
288
select date_add(date_arg, INTERVAL 1 YEAR) from t1;
289
select date_add(date_arg, INTERVAL "1:1" MINUTE_SECOND) from t1;
290
select date_add(date_arg, INTERVAL "1:1" HOUR_MINUTE) from t1;
291
select date_add(date_arg, INTERVAL "1:1" DAY_HOUR) from t1;
292
select date_add(date_arg, INTERVAL "1 1" YEAR_MONTH) from t1;
293
select date_add(date_arg, INTERVAL "1:1:1" HOUR_SECOND) from t1;
294
select date_add(date_arg, INTERVAL "1 1:1" DAY_MINUTE) from t1;
295
select date_add(date_arg, INTERVAL "1 1:1:1" DAY_SECOND) from t1;
296
select date_add(date_arg, INTERVAL "1" WEEK) from t1;
297
select date_add(date_arg, INTERVAL "1" QUARTER) from t1;
298
select timestampadd(MINUTE, 1, date_arg) from t1;
299
select timestampadd(WEEK, 1, date_arg) from t1;
300
select timestampadd(SQL_TSI_SECOND, 1, date_arg) from t1;
301
301
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
302
302
--disable_ps_protocol
303
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
303
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date_arg) from t1;
304
304
--enable_ps_protocol
306
306
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;