MCPcopy Create free account
hub / github.com/bytebase/bytebase / isReservedKeyword

Function isReservedKeyword

backend/plugin/parser/tidb/completion.go:385–393  ·  view source on GitHub ↗

isReservedKeyword reports whether a bare-shaped name is a reserved keyword that cannot be used as an unquoted identifier. omni exposes no reserved-word predicate, so we parse-check only names that lex as a single keyword token (plain identifiers are never reserved), which keeps this cheap for ordina

(name string)

Source from the content-addressed store, hash-verified

383// (plain identifiers are never reserved), which keeps this cheap for ordinary
384// names. A keyword is reserved iff it cannot stand as a bare table reference.
385func isReservedKeyword(name string) bool {
386 upper := strings.ToUpper(name)
387 toks := tidbparser.Tokenize(upper)
388 if len(toks) != 1 || tidbparser.TokenName(toks[0].Type) == "" {
389 return false
390 }
391 _, err := tidbparser.Parse("SELECT 1 FROM " + upper)
392 return err != nil
393}
394
395// caretInsideBacktickIdentifier reports whether the caret sits inside an open
396// backtick-quoted identifier (an odd number of backticks precede it), in which

Callers 1

identifierNeedsQuotingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected