pganalyze / pg_query_go

Go library to parse and normalize SQL queries using the PostgreSQL query parser
BSD 3-Clause "New" or "Revised" License
663 stars 79 forks source link

Deparse of CREATE TRIGGER … EXECUTE PROCEDURE gives statement with syntax error #70

Closed lwithers closed 1 year ago

lwithers commented 1 year ago

Hi,

If I try to parse and then de-parse the SQL:

CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE PROCEDURE p()

then I end up with the slightly different result:

CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p()

Unfortunately, the latter is a syntax error:

postgres=# CREATE TRIGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p();
ERROR:  syntax error at or near "FUNCTION"
LINE 1: ...IGGER tr AFTER INSERT ON rel FOR EACH ROW EXECUTE FUNCTION p...

I have attached a reproducer: deparse_proc_func.go.gz

lwithers commented 1 year ago

Ah, and having raised the issue I discover this is due to a difference in PostgresQL 10 (which I am unfortunately still stuck with for another few months). In PostgresQL 11+, EXECUTE FUNCTION is accepted (and preferred) syntax.

I don't think there's anything for the project to do here, so closing.