Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Rushabh Lathia <rushabh.lathia@gmail.com>,
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-21T15:26:05Z
Lists: pgsql-hackers
On Wed, Mar 12, 2025 at 2:20 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > Taking a step back after discussing this with some colleagues, I need to > contradict what I said at the start of this thread. There's a worry > that changing pg_attribute.attnotnull in the way I initially suggested > might not be such a great idea after all. I did a quick search using > codesearch.debian.net for applications reading that column and thinking > about how they would react to this change; I think in the end it's going > to be quite disastrous. We would break a vast number of these apps, and > there are probably countless other apps and frameworks that we would > also break. Everybody would hate us forever. Upgrading to Postgres 18 > would become as bad an experience as the drastic change of implicit > casts to text in 8.3. Nothing else in the intervening 17 years strikes > me as so problematic as this change would be. I don't agree with this conclusion. The 8.3 casting changes were problematic because any piece of SQL you'd ever written could have problems. This change will only break queries that look at the attnotnull column. While there may be quite a few of those, it can't possibly be of the same order. I think it's routine that changing the name or type of system catalog columns breaks things for a few people (e.g. procpid->pid, or relistemp->relpersistence) and we sometimes get complaints about that, but at least you can grep for it and it's mostly going to affect admin tools rather than all the queries everywhere. That's not to say that adding a second bool column instead of changing the existing column's data type is necessarily the wrong way to go. But I think you're overestimating the blast radius by quite a lot. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Allow NOT NULL constraints to be added as NOT VALID
- a379061a22a8 18.0 landed
-
Add missing deparsing of [NO] IDENT to XMLSERIALIZE()
- 984410b92326 18.0 cited
-
backend launchers void * arguments for binary data
- 7202d72787d3 18.0 cited
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 cited
-
Create the infrastructure for planner support functions.
- 1fb57af92069 12.0 cited
-
Add prokind column, replacing proisagg and proiswindow
- fd1a421fe661 11.0 cited