public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
		{
			_subqueryContextCounter++;
			try
			{
				return base.VisitSingleRowSubselect(expression);
			}
			finally
			{
				_subqueryContextCounter--;
			}
		}
Exemple #2
0
        public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
        {
            AlgebraNode inputNode = GetOrCreateInput();
            ResultAlgebraNode algebrizedSubquery = Algebrizer.Convert(expression.Query);
            ResultAlgebraNode assertedSubquery = CreateAssertedSubquery(algebrizedSubquery);

            JoinAlgebraNode joinAlgebraNode = new JoinAlgebraNode();
            joinAlgebraNode.PassthruPredicate = CurrentPassthruPredicate;
            joinAlgebraNode.Op = JoinAlgebraNode.JoinOperator.LeftOuterJoin;
            joinAlgebraNode.Left = inputNode;
            joinAlgebraNode.Right = assertedSubquery;
            SetLastAlgebraNode(joinAlgebraNode);

            return new RowBufferEntryExpression(assertedSubquery.OutputList[0]);
        }
Exemple #3
0
		private static bool VisitSingleRowSubselect(SingleRowSubselect node1, SingleRowSubselect node2)
		{
			return node2 != null &&
			       Visit(node1.Query, node2.Query);
		}
Exemple #4
0
 private static bool VisitSingleRowSubselect(SingleRowSubselect node1, SingleRowSubselect node2)
 {
     return(node2 != null &&
            Visit(node1.Query, node2.Query));
 }
Exemple #5
0
		public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
		{
			_writer.Write("(");
			Visit(expression.Query);
			_writer.Write(")");

			return expression;
		}
Exemple #6
0
		public override AstElement Clone(Dictionary<AstElement, AstElement> alreadyClonedElements)
		{
			SingleRowSubselect result = new SingleRowSubselect();
			result.Query = (QueryNode)Query.Clone(alreadyClonedElements);
			return result;
		}
Exemple #7
0
        private ExpressionNode[] ParseSimpleQueryExpressionList()
        {
            if (_token.Id == TokenId.LeftParentheses && _lookahead.Id == TokenId.SELECT)
            {
                NextToken();
                SingleRowSubselect singleRowSubselect = new SingleRowSubselect();
                singleRowSubselect.Query = ParseQuery();
                Match(TokenId.RightParentheses);

                return new ExpressionNode[] { singleRowSubselect };
            }

            return ParseExpressionList();
        }
Exemple #8
0
		public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
		{
			_xmlWriter.WriteStartElement("singleRowSubselect");
			WriteTypeAttribute(expression.ExpressionType);

			WriteAstNode("query", expression.Query);

			_xmlWriter.WriteEndElement();

			return expression;
		}
Exemple #9
0
 public virtual ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
 {
     expression.Query = VisitQuery(expression.Query);
     return(expression);
 }
Exemple #10
0
		public virtual ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
		{
			expression.Query = VisitQuery(expression.Query);
			return expression;
		}
 public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
 {
     return(expression);
 }
Exemple #12
0
        private ExpressionNode ParsePrimaryExpression()
        {
            switch (_token.Id)
            {
            case TokenId.NULL:
                NextToken();
                return(LiteralExpression.FromNull());

            case TokenId.TRUE:
            case TokenId.FALSE:
                return(ParseBooleanLiteral());

            case TokenId.Date:
                return(ParseDateLiteral());

            case TokenId.Number:
                return(ParseNumberLiteral());

            case TokenId.String:
                return(LiteralExpression.FromString(ParseString()));

            case TokenId.EXISTS:
            {
                ExistsSubselect result = new ExistsSubselect();
                NextToken();
                Match(TokenId.LeftParentheses);
                result.Query = ParseQuery();
                Match(TokenId.RightParentheses);

                return(result);
            }

            case TokenId.ParameterMarker:
            {
                _rangeRecorder.Begin();
                NextToken();
                Identifier  name            = ParseIdentifier();
                SourceRange nameSourceRange = _rangeRecorder.End();

                ParameterExpression result = new ParameterExpression();
                result.Name            = name;
                result.NameSourceRange = nameSourceRange;
                return(result);
            }

            case TokenId.CAST:
            {
                NextToken();
                CastExpression castExpression = new CastExpression();
                Match(TokenId.LeftParentheses);
                castExpression.Expression = ParseExpression();
                Match(TokenId.AS);
                castExpression.TypeReference = ParseTypeReference();
                Match(TokenId.RightParentheses);

                return(castExpression);
            }

            case TokenId.CASE:
            {
                NextToken();

                CaseExpression caseExpression = new CaseExpression();

                if (_token.Id != TokenId.WHEN && _token.Id != TokenId.ELSE && _token.Id != TokenId.END)
                {
                    caseExpression.InputExpression = ParseExpression();
                }

                List <ExpressionNode> whenExpressionList = new List <ExpressionNode>();
                List <ExpressionNode> expressionList     = new List <ExpressionNode>();

                if (_token.Id != TokenId.WHEN)
                {
                    Match(TokenId.WHEN);
                }
                else
                {
                    while (_token.Id == TokenId.WHEN)
                    {
                        NextToken();

                        whenExpressionList.Add(ParseExpression());
                        Match(TokenId.THEN);
                        expressionList.Add(ParseExpression());
                    }
                }

                caseExpression.WhenExpressions = whenExpressionList.ToArray();
                caseExpression.ThenExpressions = expressionList.ToArray();

                if (_token.Id == TokenId.ELSE)
                {
                    NextToken();
                    caseExpression.ElseExpression = ParseExpression();
                }

                Match(TokenId.END);

                return(caseExpression);
            }

            case TokenId.COALESCE:
            {
                NextToken();
                CoalesceExpression coalesceExpression = new CoalesceExpression();
                coalesceExpression.Expressions = ParseExpressionList();
                return(coalesceExpression);
            }

            case TokenId.NULLIF:
            {
                NextToken();
                NullIfExpression nullIfExpression = new NullIfExpression();
                Match(TokenId.LeftParentheses);
                nullIfExpression.LeftExpression = ParseExpression();
                Match(TokenId.Comma);
                nullIfExpression.RightExpression = ParseExpression();
                Match(TokenId.RightParentheses);
                return(nullIfExpression);
            }

            case TokenId.Identifier:
            {
                _rangeRecorder.Begin();
                Identifier  name            = ParseIdentifier();
                SourceRange nameSourceRange = _rangeRecorder.End();

                if (_token.Id != TokenId.LeftParentheses)
                {
                    NameExpression result = new NameExpression();
                    result.Name            = name;
                    result.NameSourceRange = nameSourceRange;
                    return(result);
                }
                else
                {
                    bool             hasAsteriskModifier;
                    ExpressionNode[] args;

                    if (_lookahead.Id != TokenId.Multiply)
                    {
                        hasAsteriskModifier = false;
                        args = ParseExpressionList();
                    }
                    else
                    {
                        NextToken();
                        NextToken();
                        Match(TokenId.RightParentheses);

                        hasAsteriskModifier = true;
                        args = new ExpressionNode[0];
                    }

                    FunctionInvocationExpression result = new FunctionInvocationExpression();
                    result.Name                = name;
                    result.NameSourceRange     = nameSourceRange;
                    result.Arguments           = args;
                    result.HasAsteriskModifier = hasAsteriskModifier;
                    return(result);
                }
            }

            case TokenId.LeftParentheses:
            {
                NextToken();

                ExpressionNode expr;

                if (_token.Id != TokenId.SELECT)
                {
                    expr = ParseExpression();
                }
                else
                {
                    SingleRowSubselect singleRowSubselect = new SingleRowSubselect();
                    singleRowSubselect.Query = ParseQuery();
                    expr = singleRowSubselect;
                }

                Match(TokenId.RightParentheses);
                return(expr);
            }

            default:
            {
                _errorReporter.SimpleExpressionExpected(_token.Range, _token.Text);
                return(LiteralExpression.FromNull());
            }
            }
        }
Exemple #13
0
 public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
 {
     EnsureSubqueryNotNestedInAggregate();
     base.VisitSingleRowSubselect(expression);
     EnsureQueryHasOneColumnOnly(expression.Query);
     EnsureQueryHasNoOrderByUnlessTopSpecified(expression.Query);
     return expression;
 }
Exemple #14
0
 public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
 {
     _containsSingleRowSubselects = true;
     VisitQueryExpression(expression.Query);
     return(expression);
 }
 public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
 {
     return expression;
 }
Exemple #16
0
        private ExpressionNode ParsePrimaryExpression()
        {
            switch (_token.Id)
            {
                case TokenId.NULL:
                    NextToken();
                    return LiteralExpression.FromNull();

                case TokenId.TRUE:
                case TokenId.FALSE:
                    return ParseBooleanLiteral();

                case TokenId.Date:
                    return ParseDateLiteral();

                case TokenId.Number:
                    return ParseNumberLiteral();

                case TokenId.String:
                    return LiteralExpression.FromString(ParseString());

                case TokenId.EXISTS:
                {
                    ExistsSubselect result = new ExistsSubselect();
                    NextToken();
                    Match(TokenId.LeftParentheses);
                    result.Query = ParseQuery();
                    Match(TokenId.RightParentheses);

                    return result;
                }

                case TokenId.ParameterMarker:
                {
                    _rangeRecorder.Begin();
                    NextToken();
                    Identifier name = ParseIdentifier();
                    SourceRange nameSourceRange = _rangeRecorder.End();

                    ParameterExpression result = new ParameterExpression();
                    result.Name = name;
                    result.NameSourceRange = nameSourceRange;
                    return result;
                }

                case TokenId.CAST:
                {
                    NextToken();
                    CastExpression castExpression = new CastExpression();
                    Match(TokenId.LeftParentheses);
                    castExpression.Expression = ParseExpression();
                    Match(TokenId.AS);
                    castExpression.TypeReference = ParseTypeReference();
                    Match(TokenId.RightParentheses);

                    return castExpression;
                }

                case TokenId.CASE:
                {
                    NextToken();

                    CaseExpression caseExpression = new CaseExpression();

                    if (_token.Id != TokenId.WHEN && _token.Id != TokenId.ELSE && _token.Id != TokenId.END)
                        caseExpression.InputExpression = ParseExpression();

                    List<ExpressionNode> whenExpressionList = new List<ExpressionNode>();
                    List<ExpressionNode> expressionList = new List<ExpressionNode>();

                    if (_token.Id != TokenId.WHEN)
                    {
                        Match(TokenId.WHEN);
                    }
                    else
                    {
                        while (_token.Id == TokenId.WHEN)
                        {
                            NextToken();

                            whenExpressionList.Add(ParseExpression());
                            Match(TokenId.THEN);
                            expressionList.Add(ParseExpression());
                        }
                    }

                    caseExpression.WhenExpressions = whenExpressionList.ToArray();
                    caseExpression.ThenExpressions = expressionList.ToArray();

                    if (_token.Id == TokenId.ELSE)
                    {
                        NextToken();
                        caseExpression.ElseExpression = ParseExpression();
                    }

                    Match(TokenId.END);

                    return caseExpression;
                }

                case TokenId.COALESCE:
                {
                    NextToken();
                    CoalesceExpression coalesceExpression = new CoalesceExpression();
                    coalesceExpression.Expressions = ParseExpressionList();
                    return coalesceExpression;
                }

                case TokenId.NULLIF:
                {
                    NextToken();
                    NullIfExpression nullIfExpression = new NullIfExpression();
                    Match(TokenId.LeftParentheses);
                    nullIfExpression.LeftExpression = ParseExpression();
                    Match(TokenId.Comma);
                    nullIfExpression.RightExpression = ParseExpression();
                    Match(TokenId.RightParentheses);
                    return nullIfExpression;
                }

                case TokenId.Identifier:
                {
                    _rangeRecorder.Begin();
                    Identifier name = ParseIdentifier();
                    SourceRange nameSourceRange = _rangeRecorder.End();

                    if (_token.Id != TokenId.LeftParentheses)
                    {
                        NameExpression result = new NameExpression();
                        result.Name = name;
                        result.NameSourceRange = nameSourceRange;
                        return result;
                    }
                    else
                    {
                        bool hasAsteriskModifier;
                        ExpressionNode[] args;

                        if (_lookahead.Id != TokenId.Multiply)
                        {
                            hasAsteriskModifier = false;
                            args = ParseExpressionList();
                        }
                        else
                        {
                            NextToken();
                            NextToken();
                            Match(TokenId.RightParentheses);

                            hasAsteriskModifier = true;
                            args = new ExpressionNode[0];
                        }

                        FunctionInvocationExpression result = new FunctionInvocationExpression();
                        result.Name = name;
                        result.NameSourceRange = nameSourceRange;
                        result.Arguments = args;
                        result.HasAsteriskModifier = hasAsteriskModifier;
                        return result;
                    }
                }

                case TokenId.LeftParentheses:
                {
                    NextToken();

                    ExpressionNode expr;

                    if (_token.Id != TokenId.SELECT)
                    {
                        expr = ParseExpression();
                    }
                    else
                    {
                        SingleRowSubselect singleRowSubselect = new SingleRowSubselect();
                        singleRowSubselect.Query = ParseQuery();
                        expr = singleRowSubselect;
                    }

                    Match(TokenId.RightParentheses);
                    return expr;
                }

                default:
                {
                    _errorReporter.SimpleExpressionExpected(_token.Range, _token.Text);
                    return LiteralExpression.FromNull();
                }
            }
        }
Exemple #17
0
		public override ExpressionNode VisitSingleRowSubselect(SingleRowSubselect expression)
		{
		    _containsSingleRowSubselects = true;
			VisitQueryExpression(expression.Query);
			return expression;
		}