Deepak Mahto parses a command:
At first glance, this code block seems incomplete. Notice the
IF
condition: it appears to be missing an additional condition after theAND
operator. Logically, this should cause an exception due to the incomplete condition followingAND
.IF i = 0 AND THENHowever, during PL/pgSQL execution, the condition is evaluated without any syntax errors or warnings. This raises a critical question:
How does PostgreSQL internally process this condition?
What allows this seemingly incomplete expression to work?
Read on for those answers.