示例#1
0
        public override Statement Translate(DevicePlan ADevicePlan, PlanNode APlanNode)
        {
            SQLDevicePlan LDevicePlan = (SQLDevicePlan)ADevicePlan;

            return
                (new CaseExpression
                 (
                     new CaseItemExpression[]
            {
                new CaseItemExpression
                (
                    new BinaryExpression
                    (
                        new CallExpression("UCase", new Expression[] { LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false) }),
                        "iEqual",
                        new CallExpression("UCase", new Expression[] { LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[1], false) })
                    ),
                    new ValueExpression(0)
                ),
                new CaseItemExpression
                (
                    new BinaryExpression
                    (
                        new CallExpression("UCase", new Expression[] { LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false) }),
                        "iLess",
                        new CallExpression("UCase", new Expression[] { LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[1], false) })
                    ),
                    new ValueExpression(-1)
                )
            },
                     new CaseElseExpression(new ValueExpression(1))
                 ));
        }
        //public SQLTimeSpanDays(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpanDays(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression      = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);

            return(new BinaryExpression(expression, "iMultiplication", new ValueExpression(864000000000m, TokenType.Decimal)));
        }
        //public SQLTimeSpanReadSeconds(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpanReadSeconds(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression      = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);

            return(new BinaryExpression(expression, "iDivision", new ValueExpression(10000000, TokenType.Integer)));
        }
示例#4
0
        public override Statement Translate(DevicePlan ADevicePlan, PlanNode APlanNode)
        {
            SQLDevicePlan LDevicePlan = (SQLDevicePlan)ADevicePlan;

            return
                (new CaseExpression
                 (
                     new CaseItemExpression[]
            {
                new CaseItemExpression
                (
                    new BinaryExpression
                    (
                        LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false),
                        "iEqual",
                        new ValueExpression(0, TokenType.Integer)
                    ),
                    new ValueExpression("false", TokenType.String)
                )
            },
                     new CaseElseExpression
                     (
                         new ValueExpression("true", TokenType.String)
                     )
                 ));
        }
示例#5
0
        //public SASRetrieve(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SASRetrieve(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan ADevicePlan, PlanNode APlanNode)
        {
            SQLDevicePlan LDevicePlan = (SQLDevicePlan)ADevicePlan;
            TableVar      LTableVar   = ((TableVarNode)APlanNode).TableVar;

            if (LTableVar is BaseTableVar)
            {
                SQLRangeVar LRangeVar = new SQLRangeVar(LDevicePlan.GetNextTableAlias());
                foreach (Schema.TableVarColumn LColumn in LTableVar.Columns)
                {
                    LRangeVar.Columns.Add(new SQLRangeVarColumn(LColumn, LRangeVar.Name, LDevicePlan.Device.ToSQLIdentifier(LColumn), LDevicePlan.Device.ToSQLIdentifier(LColumn.Name)));
                }
                LDevicePlan.CurrentQueryContext().RangeVars.Add(LRangeVar);
                SelectExpression LSelectExpression = new SelectExpression();
                LSelectExpression.FromClause = new AlgebraicFromClause(new TableSpecifier(new TableExpression(D4.MetaData.GetTag(LTableVar.MetaData, "Storage.Schema", LDevicePlan.Device.Schema), LDevicePlan.Device.ToSQLIdentifier(LTableVar)), LRangeVar.Name));
                //LSelectExpression.FromClause = new CalculusFromClause(new TableSpecifier(new TableExpression(D4.MetaData.GetTag(LTableVar.MetaData, "Storage.Schema", LDevicePlan.Device.Schema), LDevicePlan.Device.ToSQLIdentifier(LTableVar)), LRangeVar.Name));
                LSelectExpression.SelectClause = new SelectClause();
                foreach (TableVarColumn LColumn in LTableVar.Columns)
                {
                    LSelectExpression.SelectClause.Columns.Add(LDevicePlan.GetRangeVarColumn(LColumn.Name, true).GetColumnExpression());
                }

                LSelectExpression.SelectClause.Distinct =
                    (LTableVar.Keys.Count == 1) &&
                    Convert.ToBoolean(D4.MetaData.GetTag(LTableVar.Keys[0].MetaData, "Storage.IsImposedKey", "false"));

                return(LSelectExpression);
            }
            else
            {
                return(LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false));
            }
        }
示例#6
0
        protected override DevicePlanNode InternalPrepare(DevicePlan devicePlan, PlanNode planNode)
        {
            CatalogDevicePlan localDevicePlan = (CatalogDevicePlan)devicePlan;

            localDevicePlan.IsSupported = true;
            return(base.InternalPrepare(devicePlan, planNode));
        }
        //public SQLTimeSpanAddTicks(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpanAddTicks(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression1     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);
            Expression    expression2     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[1], false);

            return(new BinaryExpression(expression1, "iAddition", expression2));
        }
        //public SQLTimeSpanReadMinutes(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpanReadMinutes(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression      = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);
            Expression    Minutes         = new BinaryExpression(expression, "iDivision", new ValueExpression(600000000m, TokenType.Decimal));

            return(Minutes);
        }
示例#9
0
        // ServerName

        public override SelectStatement TranslateOrder(DevicePlan devicePlan, TableNode node, SelectStatement statement, bool inContextOrderBy)
        {
            if (statement.Modifiers == null)
            {
                statement.Modifiers = new LanguageModifiers();
            }
            statement.Modifiers.Add(new LanguageModifier("OptimizerHints", "option (fast 1)"));
            return(base.TranslateOrder(devicePlan, node, statement, inContextOrderBy));
        }
        //public SQLTimeSpanTime2Operands(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpanTime2Operands(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression1     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);
            Expression    expression2     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[1], false);
            Expression    First           = new BinaryExpression(expression1, "iMultiplication", new ValueExpression(36000000000m, TokenType.Decimal));
            Expression    Second          = new BinaryExpression(expression2, "iMultiplication", new ValueExpression(600000000m, TokenType.Decimal));

            return(new BinaryExpression(First, "iAddition", Second));
        }
        //public SQLTimeSpan5Operands(Operator AOperator, D4.ClassDefinition AClassDefinition) : base(AOperator, AClassDefinition){}
        //public SQLTimeSpan5Operands(Operator AOperator, D4.ClassDefinition AClassDefinition, bool AIsSystem) : base(AOperator, AClassDefinition, AIsSystem){}

        public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
        {
            SQLDevicePlan localDevicePlan = (SQLDevicePlan)devicePlan;
            Expression    expression1     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[0], false);
            Expression    expression2     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[1], false);
            Expression    expression3     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[2], false);
            Expression    expression4     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[3], false);
            Expression    expression5     = localDevicePlan.Device.TranslateExpression(localDevicePlan, planNode.Nodes[4], false);
            Expression    First           = new BinaryExpression(expression1, "iMultiplication", new ValueExpression(864000000000m, TokenType.Decimal));
            Expression    Second          = new BinaryExpression(expression2, "iMultiplication", new ValueExpression(36000000000m, TokenType.Decimal));
            Expression    Third           = new BinaryExpression(expression3, "iMultiplication", new ValueExpression(600000000m, TokenType.Decimal));
            Expression    Fourth          = new BinaryExpression(expression4, "iMultiplication", new ValueExpression(10000000m, TokenType.Decimal));
            Expression    Fifth           = new BinaryExpression(expression5, "iMultiplication", new ValueExpression(10000m, TokenType.Decimal));
            Expression    FirstSecond     = new BinaryExpression(First, "iAddition", Second);
            Expression    ThirdFourth     = new BinaryExpression(Third, "iAddition", Fourth);
            Expression    FirstFour       = new BinaryExpression(FirstSecond, "iAddition", ThirdFourth);

            return(new BinaryExpression(FirstFour, "iAddition", Fifth));
        }
示例#12
0
        protected override DevicePlanNode InternalPrepare(DevicePlan devicePlan, PlanNode planNode)
        {
            CatalogDevicePlan     localDevicePlan = (CatalogDevicePlan)devicePlan;
            CatalogDevicePlanNode devicePlanNode  = new CatalogDevicePlanNode(planNode);

            TranslatePlanNode(localDevicePlan, devicePlanNode, planNode);
            if (planNode is TableNode)
            {
                TranslateOrder(localDevicePlan, devicePlanNode, (TableNode)planNode);
            }

            if (localDevicePlan.IsSupported)
            {
                return(devicePlanNode);
            }
            else
            {
                return(base.InternalPrepare(devicePlan, planNode));
            }
        }
示例#13
0
        public override Statement Translate(DevicePlan ADevicePlan, PlanNode APlanNode)
        {
            SQLDevicePlan LDevicePlan = (SQLDevicePlan)ADevicePlan;

            return
                (new CallExpression
                 (
                     "SubStr",
                     new Expression[]
            {
                LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false),
                new BinaryExpression
                (
                    LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[1], false),
                    "iAddition",
                    new ValueExpression(1, TokenType.Integer)
                ),
                LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[2], false)
            }
                 ));
        }
示例#14
0
        public override Statement Translate(DevicePlan ADevicePlan, PlanNode APlanNode)
        {
            SQLDevicePlan LDevicePlan = (SQLDevicePlan)ADevicePlan;

            return
                (new BinaryExpression
                 (
                     new CaseExpression
                     (
                         new CaseItemExpression[]
            {
                new CaseItemExpression
                (
                    new BinaryExpression
                    (
                        LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false),
                        "iEqual",
                        new ValueExpression(String.Empty, TokenType.String)
                    ),
                    new ValueExpression(1, TokenType.Integer)
                )
            },
                         new CaseElseExpression
                         (
                             new CallExpression
                             (
                                 "CharIndex",
                                 new Expression[]
            {
                LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[1], false),
                LDevicePlan.Device.TranslateExpression(LDevicePlan, APlanNode.Nodes[0], false)
            }
                             )
                         )
                     ),
                     "iSubtraction",
                     new ValueExpression(1, TokenType.Integer)
                 ));
        }
示例#15
0
 public override Statement Translate(DevicePlan devicePlan, PlanNode planNode)
 {
     throw new Exception("The method or operation is not implemented.");
 }