mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
2c7b6214e7
- 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
57 lines
2.8 KiB
Text
57 lines
2.8 KiB
Text
-- source include/not_embedded.inc
|
|
|
|
--echo #
|
|
--echo # MDEV-17088 Provide tools to encode/decode mysql-encoded file system names
|
|
--echo #
|
|
|
|
--character_set utf8
|
|
SET NAMES utf8;
|
|
|
|
--let $MYSQLD_DATADIR= `select @@datadir`
|
|
|
|
# simple I/O
|
|
--exec echo "測試資料" | $MARIADB_CONV -f utf8 -t filename --delimiter="\r\n"
|
|
--exec echo "@6e2c@8a66@8cc7@6599@5eab" | $MARIADB_CONV -f filename -t utf8 --delimiter="\r\n"
|
|
|
|
# undo query result
|
|
--let $query_result=`SELECT CONVERT(CONVERT('測試資料' USING filename) USING binary);`
|
|
--echo $query_result
|
|
--exec echo $query_result | $MARIADB_CONV -f filename -t utf8 --delimiter="\r\n"
|
|
|
|
--let $reverse_query_result=`SELECT CONVERT(_filename '@6e2c@8a66@8cc7@6599@5eab' USING utf8);`
|
|
--echo $reverse_query_result
|
|
--exec echo $reverse_query_result | $MARIADB_CONV -f utf8 -t filename --delimiter="\r\n"
|
|
|
|
--echo # bulk convert with pipe
|
|
|
|
CREATE TABLE t1 (id SERIAL, a VARCHAR(64) CHARACTER SET utf8);
|
|
INSERT INTO t1 (a) VALUES ('測試資料'), ('測試資料2');
|
|
--exec $MYSQL -Dtest --default-character-set=utf8 -e "SELECT a FROM t1 ORDER BY id" | $MARIADB_CONV -f utf8 -t filename --delimiter="\r\n"
|
|
--exec $MYSQL -Dtest --default-character-set=utf8 -e "SELECT BINARY CONVERT(a USING filename) FROM t1 ORDER BY id"
|
|
--exec $MYSQL -Dtest --default-character-set=utf8 --column-names=0 -e "SELECT BINARY CONVERT(a USING filename) FROM t1 ORDER BY id" | $MARIADB_CONV -f filename -t utf8 --delimiter="\r\n"
|
|
--exec $MYSQL -Dtest --default-character-set=utf8 --column-names=0 -e "SELECT CONCAT('test/', BINARY CONVERT(a USING filename),'.frm') FROM t1 ORDER BY id" | $REPLACE "/" "@002f" "." "@002e"| $MARIADB_CONV -f filename -t utf8 --delimiter="\r\n"
|
|
--exec $MYSQL -Dtest --default-character-set=utf8 --column-names=0 -e "SELECT CONCAT('test/', BINARY CONVERT(a USING filename),'.frm') FROM t1 ORDER BY id" | $MARIADB_CONV -f filename -t utf8 --delimiter="/.\r\n"
|
|
DROP TABLE t1;
|
|
|
|
|
|
--echo # bulk convert with file
|
|
--write_file $MYSQL_TMP_DIR/mysql-conv-test-utf8.txt
|
|
|
|
測試資料
|
|
|
|
測試資料2
|
|
測試資料3
|
|
|
|
EOF
|
|
|
|
--echo # --- Start of mariadb-conv for mysql-conv-test-utf8.txt ---
|
|
--exec $MARIADB_CONV -f utf8 -t filename --delimiter="\r\n" $MYSQL_TMP_DIR/mysql-conv-test-utf8.txt
|
|
--echo # --- End of mariadb-conv for mysql-conv-test-utf8.txt ---
|
|
|
|
--copy_file $MYSQL_TMP_DIR/mysql-conv-test-utf8.txt $MYSQL_TMP_DIR/mysql-conv-test-utf8-2.txt
|
|
--echo # --- Start of mariadb-conv for mysql-conv-test-utf8.txt and mysql-conv-test-utf8-2.txt ---
|
|
--exec $MARIADB_CONV -f utf8 -t filename --delimiter="\r\n" $MYSQL_TMP_DIR/mysql-conv-test-utf8.txt $MYSQL_TMP_DIR/mysql-conv-test-utf8-2.txt
|
|
--echo # --- Start of mariadb-conv for mysql-conv-test-utf8.txt and mysql-conv-test-utf8-2.txt ---
|
|
|
|
--remove_file $MYSQL_TMP_DIR/mysql-conv-test-utf8.txt
|
|
--remove_file $MYSQL_TMP_DIR/mysql-conv-test-utf8-2.txt
|