Beispiel #1
0
 public NormalizeOrderByVisitor(BestCaseDictionary <IEnumerable <string> > tableColumns
                                , bool ignoreCase = true)
     : base(tableColumns, ignoreCase)
 {
     _orderByInMainQuery      = new Stack <OrderingTerm>();
     _candidateReplaceColumns = new List <Tuple <OrderingTerm, Column> >();
 }
Beispiel #2
0
 public GetCNFVisitor(BestCaseDictionary <IEnumerable <string> > tableColumns
                      , bool ignoreCase = true)
     : base(tableColumns, ignoreCase)
 {
     //_cnfSet = new TwoKeysDictionary<Table, string, string>();
     _cnfSet = new CNFSet();
 }
 public GetResultInfoListVisitor(BestCaseDictionary <IEnumerable <string> > tableColumns
                                 , bool ignoreCase = true)
 {
     _tableColumns  = tableColumns;
     _stack         = new Stack <ResultInfoList>();
     _subQueryStack = new Stack <SubQueryType>();
     _ignoreCase    = ignoreCase;
 }
Beispiel #4
0
        public void WrapInSelectStar(Dictionary <string, IEnumerable <string> > tableColumns, string AliasName = "V0_")
        {
            var stmt = this.GetStmt();

            if (stmt.Type == StmtType.Select)
            {
                var selectStmt = (SelectStmt)stmt;

                var bestcaseTableColumns = new BestCaseDictionary <IEnumerable <string> >(tableColumns);
                var visitor = new NormalizeOrderByVisitor(bestcaseTableColumns);
                selectStmt.Accept(visitor);

                var singleQueryClause =
                    SingleQuery.WrapInSelectStar(new AliasedQuery((IQueryClause)selectStmt.Query, false, AliasName));
                // Limit句にはColumnを指定できないので変換処理は必要ない
                selectStmt.Query =
                    new SingleQuery(singleQueryClause, selectStmt.Query.OrderBy, selectStmt.Query.Limit);
            }
        }
Beispiel #5
0
        GetCNF(Dictionary <string, IEnumerable <string> > tableColumns)
        {
            var ret = new Dictionary <SqlTable, Dictionary <string, string> >();

            var stmt = this.GetStmt();
            var bestcaseTableColumns = new BestCaseDictionary <IEnumerable <string> >(tableColumns);
            var visitor = new GetCNFVisitor(bestcaseTableColumns);

            stmt.Accept(visitor);

            foreach (var equalities in visitor.CNF)
            {
                var table = new SqlTable(equalities.Key);
                ret.Add(table, new Dictionary <string, string>());
                foreach (var equalitie in equalities.Value)
                {
                    var columnName   = equalitie.Key;
                    var literalValue = equalitie.Value.Value;
                    ret[table].Add(columnName, literalValue);
                }
            }

            return(ret);
        }