mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Save a few bytes in pg_attribute
Change the columns attndims, attstattarget, and attinhcount from int32 to int16, and reorder a bit. This saves some space (currently 4 bytes) in pg_attribute and tuple descriptors, which translates into small performance benefits and/or room for new columns in pg_attribute needed by future features. attndims and attinhcount are never realistically used with values larger than int16. Just to be sure, add some overflow checks. attstattarget is currently limited explicitly to 10000. For consistency, pg_constraint.coninhcount is also changed like attinhcount. Discussion: https://www.postgresql.org/message-id/flat/d07ffc2b-e0e8-77f7-38fb-be921dff71af%40enterprisedb.com
This commit is contained in:
@@ -597,6 +597,8 @@ TupleDescInitEntry(TupleDesc desc,
|
||||
Assert(PointerIsValid(desc));
|
||||
Assert(attributeNumber >= 1);
|
||||
Assert(attributeNumber <= desc->natts);
|
||||
Assert(attdim >= 0);
|
||||
Assert(attdim <= PG_INT16_MAX);
|
||||
|
||||
/*
|
||||
* initialize the attribute fields
|
||||
@@ -667,6 +669,8 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
|
||||
Assert(PointerIsValid(desc));
|
||||
Assert(attributeNumber >= 1);
|
||||
Assert(attributeNumber <= desc->natts);
|
||||
Assert(attdim >= 0);
|
||||
Assert(attdim <= PG_INT16_MAX);
|
||||
|
||||
/* initialize the attribute fields */
|
||||
att = TupleDescAttr(desc, attributeNumber - 1);
|
||||
@@ -827,6 +831,10 @@ BuildDescForRelation(List *schema)
|
||||
|
||||
attcollation = GetColumnDefCollation(NULL, entry, atttypid);
|
||||
attdim = list_length(entry->typeName->arrayBounds);
|
||||
if (attdim > PG_INT16_MAX)
|
||||
ereport(ERROR,
|
||||
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("too many array dimensions"));
|
||||
|
||||
if (entry->typeName->setof)
|
||||
ereport(ERROR,
|
||||
|
Reference in New Issue
Block a user