Ejemplo n.º 1
0
        public SysVarPrimary SystemVariable()
        {
            SysVarPrimary sys;
            VariableScope scope = VariableScope.Session;
            string        str   = lexer.StringValue;
            string        strUp = lexer.StringValueUppercase;

            Match(MySQLToken.SYS_VAR);
            SpecialIdentifier si = SpecialIdentifier.Global;

            if (Enum.TryParse <SpecialIdentifier>(strUp, out si))
            {
                switch (si)
                {
                case SpecialIdentifier.Global:
                    scope = VariableScope.Global;
                    break;

                case SpecialIdentifier.Session:
                case SpecialIdentifier.Local:
                    Match(MySQLToken.PUNC_DOT);
                    str   = lexer.StringValue;
                    strUp = lexer.StringValueUppercase;
                    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);
        }
Ejemplo n.º 2
0
        private SelectStatement.SelectOption SelectOption()
        {
            SelectStatement.SelectOption option = new SelectStatement.SelectOption();
            MySQLToken token = MySQLToken.NONE;

            for (; ; lexer.NextToken())
            {
                token = lexer.Token();
                if (token == MySQLToken.KW_ALL)
                {
                    option.resultDup = SelectStatement.SelectDuplicationStrategy.All;
                }
                else if (token == MySQLToken.KW_DISTINCT)
                {
                    option.resultDup = SelectStatement.SelectDuplicationStrategy.Distinct;
                }
                else if (token == MySQLToken.KW_DISTINCTROW)
                {
                    option.resultDup = SelectStatement.SelectDuplicationStrategy.DistinctRow;
                }
                else if (token == MySQLToken.KW_HIGH_PRIORITY)
                {
                    option.highPriority = true;
                }
                else if (token == MySQLToken.KW_STRAIGHT_JOIN)
                {
                    option.straightJoin = true;
                }
                else if (token == MySQLToken.KW_SQL_SMALL_RESULT)
                {
                    option.resultSize = SelectStatement.SmallOrBigResult.SqlSmallResult;
                }
                else if (token == MySQLToken.KW_SQL_BIG_RESULT)
                {
                    option.resultSize = SelectStatement.SmallOrBigResult.SqlBigResult;
                }
                else if (token == MySQLToken.KW_SQL_CALC_FOUND_ROWS)
                {
                    option.sqlCalcFoundRows = true;
                }
                else if (token == MySQLToken.IDENTIFIER)
                {
                    string            optionStringUp = lexer.StringValueUppercase;
                    SpecialIdentifier specialId      = SpecialIdentifier.SqlBufferResult;
                    if (Enum.TryParse <SpecialIdentifier>(optionStringUp, out specialId))
                    {
                        switch (specialId)
                        {
                        case SpecialIdentifier.SqlBufferResult:
                            if (option.sqlBufferResult)
                            {
                                return(option);
                            }
                            option.sqlBufferResult = true;
                            break;

                        case SpecialIdentifier.SqlCache:
                            if (option.queryCache != SelectStatement.QueryCacheStrategy.Undefine)
                            {
                                return(option);
                            }
                            option.queryCache = SelectStatement.QueryCacheStrategy.SqlCache;
                            break;

                        case SpecialIdentifier.SqlNoCache:
                            if (option.queryCache != SelectStatement.QueryCacheStrategy.Undefine)
                            {
                                return(option);
                            }
                            option.queryCache = SelectStatement.QueryCacheStrategy.SqlNoCache;
                            break;
                        }
                    }
                }
                else
                {
                    return(option);
                }
            }
        }