Re: Persistent changes in rolled-back transactions

From: Rui DeSousa <rui(at)crazybean(dot)net>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>, Wael Khobalatte <wael(at)vendr(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Persistent changes in rolled-back transactions
Date: 2022-11-11 23:18:18
Message-ID: 9B0F9F61-113F-419E-BC6B-12C9DE0D5BE9@crazybean.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> On Nov 9, 2022, at 8:23 PM, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> Or just read the documentation for the current version (I seem to recall it used to be non-transactional, maybe...doesn't matter now).

In a lot of other databases DDL is not transactional and truncate is DDL — most likely confusing it with another RDBMS systems.

DDL is transactional in PostgreSQL thus you can even rollback table changes, etc. which is not possible in other RDBMS systems.

prod=# create table demo (a int);
CREATE TABLE
prod=#
prod=# \d+ demo;
Table "dev.demo"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain | | |
Access method: heap

prod=# begin;
BEGIN
prod=*# alter table demo add column b int;
ALTER TABLE
prod=*# \d+ demo;
Table "dev.demo"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain | | |
b | integer | | | | plain | | |
Access method: heap

prod=*# rollback;
ROLLBACK
prod=# \d+ demo;
Table "dev.demo"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain | | |
Access method: heap

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Santanu Das 2022-11-12 00:05:40 PGAdmin 4 SSH tunnel asking for identity file password
Previous Message Rui DeSousa 2022-11-11 22:52:09 Re: How to test replication without doing a failover