What are the default rules used by the parser for parsing names of built-in functions?

MySQLMySQLi Database

Actually, when a parser encounters a word that is the name of a built-in function, it must determine whether the name represents a function call or is instead a non-expression reference to an identifier such as a table or column name. consider the following queries −

1. Select sum(salary) from employee;
2. Create table sum (i int);

In the first query SUM is a reference to a function call and in the second query, it is referencing to table name.

Parser follows the following rules to distinguish whether their names are being used as function calls or as identifiers in non-reference context −

  • Rule1 − To use the name as a function call in an expression, there must be no whitespace between the name and the following ( parenthesis character).
  • Rule2 − Conversely, to use the function name as an identifier, it must not be followed immediately by a parenthesis.
raja
Published on 21-Feb-2018 08:11:35
Advertisements