Mention FK creation take ShareRowExclusiveLock on referenced table

Adrien NAYRAT <adrien.nayrat@anayrat.info>

From: Adrien NAYRAT <adrien.nayrat@anayrat.info>
To: <pgsql-docs@lists.postgresql.org>
Date: 2018-09-18T10:32:54Z
Lists: pgsql-docs
Hello,

A few days ago I was surprised a CREATE TABLE containing FK constraint 
was stuck due to an automatic vacuum freeze (which took 
ShareUpdateExclusiveLock if I remember) on referenced table.

After digging into the code I found theses lines in tablecmds.c :


/*
  * Grab ShareRowExclusiveLock on the pk table, so that someone doesn't
  * delete rows out from under us.
  */


Maybe it should be documented in theses pages?

https://www.postgresql.org/docs/current/static/sql-createtable.html
https://www.postgresql.org/docs/current/static/sql-altertable.html

If you agree I can send a patch.

Regards,


Commits

  1. Document lock taken on referenced table when adding a foreign key