private void SetVersion() { try { var stmt = @"select @@version"; var versionStr = (String)this.ExecuteSingleValue(stmt); if (!String.IsNullOrEmpty(versionStr)) { var regex = new Regex(@"([0-9]{1})\.([0-9]+)\.([0-9]+).*"); var match = regex.Match(versionStr); if (match.Success && match.Groups.Count == 4) { var major = Int32.Parse(match.Groups[1].Value); var minor = Int32.Parse(match.Groups[2].Value); var fix = Int32.Parse(match.Groups[3].Value); this._runningVersion = new MySQLVersion { Major = major, Minor = minor, Fix = fix }; } } } catch { } }
public static bool isReservedKeyword(string identifier, MySQLVersion version) { bool found = reservedKeywords.TryGetValue(version, out HashSet <string> value); if (!found) { return(false); } return(value.Contains(identifier)); }
public static HashSet <string> systemFunctionsForVersion(MySQLVersion version) { switch (version) { case MySQLVersion.MySQL56: return(SystemFunctions.systemFunctions56); case MySQLVersion.MySQL57: return(SystemFunctions.systemFunctions57); case MySQLVersion.MySQL80: return(SystemFunctions.systemFunctions80); default: return(empty); } }
public static bool isKeyword(string identifier, MySQLVersion version) { var keywords = keywordsForVersion(version); return(keywords.Contains(identifier)); }
public static bool isReservedKeyword(string identifier, MySQLVersion version) { keywordsForVersion(version); return(reservedKeywords[version].Contains(identifier)); }
public static HashSet <string> keywordsForVersion(MySQLVersion version) { if (!keywords.ContainsKey(version)) { HashSet <string> list = new HashSet <string>(); HashSet <string> reservedList = new HashSet <string>(); switch (version) { case MySQLVersion.MySQL56: { int listSize = KeywordLists.keyword_list56.Count; for (int i = 0; i < listSize; ++i) { string word = KeywordLists.keyword_list56[i].word; list.Add(word); if (KeywordLists.keyword_list56[i].reserved != 0) { reservedList.Add(word); } } break; } case MySQLVersion.MySQL57: { int listSize = KeywordLists.keyword_list57.Count; for (int i = 0; i < listSize; ++i) { string word = KeywordLists.keyword_list57[i].word; list.Add(word); if (KeywordLists.keyword_list57[i].reserved != 0) { reservedList.Add(word); } } break; } case MySQLVersion.MySQL80: { int listSize = KeywordLists.keyword_list80.Count; for (int i = 0; i < listSize; ++i) { string word = KeywordLists.keyword_list80[i].word; list.Add(word); if (KeywordLists.keyword_list80[i].reserved != 0) { reservedList.Add(word); } } break; } default: break; } keywords[version] = list; } return(keywords[version]); }
public static HashSet <string> keywordsForVersion(MySQLVersion version) { if (!keywords.TryGetValue(version, out HashSet <string> value) || value.Count == 0) { HashSet <string> list = new HashSet <string>(); HashSet <string> reservedList = new HashSet <string>(); switch (version) { case MySQLVersion.MySQL56: { foreach (var keyword in keyword_list56.data) { string word = keyword.Item1; list.Add(word); if (keyword.Item2 != 0) { reservedList.Add(word); } } break; } case MySQLVersion.MySQL57: { foreach (var keyword in keyword_list57.data) { string word = keyword.Item1; list.Add(word); if (keyword.Item2 != 0) { reservedList.Add(word); } } break; } case MySQLVersion.MySQL80: { foreach (var keyword in keyword_list80.data) { string word = keyword.Item1; list.Add(word); if (keyword.Item2 != 0) { reservedList.Add(word); } } break; } default: break; } keywords[version] = list; } return(keywords[version]); }
public static HashSet <string> systemFunctionsForVersion(MySQLVersion version) { throw new Exception(); }