MCPcopy Create free account
hub / github.com/apache/cloudberry / valid_variable_name

Function valid_variable_name

src/bin/psql/variables.c:21–41  ·  view source on GitHub ↗

* Check whether a variable's name is allowed. * * We allow any non-ASCII character, as well as ASCII letters, digits, and * underscore. Keep this in sync with the definition of variable_char in * psqlscan.l and psqlscanslash.l. */

Source from the content-addressed store, hash-verified

19 * psqlscan.l and psqlscanslash.l.
20 */
21static bool
22valid_variable_name(const char *name)
23{
24 const unsigned char *ptr = (const unsigned char *) name;
25
26 /* Mustn't be zero-length */
27 if (*ptr == '\0')
28 return false;
29
30 while (*ptr)
31 {
32 if (IS_HIGHBIT_SET(*ptr) ||
33 strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"
34 "_0123456789", *ptr) != NULL)
35 ptr++;
36 else
37 return false;
38 }
39
40 return true;
41}
42
43/*
44 * A "variable space" is represented by an otherwise-unused struct _variable

Callers 2

SetVariableFunction · 0.70
SetVariableHooksFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected