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 a54bcedaa8434270087352c316d2f0a215a86c4f..ec88ca18886157867a7551f94c4b6866d1141453 100644 (file)
@@ -9389,11 +9389,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');
@@ -9539,13 +9539,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
 
 
        
@@ -9692,7 +9692,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
 
       
      
@@ -9756,10 +9756,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