Thread: How to test something using ROLLBACK TRANSACTION

How to test something using ROLLBACK TRANSACTION

From
William Garrison
Date:
Coming from MS SQL server, if I ever change anything vital on a
production system, or do any kind of major hackery on my own, I wrap it
in a transaction first:

BEGIN TRANSACTION;
DELETE FROM vital_information WHERE primary_key = 10;
ROLLBACK TRANSACTION;

I then make sure that the result comes back and says
    1 row(s) modified
or something equally reassuring.  I have horror stories where DBAs
fat-fingered something and deleted data.  But when I do this in
pgadmin3, I get a dissatisfying result:
    Query returned successfully with no result in 15 ms.
This response isn't wrong really... but it is not what I was hoping
for.  Any way to get the result of the commands that were inside the
transaction?




Re: How to test something using ROLLBACK TRANSACTION

From
"Scott Marlowe"
Date:
On Thu, Sep 4, 2008 at 1:17 PM, William Garrison <postgres@mobydisk.com> wrote:
> Coming from MS SQL server, if I ever change anything vital on a production
> system, or do any kind of major hackery on my own, I wrap it in a
> transaction first:
>
> BEGIN TRANSACTION;
> DELETE FROM vital_information WHERE primary_key = 10;
> ROLLBACK TRANSACTION;
>
> I then make sure that the result comes back and says
>   1 row(s) modified
> or something equally reassuring.  I have horror stories where DBAs
> fat-fingered something and deleted data.  But when I do this in pgadmin3, I
> get a dissatisfying result:

Have you tried psql?  That's all I usually use.  Here's what I get
from inside psql:

smarlowe=# begin;
BEGIN
smarlowe=# delete from test where i between 4 and 6;
DELETE 3
smarlowe=# rollback;
ROLLBACK

Re: How to test something using ROLLBACK TRANSACTION

From
"Richard Broersma"
Date:
On Thu, Sep 4, 2008 at 12:28 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
> Have you tried psql?  That's all I usually use.  Here's what I get

The only problem with psql is that it is addictive.  Once your hooked,
it is hard to use anything else.
:o)


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug