Skip to content

Commit fdf9ab0

Browse files
committed
Bug #25575727: ALGORITHM, SQL SECURITY AND CHECK OPTION ARE NOT GETTING RESET AFTER CREATE VIEW
Make sure that view creation options are set in the protocol message only when user specifies them explicitly.
1 parent 716e13b commit fdf9ab0

File tree

1 file changed

+56
-43
lines changed

1 file changed

+56
-43
lines changed

devapi/table_crud.cc

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <forward_list>
3131
#include <boost/format.hpp>
3232
#include <list>
33+
#include <bitset>
3334

3435
#include "impl.h"
3536

@@ -487,12 +488,16 @@ class Op_ViewCreateAlter
487488
private:
488489

489490
op_type m_op_type;
490-
CheckOption m_check_option;
491491
std::unique_ptr<TableSelect> m_table_select;
492-
SQLSecurity m_security;
493-
Algorithm m_algorythm;
494-
std::vector<mysqlx::string> m_columns;
495-
mysqlx::string m_user;
492+
std::vector<mysqlx::string> m_columns;
493+
494+
CheckOption m_check_option;
495+
SQLSecurity m_security;
496+
Algorithm m_algorithm;
497+
mysqlx::string m_definer;
498+
499+
enum view_option { CHECK, SECURITY, ALGORITHM, DEFINER, LAST};
500+
std::bitset<LAST> m_opts_mask;
496501

497502
Executable_impl* clone() const override
498503
{
@@ -503,11 +508,11 @@ class Op_ViewCreateAlter
503508
: Op_base(other)
504509
, Table_ref(other)
505510
, m_op_type (other.m_op_type )
511+
, m_columns (other.m_columns )
506512
, m_check_option (other.m_check_option)
507513
, m_security (other.m_security )
508-
, m_algorythm (other.m_algorythm )
509-
, m_columns (other.m_columns )
510-
, m_user (other.m_user )
514+
, m_algorithm (other.m_algorithm )
515+
, m_definer (other.m_definer )
511516
{
512517
if (other.m_table_select.get() != NULL)
513518
{
@@ -527,6 +532,7 @@ class Op_ViewCreateAlter
527532
void with_check_option(CheckOption option) override
528533
{
529534
m_check_option = option;
535+
m_opts_mask.set(CHECK);
530536
}
531537

532538
void defined_as(TableSelect &&select) override
@@ -537,17 +543,20 @@ class Op_ViewCreateAlter
537543

538544
void definer(const mysqlx::string &user) override
539545
{
540-
m_user = user;
546+
m_definer = user;
547+
m_opts_mask.set(DEFINER);
541548
}
542549

543550
void security(SQLSecurity security) override
544551
{
545552
m_security = security;
553+
m_opts_mask.set(SECURITY);
546554
}
547555

548556
void algorithm(Algorithm algorythm) override
549557
{
550-
m_algorythm = algorythm;
558+
m_algorithm = algorythm;
559+
m_opts_mask.set(ALGORITHM);
551560
}
552561

553562
void add_columns(const mysqlx::string &name) override
@@ -594,40 +603,44 @@ class Op_ViewCreateAlter
594603
if (options)
595604
{
596605

597-
options->definer(m_user);
606+
if (m_opts_mask.test(DEFINER))
607+
options->definer(m_definer);
598608

599-
switch (m_algorythm)
600-
{
601-
case Algorithm::MERGE:
602-
options->algorithm(cdk::api::View_algorithm::MERGE);
603-
break;
604-
case Algorithm::TEMPTABLE:
605-
options->algorithm(cdk::api::View_algorithm::TEMPTABLE);
606-
break;
607-
case Algorithm::UNDEFINED:
608-
options->algorithm(cdk::api::View_algorithm::UNDEFINED);
609-
break;
610-
}
611-
612-
switch(m_check_option)
613-
{
614-
case CheckOption::CASCADED:
615-
options->check(cdk::api::View_check::CASCADED);
616-
break;
617-
case CheckOption::LOCAL:
618-
options->check(cdk::api::View_check::LOCAL);
619-
break;
620-
}
621-
622-
switch(m_security)
623-
{
624-
case SQLSecurity::DEFINER:
625-
options->security(cdk::api::View_security::DEFINER);
626-
break;
627-
case SQLSecurity::INVOKER:
628-
options->security(cdk::api::View_security::INVOKER);
629-
break;
630-
}
609+
if (m_opts_mask.test(ALGORITHM))
610+
switch (m_algorithm)
611+
{
612+
case Algorithm::MERGE:
613+
options->algorithm(cdk::api::View_algorithm::MERGE);
614+
break;
615+
case Algorithm::TEMPTABLE:
616+
options->algorithm(cdk::api::View_algorithm::TEMPTABLE);
617+
break;
618+
case Algorithm::UNDEFINED:
619+
options->algorithm(cdk::api::View_algorithm::UNDEFINED);
620+
break;
621+
};
622+
623+
if (m_opts_mask.test(CHECK))
624+
switch(m_check_option)
625+
{
626+
case CheckOption::CASCADED:
627+
options->check(cdk::api::View_check::CASCADED);
628+
break;
629+
case CheckOption::LOCAL:
630+
options->check(cdk::api::View_check::LOCAL);
631+
break;
632+
};
633+
634+
if (m_opts_mask.test(SECURITY))
635+
switch(m_security)
636+
{
637+
case SQLSecurity::DEFINER:
638+
options->security(cdk::api::View_security::DEFINER);
639+
break;
640+
case SQLSecurity::INVOKER:
641+
options->security(cdk::api::View_security::INVOKER);
642+
break;
643+
};
631644
}
632645

633646
}

0 commit comments

Comments
 (0)