@@ -528,101 +528,152 @@ std::ostream &operator<<(std::ostream &os, const StatementType &type) {
528
528
// QueryType - String Utilities
529
529
// ===--------------------------------------------------------------------===//
530
530
std::string QueryTypeToString (QueryType query_type) {
531
- switch (query_type) {
532
- case QueryType::QUERY_BEGIN:return " BEGIN" ;
533
- case QueryType::QUERY_COMMIT:return " COMMIT" ;
534
- case QueryType::QUERY_ROLLBACK:return " ROLLBACK" ;
535
- case QueryType::QUERY_CREATE_DB:return " CREATE DATABASE" ;
536
- case QueryType::QUERY_CREATE_INDEX: return " CREATE INDEX" ;
537
- case QueryType::QUERY_CREATE_TABLE: return " CREATE TABLE" ;
538
- case QueryType::QUERY_CREATE_TRIGGER: return " CREATE TRIGGER" ;
539
- case QueryType::QUERY_CREATE_SCHEMA: return " CREATE SCHEMA" ;
540
- case QueryType::QUERY_CREATE_VIEW: return " CREATE VIEW" ;
541
- case QueryType::QUERY_DROP:return " DROP" ;
542
- case QueryType::QUERY_INSERT:return " INSERT" ;
543
- case QueryType::QUERY_SET: return " SET" ;
544
- case QueryType::QUERY_SHOW: return " SHOW" ;
545
- case QueryType::QUERY_UPDATE: return " UPDATE" ;
546
- case QueryType::QUERY_ALTER: return " ALTER" ;
547
- case QueryType::QUERY_DELETE: return " DELETE" ;
548
- case QueryType::QUERY_COPY: return " COPY" ;
549
- case QueryType::QUERY_ANALYZE: return " ANALYZE" ;
550
- case QueryType::QUERY_RENAME: return " RENAME" ;
551
- case QueryType::QUERY_PREPARE: return " PREPARE" ;
552
- case QueryType::QUERY_EXECUTE: return " EXECUTE" ;
553
- case QueryType::QUERY_SELECT: return " SELECT" ;
554
- case QueryType::QUERY_OTHER: default : return " OTHER" ;
531
+ switch (query_type) {
532
+ case QueryType::QUERY_BEGIN:
533
+ return " BEGIN" ;
534
+ case QueryType::QUERY_COMMIT:
535
+ return " COMMIT" ;
536
+ case QueryType::QUERY_ROLLBACK:
537
+ return " ROLLBACK" ;
538
+ case QueryType::QUERY_CREATE_DB:
539
+ return " CREATE DATABASE" ;
540
+ case QueryType::QUERY_CREATE_INDEX:
541
+ return " CREATE INDEX" ;
542
+ case QueryType::QUERY_CREATE_TABLE:
543
+ return " CREATE TABLE" ;
544
+ case QueryType::QUERY_CREATE_TRIGGER:
545
+ return " CREATE TRIGGER" ;
546
+ case QueryType::QUERY_CREATE_SCHEMA:
547
+ return " CREATE SCHEMA" ;
548
+ case QueryType::QUERY_CREATE_VIEW:
549
+ return " CREATE VIEW" ;
550
+ case QueryType::QUERY_DROP:
551
+ return " DROP" ;
552
+ case QueryType::QUERY_INSERT:
553
+ return " INSERT" ;
554
+ case QueryType::QUERY_SET:
555
+ return " SET" ;
556
+ case QueryType::QUERY_SHOW:
557
+ return " SHOW" ;
558
+ case QueryType::QUERY_UPDATE:
559
+ return " UPDATE" ;
560
+ case QueryType::QUERY_ALTER:
561
+ return " ALTER" ;
562
+ case QueryType::QUERY_DELETE:
563
+ return " DELETE" ;
564
+ case QueryType::QUERY_COPY:
565
+ return " COPY" ;
566
+ case QueryType::QUERY_ANALYZE:
567
+ return " ANALYZE" ;
568
+ case QueryType::QUERY_RENAME:
569
+ return " RENAME" ;
570
+ case QueryType::QUERY_PREPARE:
571
+ return " PREPARE" ;
572
+ case QueryType::QUERY_EXECUTE:
573
+ return " EXECUTE" ;
574
+ case QueryType::QUERY_SELECT:
575
+ return " SELECT" ;
576
+ case QueryType::QUERY_OTHER:
577
+ default :
578
+ return " OTHER" ;
555
579
}
556
580
}
557
581
558
582
QueryType StringToQueryType (const std::string &str) {
559
- static std::unordered_map<std::string, QueryType> querytype_string_map {
560
- {" BEGIN" , QueryType::QUERY_BEGIN}, {" COMMIT" , QueryType::QUERY_COMMIT},
561
- {" ROLLBACK" , QueryType::QUERY_ROLLBACK}, {" CREATE DATABASE" , QueryType::QUERY_CREATE_DB},
562
- {" CREATE INDEX" , QueryType::QUERY_CREATE_INDEX}, {" CREATE TABLE" , QueryType::QUERY_CREATE_TABLE},
563
- {" DROP" , QueryType::QUERY_DROP}, {" INSERT" , QueryType::QUERY_INSERT},
564
- {" SET" , QueryType::QUERY_SET}, {" SHOW" , QueryType::QUERY_SHOW},
565
- {" SHOW" , QueryType::QUERY_SHOW}, {" UPDATE" , QueryType::QUERY_UPDATE},
566
- {" ALTER" , QueryType::QUERY_ALTER}, {" DELETE" , QueryType::QUERY_DELETE},
567
- {" COPY" , QueryType::QUERY_COPY}, {" ANALYZE" , QueryType::QUERY_ANALYZE},
568
- {" RENAME" , QueryType::QUERY_RENAME}, {" PREPARE" , QueryType::QUERY_PREPARE},
569
- {" EXECUTE" , QueryType::QUERY_EXECUTE}, {" SELECT" , QueryType::QUERY_SELECT},
570
- {" CREATE TRIGGER" , QueryType::QUERY_CREATE_TRIGGER}, {" CREATE SCHEMA" , QueryType::QUERY_CREATE_SCHEMA},
571
- {" CREATE VIEW" , QueryType::QUERY_CREATE_VIEW}, {" OTHER" , QueryType::QUERY_OTHER},
583
+ static std::unordered_map<std::string, QueryType> querytype_string_map{
584
+ {" BEGIN" , QueryType::QUERY_BEGIN},
585
+ {" COMMIT" , QueryType::QUERY_COMMIT},
586
+ {" ROLLBACK" , QueryType::QUERY_ROLLBACK},
587
+ {" CREATE DATABASE" , QueryType::QUERY_CREATE_DB},
588
+ {" CREATE INDEX" , QueryType::QUERY_CREATE_INDEX},
589
+ {" CREATE TABLE" , QueryType::QUERY_CREATE_TABLE},
590
+ {" DROP" , QueryType::QUERY_DROP},
591
+ {" INSERT" , QueryType::QUERY_INSERT},
592
+ {" SET" , QueryType::QUERY_SET},
593
+ {" SHOW" , QueryType::QUERY_SHOW},
594
+ {" SHOW" , QueryType::QUERY_SHOW},
595
+ {" UPDATE" , QueryType::QUERY_UPDATE},
596
+ {" ALTER" , QueryType::QUERY_ALTER},
597
+ {" DELETE" , QueryType::QUERY_DELETE},
598
+ {" COPY" , QueryType::QUERY_COPY},
599
+ {" ANALYZE" , QueryType::QUERY_ANALYZE},
600
+ {" RENAME" , QueryType::QUERY_RENAME},
601
+ {" PREPARE" , QueryType::QUERY_PREPARE},
602
+ {" EXECUTE" , QueryType::QUERY_EXECUTE},
603
+ {" SELECT" , QueryType::QUERY_SELECT},
604
+ {" CREATE TRIGGER" , QueryType::QUERY_CREATE_TRIGGER},
605
+ {" CREATE SCHEMA" , QueryType::QUERY_CREATE_SCHEMA},
606
+ {" CREATE VIEW" , QueryType::QUERY_CREATE_VIEW},
607
+ {" OTHER" , QueryType::QUERY_OTHER},
572
608
};
573
- std::unordered_map<std::string, QueryType>::iterator it = querytype_string_map.find (str);
609
+ std::unordered_map<std::string, QueryType>::iterator it =
610
+ querytype_string_map.find (str);
574
611
if (it != querytype_string_map.end ()) {
575
- return it -> second;
612
+ return it-> second ;
576
613
} else {
577
614
return QueryType::QUERY_INVALID;
578
615
}
579
616
}
580
617
581
- QueryType StatementTypeToQueryType (StatementType stmt_type, const parser::SQLStatement* sql_stmt) {
618
+ QueryType StatementTypeToQueryType (StatementType stmt_type,
619
+ const parser::SQLStatement *sql_stmt) {
582
620
LOG_TRACE (" %s" , StatementTypeToString (stmt_type).c_str ());
583
- static std::unordered_map<StatementType, QueryType, EnumHash<StatementType>> type_map {
584
- {StatementType::EXECUTE, QueryType::QUERY_EXECUTE},
585
- {StatementType::PREPARE, QueryType::QUERY_PREPARE},
586
- {StatementType::INSERT, QueryType::QUERY_INSERT},
587
- {StatementType::UPDATE, QueryType::QUERY_UPDATE},
588
- {StatementType::DELETE, QueryType::QUERY_DELETE},
589
- {StatementType::COPY, QueryType::QUERY_COPY},
590
- {StatementType::ANALYZE, QueryType::QUERY_ANALYZE},
591
- {StatementType::ALTER, QueryType::QUERY_ALTER},
592
- {StatementType::DROP, QueryType::QUERY_DROP},
593
- {StatementType::SELECT, QueryType::QUERY_SELECT},
594
- {StatementType::VARIABLE_SET, QueryType::QUERY_SET},
595
- };
621
+ static std::unordered_map<StatementType, QueryType, EnumHash<StatementType>>
622
+ type_map{
623
+ {StatementType::EXECUTE, QueryType::QUERY_EXECUTE},
624
+ {StatementType::PREPARE, QueryType::QUERY_PREPARE},
625
+ {StatementType::INSERT, QueryType::QUERY_INSERT},
626
+ {StatementType::UPDATE, QueryType::QUERY_UPDATE},
627
+ {StatementType::DELETE, QueryType::QUERY_DELETE},
628
+ {StatementType::COPY, QueryType::QUERY_COPY},
629
+ {StatementType::ANALYZE, QueryType::QUERY_ANALYZE},
630
+ {StatementType::ALTER, QueryType::QUERY_ALTER},
631
+ {StatementType::DROP, QueryType::QUERY_DROP},
632
+ {StatementType::SELECT, QueryType::QUERY_SELECT},
633
+ {StatementType::VARIABLE_SET, QueryType::QUERY_SET},
634
+ };
596
635
QueryType query_type = QueryType::QUERY_OTHER;
597
- std::unordered_map<StatementType, QueryType, EnumHash<StatementType>>::iterator it = type_map.find (stmt_type);
636
+ std::unordered_map<StatementType, QueryType,
637
+ EnumHash<StatementType>>::iterator it =
638
+ type_map.find (stmt_type);
598
639
if (it != type_map.end ()) {
599
- query_type = it -> second;
640
+ query_type = it-> second ;
600
641
} else {
601
- switch (stmt_type) {
642
+ switch (stmt_type) {
602
643
case StatementType::TRANSACTION: {
603
- switch (static_cast <const parser::TransactionStatement*>(sql_stmt) ->type ) {
604
- case parser::TransactionStatement::CommandType::kBegin :query_type = QueryType::QUERY_BEGIN;
644
+ switch (
645
+ static_cast <const parser::TransactionStatement *>(sql_stmt)->type ) {
646
+ case parser::TransactionStatement::CommandType::kBegin :
647
+ query_type = QueryType::QUERY_BEGIN;
605
648
break ;
606
- case parser::TransactionStatement::CommandType::kCommit :query_type = QueryType::QUERY_COMMIT;
649
+ case parser::TransactionStatement::CommandType::kCommit :
650
+ query_type = QueryType::QUERY_COMMIT;
607
651
break ;
608
- case parser::TransactionStatement::CommandType::kRollback :query_type = QueryType::QUERY_ROLLBACK;
652
+ case parser::TransactionStatement::CommandType::kRollback :
653
+ query_type = QueryType::QUERY_ROLLBACK;
609
654
break ;
610
655
}
611
656
break ;
612
657
}
613
658
case StatementType::CREATE: {
614
- switch (static_cast <const parser::CreateStatement*>(sql_stmt) ->type ) {
615
- case parser::CreateStatement::CreateType::kDatabase :query_type = QueryType::QUERY_CREATE_DB;
659
+ switch (static_cast <const parser::CreateStatement *>(sql_stmt)->type ) {
660
+ case parser::CreateStatement::CreateType::kDatabase :
661
+ query_type = QueryType::QUERY_CREATE_DB;
616
662
break ;
617
- case parser::CreateStatement::CreateType::kIndex :query_type = QueryType::QUERY_CREATE_INDEX;
663
+ case parser::CreateStatement::CreateType::kIndex :
664
+ query_type = QueryType::QUERY_CREATE_INDEX;
618
665
break ;
619
- case parser::CreateStatement::CreateType::kTable :query_type = QueryType::QUERY_CREATE_TABLE;
666
+ case parser::CreateStatement::CreateType::kTable :
667
+ query_type = QueryType::QUERY_CREATE_TABLE;
620
668
break ;
621
- case parser::CreateStatement::CreateType::kTrigger :query_type = QueryType::QUERY_CREATE_TRIGGER;
669
+ case parser::CreateStatement::CreateType::kTrigger :
670
+ query_type = QueryType::QUERY_CREATE_TRIGGER;
622
671
break ;
623
- case parser::CreateStatement::CreateType::kSchema :query_type = QueryType::QUERY_CREATE_SCHEMA;
672
+ case parser::CreateStatement::CreateType::kSchema :
673
+ query_type = QueryType::QUERY_CREATE_SCHEMA;
624
674
break ;
625
- case parser::CreateStatement::CreateType::kView :query_type = QueryType::QUERY_CREATE_VIEW;
675
+ case parser::CreateStatement::CreateType::kView :
676
+ query_type = QueryType::QUERY_CREATE_VIEW;
626
677
break ;
627
678
}
628
679
break ;
@@ -707,9 +758,9 @@ std::string PostgresValueTypeToString(PostgresValueType type) {
707
758
return " DECIMAL" ;
708
759
}
709
760
default : {
710
- throw ConversionException (
711
- StringUtil::Format ( " No string conversion for PostgresValueType value '%d'" ,
712
- static_cast <int >(type)));
761
+ throw ConversionException (StringUtil::Format (
762
+ " No string conversion for PostgresValueType value '%d'" ,
763
+ static_cast <int >(type)));
713
764
}
714
765
}
715
766
return " INVALID" ;
@@ -765,7 +816,7 @@ PostgresValueType StringToPostgresValueType(const std::string &str) {
765
816
return PostgresValueType::DECIMAL;
766
817
} else {
767
818
throw ConversionException (StringUtil::Format (
768
- " No PostgresValueType conversion from string '%s'" , upper_str.c_str ()));
819
+ " No PostgresValueType conversion from string '%s'" , upper_str.c_str ()));
769
820
}
770
821
return PostgresValueType::INVALID;
771
822
}
@@ -1089,8 +1140,12 @@ std::string IndexTypeToString(IndexType type) {
1089
1140
case IndexType::ART: {
1090
1141
return " ART" ;
1091
1142
}
1143
+ default : {
1144
+ throw ConversionException (
1145
+ StringUtil::Format (" No string conversion for IndexType value '%d'" ,
1146
+ static_cast <int >(type)));
1147
+ }
1092
1148
}
1093
- return " INVALID" ;
1094
1149
}
1095
1150
1096
1151
IndexType StringToIndexType (const std::string &str) {
0 commit comments