From: Tom Lane Date: Sun, 7 Dec 2025 16:33:35 +0000 (-0500) Subject: Add a macro for the declared typlen of type timetz. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3628af42107d588af73280d7e96d1c6188aadad7;p=postgresql.git Add a macro for the declared typlen of type timetz. pg_type.typlen says 12 for the size of timetz, but sizeof(TimeTzADT) will be 16 on most platforms due to alignment padding. Using the sizeof number is no problem for usages such as palloc'ing a result datum, but in usages such as datumCopy we really ought to match what pg_type says. Add a macro TIMETZ_TYPLEN so that we have a symbolic way to write that rather than hard-coding "12". I cannot find any place where we've needed this so far, but an upcoming patch requires it. Author: Tom Lane Reviewed-by: Chao Li Discussion: https://postgr.es/m/2329959.1765047648@sss.pgh.pa.us --- diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 7316ac0ff17..2aca785b65d 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -30,6 +30,14 @@ typedef struct int32 zone; /* numeric time zone, in seconds */ } TimeTzADT; +/* + * sizeof(TimeTzADT) will be 16 on most platforms due to alignment padding. + * However, timetz's typlen is 12 according to pg_type. In most places + * we can get away with using sizeof(TimeTzADT), but where it's important + * to match the declared typlen, use TIMETZ_TYPLEN. + */ +#define TIMETZ_TYPLEN 12 + /* * Infinity and minus infinity must be the max and min values of DateADT. */