From: | Juan Rodrigo Alejandro Burgos Mella <rodrigoburgosmella(at)gmail(dot)com> |
---|---|
To: | Wen Yi <wen-yi(at)qq(dot)com> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: My question about the transaction |
Date: | 2023-10-19 16:05:40 |
Message-ID: | CAHbZ42wBh-tAo_zDUpk62j_yu1K8CC+d2ACwGuMiJ3cUz06GvQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
By default, psql is configured with autocommit on.
Use another administrator, like phpadmin, and configure the connection with
autocommit off.
Atte
JRBM
El jue, 19 oct 2023 a las 11:49, Wen Yi (<wen-yi(at)qq(dot)com>) escribió:
> Hi community,
> I am learning the transaction of the postgresql, and I try to test using
> these:
>
> ######
>
> terminal 1:
>
> postgres=# select * from t;
> number
> --------
> 1
> (1 row)
>
> postgres=# update t set number = 2;
> UPDATE 1
> postgres=# select * from t;
> number
> --------
> 2
> (1 row)
>
> postgres=# select * from t;
> number
> --------
> 2
> (1 row)
>
> postgres=#
>
> ######
>
> terminal 2:
>
> postgres=# create table t (number integer);
> CREATE TABLE
> postgres=# insert into t values (1);
> INSERT 0 1
> postgres=# begin;
> BEGIN
> postgres=*# insert into t values (2);
> INSERT 0 1
> postgres=*# select * from t;
> number
> --------
> 2
> 2
> (2 rows)
>
> postgres=*# rollback;
> ROLLBACK
>
> My question is, in my view, the transaction model should make sure that
> when one on-process transaction don't commit itself, the data on this
> transaction shouldn't can be modified by other transaction(I the
> single-statement also be treated as a simple transaction), but why the
> update works?(I think terminal 1 will block until the terminal 2's
> transaction commit or rollback).
> Can someone share you opinion to me?
> Thanks in advance!
>
> Yours,
> Wen Yi
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2023-10-19 16:33:08 | Re: My question about the transaction |
Previous Message | Adrian Klaver | 2023-10-19 15:40:54 | Re: My question about the transaction |