1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-31948 Add class DBNameBuffer, split check_db_name() into stages

- Adding a class Lex_ident_fs, to store identifiers for on-disk
  database objects, such as databases, tables, triggers.

- Moving the validation code from check_db_name()
  to non-modifying methods in Lex_ident_fs:

    Lex_ident_fs::check_body()
    Lex_ident_fs::check_db_name()

  Adding a new method Lex_ident_fs::check_db_name_with_error(),
  which performs validation and raises an error on validation failure.

  Unlike the old function check_db_name(), the new class Lex_ident_fs
  does not lower-case the identifier during the validation.
  Lower-casing must be done before calling Lex_ident_fs validation methods.

- Adding a low level helper template class CharBuffer which can:
  * store exact or lower-cased strings with a short fixed maximum length
  * return the value as a LEX_CSTRING efficiently

- Adding a helper template class DBNameBuffer (deriving from CharBuffer), to
  allocate optionally lower-cased database identifiers on stack when relevant.
  Useful for temporary values which don't need to be allocated on MEM_ROOT.

- Using DBNameBuffer in mysql_change_db()

- Using DBNameBuffer in show_create_db()
This commit is contained in:
Alexander Barkov
2023-08-17 13:49:46 +04:00
parent 8528eaccb2
commit b956a6a259
8 changed files with 281 additions and 40 deletions

View File

@ -164,3 +164,30 @@ delete from mysql.proc where name = '';
#
# End of 10.3 tests
#
#
# Start of 11.3 tests
#
#
# MDEV-31948 Add class DBNameBuffer, split check_db_name() into stages
#
SET NAMES utf8;
SET @mb3char= _utf8 0xEFBFAD;
EXECUTE IMMEDIATE CONCAT('use `', REPEAT(@mb3char, 64), '`');
ERROR 42000: Unknown database '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■'
EXECUTE IMMEDIATE CONCAT('use `#mysql50#', REPEAT(@mb3char, 64), '`');
ERROR 42000: Unknown database '#mysql50#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■'
EXECUTE IMMEDIATE CONCAT('SHOW CREATE DATABASE `', REPEAT(@mb3char, 64), '`');
ERROR 42000: Unknown database '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■'
EXECUTE IMMEDIATE CONCAT('SHOW CREATE DATABASE `#mysql50#', REPEAT(@mb3char, 64), '`');
ERROR 42000: Unknown database '#mysql50#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■'
EXECUTE IMMEDIATE CONCAT('use `', REPEAT(@mb3char, 65), '`');
ERROR 42000: Incorrect database name '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■...'
EXECUTE IMMEDIATE CONCAT('use `#mysql50#', REPEAT(@mb3char, 65), '`');
ERROR 42000: Incorrect database name '#mysql50#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■...'
EXECUTE IMMEDIATE CONCAT('SHOW CREATE DATABASE `', REPEAT(@mb3char, 65), '`');
ERROR 42000: Incorrect database name '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■...'
EXECUTE IMMEDIATE CONCAT('SHOW CREATE DATABASE `#mysql50#', REPEAT(@mb3char, 65), '`');
ERROR 42000: Incorrect database name '#mysql50#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■...'
#
# End of 11.3 tests
#