mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-04 12:56:14 +01:00 
			
		
		
		
	- 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 cp932
 | 
						||
SET NAMES cp932;
 | 
						||
 | 
						||
--let $MYSQLD_DATADIR= `select @@datadir`
 | 
						||
 | 
						||
# simple I/O
 | 
						||
--exec echo "‘ªŽŽŽ‘—¿" | $MARIADB_CONV -f cp932 -t filename --delimiter="\r\n"
 | 
						||
--exec echo "@6e2c@8a66@8cc7@6599@5eab" | $MARIADB_CONV -f filename -t cp932 --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 cp932 --delimiter="\r\n"
 | 
						||
 | 
						||
--let $reverse_query_result=`SELECT CONVERT(_filename '@6e2c@8a66@8cc7@6599@5eab' USING cp932);`
 | 
						||
--echo $reverse_query_result
 | 
						||
--exec echo $reverse_query_result | $MARIADB_CONV -f cp932 -t filename  --delimiter="\r\n"
 | 
						||
 | 
						||
--echo # bulk convert with pipe
 | 
						||
 | 
						||
CREATE TABLE t1 (id SERIAL, a VARCHAR(64) CHARACTER SET cp932);
 | 
						||
INSERT INTO t1 (a) VALUES ('‘ªŽŽŽ‘—¿'), ('‘ªŽŽŽ‘—¿2');
 | 
						||
--exec $MYSQL -Dtest --default-character-set=cp932 -e "SELECT a FROM t1 ORDER BY id" | $MARIADB_CONV -f cp932 -t filename --delimiter="\r\n"
 | 
						||
--exec $MYSQL -Dtest --default-character-set=cp932 -e "SELECT BINARY CONVERT(a USING filename) FROM t1 ORDER BY id"
 | 
						||
--exec $MYSQL -Dtest --default-character-set=cp932 --column-names=0 -e "SELECT BINARY CONVERT(a USING filename) FROM t1 ORDER BY id" | $MARIADB_CONV -f filename -t cp932 --delimiter="\r\n"
 | 
						||
--exec $MYSQL -Dtest --default-character-set=cp932 --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 cp932  --delimiter="\r\n"
 | 
						||
--exec $MYSQL -Dtest --default-character-set=cp932 --column-names=0 -e "SELECT CONCAT('test/', BINARY CONVERT(a USING filename),'.frm') FROM t1 ORDER BY id" | $MARIADB_CONV -f filename -t cp932  --delimiter="/.\r\n"
 | 
						||
DROP TABLE t1;
 | 
						||
 | 
						||
 | 
						||
--echo # bulk convert with file
 | 
						||
--write_file $MYSQL_TMP_DIR/mysql-conv-test-cp932.txt
 | 
						||
 | 
						||
‘ªŽŽŽ‘—¿
 | 
						||
 | 
						||
‘ªŽŽŽ‘—¿2
 | 
						||
‘ªŽŽŽ‘—¿3
 | 
						||
 | 
						||
EOF
 | 
						||
 | 
						||
--echo # --- Start of mariadb-conv for mysql-conv-test-cp932.txt ---
 | 
						||
--exec $MARIADB_CONV -f cp932 -t filename  --delimiter="\r\n" $MYSQL_TMP_DIR/mysql-conv-test-cp932.txt
 | 
						||
--echo # --- End of mariadb-conv for mysql-conv-test-cp932.txt ---
 | 
						||
 | 
						||
--copy_file $MYSQL_TMP_DIR/mysql-conv-test-cp932.txt $MYSQL_TMP_DIR/mysql-conv-test-cp932-2.txt
 | 
						||
--echo # --- Start of mariadb-conv for mysql-conv-test-cp932.txt and mysql-conv-test-cp932-2.txt ---
 | 
						||
--exec $MARIADB_CONV -f cp932 -t filename  --delimiter="\r\n" $MYSQL_TMP_DIR/mysql-conv-test-cp932.txt $MYSQL_TMP_DIR/mysql-conv-test-cp932-2.txt
 | 
						||
--echo # --- Start of mariadb-conv for mysql-conv-test-cp932.txt and mysql-conv-test-cp932-2.txt ---
 | 
						||
 | 
						||
--remove_file $MYSQL_TMP_DIR/mysql-conv-test-cp932.txt
 | 
						||
--remove_file $MYSQL_TMP_DIR/mysql-conv-test-cp932-2.txt
 |