diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-21 13:03:48 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-21 13:03:48 -0400 |
| commit | fc032bed2fb809ee69eaf2fece349f65274c876f (patch) | |
| tree | ffa25e5ca8c23870892aaf0b8b292b46637de7aa /src/include/catalog/pg_partitioned_table.h | |
| parent | 3e66019f15549d3e1e13da665b2549684061d630 (diff) | |
| download | postgresql-fc032bed2fb809ee69eaf2fece349f65274c876f.tar.gz | |
Be more careful about marking catalog columns NOT NULL by default.
The bug fixed in commit 72eab84a5 would not have occurred if initdb
had a less surprising rule about which columns should be marked
NOT NULL by default. Let's make that rule be strictly that the
column must be fixed-width and its predecessors must be fixed-width
and NOT NULL, removing the hacky and unsafe exceptions for oidvector
and int2vector.
Since we do still want all existing oidvector and int2vector columns
to be marked NOT NULL, we have to put BKI_FORCE_NOT_NULL labels on
them. But making this less magic and more documented seems like a
good idea, even if it's a shade more verbose.
I didn't bump catversion since the initial catalog contents are
not actually changed by this patch. Note however that the
contents of postgres.bki do change, and feeding an old copy of
that to a new backend will produce wrong results.
Discussion: https://postgr.es/m/204760.1595181800@sss.pgh.pa.us
Diffstat (limited to 'src/include/catalog/pg_partitioned_table.h')
| -rw-r--r-- | src/include/catalog/pg_partitioned_table.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h index a73cd0d3a4..7ee0419373 100644 --- a/src/include/catalog/pg_partitioned_table.h +++ b/src/include/catalog/pg_partitioned_table.h @@ -41,13 +41,17 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId) * field of a heap tuple can be reliably accessed using its C struct * offset, as previous fields are all non-nullable fixed-length fields. */ - int2vector partattrs; /* each member of the array is the attribute - * number of a partition key column, or 0 if - * the column is actually an expression */ + int2vector partattrs BKI_FORCE_NOT_NULL; /* each member of the array is + * the attribute number of a + * partition key column, or 0 + * if the column is actually + * an expression */ #ifdef CATALOG_VARLEN - oidvector partclass; /* operator class to compare keys */ - oidvector partcollation; /* user-specified collation for keys */ + oidvector partclass BKI_FORCE_NOT_NULL; /* operator class to compare + * keys */ + oidvector partcollation BKI_FORCE_NOT_NULL; /* user-specified + * collation for keys */ pg_node_tree partexprs; /* list of expressions in the partition key; * one item for each zero entry in partattrs[] */ #endif |
