Re: [RFC] Add an until-0 loop in psql - Mailing list pgsql-hackers

From Pierre Ducroquet
Subject Re: [RFC] Add an until-0 loop in psql
Date
Msg-id 1774744.xorj2R6y5C@pierred-pdoc
Whole thread Raw
In response to Re: [RFC] Add an until-0 loop in psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: [RFC] Add an until-0 loop in psql
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: [RFC] Add an until-0 loop in psql
Next
From: Markus Winand
Date:
Subject: Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated with wrong context