mirror of
https://github.com/postgres/postgres.git
synced 2025-06-20 15:22:23 +03:00
Attached is the new patch. To summarize:
- new function justify_interval(interval) - modified function justify_hours(interval) - modified function justify_days(interval) These functions are defined to meet the requirements as discussed in this thread. Specifically: - justify_hours makes certain the sign bit on the hours matches the sign bit on the days. It only checks the sign bit on the days, and not the months, when determining if the hours should be positive or negative. After the call, -24 < hours < 24. - justify_days makes certain the sign bit on the days matches the sign bit on the months. It's behavior does not depend on the hours, nor does it modify the hours. After the call, -30 < days < 30. - justify_interval makes sure the sign bits on all three fields months, days, and hours are all the same. After the call, -24 < hours < 24 AND -30 < days < 30. Mark Dilger
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.309 2006/03/06 04:53:50 momjian Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.310 2006/03/06 22:49:15 momjian Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -5287,11 +5287,14 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
|
||||
<indexterm>
|
||||
<primary>isfinite</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>justify_days</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>justify_hours</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>justify_days</primary>
|
||||
<primary>justify_interval</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>localtime</primary>
|
||||
@ -5429,6 +5432,14 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
|
||||
<entry><literal>true</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>justify_days</function>(<type>interval</type>)</literal></entry>
|
||||
<entry><type>interval</type></entry>
|
||||
<entry>Adjust interval so 30-day time periods are represented as months</entry>
|
||||
<entry><literal>justify_days(interval '30 days')</literal></entry>
|
||||
<entry><literal>1 month</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>justify_hours</function>(<type>interval</type>)</literal></entry>
|
||||
<entry><type>interval</type></entry>
|
||||
@ -5438,11 +5449,11 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>justify_days</function>(<type>interval</type>)</literal></entry>
|
||||
<entry><literal><function>justify_interval</function>(<type>interval</type>)</literal></entry>
|
||||
<entry><type>interval</type></entry>
|
||||
<entry>Adjust interval so 30-day time periods are represented as months</entry>
|
||||
<entry><literal>justify_days(interval '30 days')</literal></entry>
|
||||
<entry><literal>1 month</literal></entry>
|
||||
<entry>Adjust interval using <function>justify_days</> and <function>justify_hours</>, with additional sign adjustments</></entry>
|
||||
<entry><literal>justify_interval(interval '1 mon -1 hour')</literal></entry>
|
||||
<entry><literal>29 days 23:00:00</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
@ -5486,13 +5497,6 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>
|
||||
If you are using both <function>justify_hours</> and
|
||||
<function>justify_days</>, it is best to use <function>justify_hours</>
|
||||
first so any additional days will be included in the
|
||||
<function>justify_days</> calculation.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In addition to these functions, the SQL <literal>OVERLAPS</> operator is
|
||||
supported:
|
||||
|
Reference in New Issue
Block a user