Hello,
You'll find enclosed the first version of my patch. I did not include the possibility of using a file to list tables to be exported as Tom suggested because I genuinely think it is a totally different matter. It does not mean I'm not open to the possibility, it just felt weird.
The patch allows using a `--functions-only` flag in `pg_dump` to export only functions and stored procedures. My code was build and passed tests on the last master branch of the PostgreSQL project. I added regression tests. Documentation has been updated too and generation of the documentation (HTML, man page, pdf in A4 and letter US format) has been tested successfully.
I did not add a warning in the documentation that the file provided might end up in a not restorable file or in a file restoring broken functions or procedures. Do you think I should?
I don't know if this patch has any impact on performance. I guess that adding 4 if statements will slow down `pg_dump` a little bit.
Vik Fearing <vik@postgresfriends.org> writes:
> On 3/17/21 6:00 PM, Lætitia Avrot wrote:
>> However, when I finally got the time to look at it in detail, I found out
>> there was no way to solve the dependencies in the functions and procedures,
>> so that the exported file, when re-played could lead to invalid objects.
>> ...
>> So, my question is: what do you think about such a feature? is it worth it?
> Yes, it is absolutely worth it to be able to extract just the functions
> from a database. I have wanted this several times.
Selective dumps always have a risk of not being restorable on their
own; I don't see that "functions only" is noticeably less safe than
"just these tables", or other cases that we support already.
What I'm wondering about is how this might interact with the
discussion at [1].
regards, tom lane
[1] https://www.postgresql.org/message-id/flat/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com