* 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 definitions of variable name characters in * "src/fe_utils/psqlscan.l", "src/bin/psql/psqlscanslash.l" and * "src/bin/pgbench/exprscan.l". Also see parseVariable(), below. * * Note: this static function is copied from "src/
| 1566 | * but changed to disallow variable names starting with a digit. |
| 1567 | */ |
| 1568 | static bool |
| 1569 | valid_variable_name(const char *name) |
| 1570 | { |
| 1571 | const unsigned char *ptr = (const unsigned char *) name; |
| 1572 | |
| 1573 | /* Mustn't be zero-length */ |
| 1574 | if (*ptr == '\0') |
| 1575 | return false; |
| 1576 | |
| 1577 | /* must not start with [0-9] */ |
| 1578 | if (IS_HIGHBIT_SET(*ptr) || |
| 1579 | strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" |
| 1580 | "_", *ptr) != NULL) |
| 1581 | ptr++; |
| 1582 | else |
| 1583 | return false; |
| 1584 | |
| 1585 | /* remaining characters can include [0-9] */ |
| 1586 | while (*ptr) |
| 1587 | { |
| 1588 | if (IS_HIGHBIT_SET(*ptr) || |
| 1589 | strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" |
| 1590 | "_0123456789", *ptr) != NULL) |
| 1591 | ptr++; |
| 1592 | else |
| 1593 | return false; |
| 1594 | } |
| 1595 | |
| 1596 | return true; |
| 1597 | } |
| 1598 | |
| 1599 | /* |
| 1600 | * Lookup a variable by name, creating it if need be. |
no outgoing calls
no test coverage detected