I have seen the double dollar sign ($$) being used often in FUNCTION declarations and while doing declare statements. I acknowledge that it is probably some syntax related feature, but I am not too clear how/why to use it and when.
Code examples of usage below:
CREATE OR REPLACE FUNCTION BuildFunction(IN prefix TEXT, IN func_id INTEGER) RETURNS BOOLEAN AS $$
BEGIN
...
END; $$
Point of confusion, how do you return a boolean as a $$, is it some special type or something?
DO $$
DECLARE
a integer := 10;
b integer := 20;
c integer;
BEGIN
c := a + b;
RAISE NOTICE'Value of c: %', c;
END $$;
This code snippet is from How do you use variables in a simple PostgreSQL script?