Getting our tables to render better in PDF output

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Getting our tables to render better in PDF output
Дата
Msg-id
9326.1581457869@sss.pgh.pa.us
Список
Дерево обсуждения
Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Jürgen Purtz <juergen@purtz.de>
Re: Getting our tables to render better in PDF output Corey Huinker <corey.huinker@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Corey Huinker <corey.huinker@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Corey Huinker <corey.huinker@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Corey Huinker <corey.huinker@gmail.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Corey Huinker <corey.huinker@gmail.com>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
Re: Getting our tables to render better in PDF output Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Getting our tables to render better in PDF output Tom Lane <tgl@sss.pgh.pa.us>
Re: Getting our tables to render better in PDF output Alexander Lakhin <exclusion@gmail.com>
The crummy formatting of our tables of functions and operators has
been an issue for a long time.  To my mind, there are several things
that need to be addressed:

* The layout is completely unfriendly to function descriptions that
run to more than a few words.

* It's not very practical to have more than one example per function
(or at least, we seldom do so).

* The results look completely awful in PDF format, because of the
narrow effectively-available space, plus the fact that the toolchain
will prefer to overprint following columns instead of breaking text
where there's no whitespace.

In [1], Alvaro suggested that we might be able to improve matters by
taking advantage of DocBook's features for column and row spanning.
I did some concrete experimentation in that line, and attached are
two alternative patches that show a couple of things we might do.
Both patches change tables 9.31 (Date/Time Functions) and 9.33
(Enum Support Functions), which I chose somewhat at random, but of
course there would be a lot more to be done if we choose to go this way.

The first patch uses only one row for each function example, while
the second patch uses two rows (i.e., example and result in separate
table rows).  Otherwise they're the same.

I initially did the enum-support table, and what I tried there included
getting rid of the separate table column for function result type by
writing the functions in the form "func(argtypes) returns resulttype".
(Note that this table failed to specify the result types at all before,
which doesn't seem great.)  The layout idea is

    function name, args, result               description
                                         example     example result

where we can repeat the "example / example result" row if we want more
examples per function.  Alternatively, in the second patch, it's

    function name, args, result          description
                                         example
                                         example result

To my eyes, the first alternative is preferable in HTML, unless maybe you
want to read the manual in a *very* narrow browser window.  But some of
the examples/results still overrun the available space when looking
at it in PDF A4 format.  The second patch fixes that problem, but seems
not very pretty in a normal-width browser window.

When I tried to apply the same idea to the date/time functions table,
it didn't really work well at all, mainly because of a few beasts like
make_interval() --- that caused the left column to be so wide that the
right-hand columns were horrid.  (At least with the toolchain version
I'm using, it seems like the colwidth specifications are respected
rigidly in PDF output but just plain ignored in HTML output.  What
seems to happen in HTML is that earlier columns get their preferred
width and later ones get squeezed.)

So the layout idea that the patches show for that table is

    function name      arg types     result type
                       description
                       example     example result

or

    function name      arg types     result type
                       description
                       example
                       example result

(Even with that, I had to savage make_interval's arg-types list a bit
to keep that column from eating too much space...)

I'm not especially wedded to any of these ideas, but I hope to provoke
some discussion about what we might do in this area.  DocBook tables
aren't the greatest layout tool in the world, but they do have abilities
we're not exploiting.

Even with these changes, the amount of space available for examples
and results in PDF format is pretty tiny.  With examples and results
in the same row, it seems that you can only have a couple of dozen
consecutive non-whitespace characters without running into overwrite
issues, whereas in HTML format the trouble threshold is a good deal
higher.  I wonder if we could improve matters by switching to some
narrower font for  text in PDF?

			regards, tom lane

[1] https://www.postgresql.org/message-id/20200116184444.GA25792%40alvherre.pgsql

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index ceda48e..385fdc0 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -6798,471 +6798,618 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
 
     
      Date/Time Functions
-     
+     
+      
+      
+      
+      
+      
+      
+      
+      
+      
       
        
-        Function
-        Return Type
-        Description
-        Example
-        Result
+        Function
+        Argument Types
+        Result Type
+       
+       
+        Description
+       
+       
+        Example
+        Example Result
        
       
        
-        
+        
          
           age
          
-         age(timestamp, timestamp)
+         age
         
-        interval
-        Subtract arguments, producing a symbolic result that
+        timestamp, timestamp
+        interval
+       
+       
+        Subtract arguments, producing a symbolic result that
         uses years and months, rather than just days
-        age(timestamp '2001-04-10', timestamp '1957-06-13')
-        43 years 9 mons 27 days
+       
+       
+        age(timestamp '2001-04-10', timestamp '1957-06-13')
+        43 years 9 mons 27 days
        
 
        
-        age(timestamp)
-        interval
-        Subtract from current_date (at midnight)
-        age(timestamp '1957-06-13')
-        43 years 8 mons 3 days
+        age
+        timestamp
+        interval
+       
+       
+        Subtract from current_date (at midnight)
+       
+       
+        age(timestamp '1957-06-13')
+        variable
        
 
        
-        
+        
          
           clock_timestamp
          
-         clock_timestamp()
+         clock_timestamp
         
-        timestamp with time zone
-        Current date and time (changes during statement execution);
+        none
+        timestamp with time zone
+       
+       
+        Current date and time (changes during statement execution);
          see 
         
-        
-        
+       
+       
+        clock_timestamp()
+        variable
        
 
        
-        
+        
          
           current_date
          
-         current_date
+         current_date
         
-        date
-        Current date;
+        none (written without parentheses)
+        date
+       
+       
+         Current date;
          see 
         
-        
-        
+       
+       
+        current_date
+        variable
        
 
        
-        
+        
          
           current_time
          
-         current_time
+         current_time
         
-        time with time zone
-        Current time of day;
+        none (written without parentheses)
+        time with time zone
+       
+       
+        Current time of day;
          see 
         
-        
-        
+       
+       
+        current_time
+        variable
        
 
        
-        
+        
          
           current_timestamp
          
-         current_timestamp
+         current_timestamp
         
-        timestamp with time zone
-        Current date and time (start of current transaction);
+        none (written without parentheses)
+        timestamp with time zone
+       
+       
+        Current date and time (start of current transaction);
          see 
         
-        
-        
+       
+       
+        current_timestamp
+        variable
        
 
        
-        
+        
          
           date_part
          
-         date_part(text, timestamp)
+         date_part
         
-        double precision
-        Get subfield (equivalent to extract);
+        text, timestamp
+        double precision
+       
+       
+        Get subfield (equivalent to extract);
          see 
         
-        date_part('hour', timestamp '2001-02-16 20:38:40')
-        20
+       
+       
+        date_part('hour', timestamp '2001-02-16 20:38:40')
+        20
        
 
        
-        date_part(text, interval)
-        double precision
-        Get subfield (equivalent to
+        date_part
+        text, interval
+        double precision
+       
+       
+        Get subfield (equivalent to
          extract); see 
         
-        date_part('month', interval '2 years 3 months')
-        3
+       
+       
+        date_part('month', interval '2 years 3 months')
+        3
        
 
        
-        
+        
          
           date_trunc
          
-         date_trunc(text, timestamp)
+         date_trunc
         
-        timestamp
-        Truncate to specified precision; see 
+        text, timestamp
+        timestamp
+       
+       
+        Truncate to specified precision; see 
         
-        date_trunc('hour', timestamp '2001-02-16 20:38:40')
-        2001-02-16 20:00:00
+       
+       
+        date_trunc('hour', timestamp '2001-02-16 20:38:40')
+        2001-02-16 20:00:00
        
 
        
-        date_trunc(text, timestamp with time zone, text)
-        timestamp with time zone
-        Truncate to specified precision in the specified time zone; see 
+        date_trunc
+        text, timestamp with time zone, text
+        timestamp with time zone
+       
+       
+        Truncate to specified precision in the specified time zone; see 
         
-        date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney')
-        2001-02-16 13:00:00+00
+       
+       
+        date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney')
+        2001-02-16 13:00:00+00
        
 
        
-        date_trunc(text, interval)
-        interval
-        Truncate to specified precision; see 
+        date_trunc
+        text, interval
+        interval
+       
+       
+        Truncate to specified precision; see 
         
-        date_trunc('hour', interval '2 days 3 hours 40 minutes')
-        2 days 03:00:00
+       
+       
+        date_trunc('hour', interval '2 days 3 hours 40 minutes')
+        2 days 03:00:00
        
 
        
-        
+        
          
           extract
          
-         extract(field from
-         timestamp)
+         extract
         
-        double precision
-        Get subfield; see 
+        field from timestamp
+        double precision
+       
+       
+        Get subfield; see 
         
-        extract(hour from timestamp '2001-02-16 20:38:40')
-        20
+       
+       
+        extract(hour from timestamp '2001-02-16 20:38:40')
+        20
        
 
        
-        extract(field from
-         interval)
-        double precision
-        Get subfield; see 
+        extract
+        field from interval
+        double precision
+       
+       
+        Get subfield; see 
         
-        extract(month from interval '2 years 3 months')
-        3
+       
+       
+        extract(month from interval '2 years 3 months')
+        3
        
 
        
-        
+        
          
           isfinite
          
-         isfinite(date)
+         isfinite
         
-        boolean
-        Test for finite date (not +/-infinity)
-        isfinite(date '2001-02-16')
-        true
+        date
+        boolean
+       
+       
+        Test for finite date (not +/-infinity)
+       
+       
+        isfinite(date '2001-02-16')
+        true
        
 
        
-        isfinite(timestamp)
-        boolean
-        Test for finite time stamp (not +/-infinity)
-        isfinite(timestamp '2001-02-16 21:28:30')
-        true
+        isfinite
+        timestamp
+        boolean
+       
+       
+        Test for finite time stamp (not +/-infinity)
+       
+       
+        isfinite(timestamp '2001-02-16 21:28:30')
+        true
        
 
        
-        isfinite(interval)
-        boolean
-        Test for finite interval
-        isfinite(interval '4 hours')
-        true
+        isfinite
+        interval
+        boolean
+       
+       
+        Test for finite interval
+       
+       
+        isfinite(interval '4 hours')
+        true
        
 
        
-        
+        
          
           justify_days
          
-         justify_days(interval)
+         justify_days
         
-        interval
-        Adjust interval so 30-day time periods are represented as months
-        justify_days(interval '35 days')
-        1 mon 5 days
+        interval
+        interval
+       
+       
+        Adjust interval so 30-day time periods are represented as months
+       
+       
+        justify_days(interval '35 days')
+        1 mon 5 days
        
 
        
-        
+        
          
           justify_hours
          
-         justify_hours(interval)
+         justify_hours
         
-        interval
-        Adjust interval so 24-hour time periods are represented as days
-        justify_hours(interval '27 hours')
-        1 day 03:00:00
+        interval
+        interval
+       
+       
+        Adjust interval so 24-hour time periods are represented as days
+       
+       
+        justify_hours(interval '27 hours')
+        1 day 03:00:00
        
 
        
-        
+        
          
           justify_interval
          
-         justify_interval(interval)
+         justify_interval
         
-        interval
-        Adjust interval using justify_days and justify_hours, with additional sign adjustments
-        justify_interval(interval '1 mon -1 hour')
-        29 days 23:00:00
+        interval
+        interval
+       
+       
+        Adjust interval using justify_days and justify_hours, with additional sign adjustments
+       
+       
+        justify_interval(interval '1 mon -1 hour')
+        29 days 23:00:00
        
 
        
-        
+        
          
           localtime
          
-         localtime
+         localtime
         
-        time
-        Current time of day;
+        none (written without parentheses)
+        time
+       
+       
+        Current time of day;
          see 
         
-        
-        
+       
+       
+        localtime
+        variable
        
 
        
-        
+        
          
           localtimestamp
          
-         localtimestamp
+         localtimestamp
         
-        timestamp
-        Current date and time (start of current transaction);
+        none (written without parentheses)
+        timestamp
+       
+       
+        Current date and time (start of current transaction);
          see 
         
-        
-        
+       
+       
+        localtimestamp
+        variable
        
 
        
-        
+        
          
           make_date
          
-         
-            
-             make_date(year int,
-             month int,
-             day int)
-            
-         
+         make_date
         
-        date
-        
+        year int,
+         month int,
+         day int
+        date
+       
+       
+        
          Create date from year, month and day fields
         
-        make_date(2013, 7, 15)
-        2013-07-15
+       
+       
+        make_date(2013, 7, 15)
+        2013-07-15
        
 
        
-        
-         
+        
           make_interval
          
-         
-          
-           make_interval(years int DEFAULT 0,
-           months int DEFAULT 0,
-           weeks int DEFAULT 0,
-           days int DEFAULT 0,
-           hours int DEFAULT 0,
-           mins int DEFAULT 0,
-           secs double precision DEFAULT 0.0)
-          
-         
+         make_interval
         
-        interval
-        
+         int
+         , int
+         , int
+         , int
+         , int
+         , int
+         , double precision
+         
+        interval
+       
+       
+        
          Create interval from years, months, weeks, days, hours, minutes and
-         seconds fields
+         seconds fields, each of which can default to zero
         
-        make_interval(days => 10)
-        10 days
+       
+       
+        make_interval(days => 10)
+        10 days
        
 
        
-        
+        
          
           make_time
          
-         
-          
-           make_time(hour int,
-           min int,
-           sec double precision)
-          
-         
+         make_time
         
-        time
-        
+        hour int,
+         min int,
+         sec double precision
+        time
+       
+       
+        
          Create time from hour, minute and seconds fields
         
-        make_time(8, 15, 23.5)
-        08:15:23.5
+       
+       
+        make_time(8, 15, 23.5)
+        08:15:23.5
        
 
        
-        
+        
          
           make_timestamp
          
-         
-          
-           make_timestamp(year int,
-           month int,
-           day int,
-           hour int,
-           min int,
-           sec double precision)
-          
-         
+         make_timestamp
         
-        timestamp
-        
+        year int,
+         month int,
+         day int,
+         hour int,
+         min int,
+         sec double precision
+        timestamp
+       
+       
+        
          Create timestamp from year, month, day, hour, minute and seconds fields
         
-        make_timestamp(2013, 7, 15, 8, 15, 23.5)
-        2013-07-15 08:15:23.5
+       
+       
+        make_timestamp(2013, 7, 15, 8, 15, 23.5)
+        2013-07-15 08:15:23.5
        
 
        
-        
+        
          
           make_timestamptz
          
-         
-          
-           make_timestamptz(year int,
-           month int,
-           day int,
-           hour int,
-           min int,
-           sec double precision,
-            timezone text )
-          
-         
+         make_timestamptz
         
-        timestamp with time zone
-        
+        year int,
+         month int,
+         day int,
+         hour int,
+         min int,
+         sec double precision,
+          timezone text 
+        timestamp with time zone
+       
+       
+        
          Create timestamp with time zone from year, month, day, hour, minute
          and seconds fields; if timezone is not
          specified, the current time zone is used
         
-        make_timestamptz(2013, 7, 15, 8, 15, 23.5)
-        2013-07-15 08:15:23.5+01
+       
+       
+        make_timestamptz(2013, 7, 15, 8, 15, 23.5)
+        2013-07-15 08:15:23.5+01
        
 
        
-        
+        
          
           now
          
-         now()
+         now
         
-        timestamp with time zone
-        Current date and time (start of current transaction);
+        none
+        timestamp with time zone
+       
+       
+        Current date and time (start of current transaction);
          see 
         
-        
-        
+       
+       
+        now()
+        variable
        
 
        
-        
+        
          
           statement_timestamp
          
-         statement_timestamp()
+         statement_timestamp
         
-        timestamp with time zone
-        Current date and time (start of current statement);
+        none
+        timestamp with time zone
+       
+       
+        Current date and time (start of current statement);
          see 
         
-        
-        
+       
+       
+        statement_timestamp()
+        variable
        
 
        
-        
+        
          
           timeofday
          
-         timeofday()
+         timeofday
         
-        text
-        Current date and time
+        none
+        text
+       
+       
+        Current date and time
          (like clock_timestamp, but as a text string);
          see 
         
-        
-        
+       
+       
+        timeofday()
+        variable
        
 
        
-        
+        
          
           transaction_timestamp
          
-         transaction_timestamp()
+         transaction_timestamp
         
-        timestamp with time zone
-        Current date and time (start of current transaction);
+        none
+        timestamp with time zone
+       
+       
+        Current date and time (start of current transaction);
          see 
         
-        
-        
        
        
-        
+        transaction_timestamp()
+        variable
+       
+       
+        
          
           to_timestamp
          
-         to_timestamp(double precision)
+         to_timestamp
         
-        timestamp with time zone
-        Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to
+        double precision
+        timestamp with time zone
+       
+       
+        Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to
          timestamp
-        to_timestamp(1284352323)
-        2010-09-13 04:32:03+00
+       
+       
+        to_timestamp(1284352323)
+        2010-09-13 04:32:03+00
        
       
      
@@ -8236,52 +8383,67 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
 
   
Enum Support Functions - + + + + + + + + - Function - Description - Example - Example Result + Function + Description + + + Example + Result - + enum_first - enum_first(anyenum) + enum_first(anyenum) returns anyenum - Returns the first value of the input enum type - enum_first(null::rainbow) - red + Returns the first value of the input enum type - + enum_first(null::rainbow) + red + + + enum_last - enum_last(anyenum) + enum_last(anyenum) returns anyenum - Returns the last value of the input enum type - enum_last(null::rainbow) - purple + Returns the last value of the input enum type - + enum_last(null::rainbow) + purple + + + enum_range - enum_range(anyenum) + enum_range(anyenum) returns anyarray - Returns all values of the input enum type in an ordered array - enum_range(null::rainbow) - {red,orange,yellow,green,blue,purple} + Returns all values of the input enum type in an ordered array + + + enum_range(null::rainbow) + {red,orange,yellow,green,blue,purple} - enum_range(anyenum, anyenum) - + enum_range(anyenum, anyenum) returns anyarray + Returns the range between the two given enum values, as an ordered array. The values must be from the same enum type. If the first parameter is null, the result will start with the first value of @@ -8289,16 +8451,18 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple If the second parameter is null, the result will end with the last value of the enum type. - enum_range('orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,green} + enum_range('orange'::rainbow, 'green'::rainbow) + {orange,yellow,green} + + + enum_range(NULL, 'green'::rainbow) + {red,orange,yellow,green} - enum_range('orange'::rainbow, NULL) - {orange,yellow,green,blue,purple} + enum_range('orange'::rainbow, NULL) + {orange,yellow,green,blue,purple} diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index ceda48e..7364294 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -6798,471 +6798,682 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
Date/Time Functions - + + + + + + + + + + - Function - Return Type - Description - Example - Result + Function + Argument Types + Result Type + + + Description + + + Example + + + Example Result - + age - age(timestamp, timestamp) + age - interval - Subtract arguments, producing a symbolic result that + timestamp, timestamp + interval + + + Subtract arguments, producing a symbolic result that uses years and months, rather than just days - age(timestamp '2001-04-10', timestamp '1957-06-13') - 43 years 9 mons 27 days + + + age(timestamp '2001-04-10', timestamp '1957-06-13') + + + 43 years 9 mons 27 days - age(timestamp) - interval - Subtract from current_date (at midnight) - age(timestamp '1957-06-13') - 43 years 8 mons 3 days + age + timestamp + interval + + + Subtract from current_date (at midnight) + + + age(timestamp '1957-06-13') + + + variable - + clock_timestamp - clock_timestamp() + clock_timestamp - timestamp with time zone - Current date and time (changes during statement execution); + none + timestamp with time zone + + + Current date and time (changes during statement execution); see - - + + + clock_timestamp() + + + variable - + current_date - current_date + current_date - date - Current date; + none (written without parentheses) + date + + + Current date; see - - + + + current_date + + + variable - + current_time - current_time + current_time - time with time zone - Current time of day; + none (written without parentheses) + time with time zone + + + Current time of day; see - - + + + current_time + + + variable - + current_timestamp - current_timestamp + current_timestamp - timestamp with time zone - Current date and time (start of current transaction); + none (written without parentheses) + timestamp with time zone + + + Current date and time (start of current transaction); see - - + + + current_timestamp + + + variable - + date_part - date_part(text, timestamp) + date_part - double precision - Get subfield (equivalent to extract); + text, timestamp + double precision + + + Get subfield (equivalent to extract); see - date_part('hour', timestamp '2001-02-16 20:38:40') - 20 + + + date_part('hour', timestamp '2001-02-16 20:38:40') + + + 20 - date_part(text, interval) - double precision - Get subfield (equivalent to + date_part + text, interval + double precision + + + Get subfield (equivalent to extract); see - date_part('month', interval '2 years 3 months') - 3 + + + date_part('month', interval '2 years 3 months') + + + 3 - + date_trunc - date_trunc(text, timestamp) + date_trunc - timestamp - Truncate to specified precision; see + text, timestamp + timestamp + + + Truncate to specified precision; see - date_trunc('hour', timestamp '2001-02-16 20:38:40') - 2001-02-16 20:00:00 + + + date_trunc('hour', timestamp '2001-02-16 20:38:40') + + + 2001-02-16 20:00:00 - date_trunc(text, timestamp with time zone, text) - timestamp with time zone - Truncate to specified precision in the specified time zone; see + date_trunc + text, timestamp with time zone, text + timestamp with time zone + + + Truncate to specified precision in the specified time zone; see - date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney') - 2001-02-16 13:00:00+00 + + + date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney') + + + 2001-02-16 13:00:00+00 - date_trunc(text, interval) - interval - Truncate to specified precision; see + date_trunc + text, interval + interval + + + Truncate to specified precision; see - date_trunc('hour', interval '2 days 3 hours 40 minutes') - 2 days 03:00:00 + + + date_trunc('hour', interval '2 days 3 hours 40 minutes') + + + 2 days 03:00:00 - + extract - extract(field from - timestamp) + extract - double precision - Get subfield; see + field from timestamp + double precision + + + Get subfield; see - extract(hour from timestamp '2001-02-16 20:38:40') - 20 + + + extract(hour from timestamp '2001-02-16 20:38:40') + + + 20 - extract(field from - interval) - double precision - Get subfield; see + extract + field from interval + double precision + + + Get subfield; see - extract(month from interval '2 years 3 months') - 3 + + + extract(month from interval '2 years 3 months') + + + 3 - + isfinite - isfinite(date) + isfinite - boolean - Test for finite date (not +/-infinity) - isfinite(date '2001-02-16') - true + date + boolean + + + Test for finite date (not +/-infinity) + + + isfinite(date '2001-02-16') + + + true - isfinite(timestamp) - boolean - Test for finite time stamp (not +/-infinity) - isfinite(timestamp '2001-02-16 21:28:30') - true + isfinite + timestamp + boolean + + + Test for finite time stamp (not +/-infinity) + + + isfinite(timestamp '2001-02-16 21:28:30') + + + true - isfinite(interval) - boolean - Test for finite interval - isfinite(interval '4 hours') - true + isfinite + interval + boolean + + + Test for finite interval + + + isfinite(interval '4 hours') + + + true - + justify_days - justify_days(interval) + justify_days - interval - Adjust interval so 30-day time periods are represented as months - justify_days(interval '35 days') - 1 mon 5 days + interval + interval + + + Adjust interval so 30-day time periods are represented as months + + + justify_days(interval '35 days') + + + 1 mon 5 days - + justify_hours - justify_hours(interval) + justify_hours - interval - Adjust interval so 24-hour time periods are represented as days - justify_hours(interval '27 hours') - 1 day 03:00:00 + interval + interval + + + Adjust interval so 24-hour time periods are represented as days + + + justify_hours(interval '27 hours') + + + 1 day 03:00:00 - + justify_interval - justify_interval(interval) + justify_interval - interval - Adjust interval using justify_days and justify_hours, with additional sign adjustments - justify_interval(interval '1 mon -1 hour') - 29 days 23:00:00 + interval + interval + + + Adjust interval using justify_days and justify_hours, with additional sign adjustments + + + justify_interval(interval '1 mon -1 hour') + + + 29 days 23:00:00 - + localtime - localtime + localtime - time - Current time of day; + none (written without parentheses) + time + + + Current time of day; see - - + + + localtime + + + variable - + localtimestamp - localtimestamp + localtimestamp - timestamp - Current date and time (start of current transaction); + none (written without parentheses) + timestamp + + + Current date and time (start of current transaction); see - - + + + localtimestamp + + + variable - + make_date - - - make_date(year int, - month int, - day int) - - + make_date - date - + year int, + month int, + day int + date + + + Create date from year, month and day fields - make_date(2013, 7, 15) - 2013-07-15 + + + make_date(2013, 7, 15) + + + 2013-07-15 - - + make_interval - - - make_interval(years int DEFAULT 0, - months int DEFAULT 0, - weeks int DEFAULT 0, - days int DEFAULT 0, - hours int DEFAULT 0, - mins int DEFAULT 0, - secs double precision DEFAULT 0.0) - - + make_interval - interval - + int + , int + , int + , int + , int + , int + , double precision + + interval + + + Create interval from years, months, weeks, days, hours, minutes and - seconds fields + seconds fields, each of which can default to zero - make_interval(days => 10) - 10 days + + + make_interval(days => 10) + + + 10 days - + make_time - - - make_time(hour int, - min int, - sec double precision) - - + make_time - time - + hour int, + min int, + sec double precision + time + + + Create time from hour, minute and seconds fields - make_time(8, 15, 23.5) - 08:15:23.5 + + + make_time(8, 15, 23.5) + + + 08:15:23.5 - + make_timestamp - - - make_timestamp(year int, - month int, - day int, - hour int, - min int, - sec double precision) - - + make_timestamp - timestamp - + year int, + month int, + day int, + hour int, + min int, + sec double precision + timestamp + + + Create timestamp from year, month, day, hour, minute and seconds fields - make_timestamp(2013, 7, 15, 8, 15, 23.5) - 2013-07-15 08:15:23.5 + + + make_timestamp(2013, 7, 15, 8, 15, 23.5) + + + 2013-07-15 08:15:23.5 - + make_timestamptz - - - make_timestamptz(year int, - month int, - day int, - hour int, - min int, - sec double precision, - timezone text ) - - + make_timestamptz - timestamp with time zone - + year int, + month int, + day int, + hour int, + min int, + sec double precision, + timezone text + timestamp with time zone + + + Create timestamp with time zone from year, month, day, hour, minute and seconds fields; if timezone is not specified, the current time zone is used - make_timestamptz(2013, 7, 15, 8, 15, 23.5) - 2013-07-15 08:15:23.5+01 + + + make_timestamptz(2013, 7, 15, 8, 15, 23.5) + + + 2013-07-15 08:15:23.5+01 - + now - now() + now - timestamp with time zone - Current date and time (start of current transaction); + none + timestamp with time zone + + + Current date and time (start of current transaction); see - - + + + now() + + + variable - + statement_timestamp - statement_timestamp() + statement_timestamp - timestamp with time zone - Current date and time (start of current statement); + none + timestamp with time zone + + + Current date and time (start of current statement); see - - + + + statement_timestamp() + + + variable - + timeofday - timeofday() + timeofday - text - Current date and time + none + text + + + Current date and time (like clock_timestamp, but as a text string); see - - + + + timeofday() + + + variable - + transaction_timestamp - transaction_timestamp() + transaction_timestamp - timestamp with time zone - Current date and time (start of current transaction); + none + timestamp with time zone + + + Current date and time (start of current transaction); see - - - + transaction_timestamp() + + + variable + + + to_timestamp - to_timestamp(double precision) + to_timestamp - timestamp with time zone - Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to + double precision + timestamp with time zone + + + Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to timestamp - to_timestamp(1284352323) - 2010-09-13 04:32:03+00 + + + to_timestamp(1284352323) + + + 2010-09-13 04:32:03+00 @@ -8236,52 +8447,74 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
Enum Support Functions - + + + + + + + - Function - Description - Example - Example Result + Function + Description + + + Example + + + Result - + enum_first - enum_first(anyenum) + enum_first(anyenum) returns anyenum - Returns the first value of the input enum type - enum_first(null::rainbow) - red + Returns the first value of the input enum type - + enum_first(null::rainbow) + + + red + + + enum_last - enum_last(anyenum) + enum_last(anyenum) returns anyenum - Returns the last value of the input enum type - enum_last(null::rainbow) - purple + Returns the last value of the input enum type - + enum_last(null::rainbow) + + + purple + + + enum_range - enum_range(anyenum) + enum_range(anyenum) returns anyarray - Returns all values of the input enum type in an ordered array - enum_range(null::rainbow) - {red,orange,yellow,green,blue,purple} + Returns all values of the input enum type in an ordered array + + + enum_range(null::rainbow) + + + {red,orange,yellow,green,blue,purple} - enum_range(anyenum, anyenum) - + enum_range(anyenum, anyenum) returns anyarray + Returns the range between the two given enum values, as an ordered array. The values must be from the same enum type. If the first parameter is null, the result will start with the first value of @@ -8289,16 +8522,24 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple If the second parameter is null, the result will end with the last value of the enum type. - enum_range('orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,green} + enum_range('orange'::rainbow, 'green'::rainbow) + + + {orange,yellow,green} + + + enum_range(NULL, 'green'::rainbow) + + + {red,orange,yellow,green} + + + enum_range('orange'::rainbow, NULL) - enum_range('orange'::rainbow, NULL) - {orange,yellow,green,blue,purple} + {orange,yellow,green,blue,purple}
В списке pgsql-docs по дате отправления
От: Jonathan S. Katz
Дата:
От: Jonathan S. Katz
Дата:
FAQ