mariadb/mysql-test/suite/maria
Alexander Barkov e63311c2cf MDEV-33496 Out of range error in AVG(YEAR(datetime)) due to a wrong data type
Functions extracting non-negative datetime components:

- YEAR(dt),        EXTRACT(YEAR FROM dt)
- QUARTER(td),     EXTRACT(QUARTER FROM dt)
- MONTH(dt),       EXTRACT(MONTH FROM dt)
- WEEK(dt),        EXTRACT(WEEK FROM dt)
- HOUR(dt),
- MINUTE(dt),
- SECOND(dt),
- MICROSECOND(dt),
- DAYOFYEAR(dt)
- EXTRACT(YEAR_MONTH FROM dt)

did not set their max_length properly, so in the DECIMAL
context they created a too small DECIMAL column, which
led to the 'Out of range value' error.

The problem is that most of these functions historically
returned the signed INT data type.

There were two simple ways to fix these functions:
1. Add +1 to max_length.
   But this would also change their size in the string context
   and create too long VARCHAR columns, with +1 excessive size.

2. Preserve max_length, but change the data type from INT to INT UNSIGNED.
   But this would break backward compatibility.
   Also, using UNSIGNED is generally not desirable,
   it's better to stay with signed when possible.

This fix implements another solution, which it makes all these functions
work well in all contexts: int, decimal, string.

Fix details:

- Adding a new special class Type_handler_long_ge0 - the data type
  handler for expressions which:
  * should look like normal signed INT
  * but which known not to return negative values
  Expressions handled by Type_handler_long_ge0 store in Item::max_length
  only the number of digits, without adding +1 for the sign.

- Fixing Item_extract to use Type_handler_long_ge0
  for non-negative datetime components:
   YEAR, YEAR_MONTH, QUARTER, MONTH, WEEK

- Adding a new abstract class Item_long_ge0_func, for functions
  returning non-negative datetime components.
  Item_long_ge0_func uses Type_handler_long_ge0 as the type handler.
  The class hierarchy now looks as follows:

Item_long_ge0_func
  Item_long_func_date_field
    Item_func_to_days
    Item_func_dayofmonth
    Item_func_dayofyear
    Item_func_quarter
    Item_func_year
  Item_long_func_time_field
    Item_func_hour
    Item_func_minute
    Item_func_second
    Item_func_microsecond

- Cleanup: EXTRACT(QUARTER FROM dt) created an excessive VARCHAR column
  in string context. Changing its length from 2 to 1.
2024-02-23 18:30:06 +04:00
..
alter.result Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
alter.test MDEV-23296 Assertion `block->type == PAGECACHE_EMPTY_PAGE.. with aria_max_sort_file_size=0 2020-09-25 13:07:04 +03:00
aria_log_dir_path.result MDEV-30971 Add a new system variable aria_data_home_dir 2023-04-04 16:05:55 +04:00
aria_log_dir_path.test MDEV-30971 Add a new system variable aria_data_home_dir 2023-04-04 16:05:55 +04:00
aria_pack_mdev14183.result fix tests 2020-01-24 15:38:25 +01:00
aria_pack_mdev14183.test MDEV-14183: aria_pack segfaults in compress_maria_file 2020-01-23 14:20:57 +03:00
aria_sort_buffer.result MDEV-24750 Various corruptions caused by Aria subsystem... 2021-02-03 02:22:47 +02:00
aria_sort_buffer.test MDEV-24750 Various corruptions caused by Aria subsystem... 2021-02-03 02:22:47 +02:00
bulk_insert_crash.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
bulk_insert_crash.result Fixed crash in aria recovery when using bulk insert 2020-05-26 20:05:17 +03:00
bulk_insert_crash.test Fixed crash in aria recovery when using bulk insert 2020-05-26 20:05:17 +03:00
collations.result MDEV-10759 Fix Aria to support 2-byte collation IDs 2016-12-02 14:05:16 +02:00
collations.test MDEV-10759 Fix Aria to support 2-byte collation IDs 2016-12-02 14:05:16 +02:00
compat_aliases-master.opt Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
concurrent.result Merge 10.1 into 10.2 2018-08-31 15:10:02 +03:00
concurrent.test MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes 2018-08-27 22:00:14 +03:00
create.opt Fixed maria.create test 2020-11-30 19:57:50 +02:00
create.result Merge branch '10.4' into 10.5 2020-11-01 14:26:15 +01:00
create.test Fixed failing maria.create test 2020-11-09 19:36:10 +02:00
ctype_utf8mb3_uca.result Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
ctype_utf8mb3_uca.test MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB 2023-10-24 03:35:48 +04:00
disabled.def MDEV-16421 Make system tables crash safe 2018-08-14 12:18:38 +03:00
distinct.result 5.3 merge. 2013-05-20 12:36:30 +02:00
distinct.test 5.3 merge. 2013-05-20 12:36:30 +02:00
dynamic.result MDEV-13748 Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed in virtual THD::~THD after query with INTERSECT 2018-02-14 18:41:37 +01:00
dynamic.test MDEV-13748 Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed in virtual THD::~THD after query with INTERSECT 2018-02-14 18:41:37 +01:00
encrypt-no-key.result MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded 2023-05-02 23:37:10 +03:00
encrypt-no-key.test Fixed wrong test cases (embedded and ASAN) 2023-05-05 13:15:14 +03:00
encrypt-wrong-key.result MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded 2023-05-02 23:37:10 +03:00
encrypt-wrong-key.test MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded 2023-05-02 23:37:10 +03:00
fulltext2.result MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches 2022-01-28 21:36:33 +01:00
fulltext2.test MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches 2022-01-28 21:36:33 +01:00
group_commit.result Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
group_commit.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
icp.result Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
icp.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
insert_select-7314.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
insert_select-7314.test 5.5 merge 2015-01-21 12:03:02 +01:00
insert_select.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
insert_select.test Fixed MDEV-7314: Deadlock when doing insert-select with Aria 2015-01-18 20:38:07 +02:00
kill.result MDEV-14996 kill during FLUSH TABLES FOR EXPORT causes assert 2019-06-27 20:57:25 +03:00
kill.test MDEV-14996 kill during FLUSH TABLES FOR EXPORT causes assert 2019-06-27 20:57:25 +03:00
lock.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
lock.test Fix for crash in Aria LOCK TABLES + CREATE TRIGGER 2020-06-14 19:39:43 +03:00
locking.result Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
locking.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-64bit.result Fix of4cb0d43ac63761174a39cea892c176b9cfa6edfc after merge in 10.5 2023-07-30 08:41:54 +02:00
maria-64bit.test Updated some test result for 32 bit systems 2023-05-24 19:22:08 +03:00
maria-autoinc.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
maria-autoinc.test MDEV-15352 AUTO_INCREMENT breaks after updating a column value to a negative number 2018-06-14 13:13:23 +04:00
maria-autozerofill.result MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash recovery, automatic repairment does not work 2021-04-06 14:57:22 +03:00
maria-autozerofill.test MDEV-17913 Encrypted transactional Aria tables remain corrupt after crash recovery, automatic repairment does not work 2021-04-06 14:57:22 +03:00
maria-big.result MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-big.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-big2.result Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-big2.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-connect.result Fix spelling mistake in error message 2020-08-21 23:00:56 +03:00
maria-connect.test Aria will now register it's transactions 2020-05-23 12:29:10 +03:00
maria-gis-recovery.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-gis-recovery.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
maria-gis-recovery.test Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
maria-gis-rtree-dynamic.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
maria-gis-rtree-dynamic.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-gis-rtree-trans.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
maria-gis-rtree-trans.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-gis-rtree.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
maria-gis-rtree.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-mvcc.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
maria-mvcc.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-no-logging.result Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
maria-no-logging.test MDEV-17665 Assertion `!share and other errors on concurrent Aria operations 2020-09-25 13:07:04 +03:00
maria-page-checksum.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
maria-page-checksum.test fix for maria.maria test 2013-07-13 22:29:17 +02:00
maria-partitioning.result Make error messages from DROP TABLE and DROP TABLE IF EXISTS consistent 2020-06-14 19:39:42 +03:00
maria-partitioning.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-preload.result Fixed MDEV-3815: Aria engine return "The table is full" (ERROR 1114) inserting record, while MyISAM and InnoDB doesn't 2014-02-11 19:40:33 +02:00
maria-preload.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-purge.result MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-purge.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria-recover-master.opt MDEV-8542 - The "aria_recover" variable should be renamed "aria_recover_options" 2015-11-26 11:34:17 +04:00
maria-recover.result MDEV-17068 mysql system table is marked as crashed and should be repaired after the server crashes or is killed 2018-08-28 12:14:13 +03:00
maria-recover.test Merge branch '10.3' into 10.4 2019-09-06 11:53:10 +02:00
maria-recovery-big-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery-big.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria-recovery-big.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-recovery-bitmap-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery-bitmap.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria-recovery-bitmap.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-recovery-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery-rtree-ft-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery-rtree-ft.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria-recovery-rtree-ft.test merge with mysql-5.5.30 minus few incorrect or not applicable changesets 2013-02-28 18:42:49 +01:00
maria-recovery.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
maria-recovery.test Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
maria-recovery2-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery2.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria-recovery2.test 5.5 merge 2013-06-06 17:51:28 +02:00
maria-recovery3-master.opt mtr: aix - stack-trace is optional 2021-07-22 15:22:47 +10:00
maria-recovery3.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria-recovery3.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria-ucs2.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
maria-ucs2.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria.result Merge commit '10.4' into 10.5 2023-07-20 11:54:52 +02:00
maria.test Merge commit '10.4' into 10.5 2023-07-20 11:54:52 +02:00
maria2.result MDEV-8466 CAST works differently for DECIMAL/INT vs DOUBLE for empty strings 2015-09-17 11:05:07 +04:00
maria2.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
maria3.result MDEV-31822 ALTER TABLE ENGINE=x started failing instead of producing warning on unsupported TRANSACTIONAL=1 2023-08-02 14:45:31 +02:00
maria3.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria_notembedded.result MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria_notembedded.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria_partition.result MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria_partition.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
maria_showlog_error.result MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
maria_showlog_error.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
max_length.result A cleanup for MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-14 19:01:26 +04:00
max_length.test Extend have_sanitizer with ASAN+UBSAN and MSAN 2022-02-23 15:48:08 +02:00
mrr.result Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
mrr.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
optimize.result MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with disabled 2015-06-09 23:24:03 +04:00
optimize.test MDEV-3870 - Valgrind warnings on OPTIMIZE MyISAM or Aria TABLE with disabled 2015-06-09 23:24:03 +04:00
partition.result MDEV-19254 Server crashes in maria_status with partitioned table 2019-08-19 19:49:45 +03:00
partition.test MDEV-19254 Server crashes in maria_status with partitioned table 2019-08-19 19:49:45 +03:00
ps_maria.result MDEV-33496 Out of range error in AVG(YEAR(datetime)) due to a wrong data type 2024-02-23 18:30:06 +04:00
ps_maria.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
repair-big-sort.result Merge commit '10.4' into 10.5 2023-07-20 11:54:52 +02:00
repair-big-sort.test MDEV-28054 Various crashes upon INSERT/UPDATE after changing Aria settings 2023-05-02 23:37:10 +03:00
repair.result MDEV-17223 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes 2022-02-16 17:16:10 +02:00
repair.test MDEV-17223 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes 2022-02-16 17:16:10 +02:00
rollback.result MDEV-28970: Add RESET MASTER to clear possible remaining binlog from previous test 2022-11-09 11:59:28 +00:00
rollback.test MDEV-28970: Add RESET MASTER to clear possible remaining binlog from previous test 2022-11-09 11:59:28 +00:00
small_blocksize-master.opt Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
small_blocksize.result Post-merge buildbot fixes: 2013-07-05 19:57:48 +04:00
small_blocksize.test Created suites for heap, archive and csv. 2012-04-04 00:16:38 +03:00
suite.pm MDEV-8542 - The "aria_recover" variable should be renamed "aria_recover_options" 2015-11-26 11:34:17 +04:00
system_tables.result Changed FLUSH TABLES to not change share version 2018-12-09 22:12:26 +02:00
system_tables.test Changed FLUSH TABLES to not change share version 2018-12-09 22:12:26 +02:00
temporary.result MDEV-19595 fixed 2019-06-19 00:35:44 +03:00
temporary.test MDEV-19595 fixed 2019-06-19 00:35:44 +03:00
transaction.result Aria will now register it's transactions 2020-05-23 12:29:10 +03:00
transaction.test Aria will now register it's transactions 2020-05-23 12:29:10 +03:00
truncate.result MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
truncate.test Fixed MDEV-3890: Server crash inserting record on a temporary table after truncating it 2013-01-25 21:40:42 +02:00