3 ms·
PL/pgSQL needs some styling improvements: 1. Get a better name, PL/pgSQL doesn't exactly roll off the tongue. 2. Get rid of those $$ at the start and end of a
by jasfi 4y ago
PL/pgSQL needs some styling improvements:
1. Get a better name, PL/pgSQL doesn't exactly roll off the tongue.
2. Get rid of those $$ at the start and end of any PL/pgSQL, it's just verbose and ugly.
- jaggederest 4y agoDollar quoting is just the easiest way to write strings with lots of escape characters, it's not required (I think it's the best way to do pl/pgsql though). You can also tag dollar-quoted strings: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING https://www.postgresql.org/docs/current/sql-syntax-lexical.h...
- hans_castorp 4y 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.