forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita2da77c
committed
Change return type of EXTRACT to numeric
The previous implementation of EXTRACT mapped internally todate_part(), which returned type double precision (since it wasimplemented long before the numeric type existed). This can lead toimprecise output in some cases, so returning numeric would bepreferrable. Changing the return type of an existing function is abit risky, so instead we do the following: We implement a new set offunctions, which are now called "extract", in parallel to the existingdate_part functions. They work the same way internally but usenumeric instead of float8. The EXTRACT construct is now mapped by theparser to these new extract functions. That way, dumps of viewsetc. from old versions (which would use date_part) continue to workunchanged, but new uses will map to the new extract functions.Additionally, the reverse compilation of EXTRACT now reproduces theoriginal syntax, using the new mechanism introduced in40c24bf.The following minor changes of behavior result from the newimplementation:- The column name from an isolated EXTRACT call is now "extract" instead of "date_part".- Extract from date now rejects inappropriate field names such as HOUR. It was previously mapped internally to extract from timestamp, so it would silently accept everything appropriate for timestamp.- Return values when extracting fields with possibly fractional values, such as second and epoch, now have the full scale that the value has internally (so, for example, '1.000000' instead of just '1').Reported-by: Petr Fedorov <petr.fedorov@phystech.edu>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu1 parentf5d94e4 commita2da77c
File tree
23 files changed
+1330
-496
lines changed- doc/src/sgml
- src
- backend
- parser
- utils/adt
- include
- catalog
- utils
- test/regress
- expected
- sql
23 files changed
+1330
-496
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8872 | 8872 |
| |
8873 | 8873 |
| |
8874 | 8874 |
| |
8875 |
| - | |
| 8875 | + | |
8876 | 8876 |
| |
8877 | 8877 |
| |
8878 | 8878 |
| |
| |||
8886 | 8886 |
| |
8887 | 8887 |
| |
8888 | 8888 |
| |
8889 |
| - | |
| 8889 | + | |
8890 | 8890 |
| |
8891 | 8891 |
| |
8892 | 8892 |
| |
| |||
9401 | 9401 |
| |
9402 | 9402 |
| |
9403 | 9403 |
| |
9404 |
| - | |
| 9404 | + | |
9405 | 9405 |
| |
9406 | 9406 |
| |
9407 | 9407 |
| |
| |||
9825 | 9825 |
| |
9826 | 9826 |
| |
9827 | 9827 |
| |
| 9828 | + | |
| 9829 | + | |
| 9830 | + | |
| 9831 | + | |
9828 | 9832 |
| |
9829 | 9833 |
| |
9830 | 9834 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14020 | 14020 |
| |
14021 | 14021 |
| |
14022 | 14022 |
| |
14023 |
| - | |
| 14023 | + | |
14024 | 14024 |
| |
14025 | 14025 |
| |
14026 | 14026 |
| |
|
0 commit comments
Comments
(0)