30
30
#include < forward_list>
31
31
#include < boost/format.hpp>
32
32
#include < list>
33
+ #include < bitset>
33
34
34
35
#include " impl.h"
35
36
@@ -487,12 +488,16 @@ class Op_ViewCreateAlter
487
488
private:
488
489
489
490
op_type m_op_type;
490
- CheckOption m_check_option;
491
491
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;
496
501
497
502
Executable_impl* clone () const override
498
503
{
@@ -503,11 +508,11 @@ class Op_ViewCreateAlter
503
508
: Op_base(other)
504
509
, Table_ref(other)
505
510
, m_op_type (other.m_op_type )
511
+ , m_columns (other.m_columns )
506
512
, m_check_option (other.m_check_option)
507
513
, 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 )
511
516
{
512
517
if (other.m_table_select .get () != NULL )
513
518
{
@@ -527,6 +532,7 @@ class Op_ViewCreateAlter
527
532
void with_check_option (CheckOption option) override
528
533
{
529
534
m_check_option = option;
535
+ m_opts_mask.set (CHECK);
530
536
}
531
537
532
538
void defined_as (TableSelect &&select) override
@@ -537,17 +543,20 @@ class Op_ViewCreateAlter
537
543
538
544
void definer (const mysqlx::string &user) override
539
545
{
540
- m_user = user;
546
+ m_definer = user;
547
+ m_opts_mask.set (DEFINER);
541
548
}
542
549
543
550
void security (SQLSecurity security) override
544
551
{
545
552
m_security = security;
553
+ m_opts_mask.set (SECURITY);
546
554
}
547
555
548
556
void algorithm (Algorithm algorythm) override
549
557
{
550
- m_algorythm = algorythm;
558
+ m_algorithm = algorythm;
559
+ m_opts_mask.set (ALGORITHM);
551
560
}
552
561
553
562
void add_columns (const mysqlx::string &name) override
@@ -594,40 +603,44 @@ class Op_ViewCreateAlter
594
603
if (options)
595
604
{
596
605
597
- options->definer (m_user);
606
+ if (m_opts_mask.test (DEFINER))
607
+ options->definer (m_definer);
598
608
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
+ };
631
644
}
632
645
633
646
}
0 commit comments