aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁlvaro Herrera <alvherre@alvh.no-ip.org>2024-11-12 11:35:43 +0100
committerÁlvaro Herrera <alvherre@alvh.no-ip.org>2024-11-12 11:35:43 +0100
commitff239c3bf4e8cc8b758450e82ff698100aa8efc0 (patch)
tree12de1e799c8b6d14b474d7bba7f7979cdb23d6f8
parent3f323eba89fb1ea2220cfe48ea7d9529fffe5cb6 (diff)
downloadpostgresql-ff239c3bf4e8cc8b758450e82ff698100aa8efc0.tar.gz
postgresql-ff239c3bf4e8cc8b758450e82ff698100aa8efc0.zip
Silence compilers about extractNotNullColumn()
Multiple buildfarm animals warn that a newly added Assert() is impossible to fail; remove it to avoid the noise. While at it, use direct assignment to obtain the value we need, avoiding an unnecessary memcpy(). (I decided to remove the "pfree" call for the detoasted short-datum; because this is only used for DDL, it's not problematic to leak such a small allocation.) Noted by Tom Lane about 14e87ffa5c54. Discussion: https://postgr.es/m/3649828.1731083171@sss.pgh.pa.us
-rw-r--r--src/backend/catalog/pg_constraint.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index e953000c01d..9c05a98d28c 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -688,7 +688,6 @@ findDomainNotNullConstraint(Oid typid)
AttrNumber
extractNotNullColumn(HeapTuple constrTup)
{
- AttrNumber colnum;
Datum adatum;
ArrayType *arr;
@@ -704,13 +703,9 @@ extractNotNullColumn(HeapTuple constrTup)
ARR_DIMS(arr)[0] != 1)
elog(ERROR, "conkey is not a 1-D smallint array");
- memcpy(&colnum, ARR_DATA_PTR(arr), sizeof(AttrNumber));
- Assert(colnum > 0 && colnum <= MaxAttrNumber);
+ /* We leak the detoasted datum, but we don't care */
- if ((Pointer) arr != DatumGetPointer(adatum))
- pfree(arr); /* free de-toasted copy, if any */
-
- return colnum;
+ return ((AttrNumber *) ARR_DATA_PTR(arr))[0];
}
/*