1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

A cleanup for MDEV-17088 Provide tools to encode/decode mysql-encoded file system names

- Load and convert the entire input file at once,
  rather than reading string-by-string using fgets().
  This change makes it possible to convert from UCS2, UTF16, UTF32 data.
- Adding the --delimiter command, to treat the specified
  characters as delimiters rather than data to convert.
  Useful in combination with `-f filename` or `-t filename`.
  The delimiter characters are not converted,
  they are copied from the input to the output as is.
- Adding diagnostics with line number and position if:
  * an illegal input byte sequence was found
  * a character cannot be converted to the target character set
This commit is contained in:
Alexander Barkov
2019-12-03 17:21:25 +04:00
parent 42a4ae54c2
commit 2c7b6214e7
13 changed files with 415 additions and 70 deletions

View File

@@ -6,8 +6,8 @@
--echo # default encoding
--exec echo "t1" | $MARIADB_CONV
--exec echo "t1" | $MARIADB_CONV -f filename
--exec echo "t1" | $MARIADB_CONV -t filename
--exec echo "t1" | $MARIADB_CONV -f filename --delimiter="\r\n"
--exec echo "t1" | $MARIADB_CONV -t filename --delimiter="\r\n"
--echo # invalid option
--replace_regex /.*mariadb-conv.*: unknown/mariadb-conv: unknown/
@@ -23,3 +23,17 @@
--replace_regex /.*mariadb-conv.*: unknown/mariadb-conv: unknown/
--error 1
--exec echo "t1" | $MARIADB_CONV -f unknown-cs -t latin1 2>&1 > /dev/null
--echo # Bad delimiter
--error 1
--exec echo "t1" | $MARIADB_CONV --delimiter="\x" 2>&1 > /dev/null
--echo # Conversion error
--error 1
--exec $MARIADB_CONV -f utf8 -t latin1 < $MYSQL_TEST_DIR/std_data/mariadb-conv/file01.utf8.txt 2>&1
--exec $MARIADB_CONV -f utf8 -t latin1 -c < $MYSQL_TEST_DIR/std_data/mariadb-conv/file01.utf8.txt 2>&1
--echo # Bad input character
--error 1
--exec $MARIADB_CONV -f utf8 -t latin1 < $MYSQL_TEST_DIR/std_data/mariadb-conv/file02.latin1.txt 2>&1
--exec $MARIADB_CONV -f utf8 -t latin1 -c < $MYSQL_TEST_DIR/std_data/mariadb-conv/file02.latin1.txt 2>&1