MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / isBareIdentifier

Function isBareIdentifier

pkg/sql/lex/predicates.go:71–92  ·  view source on GitHub ↗

isBareIdentifier returns true if the input string is a permissible bare SQL identifier.

(s string)

Source from the content-addressed store, hash-verified

69// isBareIdentifier returns true if the input string is a permissible bare SQL
70// identifier.
71func isBareIdentifier(s string) bool {
72 if len(s) == 0 || !IsIdentStart(int(s[0])) || (s[0] >= 'A' && s[0] <= 'Z') {
73 return false
74 }
75 // Keep track of whether the input string is all ASCII. If it is, we don't
76 // have to bother running the full Normalize() function at the end, which is
77 // quite expensive.
78 isASCII := s[0] < utf8.RuneSelf
79 for i := 1; i < len(s); i++ {
80 if !IsIdentMiddle(int(s[i])) {
81 return false
82 }
83 if s[i] >= 'A' && s[i] <= 'Z' {
84 // Non-lowercase identifiers aren't permissible.
85 return false
86 }
87 if s[i] >= utf8.RuneSelf {
88 isASCII = false
89 }
90 }
91 return isASCII || NormalizeName(s) == s
92}
93
94// IsIdentStart returns true if the character is valid at the start of an identifier.
95func IsIdentStart(ch int) bool {

Callers 2

EncodeRestrictedSQLIdentFunction · 0.85

Calls 3

IsIdentStartFunction · 0.85
IsIdentMiddleFunction · 0.85
NormalizeNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…