Re: psql - -dry-run option - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: psql - -dry-run option
Date
Msg-id CAMsr+YGiYQ7PYvYR2Voio37YdCpp79j5S+cmgVJMOLM2LnRQcA@mail.gmail.com
Whole thread Raw
In response to Re: psql - -dry-run option  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
List pgsql-hackers
On 18 December 2015 at 16:50, Shulgin, Oleksandr <oleksandr.shulgin@zalando.de> wrote:
 
I'm on the same line: BEGIN/ROLLBACK requires trivial effort and a --dry-run option might give a false sense of security, but it cannot possibly rollback side-effects of user functions which modify filesystem or interact with the outside world in some other way.

Pretty much. Side effects.

The most glaringly obvious example is nextval(...) and setval(...). You can't make them have no effect, since your script will then fail to run. But you can't roll them back either.

Also, anything that touches the file system, like COPY. Untrusted PLs that can fiddle with the file system. FDWs. All sorts. Oh, and of course psql commands like \o .

I think this idea is completely unworkable. You might work around the filesystem access issues with a new attribute (like LEAKPROOF) that asserts that a function relies strictly on in-database transactional behaviour. But you're not going to be able to do a dry run with sequence setting. You could ignore setval and run nextval as normal, but then your dry-run wouldn't reflect what the real run would do...

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: psql - -dry-run option
Next
From: Haribabu Kommi
Date:
Subject: Re: Parallel Aggregate