private void ProcessHint(OptimizerHint Hint, SelectStatement SelStatement)
 {
     switch (Hint.HintKind)
     {
         case OptimizerHintKind.OrderGroup:
         case OptimizerHintKind.MergeJoin:
         case OptimizerHintKind.HashJoin:
         case OptimizerHintKind.LoopJoin:
         case OptimizerHintKind.ConcatUnion:
         case OptimizerHintKind.HashUnion:
         case OptimizerHintKind.MergeUnion:
         case OptimizerHintKind.KeepUnion:
             _smells.SendFeedBack(4, SelStatement);
             break;
     }
 }
Ejemplo n.º 2
0
 private void ProcessHint(OptimizerHint Hint, SelectStatement SelStatement)
 {
     switch (Hint.HintKind)
     {
     case OptimizerHintKind.OrderGroup:
     case OptimizerHintKind.MergeJoin:
     case OptimizerHintKind.HashJoin:
     case OptimizerHintKind.LoopJoin:
     case OptimizerHintKind.ConcatUnion:
     case OptimizerHintKind.HashUnion:
     case OptimizerHintKind.MergeUnion:
     case OptimizerHintKind.KeepUnion:
         _smells.SendFeedBack(4, SelStatement);
         break;
     }
 }
Ejemplo n.º 3
0
 public override void Visit(OptimizerHint node) { this.action(node); }
 public override void ExplicitVisit(OptimizerHint fragment)
 {
     _fragments.Add(fragment);
 }
Ejemplo n.º 5
0
        // Turns T-SQL OptimizerHint into string
        internal static string OptimizerHintToString(OptimizerHint hint)
        {
            var sb = new StringBuilder(1024);

            // Literal hint
            if (hint is LiteralOptimizerHint)
            {
                sb.Append(TsqlFragmentToString.OptimizerHintKind(hint.HintKind));
                var loh = hint as LiteralOptimizerHint;

                // TODO: Only support numeric literal
                sb.AppendFormat(" {0}", loh.Value.Value);
            }
            // OptimizeFor hint
            else if (hint is OptimizeForOptimizerHint)
            {
                var ooh = hint as OptimizeForOptimizerHint;
                sb.AppendFormat("OPTIMIZE FOR ");
                if (ooh.IsForUnknown)
                {
                    sb.Append("UNKNOWN");
                }
                else
                {
                    sb.Append("(");
                    for (int i = 0; i < ooh.Pairs.Count; i++)
                    {
                        if (i > 0)
                        {
                            sb.Append(", ");
                        }
                        sb.Append(ooh.Pairs[i].Variable.Name);

                        // TODO: Only support value expression
                        if (ooh.Pairs[i].Value != null && ooh.Pairs[i].Value is Literal)
                        {
                            if (ooh.Pairs[i].Value is StringLiteral)
                            {
                                sb.AppendFormat(" = '{0}'", ((Literal)ooh.Pairs[i].Value).Value);
                            }
                            else
                            {
                                sb.AppendFormat(" = {0}", ((Literal)ooh.Pairs[i].Value).Value);
                            }
                        }
                        else
                        {
                            sb.Append(" UNKNOWN");
                        }
                    }
                    sb.Append(")");
                }
            }
            // Table hint
            else if (hint is TableHintsOptimizerHint)
            {
                var toh = hint as TableHintsOptimizerHint;
                sb.Append("TABLE HINT ");
                sb.Append("(");
                // sb.Append(TsqlFragmentToString.WSchemaObjectName(toh.ObjectName));
                for (int i = 0; i < toh.TableHints.Count; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }
                    // TODO: Table hint in WSQL Syntax tree is incomplete
                    sb.AppendFormat("@{0}", toh.TableHints[i].HintKind.ToString());
                }
                sb.Append(")");
            }
            // Regular hint
            else
            {
                sb.Append(TsqlFragmentToString.OptimizerHintKind(hint.HintKind));
            }
            return(sb.ToString());
        }
Ejemplo n.º 6
0
        // Turns T-SQL OptimizerHint into string
        internal static string OptimizerHintToString(OptimizerHint hint)
        {
            var sb = new StringBuilder(1024);
            // Literal hint
            if (hint is LiteralOptimizerHint)
            {
                sb.Append(TsqlFragmentToString.OptimizerHintKind(hint.HintKind));
                var loh = hint as LiteralOptimizerHint;

                // TODO: Only support numeric literal
                sb.AppendFormat(" {0}",loh.Value.Value);
            }
            // OptimizeFor hint
            else if (hint is OptimizeForOptimizerHint)
            {
                var ooh = hint as OptimizeForOptimizerHint;
                sb.AppendFormat("OPTIMIZE FOR ");
                if (ooh.IsForUnknown)
                    sb.Append("UNKNOWN");
                else
                {
                    sb.Append("(");
                    for (int i = 0; i < ooh.Pairs.Count; i++)
                    {
                        if (i > 0)
                            sb.Append(", ");
                        sb.Append(ooh.Pairs[i].Variable.Name);

                        // TODO: Only support value expression
                        if (ooh.Pairs[i].Value != null && ooh.Pairs[i].Value is Literal)
                        {
                            if (ooh.Pairs[i].Value is StringLiteral)
                                sb.AppendFormat(" = '{0}'", ((Literal)ooh.Pairs[i].Value).Value);
                            else
                                sb.AppendFormat(" = {0}", ((Literal)ooh.Pairs[i].Value).Value);
                        }
                        else
                            sb.Append(" UNKNOWN");
                    }
                    sb.Append(")");

                }
            }
            // Table hint
            else if (hint is TableHintsOptimizerHint)
            {
                var toh = hint as TableHintsOptimizerHint;
                sb.Append("TABLE HINT ");
                sb.Append("(");
                sb.Append(TsqlFragmentToString.SchemaObjectName(toh.ObjectName));
                for (int i = 0; i < toh.TableHints.Count; i++)
                {
                    if (i > 0)
                        sb.Append(", ");
                    // TODO: Table hint in WSQL Syntax tree is incomplete
                    sb.AppendFormat("@{0}", toh.TableHints[i].HintKind.ToString());
                }
                sb.Append(")");

            }
            // Regular hint
            else
            {
                sb.Append(TsqlFragmentToString.OptimizerHintKind(hint.HintKind));
            }
            return sb.ToString();
        }
Ejemplo n.º 7
0
 public override void ExplicitVisit(OptimizerHint node)
 {
     this.Hints.Add(node);
 }