File: binary_to_hex.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (93 lines) | stat: -rw-r--r-- 2,790 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# === Purpose ===
# The purpose of this test case is to make
# sure that the binary data in tables is printed
# as hex when the option binary-as-hex is enabled.
#
# === Related bugs and/or worklogs ===
# Bug #25340722 - PRINT BINARY DATA AS HEX IN THE MYSQL
#                 CLIENT (CONTRIBUTION)
#

# Save the initial number of concurrent sessions
--source include/count_sessions.inc

USE test;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

CREATE TABLE t1 (c1  TINYBLOB,
                 c2  BLOB,
                 c3  MEDIUMBLOB,
                 c4  LONGBLOB,
                 c5  TEXT,
                 c6  BIT(1),
                 c7  CHAR,
                 c8  VARCHAR(10),
                 c9  GEOMETRY) CHARACTER SET = binary;

SHOW CREATE TABLE t1;

INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable',
                       'mediumblob-text readable', 'longblob-text readable',
                       'text readable', b'1', 'c', 'variable',
                        POINT(1, 1));

CREATE TABLE t2(id int, `col1` binary(10),`col2` blob);

SHOW CREATE TABLE t2;

INSERT INTO t2 VALUES (1, X'AB1234', X'123ABC'), (2, X'DE1234', X'123DEF');

--echo #Print the table contents when binary-as-hex option is off.
--replace_column 6 # 9 #
SELECT * FROM t1;

--replace_column 2 # 3 #
SELECT * FROM t2;

--echo #Print the table contents after turning on the binary-as-hex option
--echo
--echo #Print the table contents in tab format
--echo
--exec $MYSQL test --binary-as-hex -e "SELECT * FROM t1; SELECT * FROM t2;"
--echo
--echo #Print the table contents in table format
--echo
--exec $MYSQL test --binary-as-hex --table -e "SELECT * FROM t1; SELECT * FROM t2 WHERE col2=0x123ABC;"
--echo
--echo #Print the table contents vertically
--echo
--exec $MYSQL test --binary-as-hex --vertical -e "SELECT * FROM t1;"
--echo
--echo #Print the table contents in xml format
--echo
--exec $MYSQL test --binary-as-hex --xml -e "SELECT * FROM t1; SELECT * FROM t2;"
--echo
--echo #Print the table contents in html format
--echo
--exec $MYSQL test --binary-as-hex --html -e "SELECT * FROM t1; SELECT * FROM t2;"

#Cleanup
DROP TABLE t1, t2;

--echo #
--echo # Bug #32961656: MYSQL CLIENT RETURNS NULL FOR EMPTY STRING WHEN --BINARY-AS-HEX=1
--echo #

--echo
--echo # "SELECT _binary''"
--exec $MYSQL test --binary-as-hex -e "SELECT _binary'';"
--echo 
--echo # "SELECT _binary''" XML
--exec $MYSQL test --binary-as-hex --xml -e "SELECT _binary'';"
--echo
--echo # "SELECT _binary''" HTML
--exec $MYSQL test --binary-as-hex --html -e "SELECT _binary'';"
--echo
--echo
--echo # "SELECT _binary''" VERTICAL
--exec $MYSQL test --binary-as-hex --vertical -e "SELECT _binary'';"

# Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc