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.
>
> postgres=# \echo :SERVER_VERSION_NAME
> 11devel
>
> postgres=# do ' begin vacuum; end ';
> ERROR: VACUUM cannot be executed from a function
> CONTEXT: SQL statement "vacuum"
> PL/pgSQL function inline_code_block line 1 at SQL statement
>
>
> Best regards,
Indeed, vacuum is going to be the biggest offender here, sadly.
One could work around this of course (on top of my head, using notify to wake-
up another client that would launch the required vacuums…)
Being able to do transactions in DO blocks is a great new feature of v11 I was
not aware of. But psql saw the addition of \if recently, so why not having
loops in there too ? (Something better than this hack of course, it was just a
10 minutes hack-sprint for a demo)
Regards
Pierre