Exemplo n.º 1
0
        protected override bool InternalValidate(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName, bool isDescending, bool isProposable)
        {
            if (_enforcePredicate && (columnName == String.Empty))
            {
                // ARow in (((table { ARow }) union <source expression>)) <quota clause>
                EnsureValidateNode(program.Plan);
                PushRow(program, newRow);
                try
                {
                    object objectValue = _validateNode.Execute(program);
                    if ((objectValue != null) && !(bool)objectValue)
                    {
                        throw new RuntimeException(RuntimeException.Codes.RowViolatesQuotaPredicate, ErrorSeverity.User);
                    }
                }
                finally
                {
                    PopRow(program);
                }
            }

            if ((columnName == String.Empty) || SourceNode.DataType.Columns.ContainsName(columnName))
            {
                return(base.InternalValidate(program, oldRow, newRow, valueFlags, columnName, isDescending, isProposable));
            }
            return(false);
        }
Exemplo n.º 2
0
        public override object InternalExecute(Program program, object argument1, object argument2)
        {
            ITable table = (ITable)argument2;

                        #if NILPROPOGATION
            if ((table == null) || (argument1 == null))
            {
                return(null);
            }
                        #endif
            program.Stack.Push(argument1);
            try
            {
                Row row = new Row(program.ValueManager, table.DataType.RowType);
                try
                {
                    program.Stack.Push(row);
                    try
                    {
                        object result = false;
                        while (table.Next())
                        {
                            table.Select(row);
                            object tempValue = _equalNode.Execute(program);
                                                        #if NILPROPOGATION
                            if (tempValue == null)
                            {
                                result = tempValue;
                                continue;
                            }
                                                        #endif
                            if ((bool)tempValue)
                            {
                                return(tempValue);
                            }
                        }
                        return(result);
                    }
                    finally
                    {
                        program.Stack.Pop();
                    }
                }
                finally
                {
                    row.Dispose();
                }
            }
            finally
            {
                program.Stack.Pop();
            }
        }
Exemplo n.º 3
0
        public override object InternalExecute(Program program)
        {
            object leftValue  = Nodes[0].Execute(program);
            object rightValue = Nodes[1].Execute(program);

                        #if NILPROPOGATION
            if ((leftValue == null) || (rightValue == null))
            {
                return(null);
            }
                        #endif

            if (_comparisonNode != null)
            {
                program.Stack.PushWindow(0);
                try
                {
                    program.Stack.Push(leftValue);
                    try
                    {
                        program.Stack.Push(rightValue);
                        try
                        {
                            return(_comparisonNode.Execute(program));
                        }
                        finally
                        {
                            program.Stack.Pop();
                        }
                    }
                    finally
                    {
                        program.Stack.Pop();
                    }
                }
                finally
                {
                    program.Stack.PopWindow();
                }
            }
            else
            {
                RowEqualNode node = new RowEqualNode();
                node.Nodes.Add(new ValueNode(((IRow)leftValue).DataType, leftValue));
                node.Nodes.Add(new ValueNode(((IRow)rightValue).DataType, rightValue));
                node.DetermineDataType(program.Plan);
                return(node.Execute(program));
            }
        }
Exemplo n.º 4
0
        public override object InternalExecute(Program program, object argument1, object argument2)
        {
            ListValue list = (ListValue)argument2;

                        #if NILPROPOGATION
            if ((list == null) || (argument1 == null))
            {
                return(null);
            }
                        #endif

            program.Stack.Push(argument1);
            try
            {
                program.Stack.Push(null);
                try
                {
                    object result = false;
                    for (int index = 0; index < list.Count(); index++)
                    {
                        program.Stack.Poke(0, list[index]);
                        object tempValue = _equalNode.Execute(program);
                                                #if NILPROPOGATION
                        if (tempValue == null)
                        {
                            result = null;
                            continue;
                        }
                                                #endif
                        if ((bool)tempValue)
                        {
                            return(tempValue);
                        }
                    }
                    return(result);
                }
                finally
                {
                    program.Stack.Pop();
                }
            }
            finally
            {
                program.Stack.Pop();
            }
        }
Exemplo n.º 5
0
 public override object InternalExecute(Program program, object argument1, object argument2)
 {
                 #if NILPROPOGATION
     if (argument1 == null || argument2 == null)
     {
         return(null);
     }
                 #endif
     if (_equalNode != null)
     {
         program.Stack.Push(argument1);
         try
         {
             program.Stack.Push(argument2);
             try
             {
                 object tempValue = _equalNode.Execute(program);
                 if ((tempValue == null) || !(bool)tempValue)
                 {
                     throw new RuntimeException(RuntimeException.Codes.InvalidRowJoin);
                 }
             }
             finally
             {
                 program.Stack.Pop();
             }
         }
         finally
         {
             program.Stack.Pop();
         }
     }
     Row result = new Row(program.ValueManager, DataType);
     try
     {
         ((IRow)argument1).CopyTo(result);
         ((IRow)argument2).CopyTo(result);
         return(result);
     }
     catch
     {
         result.Dispose();
         throw;
     }
 }
Exemplo n.º 6
0
 public override DataVar InternalExecute(ServerProcess AProcess, DataVar[] AArguments)
 {
     AProcess.Context.Push(AArguments[0]);
     try
     {
         using (Table LTable = (Table)FNode.Execute(AProcess).Value)
         {
             int LValue = 0;
             if (LTable.Next())
             {
                 Row LRow = LTable.Select();
                 try
                 {
                     LValue  = LRow[1].AsInt32;
                     LRow[1] = new Scalar(AProcess, AProcess.DataTypes.SystemInteger, LValue + 1);
                     LTable.Update(LRow);
                 }
                 finally
                 {
                     LRow.Dispose();
                 }
             }
             else
             {
                 LValue = 1;
                 Row LRow = new Row(AProcess, LTable.DataType.CreateRowType());
                 try
                 {
                     LRow[0] = (Scalar)AArguments[0].Value;
                     LRow[1] = new Scalar(AProcess, AProcess.DataTypes.SystemInteger, LValue + 1);
                     LTable.Insert(LRow);
                 }
                 finally
                 {
                     LRow.Dispose();
                 }
             }
             return(new DataVar(AProcess.Plan.Catalog.DataTypes.SystemInteger, new Scalar(AProcess, AProcess.DataTypes.SystemInteger, LValue)));
         }
     }
     finally
     {
         AProcess.Context.Pop();
     }
 }
Exemplo n.º 7
0
        public override object InternalExecute(Program program)
        {
            object leftVar  = Nodes[0].Execute(program);
            object rightVar = Nodes[1].Execute(program);

                        #if NILPROPOGATION
            if ((leftVar == null) || (rightVar == null))
            {
                return(null);
            }
                        #endif

            object leftValue  = DataValue.FromNative(program.ValueManager, ((Schema.ScalarType)Nodes[0].DataType).CompoundRowType, leftVar);
            object rightValue = DataValue.FromNative(program.ValueManager, ((Schema.ScalarType)Nodes[1].DataType).CompoundRowType, rightVar);
            program.Stack.PushWindow(0);
            try
            {
                program.Stack.Push(leftValue);
                try
                {
                    program.Stack.Push(rightValue);
                    try
                    {
                        return(_comparisonNode.Execute(program));
                    }
                    finally
                    {
                        program.Stack.Pop();
                    }
                }
                finally
                {
                    program.Stack.Pop();
                }
            }
            finally
            {
                program.Stack.PopWindow();
            }
        }