Updates
Let's create a simple table with one row in it to get started.
Note
The first two lines in the following code are duplicated from Chapter 5, Memory for Database Caching. If you've already created them there, you should DROP TABLE t
before this session to clear them out.
$ psql -c "CREATE TABLE t (s SERIAL, i INTEGER);" $ psql -c "INSERT into t(i) values (0)" INSERT 0 1 $ psql -c "SELECT *,xmin,xmax from t;" s | i | xmin | xmax ---+---+--------+------ 1 | 0 | 158208 | 0 $ psql -c "SELECT txid_current(); txid_current -------------- 158209
So there's the new row inserted, with the transaction ID xmin
active for the statement that inserted it. There's no maximum yet because nothing has ever updated or deleted this row.
Now run psql
, start a transaction with BEGIN
, and update the row—but don't commit it yet:
$ psql postgres=# BEGIN; BEGIN postgres=# select txid_current(); txid_current ----...