MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / GetKeywordID

Function GetKeywordID

pkg/sql/plpgsql/parser/lexbase/keywords.go:239–359  ·  view source on GitHub ↗

GetKeywordID returns the lex id of the SQL keyword k or IDENT if k is not a keyword.

(k string)

Source from the content-addressed store, hash-verified

237// GetKeywordID returns the lex id of the SQL keyword k or IDENT if k is
238// not a keyword.
239func GetKeywordID(k string) int32 {
240 // The previous implementation generated a map that did a string ->
241 // id lookup. Various ideas were benchmarked and the implementation below
242 // was the fastest of those, between 3% and 10% faster (at parsing, so the
243 // scanning speedup is even more) than the map implementation.
244 switch k {
245 case "absolute": return ABSOLUTE
246 case "alias": return ALIAS
247 case "all": return ALL
248 case "and": return AND
249 case "array": return ARRAY
250 case "assert": return ASSERT
251 case "backward": return BACKWARD
252 case "begin": return BEGIN
253 case "by": return BY
254 case "call": return CALL
255 case "case": return CASE
256 case "chain": return CHAIN
257 case "close": return CLOSE
258 case "collate": return COLLATE
259 case "column": return COLUMN
260 case "column_name": return COLUMN_NAME
261 case "commit": return COMMIT
262 case "constant": return CONSTANT
263 case "constraint": return CONSTRAINT
264 case "constraint_name": return CONSTRAINT_NAME
265 case "continue": return CONTINUE
266 case "current": return CURRENT
267 case "cursor": return CURSOR
268 case "datatype": return DATATYPE
269 case "debug": return DEBUG
270 case "declare": return DECLARE
271 case "default": return DEFAULT
272 case "detail": return DETAIL
273 case "diagnostics": return DIAGNOSTICS
274 case "do": return DO
275 case "dump": return DUMP
276 case "else": return ELSE
277 case "elsif": return ELSIF
278 case "end": return END
279 case "end_case": return END_CASE
280 case "end_if": return END_IF
281 case "errcode": return ERRCODE
282 case "error": return ERROR
283 case "exception": return EXCEPTION
284 case "execute": return EXECUTE
285 case "exit": return EXIT
286 case "fetch": return FETCH
287 case "first": return FIRST
288 case "for": return FOR
289 case "foreach": return FOREACH
290 case "forward": return FORWARD
291 case "from": return FROM
292 case "get": return GET
293 case "hint": return HINT
294 case "if": return IF
295 case "import": return IMPORT
296 case "in": return IN

Callers 1

scanIdentMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…