Doc: adjust examples of EXTRACT() output to match current reality.
authorTom Lane
Mon, 10 Apr 2023 17:09:18 +0000 (13:09 -0400)
committerTom Lane
Mon, 10 Apr 2023 17:09:18 +0000 (13:09 -0400)
EXTRACT(EPOCH), EXTRACT(SECOND), and some related cases print more
trailing zeroes than they used to.  This behavior change happened
with commit a2da77cdb (Change return type of EXTRACT to numeric),
and it was intentional according to the commit log:

    - 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').

It's been like that for two releases now, so while I suggested
changing this back, it's probably better to adjust the documentation
examples.

Per bug #17866 from Евгений Жужнев.  Back-patch to v14 where the
change came in.

Discussion: https://postgr.es/m/17866-18eb70095b1594e2@postgresql.org

doc/src/sgml/func.sgml

index bf4c61ccfbd32ceaebdf3575d3d7330c6e2af60a..e6a7514100e961ce181338978ce41ede58eee8a9 100644 (file)
@@ -9914,11 +9914,11 @@ SELECT timestamp with time zone '2005-04-02 12:00:00-07' + interval '24 hours';
 
 SELECT EXTRACT(EPOCH FROM timestamptz '2013-07-01 12:00:00') -
        EXTRACT(EPOCH FROM timestamptz '2013-03-01 12:00:00');
-Result: 10537200
+Result: 10537200.000000
 SELECT (EXTRACT(EPOCH FROM timestamptz '2013-07-01 12:00:00') -
         EXTRACT(EPOCH FROM timestamptz '2013-03-01 12:00:00'))
         / 60 / 60 / 24;
-Result: 121.958333333333
+Result: 121.9583333333333333
 SELECT timestamptz '2013-07-01 12:00:00' - timestamptz '2013-03-01 12:00:00';
 Result: 121 days 23:00:00
 SELECT age(timestamptz '2013-07-01 12:00:00', timestamptz '2013-03-01 12:00:00');
@@ -10064,13 +10064,13 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
 
 
 SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
-Result: 982384720.12
+Result: 982384720.120000
 
 SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
-Result: 982355920.12
+Result: 982355920.120000
 
 SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
-Result: 442800
+Result: 442800.000000
 
 
        
@@ -10217,7 +10217,7 @@ SELECT EXTRACT(MILLENNIUM FROM TIMESTAMP '2001-02-16 20:38:40');
 
 
 SELECT EXTRACT(MILLISECONDS FROM TIME '17:12:28.5');
-Result: 28500
+Result: 28500.000
 
       
      
@@ -10281,10 +10281,10 @@ SELECT EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40');
 
 
 SELECT EXTRACT(SECOND FROM TIMESTAMP '2001-02-16 20:38:40');
-Result: 40
+Result: 40.000000
 
 SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
-Result: 28.5
+Result: 28.500000