Re: cataloguing NOT NULL constraints
От | Alvaro Herrera |
---|---|
Тема | Re: cataloguing NOT NULL constraints |
Дата | |
Msg-id | 20230711141720.wzjikyy3ckjgavas@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: cataloguing NOT NULL constraints (Peter Eisentraut <peter@eisentraut.org>) |
Ответы |
Re: cataloguing NOT NULL constraints
|
Список | pgsql-hackers |
I left two questions unanswered here, so here I respond to them while giving one more revision of the patch. I realized that the AT_CheckNotNull stuff is now dead code, so in this version I remove it. I also changed on heap_getattr to SysCacheGetAttrNotNull, per a very old review comment from Justin that I hadn't acted upon. The other changes are minor code comments and test adjustments. At this point I think this is committable. On 2023-Jul-03, Peter Eisentraut wrote: > + /* > + * Copy NOT NULL constraints, too (these do not require any option to have > + * been given). > + */ > > Shouldn't that be governed by the INCLUDING CONSTRAINTS option? To clarify: this is in LIKE, such as CREATE TABLE (LIKE someother); and the reason we don't want to make this behavior depend on INCLUDING CONSTRAINTS, is backwards compatibility; NOT NULL markings have traditionally been propagated, so it can be used to create partitions based on the parent table, and if we made that require the option to be specified, that would no longer occur in the default case. Maybe we can change that behavior, but I'm pretty sure it would be resisted. > Btw., there is some asymmetry here between check constraints and > not-null constraints: Check constraints are in the tuple descriptor, > but not-null constraints are not. Should that be unified? Or at > least explained? Well, the reason check constraints are in the descriptor, is that they are needed to verify a table. NOT NULL constraint as catalog objects are (at present) only useful from a DDL point of view; they won't change the underlying implementation, which still depends on just the attnotnull markings. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
Вложения
В списке pgsql-hackers по дате отправления: