I'm still a bit confused. If I replace the ROLLBACK; command with ELEPHANT; the result is a syntax error. Why doesn't ROLLBACK; produce the same error since it is not valid in the LANGUAGE plpgsql. I understand that "ROLLBACK TO SAVEPOINT" IS valid. But it's not the same thing.
Here is the complete function, but all you need to look at is the exception block. (I didn't write this code) :-) I will ask the question after the code.
[...]
RETURN TRUE;
EXCEPTION WHEN OTHERS THEN
RAISE EXCEPTION '% %', SQLERRM, SQLSTATE;
ROLLBACK;
RETURN FALSE;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
So, here is the question. Why does the compiler not catch:
1) ROLLBACK; is not a valid PL/pgSQL command
R
eading section 41.10.2 at the linked page should answer this part.