Skip to content

Commit 1110bec

Browse files
committed
Merge 10.5 into 10.6
2 parents 8a495d7 + b76e5c6 commit 1110bec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1814
-1446
lines changed

client/mysql_upgrade.c

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static my_bool upgrade_from_mysql;
5151

5252
static DYNAMIC_STRING ds_args;
5353
static DYNAMIC_STRING conn_args;
54+
static DYNAMIC_STRING ds_plugin_data_types;
5455

5556
static char *opt_password= 0;
5657
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
@@ -187,6 +188,7 @@ static void free_used_memory(void)
187188

188189
dynstr_free(&ds_args);
189190
dynstr_free(&conn_args);
191+
dynstr_free(&ds_plugin_data_types);
190192
if (cnf_file_path)
191193
my_delete(cnf_file_path, MYF(MY_WME));
192194
}
@@ -965,6 +967,73 @@ static my_bool from_before_10_1()
965967
}
966968

967969

970+
static void uninstall_plugins(void)
971+
{
972+
if (ds_plugin_data_types.length)
973+
{
974+
char *plugins= ds_plugin_data_types.str;
975+
char *next= get_line(plugins);
976+
char buff[512];
977+
while(*plugins)
978+
{
979+
if (next[-1] == '\n')
980+
next[-1]= 0;
981+
verbose("uninstalling plugin for %s data type", plugins);
982+
strxnmov(buff, sizeof(buff)-1, "UNINSTALL SONAME ", plugins,"", NULL);
983+
run_query(buff, NULL, TRUE);
984+
plugins= next;
985+
next= get_line(next);
986+
}
987+
}
988+
}
989+
/**
990+
@brief Install plugins for missing data types
991+
@details Check for entries with "Unknown data type" in I_S.TABLES,
992+
try to load plugins for these tables if available (MDEV-24093)
993+
994+
@return Operation status
995+
@retval TRUE - error
996+
@retval FALSE - success
997+
*/
998+
static int install_used_plugin_data_types(void)
999+
{
1000+
DYNAMIC_STRING ds_result;
1001+
const char *query = "SELECT table_comment FROM information_schema.tables"
1002+
" WHERE table_comment LIKE 'Unknown data type: %'";
1003+
if (init_dynamic_string(&ds_result, "", 512, 512))
1004+
die("Out of memory");
1005+
run_query(query, &ds_result, TRUE);
1006+
1007+
if (ds_result.length)
1008+
{
1009+
char *line= ds_result.str;
1010+
char *next= get_line(line);
1011+
while(*line)
1012+
{
1013+
if (next[-1] == '\n')
1014+
next[-1]= 0;
1015+
if (strstr(line, "'MYSQL_JSON'"))
1016+
{
1017+
verbose("installing plugin for MYSQL_JSON data type");
1018+
if(!run_query("INSTALL SONAME 'type_mysql_json'", NULL, TRUE))
1019+
{
1020+
dynstr_append(&ds_plugin_data_types, "'type_mysql_json'");
1021+
dynstr_append(&ds_plugin_data_types, "\n");
1022+
break;
1023+
}
1024+
else
1025+
{
1026+
fprintf(stderr, "... can't %s\n", "INSTALL SONAME 'type_mysql_json'");
1027+
return 1;
1028+
}
1029+
}
1030+
line= next;
1031+
next= get_line(next);
1032+
}
1033+
}
1034+
dynstr_free(&ds_result);
1035+
return 0;
1036+
}
9681037
/*
9691038
Check for entries with "Unknown storage engine" in I_S.TABLES,
9701039
try to load plugins for these tables if available (MDEV-11942)
@@ -1218,7 +1287,8 @@ int main(int argc, char **argv)
12181287
}
12191288

12201289
if (init_dynamic_string(&ds_args, "", 512, 256) ||
1221-
init_dynamic_string(&conn_args, "", 512, 256))
1290+
init_dynamic_string(&conn_args, "", 512, 256) ||
1291+
init_dynamic_string(&ds_plugin_data_types, "", 512, 256))
12221292
die("Out of memory");
12231293

12241294
if (handle_options(&argc, &argv, my_long_options, get_one_option))
@@ -1281,13 +1351,15 @@ int main(int argc, char **argv)
12811351
*/
12821352
if (run_mysqlcheck_upgrade(TRUE) ||
12831353
install_used_engines() ||
1354+
install_used_plugin_data_types() ||
12841355
run_mysqlcheck_views() ||
12851356
run_sql_fix_privilege_tables() ||
12861357
run_mysqlcheck_fixnames() ||
12871358
run_mysqlcheck_upgrade(FALSE) ||
12881359
check_slave_repositories())
12891360
die("Upgrade failed" );
12901361

1362+
uninstall_plugins();
12911363
verbose("Phase %d/%d: Running 'FLUSH PRIVILEGES'", ++phase, phases_total);
12921364
if (run_query("FLUSH PRIVILEGES", NULL, TRUE))
12931365
die("Upgrade failed" );

cmake/for_clients.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ REPLACE_FOR_CLIENTS(CFLAGS "[DU]DBUG_OFF" "[DU]SAFE_MUTEX" "[DU]NDEBUG"
7070

7171
# Same for --libs
7272
REPLACE_FOR_CLIENTS(LIBS "Wl,[^ ]*" lmtmalloc static-libcxa i-static static-intel)
73-
REPLACE_FOR_CLIENTS(EMB_LIBS lmtmalloc static-libcxa i-static static-intel)
73+
REPLACE_FOR_CLIENTS(EMB_LIBS lmtmalloc static-libcxa i-static static-intel ltpool)
7474

include/my_global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# if defined(__i386__) || defined(__ppc__)
153153
# define SIZEOF_CHARP 4
154154
# define SIZEOF_LONG 4
155-
# elif defined(__x86_64__) || defined(__ppc64__)
155+
# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) || defined(__arm64__)
156156
# define SIZEOF_CHARP 8
157157
# define SIZEOF_LONG 8
158158
# else
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (!$TYPE_MYSQL_JSON_SO) {
2+
skip Need MYSQL_JSON plugin;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--loose-type_mysql_json
2+
--plugin-load-add=$TYPE_MYSQL_JSON_SO
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#
2+
# MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so
3+
# is needed and load it
4+
#
5+
SET NAMES utf8;
6+
show create table mysql_json_test;
7+
ERROR HY000: Unknown data type: 'MYSQL_JSON'
8+
Phase 1/7: Checking and upgrading mysql database
9+
Processing databases
10+
mysql
11+
mysql.column_stats OK
12+
mysql.columns_priv OK
13+
mysql.db OK
14+
mysql.event OK
15+
mysql.func OK
16+
mysql.global_priv OK
17+
mysql.gtid_slave_pos OK
18+
mysql.help_category OK
19+
mysql.help_keyword OK
20+
mysql.help_relation OK
21+
mysql.help_topic OK
22+
mysql.index_stats OK
23+
mysql.innodb_index_stats
24+
Error : Unknown storage engine 'InnoDB'
25+
error : Corrupt
26+
mysql.innodb_table_stats
27+
Error : Unknown storage engine 'InnoDB'
28+
error : Corrupt
29+
mysql.plugin OK
30+
mysql.proc OK
31+
mysql.procs_priv OK
32+
mysql.proxies_priv OK
33+
mysql.roles_mapping OK
34+
mysql.servers OK
35+
mysql.table_stats OK
36+
mysql.tables_priv OK
37+
mysql.time_zone OK
38+
mysql.time_zone_leap_second OK
39+
mysql.time_zone_name OK
40+
mysql.time_zone_transition OK
41+
mysql.time_zone_transition_type OK
42+
mysql.transaction_registry
43+
Error : Unknown storage engine 'InnoDB'
44+
error : Corrupt
45+
46+
Repairing tables
47+
mysql.innodb_index_stats
48+
Error : Unknown storage engine 'InnoDB'
49+
error : Corrupt
50+
mysql.innodb_table_stats
51+
Error : Unknown storage engine 'InnoDB'
52+
error : Corrupt
53+
mysql.transaction_registry
54+
Error : Unknown storage engine 'InnoDB'
55+
error : Corrupt
56+
Phase 2/7: Installing used storage engines... Skipped
57+
installing plugin for MYSQL_JSON data type
58+
Phase 3/7: Fixing views
59+
mysql.user OK
60+
Phase 4/7: Running 'mysql_fix_privilege_tables'
61+
Phase 5/7: Fixing table and database names
62+
Phase 6/7: Checking and upgrading tables
63+
Processing databases
64+
information_schema
65+
mtr
66+
mtr.global_suppressions OK
67+
mtr.test_suppressions OK
68+
performance_schema
69+
test
70+
test.mysql_json_test Needs upgrade
71+
test.mysql_json_test_big Needs upgrade
72+
73+
Repairing tables
74+
test.mysql_json_test OK
75+
test.mysql_json_test_big OK
76+
uninstalling plugin for 'type_mysql_json' data type
77+
Phase 7/7: Running 'FLUSH PRIVILEGES'
78+
OK
79+
show create table mysql_json_test;
80+
Table Create Table
81+
mysql_json_test CREATE TABLE `mysql_json_test` (
82+
`description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
83+
`expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
84+
`actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
85+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
86+
select * from mysql_json_test;
87+
description expected actual
88+
Raw integers as JSON 0 0
89+
Raw integers as JSON -127 -127
90+
Raw integers as JSON 128 128
91+
Raw integers as JSON 32767 32767
92+
Raw integers as JSON -32768 -32768
93+
Raw integers as JSON 65535 65535
94+
Raw integers as JSON 65536 65536
95+
Raw integers as JSON -2147483648 -2147483648
96+
Raw integers as JSON 2147483647 2147483647
97+
Raw integers as JSON 4294967295 4294967295
98+
Raw integers as JSON -9223372036854775807 -9223372036854775807
99+
Raw integers as JSON 9223372036854775807 9223372036854775807
100+
Raw integers as JSON 18446744073709551615 18446744073709551615
101+
Raw doubles as JSON 3.14 3.14
102+
Raw doubles as JSON -5678.987 -5678.987
103+
Raw doubles as JSON -2.2250738585072014e-308 -2.2250738585072014e-308
104+
Raw doubles as JSON 2.2250738585072014e-308 2.2250738585072014e-308
105+
Simple JSON test {"key1": "val1", "key2": "val2"} {"key1": "val1", "key2": "val2"}
106+
Raw doubles as JSON 0.0 0.0
107+
Simple Array as Value {"a": [1, 2], "b": ["x", "y"]} {"a": [1, 2], "b": ["x", "y"]}
108+
Simple Array as Base Key [1, 2, 3, 4, 5, [], "a", "b", "c"] [1, 2, 3, 4, 5, [], "a", "b", "c"]
109+
GeoJSON {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]} {"type": "MultiPoint", "coordinates": [[1, 1], [2, 2], [3, 3]]}
110+
GeoJSON {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]} {"type": "LineString", "coordinates": [[0, 5], [5, 10], [10, 15]]}
111+
GeoJSON {"type": "GeometryCollection", "geometries": []} {"type": "GeometryCollection", "geometries": []}
112+
GeoJSON {"type": "Point", "coordinates": [11.1111, 12.22222]} {"type": "Point", "coordinates": [11.1111, 12.22222]}
113+
Opaque Types: opaque_mysql_type_set "b,c" "b,c"
114+
Opaque Types: opaque_mysql_type_enum "b" "b"
115+
Opaque Types: opaque_mysql_type_date "2015-01-15" "2015-01-15"
116+
Opaque Types: opaque_mysql_type_time "23:24:25.000000" "23:24:25.000000"
117+
Opaque Types: opaque_mysql_type_datetime "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000"
118+
Opaque Types: opaque_mysql_type_geom {"type": "Point", "coordinates": [1, 1]} {"type": "Point", "coordinates": [1, 1]}
119+
Opaque Types: opaque_mysql_type_bit "base64:type16:yv4=" "base64:type16:yv4="
120+
Opaque Types: opaque_mysql_type_year "base64:type13:MjAxOQ==" "base64:type13:MjAxOQ=="
121+
Opaque Types: opaque_mysql_type_blob "base64:type252:yv66vg==" "base64:type252:yv66vg=="
122+
Opaque Types: opaque_mysql_type_longblob "base64:type251:yv66vg==" "base64:type251:yv66vg=="
123+
Opaque Types: opaque_mysql_type_mediumblob "base64:type250:yv66vg==" "base64:type250:yv66vg=="
124+
Opaque Types: opaque_mysql_type_tinyblob "base64:type249:yv66vg==" "base64:type249:yv66vg=="
125+
Opaque Types: opaque_mysql_type_varchar "base64:type15:Zm9v" "base64:type15:Zm9v"
126+
DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000"
127+
Opaque Types: opaque_mysql_type_varbinary "base64:type15:YWJj" "base64:type15:YWJj"
128+
Opaque Types: opaque_mysql_type_binary "base64:type254:YWJjAAAAAAAAAA==" "base64:type254:YWJjAAAAAAAAAA=="
129+
DateTime as Raw Value: "23:24:25.000000" "23:24:25.000000"
130+
DateTime as Raw Value: "2015-01-15" "2015-01-15"
131+
DateTime as Raw Value: "2015-01-15 23:24:25.000000" "2015-01-15 23:24:25.000000"
132+
UTF8 Characters: {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćč"}} {"Person": "EMP", "details": {"Name": "Anel Husaković - test: đžšćč"}}
133+
UTF8 Characters: "Anel Husaković - test: đžšćč" "Anel Husaković - test: đžšćč"
134+
UTF8 Characters: {"Name": "Anel Husaković - test: đžšćč"} {"Name": "Anel Husaković - test: đžšćč"}
135+
UTF8 Characters: {"details": {"Name": "Anel Husaković - test: đžšćč"}, "\"Anel Husaković - test: đžšćč\"": "EMP"} {"details": {"Name": "Anel Husaković - test: đžšćč"}, "\"Anel Husaković - test: đžšćč\"": "EMP"}
136+
Special Characters: {"{": "}"} {"{": "}"}
137+
Special Characters: "key1 - with \" val " "key1 - with \" val "
138+
Special Characters: {"key1 and \n\"key2\"": "val1\t val2"} {"key1 and \n\"key2\"": "val1\t val2"}
139+
Special Characters: "'" "'"
140+
Special Characters: "q" "q"
141+
Special Characters: {"[": "]"} {"[": "]"}
142+
Special Characters: {"{": "}"} {"{": "}"}
143+
Empty JSON Object/Array: [] []
144+
Special Characters: "some_string" "some_string"
145+
Special Characters: "'" "'"
146+
Special Characters: "\"" "\""
147+
Special Characters: "" ""
148+
Special Characters: "'" "'"
149+
Special Characters: "''" "''"
150+
Empty JSON Object/Array: {} {}
151+
Special Characters: "f" "f"
152+
Special Characters: "\\" "\\"
153+
Special Characters: "\n" "\n"
154+
Special Characters: "\f" "\f"
155+
Special Characters: "\t" "\t"
156+
Special Characters: "\r" "\r"
157+
Special Characters: "\b" "\b"
158+
Special Characters: "\\b" "\\b"
159+
Special Characters: {"key \n key": "val \n val"} {"key \n key": "val \n val"}
160+
Special Characters: {"key \f key": "val \f val"} {"key \f key": "val \f val"}
161+
Special Characters: {"key \t key": "val \t val"} {"key \t key": "val \t val"}
162+
Special Characters: {"key \r key": "val \r val"} {"key \r key": "val \r val"}
163+
Special Characters: {"key \b key": "val \b val"} {"key \b key": "val \b val"}
164+
Special Characters: {"key \\0 key": "val \n val"} {"key \\0 key": "val \n val"}
165+
Special Characters: {"key \\ key": "val \\ val"} {"key \\ key": "val \\ val"}
166+
Special Characters: {"key \" key": "val \" val"} {"key \" key": "val \" val"}
167+
Special Characters: {"key ' key": "val ' val"} {"key ' key": "val ' val"}
168+
Special Characters: {"key \\Z key": "val ' val"} {"key \\Z key": "val ' val"}
169+
Special Characters: ["a \f b", "c \f d"] ["a \f b", "c \f d"]
170+
Special Characters: ["a \t b", "c \t d"] ["a \t b", "c \t d"]
171+
Special Characters: ["a \r b", "c \r d"] ["a \r b", "c \r d"]
172+
Special Characters: ["a \b b", "c \b d"] ["a \b b", "c \b d"]
173+
Special Characters: ["a \\ b", "c \\ d"] ["a \\ b", "c \\ d"]
174+
Special Characters: ["a \" b", "c \" d"] ["a \" b", "c \" d"]
175+
Special Characters: ["a ' b", "c ' d"] ["a ' b", "c ' d"]
176+
Special String Cases: {"": ""} {"": ""}
177+
Special String Cases: [""] [""]
178+
Raw LITERALS: true true
179+
Raw LITERALS: false false
180+
Raw LITERALS: null null
181+
JSON LITERALS: {"val": true} {"val": true}
182+
JSON LITERALS: {"val": false} {"val": false}
183+
JSON LITERALS: {"val": null} {"val": null}
184+
Timestamp as RawValue "2019-12-26 19:56:03.000000" "2019-12-26 19:56:03.000000"
185+
Array LITERALS: ["prefix", null, "suffix", 1] ["prefix", null, "suffix", 1]
186+
Array LITERALS: ["prefix", false, "suffix", 1] ["prefix", false, "suffix", 1]
187+
Array LITERALS: ["prefix", true, "suffix", 1] ["prefix", true, "suffix", 1]
188+
show create table mysql_json_test_big;
189+
Table Create Table
190+
mysql_json_test_big CREATE TABLE `mysql_json_test_big` (
191+
`description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
192+
`expected` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
193+
`actual` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
194+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
195+
select * from mysql.plugin;
196+
name dl
197+
drop table mysql_json_test;
198+
drop table mysql_json_test_big;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--echo #
2+
--echo # MDEV-24093: Detect during mysql_upgrade if type_mysql_json.so
3+
--echo # is needed and load it
4+
--echo #
5+
6+
-- source include/have_utf8.inc
7+
-- source include/mysql_upgrade_preparation.inc
8+
9+
SET NAMES utf8;
10+
11+
let $MYSQLD_DATADIR= `select @@datadir`;
12+
13+
--copy_file std_data/mysql_json/mysql_json_test.frm $MYSQLD_DATADIR/test/mysql_json_test.frm
14+
--copy_file std_data/mysql_json/mysql_json_test.MYI $MYSQLD_DATADIR/test/mysql_json_test.MYI
15+
--copy_file std_data/mysql_json/mysql_json_test.MYD $MYSQLD_DATADIR/test/mysql_json_test.MYD
16+
17+
--copy_file std_data/mysql_json/mysql_json_test_big.frm $MYSQLD_DATADIR/test/mysql_json_test_big.frm
18+
--copy_file std_data/mysql_json/mysql_json_test_big.MYI $MYSQLD_DATADIR/test/mysql_json_test_big.MYI
19+
--copy_file std_data/mysql_json/mysql_json_test_big.MYD $MYSQLD_DATADIR/test/mysql_json_test_big.MYD
20+
21+
--error ER_UNKNOWN_DATA_TYPE
22+
show create table mysql_json_test;
23+
24+
--exec $MYSQL_UPGRADE --force 2>&1
25+
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
26+
27+
show create table mysql_json_test;
28+
select * from mysql_json_test;
29+
show create table mysql_json_test_big;
30+
select * from mysql.plugin;
31+
drop table mysql_json_test;
32+
drop table mysql_json_test_big;

0 commit comments

Comments
 (0)