NAME
DBIO::MySQL::IndexType - MySQL/MariaDB CREATE INDEX class/type keyword grammar
VERSION
version 0.900004
DESCRIPTION
Single source of truth for how a MySQL/MariaDB index type token renders in a CREATE INDEX statement. MySQL's grammar (8.4 Reference Manual) is
CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX name [index_type]
ON tbl (key_part,...) [index_option] ...
where index_type is USING {BTREE | HASH}. The four tokens are not rendered alike, because the grammar does not treat them alike: BTREE and HASH are index types and render as a trailing USING clause, while FULLTEXT and SPATIAL are index classes and render in front of INDEX (the manual states outright that "the index_type clause cannot be used for FULLTEXT INDEX specifications", so USING FULLTEXT is not a statement any server accepts).
This split is needed in two places -- desired-state DDL generation (DBIO::MySQL::DDL) and migration-diff rendering (DBIO::MySQL::Diff::Index) -- so it lives here once rather than being rendered twice.
METHODS
index_type_split
my ($class_kw, $using_clause) = DBIO::MySQL::IndexType::index_type_split($token);
Maps a single index type token (BTREE, HASH, FULLTEXT, SPATIAL, matched case-insensitively) to the two rendering fragments CREATE INDEX needs: a leading class keyword (with a trailing space, empty for the type tokens) and a trailing USING clause (with a leading space, empty for the class tokens). Exactly one of the two is non-empty for a recognised token.
Returns the empty list for undef, an empty string, or an unrecognised token. The distinction is deliberately left to the caller: this function only maps, it never croaks. DBIO::MySQL::DDL refuses an unrecognised using value (and the UNIQUE/class combination) at DDL-generation time, naming the offending index; DBIO::MySQL::Diff::Index, whose token comes from the server's own introspect, falls back to a plain CREATE INDEX.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.