diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l
index a492a32416..58026fe90a 100644
--- a/src/fe_utils/psqlscan.l
+++ b/src/fe_utils/psqlscan.l
@@ -871,7 +871,9 @@ other           .

 {identifier}   {
                    cur_state->identifier_count++;
-                   if (pg_strcasecmp(yytext, "begin") == 0)
+                   if ((pg_strcasecmp(yytext, "begin") == 0)
+                       || (pg_strcasecmp(yytext, "case") == 0)
+                       )
                    {
                        if (cur_state->identifier_count > 1)
                            cur_state->begin_depth++;
