diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml index 341351e46ff..040b29c1453 100644 --- a/doc/src/sgml/mvcc.sgml +++ b/doc/src/sgml/mvcc.sgml @@ -1181,6 +1181,26 @@ SELECT pg_advisory_lock(q.id) FROM + + Caveats + + + Some DDL commands, currently only and the + table-rewriting forms of , are not + MVCC-safe. This means that after the truncation or rewrite commits, the + table will appear empty to concurrent transactions, if they are using a + snapshot taken before the DDL command committed. This will only be an + issue for a transaction that did not access the table in question + before the DDL command started — any transaction that has done so + would hold at least an ACCESS SHARE table lock, + which would block the DDL command until that transaction completes. + So these commands will not cause any apparent inconsistency in the + table contents for successive queries on the target table, but they + could cause visible inconsistency between the contents of the target + table and other tables in the database. + + + Locking and Indexes diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 94343f88f6e..91f26f0d584 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -699,7 +699,8 @@ ALTER TABLE name Adding a CHECK or NOT NULL constraint requires - scanning the table to verify that existing rows meet the constraint. + scanning the table to verify that existing rows meet the constraint, + but does not require a table rewrite. @@ -735,6 +736,13 @@ ALTER TABLE table ALTER COLUMN anycol TYPE anytype; data. + + The rewriting forms of ALTER TABLE are not MVCC-safe. + After a table rewrite, the table will appear empty to concurrent + transactions, if they are using a snapshot taken before the rewrite + occurred. See for more details. + + The USING option of SET DATA TYPE can actually specify any expression involving the old values of the row; that is, it diff --git a/doc/src/sgml/ref/truncate.sgml b/doc/src/sgml/ref/truncate.sgml index 99202de5b49..2f1fafc6547 100644 --- a/doc/src/sgml/ref/truncate.sgml +++ b/doc/src/sgml/ref/truncate.sgml @@ -137,23 +137,12 @@ TRUNCATE [ TABLE ] [ ONLY ] name [ that were added due to cascading). - - - TRUNCATE is not MVCC-safe (see - for general information about MVCC). After truncation, the table - will appear empty to all concurrent transactions, even if they - are using a snapshot taken before the truncation occurred. This - will only be an issue for a transaction that did not access the - truncated table before the truncation happened — any - transaction that has done so would hold at least an - ACCESS SHARE lock, which would block - TRUNCATE until that transaction completes. So - truncation will not cause any apparent inconsistency in the table - contents for successive queries on the same table, but it could - cause visible inconsistency between the contents of the truncated - table and other tables in the database. - - + + TRUNCATE is not MVCC-safe. After truncation, the table will + appear empty to concurrent transactions, if they are using a snapshot + taken before the truncation occurred. + See for more details. + TRUNCATE is transaction-safe with respect to the data