transform-interval-precis-v1.patch

text/plain

Filename: transform-interval-precis-v1.patch
Type: text/plain
Part: 0
Message: Re: Add protransform for numeric, varbit, and temporal types

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
Series: patch v1
File+
src/backend/utils/adt/timestamp.c 7 0
*** a/src/backend/utils/adt/timestamp.c
--- b/src/backend/utils/adt/timestamp.c
***************
*** 958,963 **** interval_transform(PG_FUNCTION_ARGS)
--- 958,964 ----
  		int			new_range = INTERVAL_RANGE(new_typmod);
  		int			new_precis = INTERVAL_PRECISION(new_typmod);
  		int			new_range_fls;
+ 		int			old_range_fls;
  
  		if (old_typmod == -1)
  		{
***************
*** 974,985 **** interval_transform(PG_FUNCTION_ARGS)
  		 * Temporally-smaller fields occupy higher positions in the range
  		 * bitmap.  Since only the temporally-smallest bit matters for length
  		 * coercion purposes, we compare the last-set bits in the ranges.
  		 */
  		new_range_fls = fls(new_range);
  		if (new_typmod == -1 ||
  			((new_range_fls >= SECOND ||
! 			  new_range_fls >= fls(old_range)) &&
! 			 (new_precis >= MAX_INTERVAL_PRECISION ||
  			  new_precis >= old_precis)))
  			ret = relabel_to_typmod(source, new_typmod);
  	}
--- 975,990 ----
  		 * Temporally-smaller fields occupy higher positions in the range
  		 * bitmap.  Since only the temporally-smallest bit matters for length
  		 * coercion purposes, we compare the last-set bits in the ranges.
+ 		 * Precision, which is to say, sub-second precision, only affects
+ 		 * ranges that include SECOND.
  		 */
  		new_range_fls = fls(new_range);
+ 		old_range_fls = fls(old_range);
  		if (new_typmod == -1 ||
  			((new_range_fls >= SECOND ||
! 			  new_range_fls >= old_range_fls) &&
! 			 (old_range_fls < SECOND ||
! 			  new_precis >= MAX_INTERVAL_PRECISION ||
  			  new_precis >= old_precis)))
  			ret = relabel_to_typmod(source, new_typmod);
  	}