3 ms·
> Get rid of those $$ at the start and end of any PL/pgSQL, it's just verbose and ugly. The Postgres parser itself doesn't know the language rules and thus ca
by hans_castorp 3y ago
> Get rid of those $$ at the start and end of any PL/pgSQL, it's just verbose and ugly.
The Postgres parser itself doesn't know the language rules and thus can not parse the source code. The body of the function/procedure is passed to the language handler as a string without Postgres looking at it. The procedural code (PL/pgSQL, PL/python, PL/perl, plv8, ...) will not be parsed until the function/procedure is actually executed.
Today there might be better ways to implement such a dynamic system to register new languages, but I guess it will be huge effort to change this to a way that would understand the old and the new syntax.
Since Postgres 14, at least "LANGUAGE SQL" functions/procedures can be written without using dollar quoting if the SQL/PSM syntax is used.