Re: Add partial :-variable expansion to psql \copy

2025-05-01 Thread Akshat Jaimini
Hi, I am unable to apply the patch on master. Can you please confirm if the patch is rebased? Regards, Akshat Jaimini

Re: Add partial :-variable expansion to psql \copy

2025-04-16 Thread Fabien Coelho
Hello, Here is a rebased and updated version of adding \gi: - improved documentation - some refactoring to share one function - signal trap disabled on \gi as well The thread subject is now a misnomer, I'm not sure whether I should update it or start a new thread. On 05/04/2025 22:14, Fabien

Re: Add partial :-variable expansion to psql \copy

2025-04-05 Thread Fabien Coelho
Hello Tom and Corey, [...] Anyway, my feeling about it is that \copy parsing is a huge hack right now, and I'd rather see it become less of a hack, that is more like other psql commands, instead of getting even hackier. After giving it some thoughts, I concluded that trying to salvage \copy i

Re: Add partial :-variable expansion to psql \copy

2025-04-05 Thread Tom Lane
Fabien COELHO writes: > I've been biten by psql's \copy lack of variable expansion, in a > limited-access docker-inside-VM context where COPY is not a viable option and > hardwired names are not desirable. The attached patch allows \copy to use > variable's values in place of table and file nam

RE: Add partial :-variable expansion to psql \copy

2025-04-05 Thread Fabien COELHO
Always better with a file attached :-/ Sorry for the noise. -- Fabien. De : Fabien COELHO Envoyé : lundi 31 mars 2025 13:48 À : PostgreSQL Hackers Objet : Add partial :-variable expansion to psql \copy Hello, I've been biten by psql's \copy lack of variable ex

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Corey Huinker
> > I'm hesitating about the right syntax, though, for an input backslash > command which in effect would really only apply to COPY? ISTM that \g* is > used for "go", i.e. a semi-colon replacement which executes the SQL, and we > should want the same thing, which suggests: > making it a \g-variant

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Fabien Coelho
Hello Corey, If we could do this:     COPY :"myschema".:"mytable" FROM STDIN \g < :"myfilename" that would fit our patterns most cleanly, but we would probably create a parsing hassle for ourselves if we ever wanted to mix pipe-to with pipe-from. It would also require checking on every comma

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Daniel Verite
Christoph Berg wrote: > Perhaps this form could be improved by changing `\copy (select) to file` > to something like `select \gcopy (to file)`. That might make :expansion > in the "select" part easier to handle. In this direction (COPY TO), it was already taken care of by commit 6d3ede5f1

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Pavel Stehule
Hi út 1. 4. 2025 v 12:00 odesílatel Christoph Berg napsal: > Re: Fabien Coelho > > (1) it seems that is the only command which is really full SQL hidden in > a > > backslash command > > Perhaps this form could be improved by changing `\copy (select) to file` > to something like `select \gcopy (t

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Christoph Berg
Re: Fabien Coelho > (1) it seems that is the only command which is really full SQL hidden in a > backslash command Perhaps this form could be improved by changing `\copy (select) to file` to something like `select \gcopy (to file)`. That might make :expansion in the "select" part easier to handle.

Re: Add partial :-variable expansion to psql \copy

2025-04-01 Thread Fabien Coelho
On 31/03/2025 17:09, Tom Lane wrote: Fabien COELHO writes: [...] The attached patch allows \copy to use variable's values in place of table and file names: Hm ... I'm on board with the general idea of the feature, but I find this implementation quite horrid. Indeed, I just added the stuff i

Re: Add partial :-variable expansion to psql \copy

2025-03-31 Thread Corey Huinker
> > Anyway, my feeling about it is that \copy parsing is a huge hack > right now, and I'd rather see it become less of a hack, that is > more like other psql commands, instead of getting even hackier. > I wasn't as horrified as Tom, but it did have the feeling of it solving half the problem. We c