You can alter the lexer and create a comment node, right? That’s how we did hints in EnterpriseDB.
I don't think so it is adequate solution - sure, it is, if I would to implement Oracle's hints. But it is not my target. I afraid about performance impacts a) for SQL queries, b) for plpgsql.
I had a possibility to see a functions, procedures (ported from Oracle) with thousands lines of comments. It is not a Oracle problem, due compilation to persistent byte code. But I don't think so this cost is accepted for pragma implementation.
The native plpgsql statement PRAGMA has zero performance impact on existing code. More, the implementation is just local inside plpgsql, what is important for me.
I looked there and It is not possible to implement it - plpgsql uses SQL lexer, and the content of comments are just ignored. So I cannot to read comments. There is not any possibility to read it simply from plpgsql. Unfortunately, but it is expected, there is nothing like query string for plpgsql statement.