Re: [RFC] Add an until-0 loop in psql

2018-04-30 Thread Peter Eisentraut
On 4/30/18 07:01, Daniel Verite wrote: >> As of v11, DO blocks can do transactions. I think this will meet your needs. > > They do support COMMIT and ROLLBACK in the current > development tree, but not VACUUM as in Pierre's example. Support for VACUUM can be added in the future. There is no big

Re: [RFC] Add an until-0 loop in psql

2018-04-30 Thread Corey Huinker
On Mon, Apr 30, 2018 at 7:05 AM Pierre Ducroquet < pierre.ducroq...@people-doc.com> wrote: > On Monday, April 30, 2018 1:01:25 PM CEST Daniel Verite wrote: > > Corey Huinker wrote: > > > As of v11, DO blocks can do transactions. I think this will meet your > > > needs. > > They do support

Re: [RFC] Add an until-0 loop in psql

2018-04-30 Thread Pierre Ducroquet
On Monday, April 30, 2018 1:01:25 PM CEST Daniel Verite wrote: > Corey Huinker wrote: > > As of v11, DO blocks can do transactions. I think this will meet your > > needs. > They do support COMMIT and ROLLBACK in the current > development tree, but not VACUUM as in Pierre's example. > >

Re: [RFC] Add an until-0 loop in psql

2018-04-30 Thread Daniel Verite
Corey Huinker wrote: > As of v11, DO blocks can do transactions. I think this will meet your needs. They do support COMMIT and ROLLBACK in the current development tree, but not VACUUM as in Pierre's example. postgres=# \echo :SERVER_VERSION_NAME 11devel postgres=# do ' begin vacuum;

Re: [RFC] Add an until-0 loop in psql

2018-04-28 Thread Pavel Stehule
2018-04-28 21:25 GMT+02:00 Corey Huinker : > >> I did it too. It is not too hard - there was not a agreement on syntax. >> >> can be nice some like CTE >> >> WITH PROCEDURE x(a int, b int) AS ... $$ SELECT x(10); >> > > I've seen "WITH function" syntax in Oracle

Re: [RFC] Add an until-0 loop in psql

2018-04-28 Thread Corey Huinker
> > > I did it too. It is not too hard - there was not a agreement on syntax. > > can be nice some like CTE > > WITH PROCEDURE x(a int, b int) AS ... $$ SELECT x(10); > I've seen "WITH function" syntax in Oracle (here's an example:

Re: [RFC] Add an until-0 loop in psql

2018-04-27 Thread Corey Huinker
>> What you don't see here is that you're using your psql process's >> available open file handles as a stack, and when you hit that limit psql >> will fail. If you remove that limit, then you get a bit further before psql >> segfaults on you. I think I got ~2700 files deep before that happened.

Re: [RFC] Add an until-0 loop in psql

2018-04-27 Thread Pavel Stehule
Hi 2018-04-27 21:40 GMT+02:00 Corey Huinker : > As of v11, DO blocks can do transactions. I think this will meet your > needs. > > A loop that starts at point X in the code and terminates at point Y has to > know how to jump back in the file (if there even is a file!) to

Re: [RFC] Add an until-0 loop in psql

2018-04-27 Thread Corey Huinker
As of v11, DO blocks can do transactions. I think this will meet your needs. A loop that starts at point X in the code and terminates at point Y has to know how to jump back in the file (if there even is a file!) to point X and re-interpret commands as it makes it's way back through the "file"

[RFC] Add an until-0 loop in psql

2018-04-24 Thread Pierre Ducroquet
Hi When running database migrations with .sql files on a live database, it's not uncommon to have to run a migration in a loop to prevent a big lock on a table. For instance if one want to delete some old datas from a big table one would write : DELETE FROM big_table WHERE id IN (SELECT id