Inheritance: VariableExpression
Example #1
0
        /// <summary>
        ///     first token must be
        ///     <see cref="MySqlToken.SysVar" />
        /// </summary>
        /// <exception cref="System.SqlSyntaxErrorException" />
        public virtual SysVarPrimary SystemVariale()
        {
            SysVarPrimary sys;
            var scope = VariableScope.Session;
            var str = lexer.GetStringValue();
            var strUp = lexer.GetStringValueUppercase();
            Match(MySqlToken.SysVar);
            var si = specialIdentifiers.GetValue(strUp);
            if (si != SpecialIdentifier.None)
            {
                switch (si)
                {
                    case SpecialIdentifier.Global:
                    {
                        scope = VariableScope.Global;
                        goto case SpecialIdentifier.Session;
                    }

                    case SpecialIdentifier.Session:
                    case SpecialIdentifier.Local:
                    {
                        Match(MySqlToken.PuncDot);
                        str = lexer.GetStringValue();
                        strUp = lexer.GetStringValueUppercase();
                        Match(MySqlToken.Identifier);
                        sys = new SysVarPrimary(scope, str, strUp);
                        sys.SetCacheEvalRst(cacheEvalRst);
                        return sys;
                    }
                }
            }
            sys = new SysVarPrimary(scope, str, strUp);
            sys.SetCacheEvalRst(cacheEvalRst);
            return sys;
        }
Example #2
0
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object VarAssign()
        {
            VariableExpression var;
            IExpression expr;
            var scope = VariableScope.Session;
            switch (lexer.Token())
            {
                case MySqlToken.Identifier:
                {
                    var explictScope = false;
                    var si = specialIdentifiers.GetValue(lexer.GetStringValueUppercase());
                    if (si != SpecialIdentifier.None)
                    {
                        switch (si)
                        {
                            case SpecialIdentifier.Transaction:
                            {
                                return SetMTSSetTransactionStatement(VariableScope.None);
                            }

                            case SpecialIdentifier.Global:
                            {
                                scope = VariableScope.Global;
                                goto case SpecialIdentifier.Session;
                            }

                            case SpecialIdentifier.Session:
                            case SpecialIdentifier.Local:
                            {
                                explictScope = true;
                                lexer.NextToken();
                                goto default;
                            }

                            default:
                            {
                                break;
                            }
                        }
                    }
                    if (explictScope
                        && specialIdentifiers.GetValue(lexer.GetStringValueUppercase()) == SpecialIdentifier.Transaction)
                    {
                        return SetMTSSetTransactionStatement(scope);
                    }
                    var = new SysVarPrimary(scope, lexer.GetStringValue(), lexer.GetStringValueUppercase());
                    Match(MySqlToken.Identifier);
                    break;
                }

                case MySqlToken.SysVar:
                {
                    var = SystemVariale();
                    break;
                }

                case MySqlToken.UsrVar:
                {
                    var = new UsrDefVarPrimary(lexer.GetStringValue());
                    lexer.NextToken();
                    break;
                }

                default:
                {
                    throw Err("unexpected token for SET statement");
                }
            }
            Match(MySqlToken.OpEquals, MySqlToken.OpAssign);
            expr = exprParser.Expression();
            return new Pair<VariableExpression, IExpression>(var, expr);
        }
 public virtual void Visit(SysVarPrimary node)
 {
 }