Add .parse_plpgsql method to parse PL/pgSQL function definitions - #316
Add .parse_plpgsql method to parse PL/pgSQL function definitions#316lfittl wants to merge 1 commit into
Conversation
This uses Postgres' PL/pgSQL parser (as extracted in libpg_query) to parse a PL/pgSQL CREATE FUNCTION statement into the AST.
| @@ -0,0 +1,43 @@ | |||
| require 'json' | |||
| module PgQuery | |||
There was a problem hiding this comment.
| module PgQuery | |
| module PgQuery |
| module PgQuery | ||
| class PlpgsqlParseError < ArgumentError | ||
| attr_reader :location | ||
| def initialize(message, source_file, source_line, location) |
There was a problem hiding this comment.
| def initialize(message, source_file, source_line, location) | |
| def initialize(message, source_file, source_line, location) |
|
Hi, I have some interest in this functionality and am using a fork. Is this PR likely to be merged more-or-less in its current form? BTW thanks @lfittl and @olleolleolle for all your efforts with this library! |
Good question! I've been meaning to merge this in, but haven't yet. One of the key reasons why is that I'm not sure whether we shouldn't also be using a Protobuf-based struct for the PL/PgSQL parsing, instead of JSON. That'd require changing this on the libpg_query side. I may try to do that once we rebase libpg_query for Postgres 18 (end of September timeframe), and I'd rework this PR on that version then. Out of curiosity, what's your use case for function definition parsing? |
This uses Postgres' PL/pgSQL parser (as extracted in libpg_query) to parse a PL/pgSQL CREATE FUNCTION statement into the AST.
TODO