Skip to content

Commit 05bea2b

Browse files
committed
Bug#24968735 - MODIFYVIEW STMT FIELD SHOULDNT BE MARKED AS REQUIRED
Description =========== `stmts` field defined in `Mysqlx.Crud.ModifyView` message was marked as required which limits future modification/features. This field must be marked as optional. Fix === The definition of "protobuf" field was changed to "optional". When X Plugin detects that the field is missing it going to generate an error. RB: 14436 Reviewed-by Andrzej Religa <[email protected]>
1 parent 5a81ebb commit 05bea2b

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

rapid/plugin/x/mysqlxtest_src/mysqlxtest.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,18 +1051,20 @@ class Command
10511051
if (msg.get())
10521052
{
10531053
bool failed = false;
1054-
if (msg->GetDescriptor()->full_name() != "Mysqlx.Error" ||
1055-
(uint32_t)ngs::stoi(args) != static_cast<Mysqlx::Error*>(msg.get())->code())
1056-
{
1057-
std::cout << error() << "Was expecting Error " << args <<", but got:" << eoerr();
1058-
failed = true;
1059-
}
1060-
else
1061-
{
1062-
std::cout << "Got expected error:\n";
1063-
}
10641054
try
10651055
{
1056+
const int expected_error_code = mysqlxtest::get_error_code_by_text(args);
1057+
if (msg->GetDescriptor()->full_name() != "Mysqlx.Error" ||
1058+
expected_error_code != (int)static_cast<Mysqlx::Error*>(msg.get())->code())
1059+
{
1060+
std::cout << error() << "Was expecting Error " << args <<", but got:" << eoerr();
1061+
failed = true;
1062+
}
1063+
else
1064+
{
1065+
std::cout << "Got expected error:\n";
1066+
}
1067+
10661068
std::cout << message_to_text(*msg) << "\n";
10671069
if (failed && OPT_fatal_errors)
10681070
return Stop_with_success;

rapid/plugin/x/protocol/mysqlx_crud.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ message ModifyView {
261261
optional ViewCheckOption check = 5;
262262

263263
repeated string column = 6;
264-
required Find stmt = 7;
264+
optional Find stmt = 7;
265265
}
266266

267267

rapid/plugin/x/src/view_statement_builder.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ namespace xpl {
2323

2424
template <typename M>
2525
void View_statement_builder::build_common(const M &msg) const {
26+
if (!msg.has_stmt())
27+
throw ngs::Error_code(ER_X_INVALID_ARGUMENT, "The field that defines the select statement is required");
28+
2629
if (msg.has_algorithm()) add_algorithm(msg.algorithm());
2730
if (msg.has_definer()) add_definer(msg.definer());
2831
if (msg.has_security()) add_sql_security(msg.security());

rapid/plugin/x/tests/mtr/r/crud_modify_view.result

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ SHOW CREATE VIEW xtest.xview;
99
View Create View character_set_client collation_connection
1010
xview CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `xtest`.`xview` AS select `xtest`.`xtable`.`first` AS `first` from `xtest`.`xtable` latin1 latin1_swedish_ci
1111

12+
Modify view (missing stmt)
13+
--------------------------
14+
Got expected error:
15+
Mysqlx.Error {
16+
severity: ERROR
17+
code: 5012
18+
msg: "The field that defines the select statement is required"
19+
sql_state: "HY000"
20+
}
21+
22+
1223
Modify view (stmt)
1324
------------------
1425
Mysqlx.Ok {
@@ -103,7 +114,7 @@ View Create View character_set_client collation_connection
103114
xview CREATE ALGORITHM=MERGE DEFINER=`xuser`@`localhost` SQL SECURITY DEFINER VIEW `xtest`.`xview` AS select `xtest`.`xtable`.`second` AS `third` from `xtest`.`xtable` utf8mb4 utf8mb4_general_ci
104115
0 rows affected
105116
Variable_name Value
106-
Mysqlx_crud_modify_view 10
117+
Mysqlx_crud_modify_view 11
107118
0 rows affected
108119
Mysqlx.Ok {
109120
msg: "bye!"

rapid/plugin/x/tests/mtr/t/crud_modify_view.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ SHOW CREATE VIEW xtest.xview
2828
-->endsql
2929
-->endmacro
3030

31+
-->title -Modify view (missing stmt)
32+
Mysqlx.Crud.ModifyView {
33+
collection { name: "xview" schema: "xtest" }
34+
algorithm: TEMPTABLE
35+
}
36+
-->recverror ER_X_INVALID_ARGUMENT
3137

3238
-->title -Modify view (stmt)
3339
-->callmacro Modify_view second doc # Mysqlx.Ok
@@ -83,7 +89,7 @@ SHOW CREATE VIEW xtest.xview;
8389
--exec $MYSQLXTEST -uroot --password='' --file=$xtest_file 2>&1
8490

8591
--let $assert_text= Global status of 'Mysqlx_crud_modify_view'
86-
--let $assert_cond= [SHOW GLOBAL STATUS LIKE \'Mysqlx_crud_modify_view\', Value, 1] = 10
92+
--let $assert_cond= [SHOW GLOBAL STATUS LIKE \'Mysqlx_crud_modify_view\', Value, 1] = 11
8793
--source include/assert.inc
8894

8995

rapid/plugin/x/tests/mtr/t/crud_view_sundries.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Mysqlx.Crud.CreateView {
3636
}
3737
}
3838
-->recvuntil Mysqlx.Ok
39+
3940
-->sql
4041
SHOW CREATE VIEW xtest.view_c;
4142
-->endsql
@@ -53,7 +54,7 @@ Mysqlx.Crud.ModifyView {
5354
}
5455
}
5556
}
56-
-->recverror 1368
57+
-->recverror ER_VIEW_NONUPD_CHECK
5758

5859

5960
-->title -Run select query on view.
@@ -87,7 +88,7 @@ Mysqlx.Crud.Find {
8788
collection { name: "view_d" schema: "xtest"}
8889
data_model: DOCUMENT
8990
}
90-
-->recverror 1356
91+
-->recverror ER_VIEW_INVALID
9192

9293

9394
-->title -Error on create view for non privilege user
@@ -99,7 +100,7 @@ Mysqlx.Crud.CreateView {
99100
data_model: TABLE
100101
}
101102
}
102-
-->recverror 1142
103+
-->recverror ER_TABLEACCESS_DENIED_ERROR
103104
-->closesession
104105

105106

0 commit comments

Comments
 (0)