Re: ROLLBACK syntax error in pgadmin4

From: Melvin Davidson <melvin6925(at)yahoo(dot)com>
To: Malik Rumi <malik(dot)a(dot)rumi(at)gmail(dot)com>, pgAdmin Support <pgadmin-support(at)postgresql(dot)org>
Subject: Re: ROLLBACK syntax error in pgadmin4
Date: 2016-11-29 18:24:22
Message-ID: 1624998339.3350088.1480443862050@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

The problem is, ROLLBACK requires a transaction. So to use it properly you need to
start with a BEGIN statement.
eg:
BEGIN;your_statements;ROLLBACK;

https://www.postgresql.org/docs/9.4/static/sql-begin.html

https://www.postgresql.org/docs/9.4/static/sql-rollback.html
fyi, in the future, it is always a good idea to include the PostgreSQL version.
Melvin Davidson
    Cell 720-320-0155
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.
www.youtube.com/unusedhero/videos
Folk Alley - All Folk - 24 Hours a day
www.folkalley.com

From: Malik Rumi <malik(dot)a(dot)rumi(at)gmail(dot)com>
To: pgAdmin Support <pgadmin-support(at)postgresql(dot)org>
Sent: Tuesday, November 29, 2016 1:17 PM
Subject: [pgadmin-support] ROLLBACK syntax error in pgadmin4

I amusing PGAdmin4 with PG 9.4 on Ubuntu 16.04 64 bit. I wanted to do an update, but was unsureof the result, so I unselected autocommit and ran explain. It saidonly one row was affected, which I didn’t understand, because itshould have affected at least 2. Then I inferred that the ‘one row’being referred to was the plan, not the rows in my data.ThenI ran the update, again no autocommit, and it was not what Iexpected. So then I added ROLLBACK to the end of the query, ran itagain, and got this error:ERROR:syntax error at or near "ROLLBACK" LINE 1: ...de" SETchildof_id = NULL WHERE codelevelsortseq=1 ROLLBACK;Ithen did a new query, with just ROLLBACK; as I see it explained withan example in the docs:https://www.postgresql.org/docs/9.4/static/sql-rollback.htmlNevertheless,I got the same error:ERROR:syntax error at or near "ROLLBACK" LINE 1: ...F, VERBOSEON, COSTS ON, BUFFERS OFF, TIMING OFF) ROLLBACK;
Note in this case ROLLBACK; is the only thing on Line 1. The error carat (^) is pointing at the R in both cases. Noother queries have been run in the interim. Tomy surprise, there are very few Google hits for this exact search: "syntaxerror at or near 'ROLLBACK'" About 30 results (0.34 seconds) Thefirst two hits are for a bug report from Nov. of 2006, which wasfixed then and there. I don’t think this is the same bug, if it isa bug. Idid find DISCARD in the docs:https://www.postgresql.org/docs/9.4/static/sql-discard.htmlhowever, I have not run it because I wanted some clarity here anddidn’t want to interfere with my ROLLBACK, if it would even havethat effect.So,my questions:1.How do I discard this update and get my data back?2.How do I check to make sure it really isn’t committed withoutupsetting my ROLLBACK options? (Yes, I do have a backup I can go to,but I would rather understand what is happening and fix it).4.If it isn’t committed, and this is a bug, can I just close PGAdmin4and/or PG and discard the changes that way?5.Is this a new, different bug?6. What was that 'one row effected' about?

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Malik Rumi 2016-11-29 19:50:32 Re: ROLLBACK syntax error in pgadmin4
Previous Message Malik Rumi 2016-11-29 18:17:09 ROLLBACK syntax error in pgadmin4