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

From: Pierre Ducroquet <pierre(dot)ducroquet(at)people-doc(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [RFC] Add an until-0 loop in psql
Date: 2018-04-30 11:05:36
Message-ID: 1774744.xorj2R6y5C@pierred-pdoc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Markus Winand 2018-04-30 12:03:46 Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated with wrong context
Previous Message Daniel Verite 2018-04-30 11:01:25 Re: [RFC] Add an until-0 loop in psql