mariadb/storage/myisam
Yuchen Pei bd1e74aa0b
MDEV-9826 More hash algorithms for PARTITION BY [LINEAR] KEY
PARTITION BY [LINEAR] KEY ALGORITHM={MYSQL51|MYSQL55|BASE31|CRC32C|XXH32|XXH3}

- The MYSQL5X algorithms are the existing algorithms, with MYSQL55
  being the default
- The BASE31 algorithm uses a base-31 representation of the bytes, see
  Modular hashing in https://algs4.cs.princeton.edu/34hash/. It serves
  as a simple baseline that distributes better than the old mysql5x
  algorithms
- CRC32C uses my_crc32c.
- XXH32 and XXH3 are xxhash algorithms - xxhash.h copied from latest
  release (0.8.3) of https://github.com/Cyan4973/xxHash

For performance (esp. xxh) we use one-shot hash functions in binary
hash_sort, and streaming hash function otherwise for byte-by-byte
hashing. XXH is the only stateful hash function. The other hash
algorithms are stateless and homomorphic, so streaming and one-shot
functions are identical.

Also updated the columnstore hash due to the change of MY_HASH_ADD
signature.

The following testing commands were run at an earlier version of the
patch with the following patch that changes the default algorithm from
MYSQL55 to CRC32C, and XXH32 (changing the patch accordingly)

mtr --suite main --do-test=.*partition
mtr --suite parts

modified   sql/ha_partition.cc
@@ -10336,6 +10336,8 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array)
   switch ((*field_array)->table->part_info->key_algorithm)
   {
   case partition_info::KEY_ALGORITHM_NONE:
+    hasher.set_algorithm(HASH_ALGORITHM_CRC32C);
+    break;
   case partition_info::KEY_ALGORITHM_55:
     /* Hasher default to mysql55 */
     break;
modified   sql/partition_info.cc
@@ -2328,7 +2328,7 @@ bool partition_info::fix_parser_data(THD *thd)
       if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
            thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
           key_algorithm == KEY_ALGORITHM_NONE)
-        key_algorithm= KEY_ALGORITHM_55;
+        key_algorithm= PARTITION_INFO_DEFAULT_ALGORITHM;
     }
     DBUG_RETURN(FALSE);
   }
@@ -2344,7 +2344,7 @@ bool partition_info::fix_parser_data(THD *thd)
     if ((thd_sql_command(thd) == SQLCOM_CREATE_TABLE ||
          thd_sql_command(thd) == SQLCOM_ALTER_TABLE) &&
         key_algorithm == KEY_ALGORITHM_NONE)
-      key_algorithm= KEY_ALGORITHM_55;
+      key_algorithm= PARTITION_INFO_DEFAULT_ALGORITHM;
   }
   defined_max_value= FALSE; // in case it already set (CREATE TABLE LIKE)
   do
modified   sql/partition_info.h
@@ -446,6 +446,8 @@ class partition_info : public DDL_LOG_STATE, public Sql_alloc
   int gen_part_type(THD *thd, String *str) const;
 };

+#define PARTITION_INFO_DEFAULT_ALGORITHM partition_info::KEY_ALGORITHM_CRC32C
+
 void part_type_error(THD *thd, partition_info *work_part_info,
                      const char *part_type, partition_info *tab_part_info);

modified   sql/sql_partition.cc
@@ -2471,7 +2471,7 @@ static int add_key_with_algorithm(String *str, const partition_info *part_info)
   err+= str->append(STRING_WITH_LEN("KEY "));

   if (part_info->key_algorithm != partition_info::KEY_ALGORITHM_NONE &&
-      part_info->key_algorithm != partition_info::KEY_ALGORITHM_55)
+      part_info->key_algorithm != PARTITION_INFO_DEFAULT_ALGORITHM)
   {
     err+= str->append(STRING_WITH_LEN("ALGORITHM = "));
     switch (part_info->key_algorithm)
@@ -2479,6 +2479,9 @@ static int add_key_with_algorithm(String *str, const partition_info *part_info)
       case partition_info::KEY_ALGORITHM_51:
         err+= str->append(STRING_WITH_LEN("MYSQL51"));
         break;
+      case partition_info::KEY_ALGORITHM_55:
+        err+= str->append(STRING_WITH_LEN("MYSQL55"));
+        break;
       case partition_info::KEY_ALGORITHM_BASE31:
         err+= str->append(STRING_WITH_LEN("BASE31"));
         break;
2026-02-05 11:55:12 +11:00
..
ftbench mtr: use env for perl 2020-06-23 03:24:46 +02:00
mysql-test MDEV-28933: Per-table unique FOREIGN KEY constraint names 2025-07-08 12:30:27 +03:00
ChangeLog Fix remaining typos 2025-04-29 11:18:00 +10:00
CMakeLists.txt Add build on AIX 2020-12-16 08:07:04 +11:00
ft_boolean_search.c MDEV-34348: Consolidate cmp function declarations 2024-11-23 08:14:22 -07:00
ft_myisam.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
ft_nlq_search.c MDEV-34348: Fix casts relating to tree_walk_action 2024-11-23 08:14:23 -07:00
ft_parser.c Merge 11.4 into 11.7 2024-12-02 17:51:17 +02:00
ft_static.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
ft_stopwords.c MDEV-34348: Fix casts relating to tree_walk_action 2024-11-23 08:14:23 -07:00
ft_update.c Merge branch '10.6' into 10.10 2023-11-08 16:23:30 +01:00
ftdefs.h Fixed typos 2025-09-04 18:08:39 +03:00
fulltext.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
ha_myisam.cc Merge branch '11.8' into 12.0 2025-06-18 07:50:39 +02:00
ha_myisam.h Merge 11.4 into 11.8 2025-09-29 18:25:09 +03:00
mi_cache.c Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
mi_changed.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_check.c Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
mi_checksum.c Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
mi_close.c Improvements for myisamchk 2025-09-04 18:08:39 +03:00
mi_create.c mhnsw: build indexes with the columns of exactly right size 2024-11-05 14:00:49 -08:00
mi_dbug.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_delete.c cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
mi_delete_all.c MDEV-9101 Limit size of created disk temporary files and tables 2024-05-27 12:39:04 +02:00
mi_delete_table.c MDEV-11412 Ensure that table is truly dropped when using DROP TABLE 2020-06-14 19:39:42 +03:00
mi_dynrec.c Improvements for myisamchk 2025-09-04 18:08:39 +03:00
mi_extra.c Fixed that HA_EXTRA_FLUSH in Aria and MyISAM flushes all data to disk 2025-04-28 12:59:39 +03:00
mi_extrafunc.h Update FSF Address 2019-05-11 21:29:06 +03:00
mi_info.c Merge branch '11.4' into 11.8 2025-07-28 21:29:29 +02:00
mi_key.c cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
mi_keycache.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_locking.c Merge 11.4 into 11.7 2024-12-02 17:51:17 +02:00
mi_log.c MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 2021-06-06 13:21:03 +02:00
mi_open.c Merge 11.4 into 11.8 2025-09-29 18:25:09 +03:00
mi_packrec.c Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
mi_page.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_panic.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_preload.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
mi_range.c Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
mi_rename.c pos-fixes for rename 2024-11-05 14:00:50 -08:00
mi_rfirst.c Fix spelling mistakes in MyISAM code comments 2019-09-20 07:21:21 +03:00
mi_rkey.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
mi_rlast.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rnext.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
mi_rnext_same.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
mi_rprev.c MDEV-21794: Optimizer flag rowid_filter leads to long query 2020-05-07 12:27:17 +02:00
mi_rrnd.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rsame.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_rsamepos.c Update FSF Address 2019-05-11 21:29:06 +03:00
mi_scan.c Fixes to make dbug traces from Windows easier to compare with Unix traces 2023-03-02 13:11:54 +02:00
mi_search.c Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
mi_static.c perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
mi_statrec.c Fix remaining typos 2025-04-29 11:18:00 +10:00
mi_test1.c Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
mi_test2.c Added page_range to records_in_range() to improve range statistics 2020-03-27 03:54:45 +02:00
mi_test3.c Fix clang -Wunused-but-set-variable 2022-09-19 13:30:52 +03:00
mi_test_all.res
mi_test_all.sh Merge remote-tracking branch 'origin/5.5' into 10.1 2019-09-24 11:18:39 +04:00
mi_unique.c MDEV-9826 More hash algorithms for PARTITION BY [LINEAR] KEY 2026-02-05 11:55:12 +11:00
mi_update.c cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
mi_write.c Merge 11.4 into 11.7 2024-12-02 17:51:17 +02:00
myisam_ftdump.c cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
myisamchk.c Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
myisamdef.h Merge 11.4 into 11.8 2025-09-29 18:25:09 +03:00
myisamlog.c Merge 10.11 into 11.4 2024-12-02 11:35:34 +02:00
myisampack.c Merge branch '11.8' into bb-12.1-release 2025-10-08 09:05:38 +02:00
NEWS Merge remote-tracking branch 'origin/10.1' into 10.2 2019-09-24 19:19:25 +04:00
rt_index.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_index.h cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_key.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_key.h cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_mbr.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_mbr.h cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_split.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
rt_test.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
sort.c Merge 11.4 into 11.7 2024-12-02 17:51:17 +02:00
sp_defs.h cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
sp_key.c cleanup: remove unconditional #ifdef's 2024-11-05 14:00:47 -08:00
sp_test.c cleanup: key algorithm vs key flags 2024-11-05 14:00:47 -08:00
test_pack