proposal: plpgsql: special comments that will be part of AST - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: plpgsql: special comments that will be part of AST
Date
Msg-id CAFj8pRBmQ195e4-1OFh-rY0+BTD5FhROrfUwXUC+VhryMQ308A@mail.gmail.com
Whole thread Raw
Responses Re: proposal: plpgsql: special comments that will be part of AST  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hi,

As an author of plpgsql_check, I permanently have to try to solve genetic problems with the necessity of external information for successful static validation.

create or replace function foo(tablename text)
returns void as $$
declare r record;
begin
  execute format('select * from %I', tablename) into r;
  raise notice '%', r.x;
end;
$$ language plpgsql;

On this very simple code it is not possible to make static validation. Currently, there is no way to push some extra information to source code, that helps with static analysis, but doesn't break evaluation without plpgsql_check, and doesn't do some significant slowdown.

I proposed Ada language pragmas, but it was rejected.

I implemented fake pragmas in plpgsql_check via arguments of special function

PERFORM plpgsql_check_pragma('plpgsql_check: off');

It is working, but it looks bizarre, and it requires a fake function plpgsql_check_pragma on production, so it is a little bit a dirty solution.

Now, I have another proposal(s).

a) Can we invite new syntax for comments, that will be stored in AST like a non executing statement?

some like:

//* plpgsql_check: OFF *//
RAISE NOTICE '%', r.x

or second design

b) can we introduce some flag for plpgsql_parser, that allows storing comments in AST (it will not be default).

so  "-- plpgsql_check: OFF " will work for my purpose, and I don't need any special syntax.

Comments, notes?

Pavel

pgsql-hackers by date:

Previous
From: Soumyadeep Chakraborty
Date:
Subject: Re: A micro-optimisation for ProcSendSignal()
Next
From: Amit Kapila
Date:
Subject: Re: [bug?] Missed parallel safety checks, and wrong parallel safety