Skip to content

Commit 1705917

Browse files
author
Grzegorz Szwarc
committed
BUG#24848125: COLLECTION NAMES WITH DIFFERENT CASING ARE HIDDEN ON UBUNTU 14.04
Description: X Plugin hides collections if the names have any letter in a different case; for example, flags or Flags or flagS where the OS is Linux. Where the OS is Windows, creating flags, Flags, and flagS is not permitted. Solution: The 'list_objects' admin command SQL query has been improved to such form to take into account a size of letters in names of tables in a process of collecting them. Reviewed-by: Lukasz Kotula <[email protected]> RB: 15173
1 parent 690b35d commit 1705917

5 files changed

+152
-7
lines changed

rapid/plugin/x/src/admin_cmd_handler.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -1153,26 +1153,29 @@ ngs::Error_code xpl::Admin_command_handler::list_objects(Command_arguments &args
11531153
return error;
11541154

11551155
Query_string_builder qb;
1156-
qb.put("SELECT T.table_name AS name, "
1156+
qb.put("SELECT BINARY T.table_name AS name, "
11571157
"IF(ANY_VALUE(T.table_type) LIKE '%VIEW', "
1158-
"IF(COUNT(*)=1 AND ").put(COUNT_DOC).put("=1, 'COLLECTION_VIEW', 'VIEW'), "
1159-
"IF(COUNT(*)-2 = ")
1158+
"IF(COUNT(*)=1 AND ")
1159+
.put(COUNT_DOC)
1160+
.put("=1, 'COLLECTION_VIEW', 'VIEW'), IF(COUNT(*)-2 = ")
11601161
.put(COUNT_GEN)
11611162
.put(" AND ")
11621163
.put(COUNT_DOC)
11631164
.put("=1 AND ")
11641165
.put(COUNT_ID)
11651166
.put("=1, 'COLLECTION', 'TABLE')) AS type "
1166-
"FROM information_schema.tables AS T LEFT JOIN "
1167-
"information_schema.columns AS C USING (table_schema,table_name)"
1167+
"FROM information_schema.tables AS T "
1168+
"LEFT JOIN information_schema.columns AS C ON ("
1169+
"BINARY T.table_schema = C.table_schema AND "
1170+
"BINARY T.table_name = C.table_name) "
11681171
"WHERE T.table_schema = ");
11691172
if (schema.empty())
11701173
qb.put("schema()");
11711174
else
11721175
qb.quote_string(schema);
11731176
if (!pattern.empty())
11741177
qb.put(" AND T.table_name LIKE ").quote_string(pattern);
1175-
qb.put(" GROUP BY T.table_name ORDER BY T.table_name");
1178+
qb.put(" GROUP BY name ORDER BY name");
11761179

11771180
Sql_data_context::Result_info info;
11781181
error = m_da.execute_sql_and_stream_results(qb.get().data(),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
install plugin mysqlx soname "mysqlx.so";
2+
call mtr.add_suppression("Plugin mysqlx reported: .Failed at SSL configuration: .SSL context is not usable without certificate and private key..");
3+
call mtr.add_suppression("Plugin mysqlx reported: .SSL_CTX_load_verify_locations failed.");
4+
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
5+
6+
Creating collections with similar names
7+
---------------------------------------
8+
9+
command ok
10+
Got expected error: Table 'fruit' already exists (code 1050)
11+
name type
12+
fruit COLLECTION
13+
command ok
14+
15+
Creating collection in another schema with similar name
16+
-------------------------------------------------------
17+
Got expected error: Can't create database 'xtest'; database exists (code 1007)
18+
Got expected error: Table 'fruit' already exists (code 1050)
19+
name type
20+
fruit COLLECTION
21+
command ok
22+
Mysqlx.Ok {
23+
msg: "bye!"
24+
}
25+
ok
26+
DROP SCHEMA IF EXISTS xtest;
27+
UNINSTALL PLUGIN mysqlx;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
install plugin mysqlx soname "mysqlx.so";
2+
call mtr.add_suppression("Plugin mysqlx reported: .Failed at SSL configuration: .SSL context is not usable without certificate and private key..");
3+
call mtr.add_suppression("Plugin mysqlx reported: .SSL_CTX_load_verify_locations failed.");
4+
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
5+
6+
Creating collections with similar names
7+
---------------------------------------
8+
9+
command ok
10+
11+
command ok
12+
name type
13+
Fruit COLLECTION
14+
fruit COLLECTION
15+
command ok
16+
17+
Creating collection in another schema with similar name
18+
-------------------------------------------------------
19+
20+
1 rows affected
21+
22+
command ok
23+
name type
24+
Fruit COLLECTION
25+
fruit COLLECTION
26+
command ok
27+
name type
28+
fruiT COLLECTION
29+
command ok
30+
Mysqlx.Ok {
31+
msg: "bye!"
32+
}
33+
ok
34+
DROP SCHEMA IF EXISTS xtest;
35+
DROP SCHEMA IF EXISTS Xtest;
36+
UNINSTALL PLUGIN mysqlx;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Simple list objects with case insensitive table names
2+
3+
--source include/have_case_insensitive_file_system.inc
4+
--source ../include/xplugin_preamble.inc
5+
6+
## Test starts here
7+
--let $xtest_file= $MYSQL_TMP_DIR/admin_list_objects_table_names.tmp
8+
--write_file $xtest_file
9+
-->quiet
10+
## Test data
11+
12+
-->title -Creating collections with similar names
13+
-->stmtadmin create_collection {"schema":"xtest", "name":"fruit"}
14+
-->recvresult
15+
-->stmtadmin create_collection {"schema":"xtest", "name":"Fruit"}
16+
-->expecterror ER_TABLE_EXISTS_ERROR
17+
-->recvresult
18+
-->stmtadmin list_objects {"schema":"xtest", "pattern":"_rui_"}
19+
-->recvresult
20+
21+
-->title -Creating collection in another schema with similar name
22+
-->stmtsql CREATE SCHEMA Xtest DEFAULT CHARSET 'utf8mb4';
23+
-->expecterror ER_DB_CREATE_EXISTS
24+
-->recvresult
25+
-->stmtadmin create_collection {"schema":"Xtest", "name":"fruiT"}
26+
-->expecterror ER_TABLE_EXISTS_ERROR
27+
-->recvresult
28+
-->stmtadmin list_objects {"schema":"xtest", "pattern":"_rui_"}
29+
-->recvresult
30+
EOF
31+
32+
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
33+
34+
--exec $MYSQLXTEST -uroot --password='' --file=$xtest_file 2>&1
35+
36+
## Postamble
37+
--remove_file $xtest_file
38+
DROP SCHEMA IF EXISTS xtest;
39+
UNINSTALL PLUGIN mysqlx;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Simple list objects with case sensitive names
2+
3+
--source include/have_case_sensitive_file_system.inc
4+
--source ../include/xplugin_preamble.inc
5+
6+
## Test starts here
7+
--let $xtest_file= $MYSQL_TMP_DIR/admin_list_objects_table_names.tmp
8+
--write_file $xtest_file
9+
-->quiet
10+
## Test data
11+
12+
-->title -Creating collections with similar names
13+
-->stmtadmin create_collection {"schema":"xtest", "name":"fruit"}
14+
-->recvresult
15+
-->stmtadmin create_collection {"schema":"xtest", "name":"Fruit"}
16+
-->recvresult
17+
-->stmtadmin list_objects {"schema":"xtest", "pattern":"_rui_"}
18+
-->recvresult
19+
20+
-->title -Creating collection in another schema with similar name
21+
-->stmtsql CREATE SCHEMA Xtest DEFAULT CHARSET 'utf8mb4';
22+
-->recvresult
23+
-->stmtadmin create_collection {"schema":"Xtest", "name":"fruiT"}
24+
-->recvresult
25+
-->stmtadmin list_objects {"schema":"xtest", "pattern":"_rui_"}
26+
-->recvresult
27+
-->stmtadmin list_objects {"schema":"Xtest", "pattern":"_rui_"}
28+
-->recvresult
29+
EOF
30+
31+
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
32+
33+
--exec $MYSQLXTEST -uroot --password='' --file=$xtest_file 2>&1
34+
35+
## Postamble
36+
--remove_file $xtest_file
37+
DROP SCHEMA IF EXISTS xtest;
38+
DROP SCHEMA IF EXISTS Xtest;
39+
UNINSTALL PLUGIN mysqlx;
40+

0 commit comments

Comments
 (0)