Пример #1
0
        public static ExecutePlanNode Build(ExecutePlanNode parentNode, IEnumerable<SqlStatement> statements)
        {
            var statementList = statements.ToList();
            statementList.Reverse();

            ExecutePlanNode node = null;
            foreach (var statement in statementList) {
                if (node == null) {
                    node = new ExecutePlanNode(statement);
                } else {
                    var oldNode = node;
                    node = new ExecutePlanNode(statement);
                    oldNode.Next = node;
                }

                if (parentNode != null)
                    node.Parent = parentNode;

                if (statement is IParentExecutable) {
                    var children = ((IParentExecutable) statement).Children;
                    var childTree = Build(node, children);
                    node.ChildTree = childTree;
                }
            }

            return node;
        }
Пример #2
0
        public ITable Execute(IQueryContext context)
        {
            var blockContext = new PlSqlBlockQueryContext(context, this);

            foreach (var declaration in Declarations) {
                declaration.Execute(blockContext);
            }

            var blockNode = new ExecutePlanNode(this);
            RootNode = ExecutePlanNode.Build(blockNode, Statements);

            var node = RootNode;
            while (node != null) {
                node.Execute(context);

                if (RootNodeChanged) {
                    node = RootNode;
                } else {
                    node = node.Next;
                }
            }

            return FunctionTable.ResultTable(context, 0);
        }