git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dde1a35)
Fix internal extract(timezone_minute) formulas
Thu, 1 Apr 2021 14:12:53 +0000 (16:12 +0200)
Thu, 1 Apr 2021 14:12:53 +0000 (16:12 +0200)
Through various refactorings over time, the extract(timezone_minute
from time with time zone) and extract(timezone_minute from timestamp
with time zone) implementations ended up with two different but
equally nonsensical formulas by using SECS_PER_MINUTE and
MINS_PER_HOUR interchangeably. Since those two are of course both the
same number, the formulas do work, but for readability, fix them to be
semantically correct.


diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 68d99a5099206c8e92ac8e07f55e989018708a99..6053d0e8a6f344ef83f8128b79551701927a7a4e 100644 (file)
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -2726,7 +2726,7 @@ timetz_part(PG_FUNCTION_ARGS)
case DTK_TZ_MINUTE:
result = -tz;
result /= SECS_PER_MINUTE;
- FMODULO(result, dummy, (double) SECS_PER_MINUTE);
+ FMODULO(result, dummy, (double) MINS_PER_HOUR);
break;
case DTK_TZ_HOUR:
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index f619b56d6f5465bfa457b7ec1dc7afd98542c307..194861f19e3a072cf6f472720eeeb9c45aad989c 100644 (file)
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -4844,7 +4844,7 @@ timestamptz_part(PG_FUNCTION_ARGS)
case DTK_TZ_MINUTE:
result = -tz;
- result /= MINS_PER_HOUR;
+ result /= SECS_PER_MINUTE;
FMODULO(result, dummy, (double) MINS_PER_HOUR);
break;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /