0

Why does the MySQL workbench show uncommitted changes?

-- create a new empty table
DROP TABLE IF EXISTS X;
CREATE TABLE X (val varchar(10));

-- disable autocommit
SET AUTOCOMMIT = 0;

-- insert a row without committing
INSERT INTO X (val) VALUES ('text');

At this point

SELECT @@autocommit, @@tx_isolation;

returns

| 0 | REPEATABLE-READ |

However, a query shows the value which has not yet been committed:

SELECT * FROM X;

| text |

Why does MySQL return a result set with uncommitted data?

If I roll back the transaction using

ROLLBACK;

then MySQL returns an empty table when querying X. (That confirms that the transaction hasn't been committed automatically at some point of time.)

nrainer
  • 2,542
  • 2
  • 23
  • 35
  • This has nothing to do with MySQL workbench and is what Transaction/Commit means. ALL SQL servers does this. The point is that you HAVE inserted the new value, just that you HAVEN'T commited the change. – Aron Jun 21 '13 at 09:16
  • Ok, but the isolation level "repeatable read" is higher than the "read committed" level. Why can I see the uncommitted change? – nrainer Jun 21 '13 at 09:26

1 Answers1

0

The reason is that I am always in the same transaction (regardless the window tab).

nrainer
  • 2,542
  • 2
  • 23
  • 35