PolarDB supports parsers for compiling functions and stored procedures. Parsers verify that the CREATE statement and the program body (the program portion following the AS keyword) conform to the SPL and SQL syntax. If a parser detects an error, the server automatically stops the compilation process.

Note that the parser detects syntax errors in expressions, rather than semantic errors. For example, if an expression references a nonexistent column, table, function, or a value of the incorrect type, an exception is thrown.

You can instruct the server to stop parsing if the parser finds one or more errors in SPL code or an error in SQL code. You can specify the spl.max_error_count parameter to control the maximum number of errors that are allowed in SPL code. The default value of the spl.max_error_count parameter is 10. The maximum value is 1000. You can set the value of spl.max_error_count to 1, which instructs the server to stop parsing when the first error in SPL or SQL code occurs.

You can use the SET command in the current session to specify a value for spl.max_error_count. Syntax:
SET spl.max_error_count = number_of_errors
number_of_errors specifies the number of SPL code errors that is allowed to occur before the server stops the compilation process. Example:
SET spl.max_error_count = 6

In this example, the server continues parsing regardless of the first five SPL code errors. When the sixth error occurs, the server stops parsing, and the six detailed error messages and an error summary are displayed.

When developing new code or importing existing code from other sources, you can set the spl.max_error_count parameter to a large value to save time.

You can instruct the server to continue parsing when an error occurs in the SPL code of a program body. The parser may then encounter an error in an SQL code segment. In this case, errors may still exist in any SPL or SQL code that follows the invalid SQL code. For example, two errors exist in the following code:
CREATE FUNCTION computeBonus(baseSalary number) RETURN number AS
BEGIN

    bonus := baseSalary * 1.10;
    total := bonus + 100;

    RETURN bonus;
END;

ERROR:  "bonus" is not a known variable
LINE 4:     bonus := baseSalary * 1.10;
            ^
ERROR:  "total" is not a known variable
LINE 5: total: = bonus + 100;
            ^
ERROR:  compilation of SPL function/procedure "computebonus" failed due to 2 errors
In the following example, a new SELECT statement is added to the preceding example. The error in the SELECT statement masks other errors that follow.
CREATE FUNCTION computeBonus(employeeName number) RETURN number AS
BEGIN
    SELECT salary INTO baseSalary FROM emp 
      WHERE ename = employeeName;

    bonus := baseSalary * 1.10;
    total := bonus + 100;

    RETURN bonus;

END; 

ERROR:  "basesalary" is not a known variable
LINE 3:     SELECT salary INTO baseSalary FROM emp WHERE ename = emp...