1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Don't crash on empty statements in SQL-standard function bodies.

gram.y should discard NULL pointers (empty statements) when
assembling a routine_body_stmt_list, as it does for other
sorts of statement lists.

Julien Rouhaud and Tom Lane, per report from Noah Misch.

Discussion: https://postgr.es/m/20210606044418.GA297923@rfd.leadboat.com
This commit is contained in:
Tom Lane
2021-06-08 11:59:34 -04:00
parent 37e1cce4dd
commit bfeede9fa4
3 changed files with 7 additions and 3 deletions

View File

@ -7990,7 +7990,11 @@ opt_routine_body:
routine_body_stmt_list:
routine_body_stmt_list routine_body_stmt ';'
{
$$ = lappend($1, $2);
/* As in stmtmulti, discard empty statements */
if ($2 != NULL)
$$ = lappend($1, $2);
else
$$ = $1;
}
| /*EMPTY*/
{