| 141 | const size_t kNameLenMax = 512; |
| 142 | |
| 143 | bool IsValidName(const std::string& str) { |
| 144 | if (str.size() < kNameLenMin || kNameLenMax < str.size()) { |
| 145 | return false; |
| 146 | } |
| 147 | if (!(isupper(str[0]) || islower(str[0]))) { |
| 148 | return false; |
| 149 | } |
| 150 | for (size_t i = 0; i < str.size(); ++i) { |
| 151 | char c = str[i]; |
| 152 | if (!(isdigit(c) || isupper(c) || islower(c) || (c == '_') || (c == '.') || (c == '-') || |
| 153 | (c == '#'))) { |
| 154 | return false; |
| 155 | } |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | bool IsValidColumnFamilyName(const std::string& str) { |
| 161 | if ((64 * 1024 - 1) < str.size()) { // [0, 64KB) |