Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j1dR9-0004KT-85 for pgsql-docs@arkaria.postgresql.org; Tue, 11 Feb 2020 21:51:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j1dR7-0002Uq-HR for pgsql-docs@arkaria.postgresql.org; Tue, 11 Feb 2020 21:51:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j1dR6-0002Ui-Nx for pgsql-docs@lists.postgresql.org; Tue, 11 Feb 2020 21:51:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j1dR1-00015t-DS for pgsql-docs@lists.postgresql.org; Tue, 11 Feb 2020 21:51:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01BLp94x009327 for ; Tue, 11 Feb 2020 16:51:09 -0500 From: Tom Lane To: pgsql-docs@lists.postgresql.org Subject: Getting our tables to render better in PDF output MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <9253.1581457747.0@sss.pgh.pa.us> Date: Tue, 11 Feb 2020 16:51:09 -0500 Message-ID: <9326.1581457869@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9253.1581457747.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable 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%40alvherr= e.pgsql ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="tables-one-row-per-example.patch"; charset="us-ascii" Content-ID: <9253.1581457747.2@sss.pgh.pa.us> Content-Description: tables-one-row-per-example.patch Content-Transfer-Encoding: quoted-printable 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 re= sult that + timestamp, timestamp<= /type> + interval + + + Subtract arguments, producing a s= ymbolic 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)<= /literal> - interval - Subtract from current_date (at midnig= ht) - age(timestamp '1957-06-13') - 43 years 8 mons 3 days + age<= /entry> + timestamp + interval + + + Subtract from current_date (at midnight) + + + age(timestamp '1957-06-13')<= /literal> + variable<= /entry> = - + clock_timestamp - clock_timestamp() + clock_timestamp - timestamp with time zone - Current date and time (changes during statement execution)= ; + none + timestamp with time zone<= /entry> + + + Current date and time (changes during st= atement execution); see - - + + + clock_timestamp()<= /entry> + variable<= /entry> = - + current_date - current_date + current_date - date - Current date; + none (written without parentheses) + date + + + Current date; see - - + + + current_date + variable<= /entry> = - + 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<= /entry> = - + 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<= /entry> + + + Current date and time (start of current = transaction); see - - + + + current_timestamp<= /entry> + variable<= /entry> = - + date_part - date_part(text, timestamp<= /type>) + date_part - double precision - Get subfield (equivalent to extract); + text, timestamp + double precision + + + Get subfield (equivalent to ex= tract); 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, inte= rval) - 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, tim= estamp 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<= /entry> + + + Truncate to specified precision in the s= pecified time zone; see - date_trunc('day', timestamptz '2001-02-16 20:38:4= 0+00', 'Australia/Sydney') - 2001-02-16 13:00:00+00 + + + date_trunc('day', timestampt= z '2001-02-16 20:38:40+00', 'Australia/Sydney') + 2001-02-16 13:00:00+00 = - date_trunc(text, int= erval) - 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 mi= nutes') - 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 fr= om 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 fr= om 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')<= /literal> + 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 +/-infin= ity) + + + 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 a= re represented as months + + + justify_days(interval '35 da= ys') + 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 h= ours') + 1 day 03:00:00 = - + justify_interval - justify_interval(interval) + justify_interval - interval - Adjust interval using justify_days an= d 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 si= gn adjustments + + + justify_interval(interval '1= mon -1 hour') + 29 days 23:00:00<= /entry> = - + localtime - localtime + localtime - time - Current time of day; + none (written without parentheses) + time + + + Current time of day; see - - + + + localtime + variable<= /entry> = - + 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<= /entry> = - + 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 DE= FAULT 0, - months int DEFAULT 0, - weeks int DEFAULT 0, - days int DEFAULT 0, - hours int DEFAULT 0, - mins int DEFAULT 0, - secs double precision DEFA= ULT 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 =3D> 10) - 10 days + + + make_interval(days =3D> 1= 0) + 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 <= /optional>) - - + 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<= /entry> + + + Create timestamp with time zone from year, month, day, hour, min= ute 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<= /entry> + + + Current date and time (start of current = transaction); see - - + + + now() + variable<= /entry> = - + statement_timestamp - statement_timestamp() + statement_timestamp - timestamp with time zone - Current date and time (start of current statement); + none + timestamp with time zone<= /entry> + + + Current date and time (start of current = statement); see - - + + + statement_timestamp() + variable<= /entry> = - + timeofday - timeofday() + timeofday - text - Current date and time + none + text + + + Current date and time (like clock_timestamp, but as a text<= /type> string); see - - + + + timeofday() + variable<= /entry> = - + transaction_timestamp - transaction_timestamp() + transaction_timestamp - timestamp with time zone - Current date and time (start of current transaction); + none + timestamp with time zone<= /entry> + + + Current date and time (start of current = transaction); see - - - + transaction_timestamp() + variable<= /entry> + + + 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<= /entry> + + + Convert Unix epoch (seconds since 1970-0= 1-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', 'yel= low', 'green', 'blue', 'purple =
Enum Support Functions - + + + + + + + + - Function - Description - Example - Example Result + Function<= /entry> + 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 arr= ay - 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,blu= e,purple} - enum_range(anyenum, anyenum) - + enum_range(anyenu= m, anyenum) returns anyarray + Returns the range between the two given enum values, as an ordere= d 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', 'yel= low', 'green', 'blue', 'purple If the second parameter is null, the result will end with the las= t 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'::rai= nbow) + {red,orange,yellow,green} - enum_range('orange'::rainbow, NULL) - {orange,yellow,green,blue,purple} + enum_range('orange'::rainbow,= NULL) + {orange,yellow,green,blue,pu= rple} ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="tables-two-rows-per-example.patch"; charset="us-ascii" Content-ID: <9253.1581457747.3@sss.pgh.pa.us> Content-Description: tables-two-rows-per-example.patch Content-Transfer-Encoding: quoted-printable 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 re= sult that + timestamp, timestamp<= /type> + interval + + + Subtract arguments, producing a s= ymbolic 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)<= /literal> - interval - Subtract from current_date (at midnig= ht) - age(timestamp '1957-06-13') - 43 years 8 mons 3 days + age<= /entry> + timestamp + interval + + + Subtract from current_date (at midnight) + + + age(timestamp '1957-06-13')<= /literal> + + + variable<= /entry> = - + clock_timestamp - clock_timestamp() + clock_timestamp - timestamp with time zone - Current date and time (changes during statement execution)= ; + none + timestamp with time zone<= /entry> + + + Current date and time (changes during st= atement execution); see - - + + + clock_timestamp()<= /entry> + + + variable<= /entry> = - + current_date - current_date + current_date - date - Current date; + none (written without parentheses) + date + + + Current date; see - - + + + current_date + + + variable<= /entry> = - + 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<= /entry> = - + 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<= /entry> + + + Current date and time (start of current = transaction); see - - + + + current_timestamp<= /entry> + + + variable<= /entry> = - + date_part - date_part(text, timestamp<= /type>) + date_part - double precision - Get subfield (equivalent to extract); + text, timestamp + double precision + + + Get subfield (equivalent to ex= tract); 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, inte= rval) - 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, tim= estamp 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<= /entry> + + + Truncate to specified precision in the s= pecified time zone; see - date_trunc('day', timestamptz '2001-02-16 20:38:4= 0+00', 'Australia/Sydney') - 2001-02-16 13:00:00+00 + + + date_trunc('day', timestampt= z '2001-02-16 20:38:40+00', 'Australia/Sydney') + + + 2001-02-16 13:00:00+00 = - date_trunc(text, int= erval) - 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 mi= nutes') - 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 fr= om 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 fr= om 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')<= /literal> + + + 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 +/-infin= ity) + + + 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 a= re represented as months + + + justify_days(interval '35 da= ys') + + + 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 h= ours') + + + 1 day 03:00:00 = - + justify_interval - justify_interval(interval) + justify_interval - interval - Adjust interval using justify_days an= d 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 si= gn adjustments + + + justify_interval(interval '1= mon -1 hour') + + + 29 days 23:00:00<= /entry> = - + localtime - localtime + localtime - time - Current time of day; + none (written without parentheses) + time + + + Current time of day; see - - + + + localtime + + + variable<= /entry> = - + 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<= /entry> = - + 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 DE= FAULT 0, - months int DEFAULT 0, - weeks int DEFAULT 0, - days int DEFAULT 0, - hours int DEFAULT 0, - mins int DEFAULT 0, - secs double precision DEFA= ULT 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 =3D> 10) - 10 days + + + make_interval(days =3D> 1= 0) + + + 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 <= /optional>) - - + 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<= /entry> + + + Create timestamp with time zone from year, month, day, hour, min= ute 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<= /entry> + + + Current date and time (start of current = transaction); see - - + + + now() + + + variable<= /entry> = - + statement_timestamp - statement_timestamp() + statement_timestamp - timestamp with time zone - Current date and time (start of current statement); + none + timestamp with time zone<= /entry> + + + Current date and time (start of current = statement); see - - + + + statement_timestamp() + + + variable<= /entry> = - + timeofday - timeofday() + timeofday - text - Current date and time + none + text + + + Current date and time (like clock_timestamp, but as a text<= /type> string); see - - + + + timeofday() + + + variable<= /entry> = - + transaction_timestamp - transaction_timestamp() + transaction_timestamp - timestamp with time zone - Current date and time (start of current transaction); + none + timestamp with time zone<= /entry> + + + Current date and time (start of current = transaction); see - - - + transaction_timestamp() + + + variable<= /entry> + + + 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<= /entry> + + + Convert Unix epoch (seconds since 1970-0= 1-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', 'yel= low', 'green', 'blue', 'purple =
Enum Support Functions - + + + + + + + - Function - Description - Example - Example Result + Function<= /entry> + 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 arr= ay - 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,blu= e,purple} - enum_range(anyenum, anyenum) - + enum_range(anyenu= m, anyenum) returns anyarray + Returns the range between the two given enum values, as an ordere= d 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', 'yel= low', 'green', 'blue', 'purple If the second parameter is null, the result will end with the las= t 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'::rai= nbow) + + + {red,orange,yellow,green} + + + enum_range('orange'::rainbow,= NULL) - enum_range('orange'::rainbow, NULL) - {orange,yellow,green,blue,purple} + {orange,yellow,green,blue,pu= rple} ------- =_aaaaaaaaaa0--