Poll: are people okay with function/operator table redesign?

Поиск
Список
Период
Сортировка
Искать

Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
As discussed in the thread at [1], I've been working on redesigning
the tables we use to present SQL functions and operators.  The
first installment of that is now up; see tables 9.30 and 9.31 at

https://www.postgresql.org/docs/devel/functions-datetime.html

and table 9.33 at

https://www.postgresql.org/docs/devel/functions-enum.html

Before I spend more time on this, I want to make sure that people
are happy with this line of attack.  Comparing these tables to
the way they look in v12, they clearly take more vertical space;
but at least to my eye they're less cluttered and more readable.
They definitely scale a lot better for cases where a long function
description is needed, or where we'd like to have more than one
example.  Does anyone prefer the old way, or have a better idea?

I know that the table headings are a bit weirdly laid out; hopefully
that can be resolved [2].

			regards, tom lane

[1] https://www.postgresql.org/message-id/flat/9326.1581457869%40sss.pgh.pa.us
[2] https://www.postgresql.org/message-id/6169.1586794603%40sss.pgh.pa.us


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 1:13 PM Tom Lane  wrote:
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
>
> https://www.postgresql.org/docs/devel/functions-datetime.html
>
> and table 9.33 at
>
> https://www.postgresql.org/docs/devel/functions-enum.html
>
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?

I find the new way quite hard to read. I prefer the old way.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Erik Rijkers <er@xs4all.nl>
Дата:
On 2020-04-13 19:13, Tom Lane wrote:
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
> 
> https://www.postgresql.org/docs/devel/functions-datetime.html
> 
> and table 9.33 at
> 
> https://www.postgresql.org/docs/devel/functions-enum.html
> 
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?
> 

+1

In the pdf it is a big improvement; and the html is better too.



Re: Poll: are people okay with function/operator table redesign?

От:
Isaac Morland <isaac.morland@gmail.com>
Дата:
On Mon, 13 Apr 2020 at 13:13, Tom Lane <tgl@sss.pgh.pa.us> wrote:
As discussed in the thread at [1], I've been working on redesigning
the tables we use to present SQL functions and operators.  The
first installment of that is now up; see tables 9.30 and 9.31 at

https://www.postgresql.org/docs/devel/functions-datetime.html

and table 9.33 at

https://www.postgresql.org/docs/devel/functions-enum.html

Before I spend more time on this, I want to make sure that people
are happy with this line of attack.  Comparing these tables to
the way they look in v12, they clearly take more vertical space;
but at least to my eye they're less cluttered and more readable.
They definitely scale a lot better for cases where a long function
description is needed, or where we'd like to have more than one
example.  Does anyone prefer the old way, or have a better idea?

I honestly don’t know. My initial reaction is a combination of “that’s weird” and “that’s cool”. So a few comments, which shouldn’t be taken as indicating a definite preference:

- showing the signature like this is interesting. For a moment I was wondering why it doesn’t say, for example, "interval → interval → interval” then I remembered this is Postgres, not Haskell. On the one hand, I like putting the signature like this; on the other, I don’t like that the return type is in a different place in each one. Could it be split into the same two columns as the example(s); first column inputs, second column results?

- another possibility for the parameters: list each one on a separate line, together with default (if applicable). Maybe that would be excessively tall, but it would sure make completely clear just exactly how many parameters there are and never wrap (well, maybe on a phone, but we can only do so much).

- for the various current-time-related functions (age, current_time, etc.), rather than saying “variable”, could it be the actual result with “now” being taken to be a specific fixed time within the year in which the documentation was generated? This would be really helpful for example with being clear that current_time is only the time of day with no date.

- the specific fixed time should be something like (current year)-06-30 18:45:54. I’ve deliberately chosen all values to be outside of the range of values with smaller ranges. For example, the hour is >12, the limit of the month field.

- I think there should be much more distinctive lines between the different functions. As it is the fact that the table is groups of 3 lines doesn’t jump out at the eye.

Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2020-Apr-13, Tom Lane wrote:

> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
> 
> https://www.postgresql.org/docs/devel/functions-datetime.html
> 
> and table 9.33 at
> 
> https://www.postgresql.org/docs/devel/functions-enum.html
> 
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.

I am torn.  On the one side, I think this new format is so much better
than the old one that we should definitely use it for all tables.  On
the other side, I also think this format is slightly more complicated to
read, so perhaps it would be sensible to keep using the old format for
the simplest tables.

One argument for the first of those positions is that if this new table
layout is everywhere, it'll take less total time to get used to it.


One improvement (that I don't know is possible in docbook) would be to
have the inter-logical-row line be slightly thicker than the
intra-logical-row one.  That'd make each entry visually more obvious.

I think you already mentioned the PDF issue that these multi-row entries
are sometimes split across pages.  I cannot believe docbook is so stupid
not to have a solution to that problem, but I don't know what that
solution would be.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Isaac Morland  writes:
> - showing the signature like this is interesting. For a moment I was
> wondering why it doesn’t say, for example, "interval → interval → interval”
> then I remembered this is Postgres, not Haskell. On the one hand, I like
> putting the signature like this; on the other, I don’t like that the return
> type is in a different place in each one. Could it be split into the same
> two columns as the example(s); first column inputs, second column results?

We tried that in an earlier iteration (see the referenced thread).  It
doesn't work very well because you end up having to allocate the max
amount of space for any result type or example result on every line.
Giving up the separate cell for return type is a lot of what makes this
workable.

> - another possibility for the parameters: list each one on a separate line,
> together with default (if applicable). Maybe that would be excessively
> tall, but it would sure make completely clear just exactly how many
> parameters there are and never wrap (well, maybe on a phone, but we can
> only do so much).

Since so few built-in functions have default parameters, that's going to
waste an awful lot of space in most cases.  I actually ended up removing
the explicit "default" clauses from make_interval (which is the only
function with defaults that I dealt with so far) and instead explained
that they all default to zero in the text description, because that took
way less space.

> - for the various current-time-related functions (age, current_time, etc.),
> rather than saying “variable”, could it be the actual result with “now”
> being taken to be a specific fixed time within the year in which the
> documentation was generated? This would be really helpful for example with
> being clear that current_time is only the time of day with no date.

Yeah, I've been waffling about that.  On the one hand, we regularly get
docs complaints from people who say "I tried this example and I didn't
get the claimed result".  On the other hand you could figure that
everybody should understand that current_timestamp won't work like that
... but the first such example in the table is age() for which that
automatic understanding might not apply.

The examples down in 9.9.4 use a specific time, which is looking pretty
long in the tooth right now, and no one has complained --- but that's
in a context where it's absolutely plain that every mentioned function
is going to have a time-varying result.

On the whole I'm kind of leaning to going back to using a specific time.
But that's a detail that's not very relevant to the bigger picture here.
(No, I'm not going to try to make it update every year; too much work
for too little reward.)

> - I think there should be much more distinctive lines between the different
> functions. As it is the fact that the table is groups of 3 lines doesn’t
> jump out at the eye.

I don't know any easy way to do that.  We do already have the grouping
visible in the first column...

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alvaro Herrera  writes:
> One improvement (that I don't know is possible in docbook) would be to
> have the inter-logical-row line be slightly thicker than the
> intra-logical-row one.  That'd make each entry visually more obvious.

Yeah, I don't see any way to do that :-(.  We could suppress the row
lines entirely between the members of the logical group, but that'd
almost surely look worse.

(I tried to implement this to see, and couldn't get rowsep="0" in
a  to render the way I expected, so there may be toolchain
bugs in the way of it anyway.)

We could leave an entirely empty row between logical groups, but
that would be really wasteful of vertical space.

Another possibility, which'd only help in HTML, would be to render
some of the cells with a slightly different background color.
That's beyond my docbook/css skills, but it might be possible.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 2:47 PM Tom Lane  wrote:
> Another possibility, which'd only help in HTML, would be to render
> some of the cells with a slightly different background color.
> That's beyond my docbook/css skills, but it might be possible.

I think some visual distinction would be really helpful, if we can get it.

I just wonder if there's too much clutter here. Like, line 1:

date - interval → timestamp

OK, gotcha. Line 2:

Subtract an interval from a date

Well, is that really adding anything non-obvious?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Дата:

On 4/13/20 1:13 PM, Tom Lane wrote:
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
>
> https://www.postgresql.org/docs/devel/functions-datetime.html
>
> and table 9.33 at
>
> https://www.postgresql.org/docs/devel/functions-enum.html
>
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?
>
> I know that the table headings are a bit weirdly laid out; hopefully
> that can be resolved [2].
>
> 			regards, tom lane
>
> [1] https://www.postgresql.org/message-id/flat/9326.1581457869%40sss.pgh.pa.us
> [2] https://www.postgresql.org/message-id/6169.1586794603%40sss.pgh.pa.us
>

Gotta say I'm not a huge fan. I appreciate the effort, and I get the
problem, but I'm not sure we have a net improvement here.


One thing that did occur to me is that the function/operator name is
essentially redundant, as it's in the signature anyway. Not sure if that
helps us any though.


Maybe we're just trying to shoehorn too much information into a single
table.


cheers


andrew


-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> I just wonder if there's too much clutter here. Like, line 1:

> date - interval → timestamp

> OK, gotcha. Line 2:

> Subtract an interval from a date

> Well, is that really adding anything non-obvious?

Yeah, back in the other thread I said

>>> I decided to try converting the date/time operators table too, to
>>> see how well this works for that.  It's bulkier than before, but
>>> also (I think) more precise.  I realized that this table actually
>>> had three examples already for float8 * interval, but it wasn't
>>> at all obvious that they were the same operator.  So that aspect
>>> is a lot nicer here.  On the other hand, it seems like the text
>>> descriptions are only marginally useful here.  I can imagine that
>>> they would be useful in some other operator tables, such as
>>> geometric operators, but I'm a bit tempted to leave them out
>>> in this particular table.  The format would adapt to that easily.

I wouldn't be averse to dropping the text descriptions for operators
in places where they seem obvious ... but who decides what is obvious?

Indeed, we've gotten more than one complaint in the past that some of the
geometric and JSON operators require a longer explanation than they've
got.  So one of the points here was to have a format that could adapt to
that.  But in this particular table I agree they're marginal.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 11:27 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Isaac Morland <isaac.morland@gmail.com> writes:

> - I think there should be much more distinctive lines between the different
> functions. As it is the fact that the table is groups of 3 lines doesn’t
> jump out at the eye.

I don't know any easy way to do that.  We do already have the grouping
visible in the first column...

Can we lightly background color every other rowgroup (i.e., "greenbar")?

I don't think having a separate Result column helps.  The additional horizontal whitespace distances all relevant context information (at least on a wide monitor).  Having the example rows mirror the Signature row seems like an easier to consume choice.

e.g., 

enum_first(null::rainbow) → red

date '2001-09-28' + 7 → 2001-10-05

Its also removes the left alignment in a fixed width column which draws unwanted visual attention.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> One thing that did occur to me is that the function/operator name is
> essentially redundant, as it's in the signature anyway. Not sure if that
> helps us any though.

Hm, you have a point there.  However, if we drop the lefthand column
then there really isn't any visual distinction between the row(s)
associated with one function and those of the next.  Unless we can
find another fix for that aspect (as already discussed in this thread)
I doubt it'd be an improvement.

> Maybe we're just trying to shoehorn too much information into a single
> table.

Yeah, back at the beginning of this exercise, Alvaro wondered aloud
if we should go to something other than tables altogether.  I dunno
what that'd look like though.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"David G. Johnston"  writes:
> Can we lightly background color every other rowgroup (i.e., "greenbar")?

If you know how to do that at all, let alone in a maintainable way (ie
one where inserting a new function doesn't require touching the entries
for the ones after), let's see it.  I agree it'd be a nice solution,
if we could make it work, but I don't see how.  I'd been imagining
instead that we could give a different background color to the first
line of each group; which I don't know how to do but it at least seems
plausible that a style could be attached to a .

> I don't think having a separate Result column helps.  The additional
> horizontal whitespace distances all relevant context information (at least
> on a wide monitor).  Having the example rows mirror the Signature row seems
> like an easier to consume choice.

Interesting idea.  I'm afraid that it would not look so great in cases
where the example-plus-result overflows one line, which would inevitably
happen in PDF format.  Still, maybe that would be rare enough to not be
a huge problem.  In most places it'd be a win to not have to separately
allocate example and result space.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I wrote:
> "David G. Johnston"  writes:
>> I don't think having a separate Result column helps.  The additional
>> horizontal whitespace distances all relevant context information (at least
>> on a wide monitor).  Having the example rows mirror the Signature row seems
>> like an easier to consume choice.

> Interesting idea.  I'm afraid that it would not look so great in cases
> where the example-plus-result overflows one line, which would inevitably
> happen in PDF format.  Still, maybe that would be rare enough to not be
> a huge problem.  In most places it'd be a win to not have to separately
> allocate example and result space.

Actually ... if we did it like that, then it would be possible to treat
the signature + description + example(s) as one big table cell with line
breaks rather than row-separator bars.  That would help address the
inadequate-visual-separation-between-groups issue, but on the other hand
maybe we'd end up with too little visual separation between the elements
of a function description.

A quick google search turned up this suggestion about how to force
line breaks in docbook table cells:

http://www.sagehill.net/docbookxsl/LineBreaks.html

which seems pretty hacky but it should work.  Anyone know a better
way?

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 1:41 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Can we lightly background color every other rowgroup (i.e., "greenbar")?

If you know how to do that at all, let alone in a maintainable way (ie
one where inserting a new function doesn't require touching the entries
for the ones after), let's see it.

The nth-child({odd|even}) CSS Selector should provide the desired functionality, at least for HTML, but the structure will need to modified so that there is some single element that represents a single rowgroup.  I tried (not too hard) to key off of the presence of the "rowspan" attribute but that does not seem possible.


David J.
 

Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 1:57 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Actually ... if we did it like that, then it would be possible to treat
the signature + description + example(s) as one big table cell with line
breaks rather than row-separator bars. 
 
That would help address the
inadequate-visual-separation-between-groups issue, but on the other hand
maybe we'd end up with too little visual separation between the elements
of a function description.

Speaking in terms of HTML if we use <hr /> instead of <br /> we would get the best of both worlds.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/13/20 1:13 PM, Tom Lane wrote:
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
> 
> https://www.postgresql.org/docs/devel/functions-datetime.html
> 
> and table 9.33 at
> 
> https://www.postgresql.org/docs/devel/functions-enum.html
> 
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?
> 
> I know that the table headings are a bit weirdly laid out; hopefully
> that can be resolved [2].

> [2] https://www.postgresql.org/message-id/6169.1586794603%40sss.pgh.pa.us

When evaluating [2], I will admit at first I was very confused about the
layout and wasn't exactly sure what you were saying was incorrect in
that note. After fixing [2] on my local copy, I started to look at it again.

For positives, I do think it's an improvement for readability on mobile.
Flow/content aside, it was easier to read and follow what was going on
and there was less side scrolling.

I think one thing that was throwing me off was having the function
signature before the description. I would recommend flipping them: have
the function description first, followed by signature, followed be
examples. I think that follows the natural flow more of what one is
doing when they look up the function.

I think that would also benefit larger tables too: instead of having to
scroll up to understand how things are laid out, it'd follow said flow.

There are probably some things we can do with shading on the pgweb side
to make items more distinguishable, I don't think that would be too
terrible to add.

Thinking out loud, it'd also be great if we could add in some anchors as
well, so perhaps in the future on the pgweb side we could add in some
discoverable links that other documentation has -- which in turn people
could click / link to others directly to the function name.

Anyway, change is hard. I'm warming up to it.

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Corey Huinker <corey.huinker@gmail.com>
Дата:
Thinking out loud, it'd also be great if we could add in some anchors as
well, so perhaps in the future on the pgweb side we could add in some
discoverable links that other documentation has -- which in turn people
could click / link to others directly to the function name.

+1 

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Вложения:
"David G. Johnston"  writes:
> On Mon, Apr 13, 2020 at 1:57 PM Tom Lane  wrote:
>> Actually ... if we did it like that, then it would be possible to treat
>> the signature + description + example(s) as one big table cell with line
>> breaks rather than row-separator bars.
>> That would help address the
>> inadequate-visual-separation-between-groups issue, but on the other hand
>> maybe we'd end up with too little visual separation between the elements
>> of a function description.

> Speaking in terms of HTML if we use 
instead of
we would get > the best of both worlds. Hm. I quickly hacked up table 9.33 to use this approach. Attached are a patch for that, as well as screenshots of HTML and PDF output. (To get the equivalent of HTML-hr.png, use
not
in the stylesheet.) I don't think I like the
version better than
--- it adds quite a bit of vertical space, more than I was expecting really. The documentation I could find with Google suggests that
can be rendered with quite a bit of variation by different agents, so other people might get different results. (This is with Safari.) It seems like the font differentiation between the description and the other parts is almost, but perhaps not quite, enough separation already. I don't know how to get the equivalent of
in PDF output, so that version just does line breaks. It seems like the vertical spacing in the examples is a bit wonky, but otherwise it's not awful. Note that the PDF rendering shows the header and function name alignment as I intended them; the HTML renderings are wrong due to website stylesheet issues. regards, tom lane diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 7a270eb..497c125 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -8645,103 +8645,89 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple Enum Support Functions - - - - - - - - - + + + - Function - Signature - - - Description - - - Example - Example Result + Function + SignatureDescriptionExample - + enum_first enum_first - enum_first(anyenum) anyenum - - - Returns the first value of the input enum type - - - enum_first(&zwsp;null::rainbow) - red + + enum_first(anyenum) + anyenum + + Returns the first value of the input enum type + + enum_first(&zwsp;null::rainbow) + red + - + enum_last enum_last - enum_last(anyenum) anyenum - - - Returns the last value of the input enum type - - - enum_last(&zwsp;null::rainbow) - purple + + enum_last(anyenum) + anyenum + + Returns the last value of the input enum type + + enum_last(&zwsp;null::rainbow) + purple + - + enum_range enum_range - enum_range(anyenum) anyarray - - - Returns all values of the input enum type in an ordered array - - - enum_range(&zwsp;null::rainbow) - {red,orange,yellow,&zwsp;green,blue,purple} - - - enum_range - enum_range(anyenum, anyenum) anyarray + + enum_range(anyenum) + anyarray + + Returns all values of the input enum type in an ordered array + + enum_range(&zwsp;null::rainbow) + {red,orange,yellow,&zwsp;green,blue,purple} + - + enum_range + enum_range(anyenum, anyenum) + 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 the enum type. If the second parameter is null, the result will end with the last value of the enum type. + + enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) + {orange,yellow,green} + + enum_range(NULL, 'green'::rainbow) + {red,orange,&zwsp;yellow,green} + + enum_range(&zwsp;'orange'::rainbow, NULL) + {orange,yellow,green,&zwsp;blue,purple} - - enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - - - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,&zwsp;green} - - - enum_range(&zwsp;'orange'::rainbow, NULL) - {orange,yellow,green,&zwsp;blue,purple} -
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl index a13565e..105ed1c 100644 --- a/doc/src/sgml/stylesheet-common.xsl +++ b/doc/src/sgml/stylesheet-common.xsl @@ -103,4 +103,11 @@ + + + + +
+ + diff --git a/doc/src/sgml/stylesheet-fo.xsl b/doc/src/sgml/stylesheet-fo.xsl index 2aaae82..713159d 100644 --- a/doc/src/sgml/stylesheet-fo.xsl +++ b/doc/src/sgml/stylesheet-fo.xsl @@ -70,6 +70,11 @@ + + + + +

Re: Poll: are people okay with function/operator table redesign?

От:
Corey Huinker <corey.huinker@gmail.com>
Дата:
Yeah, back at the beginning of this exercise, Alvaro wondered aloud
if we should go to something other than tables altogether.  I dunno
what that'd look like though.

It would probably look like our acronyms and glossary pages.

Maybe the return example and return values get replaced with a programlisting?
 

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> I think one thing that was throwing me off was having the function
> signature before the description. I would recommend flipping them: have
> the function description first, followed by signature, followed be
> examples. I think that follows the natural flow more of what one is
> doing when they look up the function.

The trouble with that is it doesn't work very well when we have
multiple similarly-named functions with different signatures.
Consider what the two enum_range() entries in 9.33 will look like,
for example.  I think we need the signature to establish which function
we're talking about.

> There are probably some things we can do with shading on the pgweb side
> to make items more distinguishable, I don't think that would be too
> terrible to add.

Per David's earlier comment, it seems like alternating backgrounds might
be feasible if we can get it down to one  per function, as the
version I just posted has.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/13/20 6:51 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> I think one thing that was throwing me off was having the function
>> signature before the description. I would recommend flipping them: have
>> the function description first, followed by signature, followed be
>> examples. I think that follows the natural flow more of what one is
>> doing when they look up the function.
> 
> The trouble with that is it doesn't work very well when we have
> multiple similarly-named functions with different signatures.
> Consider what the two enum_range() entries in 9.33 will look like,
> for example.  I think we need the signature to establish which function
> we're talking about.

I get that, I just find I'm doing too much thinking looking at it.

Perhaps a counterproposal: We eliminate the content in the leftmost
"function column, but leave that there to allow the function name /
signature to span the full 3 columns. Then the rest of the info goes
below. This will also compress the table height down a bit.

>> There are probably some things we can do with shading on the pgweb side
>> to make items more distinguishable, I don't think that would be too
>> terrible to add.
> 
> Per David's earlier comment, it seems like alternating backgrounds might
> be feasible if we can get it down to one  per function, as the
> version I just posted has.

or a classname on the "" when a new function starts or the like.
Easy enough to get the CSS to work off of that :)

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/13/20 7:02 PM, Jonathan S. Katz wrote:
> On 4/13/20 6:51 PM, Tom Lane wrote:
>> "Jonathan S. Katz"  writes:
>>> I think one thing that was throwing me off was having the function
>>> signature before the description. I would recommend flipping them: have
>>> the function description first, followed by signature, followed be
>>> examples. I think that follows the natural flow more of what one is
>>> doing when they look up the function.
>>
>> The trouble with that is it doesn't work very well when we have
>> multiple similarly-named functions with different signatures.
>> Consider what the two enum_range() entries in 9.33 will look like,
>> for example.  I think we need the signature to establish which function
>> we're talking about.
> 
> I get that, I just find I'm doing too much thinking looking at it.
> 
> Perhaps a counterproposal: We eliminate the content in the leftmost
> "function column, but leave that there to allow the function name /
> signature to span the full 3 columns. Then the rest of the info goes
> below. This will also compress the table height down a bit.

An attempt at a "POC" of what I'm describing (attached image).

I'm not sure if I 100% like it, but it does reduce the amount of
information we're displaying but conveys all the details (and matches
what we have in the previous version).

The alignment could be adjusted if need be, too.

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I wrote:
> I don't think I like the 
version better than
--- it adds > quite a bit of vertical space, more than I was expecting really. Actually, after staring more at HTML-hr.png, what's *really* bothering me about that rendering is that the lines made by
are actually wider than the inter-table-cell lines. Surely we want the opposite relationship. Presumably that could be fixed with some css-level adjustments; and maybe the spacing could be tightened up a bit too? I do like having that visual separation, it just needs to be toned down compared to the table cell separators. Reproducing the effect in the PDF build remains an issue, too. regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2020-Apr-13, Jonathan S. Katz wrote:

> On 4/13/20 7:02 PM, Jonathan S. Katz wrote:

> > Perhaps a counterproposal: We eliminate the content in the leftmost
> > "function column, but leave that there to allow the function name /
> > signature to span the full 3 columns. Then the rest of the info goes
> > below. This will also compress the table height down a bit.
> 
> An attempt at a "POC" of what I'm describing (attached image).
> 
> I'm not sure if I 100% like it, but it does reduce the amount of
> information we're displaying but conveys all the details (and matches
> what we have in the previous version).

Ooh, this seems a nice idea -- the indentation seems to be sufficient to
tell apart entries from each other.  Your point about information
reduction refers to the fact that we no longer keep the unadorned name
but only the signature, right?  That seems an improvement to me now that
I look at it.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> On 4/13/20 7:02 PM, Jonathan S. Katz wrote:
>> Perhaps a counterproposal: We eliminate the content in the leftmost
>> "function column, but leave that there to allow the function name /
>> signature to span the full 3 columns. Then the rest of the info goes
>> below. This will also compress the table height down a bit.

> An attempt at a "POC" of what I'm describing (attached image).

Hmm ... what is determining the width of the left-hand column?
It doesn't seem to have any content, since the function entries
are being spanned across the whole table.

I think the main practical problem though is that it wouldn't
work nicely for operators, since the key "name" you'd be looking
for would not be at the left of the signature line.  I suppose we
don't necessarily have to have the same layout for operators as
for functions, but it feels like it'd be jarringly inconsistent.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Fabien COELHO <coelho@cri.ensmp.fr>
Дата:

Hello Tom,

> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.

+1

I like it this way, because the structure is quite readable, which is the 
point.

My 0.02€:

Maybe column heander "Example Result" should be simply "Result", because 
it is already on the same line as "Example" on its left, and "Example | 
Example Result" looks redundant.

Maybe the signature and description lines could be exchanged: I'm more 
interested and the description first, and the signature just above the 
example would make sense.

I'm wondering whether the function/operator name should be vertically 
centered in its cell? I'd left it left justified.

-- 
Fabien.

Re: Poll: are people okay with function/operator table redesign?

От:
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Дата:

On 4/13/20 7:55 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> On 4/13/20 7:02 PM, Jonathan S. Katz wrote:
>>> Perhaps a counterproposal: We eliminate the content in the leftmost
>>> "function column, but leave that there to allow the function name /
>>> signature to span the full 3 columns. Then the rest of the info goes
>>> below. This will also compress the table height down a bit.
>> An attempt at a "POC" of what I'm describing (attached image).
> Hmm ... what is determining the width of the left-hand column?
> It doesn't seem to have any content, since the function entries
> are being spanned across the whole table.
>
> I think the main practical problem though is that it wouldn't
> work nicely for operators, since the key "name" you'd be looking
> for would not be at the left of the signature line.  I suppose we
> don't necessarily have to have the same layout for operators as
> for functions, but it feels like it'd be jarringly inconsistent.
>
> 			



Maybe highlight the item by bolding or colour?


cheers


andrew

-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Re: Poll: are people okay with function/operator table redesign?

От:
Andreas Karlsson <andreas@proxel.se>
Дата:
On 4/13/20 7:13 PM, Tom Lane wrote:
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
> 
> https://www.postgresql.org/docs/devel/functions-datetime.html
> 
> and table 9.33 at
> 
> https://www.postgresql.org/docs/devel/functions-enum.html
> 
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?
> 
> I know that the table headings are a bit weirdly laid out; hopefully
> that can be resolved [2].

I prefer the old way since I find it very hard to see which fields 
belong to which function in the new way. I think what confuses my eyes 
is how some rows are split in half while others are not, especially for 
those functions where there is only one example output. I do not have 
any issue reading those with many example outputs.

For the old tables I can at least just make the browser window 
ridiculously wide ro read them.

Andreas



Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andreas Karlsson  writes:
> For the old tables I can at least just make the browser window 
> ridiculously wide ro read them.

A large part of the point here is to make the tables usable
when you don't have that option, as for example in PDF output.

Even with a wide window, though, some of our function tables are
monstrously ugly.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Andreas Karlsson <andreas@proxel.se>
Дата:
On 4/14/20 4:29 PM, Tom Lane wrote:
> Andreas Karlsson  writes:
>> For the old tables I can at least just make the browser window
>> ridiculously wide ro read them.
> 
> A large part of the point here is to make the tables usable
> when you don't have that option, as for example in PDF output.
> 
> Even with a wide window, though, some of our function tables are
> monstrously ugly.

Sure, but I wager the number of people using the HTML version of our 
documentation on laptops and desktop computers are the biggest group of 
users.

That said, I agree with that quite many of our tables right now are 
ugly, but I prefer ugly to hard to read. For me the mix of having every 
third row split into two fields makes the tables very hard to read. I 
have a hard time seeing which rows belong to which function.

Andreas


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andreas Karlsson  writes:
> That said, I agree with that quite many of our tables right now are 
> ugly, but I prefer ugly to hard to read. For me the mix of having every 
> third row split into two fields makes the tables very hard to read. I 
> have a hard time seeing which rows belong to which function.

Did you look at the variants without that discussed downthread?

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 4:29 PM Tom Lane  wrote:
> I wouldn't be averse to dropping the text descriptions for operators
> in places where they seem obvious ... but who decides what is obvious?

Well, we do. We're smart, right? I don't think it's a good idea to add
clutter to table A just because table B needs more details. What
matters is whether table A needs more details.

The v12 version of the "Table 9.30. Date/Time Operators" is not that
wide, and is really quite clear. The new version takes 3 lines per
operator where the old one took one. That's because you've added (1) a
description of the fact that + does addition and - does subtraction,
repeated for each operator, and (2) explicit information about the
input and result types. I don't think either add much, in this case.
The former doesn't really need to be explained, and the latter was
clear enough from the way the examples were presented - everything had
explicit types.

For more complicated cases, one thing we could do is ditch the table
and use a  with a separate  for each
operator. So you could have something like:


date + date &arrow; timestamp

Lengthy elocution, including an example.



But I would only advocate for this style in cases where there is
substantial explaining to be done.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> The v12 version of the "Table 9.30. Date/Time Operators" is not that
> wide, and is really quite clear.

Well, no it isn't. The main nit I would pick in that claim is that
it's far from obvious that the three examples of float8 * interval
are all talking about the same operator; in fact, a reader would
be very likely to draw the false conclusion that there is an
integer * interval operator.

This is an aspect of the general problem that we don't have a nice
way to deal with multiple examples in the tables.  Somebody kluged
their way around it here in this particular way, but I'd really like
a clearer way, because we need more examples.

I would also point out that this table is quite out of step with
the rest of the docs in its practice of showing the results as
though they were typed literals.  Most places that show results
just show what you'd expect to see in a psql output column, making
it necessary to show the result data type somewhere else.

> The new version takes 3 lines per
> operator where the old one took one. That's because you've added (1) a
> description of the fact that + does addition and - does subtraction,
> repeated for each operator, and (2) explicit information about the
> input and result types. I don't think either add much, in this case.

As I already said, I agree about the text descriptions being of marginal
value in this case.  I disagree about the explicit datatypes, because the
float8 * interval cases already show a hole in that argument, and surely
we don't want to require every example to use explicitly-typed literals
and nothing but.  Besides, what will you do for operators that take
anyarray or the like?

> For more complicated cases, one thing we could do is ditch the table
> and use a  with a separate  for each
> operator. So you could have something like:
> ...
> But I would only advocate for this style in cases where there is
> substantial explaining to be done.

I'd like to have more consistency, not less.  I do not think it helps
readers to have each page in Chapter 9 have its own idiosyncratic way of
presenting operators/functions.  The operator tables are actually almost
that bad, right now --- compare section 9.1 (hasn't even bothered with
a formal ) with tables 9.1, 9.4, 9.9, 9.12, 9.14, 9.30, 9.34,
9.37, 9.41, 9.44.  The variation in level of detail and precision is
striking, and not in a good way.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Tue, Apr 14, 2020 at 11:26 AM Tom Lane  wrote:
> Well, no it isn't. The main nit I would pick in that claim is that
> it's far from obvious that the three examples of float8 * interval
> are all talking about the same operator; in fact, a reader would
> be very likely to draw the false conclusion that there is an
> integer * interval operator.

I agree that's not great. I think that could possibly be fixed by
showing all three examples in the same cell, and maybe by revising the
choice of examples.

> I'd like to have more consistency, not less.  I do not think it helps
> readers to have each page in Chapter 9 have its own idiosyncratic way of
> presenting operators/functions.  The operator tables are actually almost
> that bad, right now --- compare section 9.1 (hasn't even bothered with
> a formal ) with tables 9.1, 9.4, 9.9, 9.12, 9.14, 9.30, 9.34,
> 9.37, 9.41, 9.44.  The variation in level of detail and precision is
> striking, and not in a good way.

Well, I don't know. Having two or even three formats is not the same
as having infinitely many formats, and may be justified if the needs
are sufficiently different from each other.

At any rate, if the price of more clarity and more examples is that
the tables become three times as long and harder to read, I am
somewhat inclined to think that the cure is worse than the disease. I
can readily see how something like table 9.10 (Other String Functions)
might be a mess on a narrow screen or in PDF format, but it's an
extremely useful table on a normal-size screen in HTML format, and
part of what makes it useful is that it's compact. Almost anything we
do is going to remove some of that compactness to save horizontal
space. Maybe that's OK, but it's sure not great. It's nice to be able
to see more on one screen.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> At any rate, if the price of more clarity and more examples is that
> the tables become three times as long and harder to read, I am
> somewhat inclined to think that the cure is worse than the disease. I
> can readily see how something like table 9.10 (Other String Functions)
> might be a mess on a narrow screen or in PDF format, but it's an
> extremely useful table on a normal-size screen in HTML format, and
> part of what makes it useful is that it's compact. Almost anything we
> do is going to remove some of that compactness to save horizontal
> space. Maybe that's OK, but it's sure not great. It's nice to be able
> to see more on one screen.

I dunno, it doesn't look to me like 9.10 is some paragon of efficient
use of screen space, even with a wide window.  (And my goodness it
looks bad if I try a window about half my usual web-browsing width.)
Maybe I should go convert that one to see what it looks like in one of
the other layouts being discussed.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
Вложения:
On Mon, Apr 13, 2020 at 10:13 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
As discussed in the thread at [1], I've been working on redesigning
the tables we use to present SQL functions and operators.  The
first installment of that is now up; see tables 9.30 and 9.31 at

https://www.postgresql.org/docs/devel/functions-datetime.html

and table 9.33 at

https://www.postgresql.org/docs/devel/functions-enum.html


As I write this the enum headers are centered horizontally while the datetime ones are left aligned.  The centering doesn't do it for me.  To much gap and the data itself is not centered so there is a large disconnected between the header and the value.

The run-on aspect of the left-aligned setup is of some concern but maybe just adding some left padding to the second column - and right padding to the first - can provide the desired negative space without adding so much as to break usability.

(gonna use embedded images here...)




David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Pierre Giraud <pierre.giraud@dalibo.com>
Дата:
Вложения:
Hi all,

Sorry I'm very new on this discussion. A colleague of mine told me I
could probably give my opinion on this thread.

I'm sorry in advance if I'm off topic. I just wanted to mention that
from Tom's proposal I played a bit with the generated HTML in order to
try to make things easier to read without thinking about technical
issues for now.

The first big issue (that may have already been mentioned) in my opinion
is that different elements are difficult to distinguish. It's difficult
for example to know what is the return type, what is the description, etc.

I think that if the idea is to get rid of the columns, you need to make
sure that it's easy to know which is which. With a very short amount of
time, the user should be able to find what he's looking for.

The best way to achieve this is to use some styling (font style and color).

Attached you will find two different options I worked on very quickly.

I would be happy to give more hints on how I did this of course and why
I chose some options. Please let me know.

Kind regards,


Le 13/04/2020 à 19:13, Tom Lane a écrit :
> As discussed in the thread at [1], I've been working on redesigning
> the tables we use to present SQL functions and operators.  The
> first installment of that is now up; see tables 9.30 and 9.31 at
> 
> https://www.postgresql.org/docs/devel/functions-datetime.html
> 
> and table 9.33 at
> 
> https://www.postgresql.org/docs/devel/functions-enum.html
> 
> Before I spend more time on this, I want to make sure that people
> are happy with this line of attack.  Comparing these tables to
> the way they look in v12, they clearly take more vertical space;
> but at least to my eye they're less cluttered and more readable.
> They definitely scale a lot better for cases where a long function
> description is needed, or where we'd like to have more than one
> example.  Does anyone prefer the old way, or have a better idea?
> 
> I know that the table headings are a bit weirdly laid out; hopefully
> that can be resolved [2].
> 
> 			regards, tom lane
> 
> [1] https://www.postgresql.org/message-id/flat/9326.1581457869%40sss.pgh.pa.us
> [2] https://www.postgresql.org/message-id/6169.1586794603%40sss.pgh.pa.us
> 
> 

Re: Poll: are people okay with function/operator table redesign?

От:
Isaac Morland <isaac.morland@gmail.com>
Дата:
On Wed, 15 Apr 2020 at 11:26, Pierre Giraud <pierre.giraud@dalibo.com> wrote:
 
The best way to achieve this is to use some styling (font style and color).

Attached you will find two different options I worked on very quickly.

I really like the first. Just a couple of suggestions I would make:

- leave a space between the function name and (. Regardless of opinions on what source code should look like, your documentation has space between each parameter and the next one, and between the ) and the -> and the ->. and the return type so it seems crowded not to have space between the function name and the (.
- At this point it's not really a table any more; I would get rid of the lines, maybe tweak the spacing, and possibly use <dl> <dt> <dd> (definition list) rather than table-related HTML elements. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl.

I think the bolding really makes stand out the crucial parts one needs to find.

Re: Poll: are people okay with function/operator table redesign?

От:
Pavel Stehule <pavel.stehule@gmail.com>
Дата:


st 15. 4. 2020 v 17:43 odesílatel Isaac Morland <isaac.morland@gmail.com> napsal:
On Wed, 15 Apr 2020 at 11:26, Pierre Giraud <pierre.giraud@dalibo.com> wrote:
 
The best way to achieve this is to use some styling (font style and color).

Attached you will find two different options I worked on very quickly.

I really like the first. Just a couple of suggestions I would make:

yes, it is very well readable

Pavel


- leave a space between the function name and (. Regardless of opinions on what source code should look like, your documentation has space between each parameter and the next one, and between the ) and the -> and the ->. and the return type so it seems crowded not to have space between the function name and the (.
- At this point it's not really a table any more; I would get rid of the lines, maybe tweak the spacing, and possibly use <dl> <dt> <dd> (definition list) rather than table-related HTML elements. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl.

I think the bolding really makes stand out the crucial parts one needs to find.

Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Wed, Apr 15, 2020 at 11:54 AM Pavel Stehule  wrote:
> st 15. 4. 2020 v 17:43 odesílatel Isaac Morland  napsal:
>> On Wed, 15 Apr 2020 at 11:26, Pierre Giraud  wrote:
>>> The best way to achieve this is to use some styling (font style and color).
>>>
>>> Attached you will find two different options I worked on very quickly.
>>
>> I really like the first. Just a couple of suggestions I would make:
>
> yes, it is very well readable

+1.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Steven Pousty <steve.pousty@gmail.com>
Дата:
Is there a way to get a heavier line between each function? It would be helpful to have a clearer demarcation of what belongs to each function.

On Wed, Apr 15, 2020 at 9:04 AM Robert Haas <robertmhaas@gmail.com> wrote:
On Wed, Apr 15, 2020 at 11:54 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> st 15. 4. 2020 v 17:43 odesílatel Isaac Morland <isaac.morland@gmail.com> napsal:
>> On Wed, 15 Apr 2020 at 11:26, Pierre Giraud <pierre.giraud@dalibo.com> wrote:
>>> The best way to achieve this is to use some styling (font style and color).
>>>
>>> Attached you will find two different options I worked on very quickly.
>>
>> I really like the first. Just a couple of suggestions I would make:
>
> yes, it is very well readable

+1.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Steven Pousty  writes:
> Is there a way to get a heavier line between each function? It would be
> helpful to have a clearer demarcation of what belongs to each function.

The first alternative I posted at

https://www.postgresql.org/message-id/31833.1586817876%40sss.pgh.pa.us

seems like it would accomplish that pretty well, by having lines
*only* between functions.  The last couple of things that have been
posted seem way more cluttered than that one.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, Apr 13, 2020 at 10:13 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
As discussed in the thread at [1], I've been working on redesigning
the tables we use to present SQL functions and operators.  The
first installment of that is now up; see tables 9.30 and 9.31 at

https://www.postgresql.org/docs/devel/functions-datetime.html

and table 9.33 at

https://www.postgresql.org/docs/devel/functions-enum.html

 
The centering of the headers doesn't do it for me.  Too much gap and the data itself is not centered so there is a large disconnect between the headers and the values.

The run-on aspect of the left-aligned setup is of some concern but maybe just adding some left padding to the second column - and right padding to the first - can provide the desired negative space without adding so much as to break usability.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Вложения:
As I threatened to do earlier, I made a pass at converting table 9.10
to a couple of the styles under discussion.  (This is just a
draft-quality patch, so it might have some minor bugs --- the point
is just to see what these styles look like.)

I've concluded after looking around that the ideas involving not having
a  at all, but just a  or the like, are not very
well-advised.  That would eliminate, or at least greatly degrade, the
visual distinction between the per-function material and the surrounding
commentary.  Which does not seem like a winner to me; for example it
would make it quite hard to skip over the detailed material when you're
just trying to skim the docs.

We did have a number of people suggesting that just reordering things as
"description, signature, examples" might be a good idea, so I gave that
a try; attached is a rendition of a portion of 9.10 in that style (the
"v1" image).  It's not bad, but there's still going to be a lot of
wasted whitespace in tables that include even one long function name.
(9.10's longest is "regexp_split_to_array", so it's showing this problem
significantly.)

I also experimented with Jonathan's idea of dropping the separate
function name and allowing the function signature to span left into
that column -- see "v2" images.  This actually works really well,
and would work even better (IMO) if we could get rid of the inter-row
and inter-column rules within a function entry.  I failed to
accomplish that with rowsep/colsep annotations, but from remarks
upthread I suppose there might be a CSS way to accomplish it.  (But
the rowsep/colsep annotations *do* work in PDF output, so I kept them;
that means we only need a CSS fix and not some kind of flow-object
magic for PDF.)

To allow direct comparison of these 9.10 images against the situation
in HEAD, I've also attached an extract of 9.10 as rendered by my
browser with "STYLE=website".  As you can see this is *not* quite
identical to how it renders on postgresql.org, so there is still some
unexplained differential in font or margins or something.  But if you
look at those three PNGs you can see that either v1 or v2 has a pretty
substantial advantage over HEAD in terms of the amount of space
needed.  v2 would be even further ahead if we could eliminate some of
the vertical space around the intra-function row split, which again
might be doable with CSS magic.

The main disadvantage I can see to the v2 design is that we're back
to having two  per function, which is inevitably going to result
in PDF builds putting page breaks between those rows.  But you can't
have everything ... and maybe we could find a way to discourage such
breaks if we tried.

Another issue is that v2 won't adapt real well to operator tables;
the operator name won't be at the left.  I don't have a lot of faith
in the proposal to fix that with font tricks.  Maybe we could stick
to something close to the layout that table 9.30 has in HEAD (ie
repeating the operator name in column 1), since we won't have long
operator names messing up the format.  Again, CSS'ing our way
out of the internal lines and extra vertical space within a single
logical table cell would make that layout look nicer.

On balance I quite like the v2 layout and would prefer to move forward
with that, assuming we can solve the remaining issues via CSS or style
sheets.

In addition to screenshots, I've attached patches against HEAD that
convert both tables 9.10 and 9.33 into v1 and v2 styles.

			regards, tom lane

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 7a270eb..84a7e57 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1798,243 +1798,276 @@
 
    
Other String Functions - + + + Function - Return Type - Description - Example - Result + DescriptionSignatureExample(s) - + ascii - ascii(string) + ascii - int - ASCII code of the first character of the - argument. For UTF8 returns the Unicode code - point of the character. For other multibyte encodings, the - argument must be an ASCII character. + Returns the numeric code of the first character of the argument. + In UTF8 encoding, returns the Unicode code point + of the character. In other multibyte encodings, the argument must + be an ASCII character. + + ascii ( text ) + integer + + ascii('x') + 120 - ascii('x') - 120 - + btrim - btrim(string text - , characters text) + btrim - text - Remove the longest string consisting only of characters + Removes the longest string consisting only of characters in characters (a space by default) - from the start and end of string + from the start and end of string. + + btrim ( string text + , characters text ) + text + + btrim('xyxtrimyyx', 'xyz') + trim - btrim('xyxtrimyyx', 'xyz') - trim - + chr - chr(int) + chr - text - Character with the given code. For UTF8 the - argument is treated as a Unicode code point. For other multibyte - encodings the argument must designate an - ASCII character. The NULL (0) character is not - allowed because text data types cannot store such bytes. + Returns the character with the given + code. In UTF8 encoding the argument is treated as + a Unicode code point. In other multibyte encodings the argument must + designate an ASCII character. The NULL (0) + character is not allowed because text data types cannot store such + bytes. + + chr ( integer ) + text + + chr(65) + A - chr(65) - A - + concat - concat(str "any" - [, str "any" [, ...] ]) + concat - text - Concatenate the text representations of all the arguments. + Concatenates the text representations of all the arguments. NULL arguments are ignored. + + concat ( val "any" + [, val "any" [, ...] ] ) + text + + concat('abcde', 2, NULL, 22) + abcde222 - concat('abcde', 2, NULL, 22) - abcde222 - + concat_ws - concat_ws(sep text, - str "any" - [, str "any" [, ...] ]) + concat_ws - text - Concatenate all but the first argument with separators. The first + Concatenates all but the first argument, with separators. The first argument is used as the separator string. NULL arguments are ignored. + + concat_ws ( sep text, + val "any" + [, val "any" [, ...] ] ) + text + + concat_ws(',', 'abcde', 2, NULL, 22) + abcde,2,22 - concat_ws(',', 'abcde', 2, NULL, 22) - abcde,2,22 - + format - format(formatstr text - [, formatarg "any" [, ...] ]) + format - text - Format arguments according to a format string. + Formats arguments according to a format string; + see . This function is similar to the C function sprintf. - See . + + format ( formatstr text + [, formatarg "any" [, ...] ] ) + text + + format('Hello %s, %1$s', 'World') + Hello World, World - format('Hello %s, %1$s', 'World') - Hello World, World - + initcap - initcap(string) + initcap - text - Convert the first letter of each word to upper case and the + Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters. + + initcap ( text ) + text + + initcap('hi THOMAS') + Hi Thomas - initcap('hi THOMAS') - Hi Thomas - + left - left(string text, - n int) + left - text - Return first n characters in the - string, or when n is negative, return - all but last |n| characters - - left('abcde', 2) - ab + Returns first n characters in the + string, or when n is negative, returns + all but last |n| characters. + + left ( string text, + n integer ) + text + + left('abcde', 2) + ab + - + length - length(string) + length - int - Number of characters in string + Returns the number of characters in the string. + + length ( text ) + integer + + length('jose') + 4 - length('jose') - 4 - + lpad - lpad(string text, - length int - , fill text) + lpad - text - Extend the string to length + Extends the string to length length by prepending the characters fill (a space by default). If the string is already longer than - length then it is truncated (on the - right). + length then it is truncated (on the right). + + lpad ( string text, + length integer + , fill text ) + text + + lpad('hi', 5, 'xy') + xyxhi - lpad('hi', 5, 'xy') - xyxhi - + ltrim - ltrim(string text - , characters text) + ltrim - text - Remove the longest string containing only characters from + Removes the longest string containing only characters from characters (a space by default) from the start of - string + string. + + ltrim ( string text + , characters text ) + text + + ltrim('zzzytest', 'xyz') + test - ltrim('zzzytest', 'xyz') - test - + md5 - md5(string) + md5 - text - MD5 hash, with - the result written in hexadecimal + Computes MD5 hash, with + the result written in hexadecimal. + + md5 ( text ) + text + + md5('abc') + 900150983cd24fb0&zwsp;d6963f7d28e17f72 - md5('abc') - 900150983cd24fb0 d6963f7d28e17f72 - + parse_ident - parse_ident(qualified_identifier text - [, strictmode boolean DEFAULT true ] ) + parse_ident - text[] - Split qualified_identifier into an array of + Splits qualified_identifier into an array of identifiers, removing any quoting of individual identifiers. By default, extra characters after the last identifier are considered an error; but if the second parameter is false, then such @@ -2042,417 +2075,513 @@ names for objects like functions.) Note that this function does not truncate over-length identifiers. If you want truncation you can cast the result to name[]. + + parse_ident ( qualified_identifier text + [, strictmode boolean DEFAULT true ] ) + text[] + + parse_ident('"SomeSchema".someTable') + {SomeSchema,sometable} - parse_ident('"SomeSchema".someTable') - {SomeSchema,sometable} - + pg_client_encoding - pg_client_encoding() + pg_client_encoding - name - Current client encoding name + Returns current client encoding name. + + pg_client_encoding ( ) + name + + pg_client_encoding() + SQL_ASCII - pg_client_encoding() - SQL_ASCII - + quote_ident - quote_ident(string text) + quote_ident - text - Return the given string suitably quoted to be used as an identifier + Returns the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled. See also . + + quote_ident ( text ) + text + + quote_ident('Foo bar') + "Foo bar" - quote_ident('Foo bar') - "Foo bar" - + quote_literal - quote_literal(string text) + quote_literal - text - Return the given string suitably quoted to be used as a string literal + Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also . + + quote_literal ( text ) + text + + quote_literal(E'O\'Reilly') + 'O''Reilly' - quote_literal(E'O\'Reilly') - 'O''Reilly' - quote_literal(value anyelement) - text + quote_literal - Coerce the given value to text and then quote it as a literal. + Coerces the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled. + + quote_literal ( anyelement ) + text + + quote_literal(42.5) + '42.5' - quote_literal(42.5) - '42.5' - + quote_nullable - quote_nullable(string text) + quote_nullable - text - Return the given string suitably quoted to be used as a string literal + Returns the given string suitably quoted to be used as a string literal in an SQL statement string; or, if the argument - is null, return NULL. + is null, returns NULL. Embedded single-quotes and backslashes are properly doubled. See also . + + quote_nullable ( text ) + text + + quote_nullable(NULL) + NULL - quote_nullable(NULL) - NULL - quote_nullable(value anyelement) - text + quote_nullable - Coerce the given value to text and then quote it as a literal; - or, if the argument is null, return NULL. + Coerces the given value to text and then quotes it as a literal; + or, if the argument is null, returns NULL. Embedded single-quotes and backslashes are properly doubled. + + quote_nullable ( anyelement ) + text + + quote_nullable(42.5) + '42.5' - quote_nullable(42.5) - '42.5' - + regexp_match - regexp_match(string text, pattern text [, flags text]) + regexp_match - text[] - Return captured substring(s) resulting from the first match of a POSIX - regular expression to the string (see - for more information) + Returns captured substring(s) resulting from the first match of a POSIX + regular expression to the string; see + . + + regexp_match ( string text, pattern text [, flags text ] ) + text[] + + regexp_match('foobarbequebaz', '(bar)(beque)') + {bar,beque} - regexp_match('foobarbequebaz', '(bar)(beque)') - {bar,beque} - + regexp_matches - regexp_matches(string text, pattern text [, flags text]) + regexp_matches - setof text[] - Return captured substring(s) resulting from matching a POSIX regular - expression to the string (see - for more information) + Returns captured substring(s) resulting from matching a POSIX regular + expression to the string; see + . + + regexp_matches ( string text, pattern text [, flags text ] ) + setof text[] + + regexp_matches('foobarbequebaz', 'ba.', 'g') + {bar}{baz}(2 rows) - regexp_matches('foobarbequebaz', 'ba.', 'g') - {bar}{baz} (2 rows) - + regexp_replace - regexp_replace(string text, pattern text, replacement text [, flags text]) + regexp_replace - text - Replace substring(s) matching a POSIX regular expression (see - for more information) + Replaces substring(s) matching a POSIX regular expression; see + . + + regexp_replace ( string text, pattern text, replacement text [, flags text ] ) + text + + regexp_replace('Thomas', '.[mN]a.', 'M') + ThM - regexp_replace('Thomas', '.[mN]a.', 'M') - ThM - + regexp_split_to_array - regexp_split_to_array(string text, pattern text [, flags text ]) + regexp_split_to_array - text[] - Split string using a POSIX regular expression as - the delimiter (see for more - information) + Splits string using a POSIX regular + expression as the delimiter; see + . + + regexp_split_to_array ( string text, pattern text [, flags text ] ) + text[] + + regexp_split_to_array('hello world', '\s+') + {hello,world} - regexp_split_to_array('hello world', '\s+') - {hello,world} - + regexp_split_to_table - regexp_split_to_table(string text, pattern text [, flags text]) + regexp_split_to_table - setof text - Split string using a POSIX regular expression as - the delimiter (see for more - information) + Splits string using a POSIX regular + expression as the delimiter; see + . + + regexp_split_to_table ( string text, pattern text [, flags text ] ) + setof text + + regexp_split_to_table('hello world', '\s+') + helloworld(2 rows) - regexp_split_to_table('hello world', '\s+') - helloworld (2 rows) - + repeat - repeat(string text, number int) + repeat + + + Repeats string the specified + number of times. + + repeat ( string text, number integer ) + text + + repeat('Pg', 4) + PgPgPgPg - text - Repeat string the specified - number of times - repeat('Pg', 4) - PgPgPgPg - + replace - replace(string text, - from text, - to text) + replace - text - Replace all occurrences in string of substring - from with substring to + + Replaces all occurrences in string of + substring from with + substring to. + + replace ( string text, + from text, + to text ) + text + + replace('abcdefabcdef', 'cd', 'XX') + abXXefabXXef - replace('abcdefabcdef', 'cd', 'XX') - abXXefabXXef - + reverse - reverse(str) + reverse - text - Reverse the order of the characters in string + Reverses the order of the characters in the string. + + reverse ( text ) + text + + reverse('abcde') + edcba - reverse('abcde') - edcba - + right - right(string text, - n int) + right - text - Return last n characters in the string, - or when n is negative, return all but - first |n| characters + Returns last n characters in the string, + or when n is negative, returns all but + first |n| characters. + + right ( string text, + n integer ) + ) + text + + right('abcde', 2) + de - right('abcde', 2) - de - + rpad - rpad(string text, - length int - , fill text) + rpad - text - Extend the string to length + Extends the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated. + + rpad ( string text, + length integer + , fill text ) + ) + text + + rpad('hi', 5, 'xy') + hixyx - rpad('hi', 5, 'xy') - hixyx - + rtrim - rtrim(string text - , characters text) + rtrim - text - Remove the longest string containing only characters from + Removes the longest string containing only characters from characters (a space by default) from the end of - string + string. + + rtrim ( string text + , characters text ) + text + + rtrim('testxxzx', 'xyz') + test - rtrim('testxxzx', 'xyz') - test - + split_part - split_part(string text, - delimiter text, - field int) + split_part - text - Split string on delimiter - and return the given field (counting from one) + + Splits string on delimiter + and returns the n'th field (counting from one). + + split_part ( string text, + delimiter text, + n integer ) + text + + split_part('abc~@~def~@~ghi', '~@~', 2) + def - split_part('abc~@~def~@~ghi', '~@~', 2) - def - + strpos - strpos(string, substring) + strpos - int - Location of specified substring (same as - position(substring in - string), but note the reversed - argument order) + Returns location of specified substring + within string, or zero if it's not present. + (Same as position(substring in + string), but note the reversed + argument order.) + + strpos ( string text, substring text ) + integer + + strpos('high', 'ig') + 2 - strpos('high', 'ig') - 2 - + substr - substr(string, from , count) + substr - text - Extract substring (same as - substring(string from from for count)) + Extracts substring starting at index start, + and extending for count characters if that is + specified. (Same + as substring(string + from start + for count).) + + substr ( string text, start integer , count integer ) + ) + text + + substr('alphabet', 3, 2) + ph - substr('alphabet', 3, 2) - ph - + starts_with - starts_with(string, prefix) + starts_with - bool - Return true if string starts - with prefix + Returns true if string starts + with prefix. + + starts_with ( string text, prefix text ) + boolean + + starts_with('alphabet', 'alph') + t - starts_with('alphabet', 'alph') - t - + to_ascii - to_ascii(string text - , encoding text) + to_ascii - text - Convert string to ASCII from another encoding - (only supports conversion from LATIN1, LATIN2, LATIN9, - and WIN1250 encodings) + Converts string to ASCII + from another encoding, which may be identified by name or number; + if encoding is omitted the database encoding + is assumed. The conversion consists primarily of dropping accents. + Conversion is only supported + from LATIN1, LATIN2, + LATIN9, and WIN1250 encodings. + + to_ascii ( string text + , encoding name or integer ) + text + + to_ascii('Karél') + Karel - to_ascii('Karel') - Karel - + to_hex - to_hex(number int - or bigint) + to_hex - text - Convert number to its equivalent hexadecimal - representation + + Converts number to its equivalent hexadecimal + representation. + + to_hex ( number + integer + or bigint ) + text + + to_hex(2147483647) + 7fffffff - to_hex(2147483647) - 7fffffff - + translate - translate(string text, - from text, - to text) + translate - text - Any character in string that matches a - character in the from set is replaced by - the corresponding character in the to + Replaces each character in string that + matches a character in the from set with the + corresponding character in the to set. If from is longer than to, occurrences of the extra characters in - from are removed. + from are deleted. + + translate ( string text, + from text, + to text ) + text + + translate('12345', '143', 'ax') + a2x5 - translate('12345', '143', 'ax') - a2x5 @@ -8645,103 +8774,90 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
Enum Support Functions - - - - - - - - - + + + - Function - Signature - - - Description - - - Example - Example Result + Function + DescriptionSignatureExample(s) - + enum_first enum_first - enum_first(anyenum) anyenum - - - Returns the first value of the input enum type - - - enum_first(&zwsp;null::rainbow) - red + + Returns the first value of the input enum type. + + enum_first ( anyenum ) + anyenum + + enum_first(&zwsp;null::rainbow) + red + - + enum_last enum_last - enum_last(anyenum) anyenum - - - Returns the last value of the input enum type - - - enum_last(&zwsp;null::rainbow) - purple + + Returns the last value of the input enum type. + + enum_last ( anyenum ) + anyenum + + enum_last(&zwsp;null::rainbow) + purple + - + enum_range enum_range - enum_range(anyenum) anyarray - - - Returns all values of the input enum type in an ordered array - - - enum_range(&zwsp;null::rainbow) - {red,orange,yellow,&zwsp;green,blue,purple} - - - enum_range - enum_range(anyenum, anyenum) anyarray + + Returns all values of the input enum type in an ordered array. + + enum_range ( anyenum ) + anyarray + + enum_range(&zwsp;null::rainbow) + {red,orange,yellow,&zwsp;green,blue,purple} + - + enum_range + 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 the enum type. If the second parameter is null, the result will end with the last value of the enum type. + + enum_range ( anyenum, anyenum ) + anyarray + + enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) + {orange,yellow,green} + + enum_range(NULL, 'green'::rainbow) + {red,orange,&zwsp;yellow,green} + + enum_range(&zwsp;'orange'::rainbow, NULL) + {orange,yellow,green,&zwsp;blue,purple} - - enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - - - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,&zwsp;green} - - - enum_range(&zwsp;'orange'::rainbow, NULL) - {orange,yellow,green,&zwsp;blue,purple} -
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl index a13565e..105ed1c 100644 --- a/doc/src/sgml/stylesheet-common.xsl +++ b/doc/src/sgml/stylesheet-common.xsl @@ -103,4 +103,11 @@ + + + + +
+ + diff --git a/doc/src/sgml/stylesheet-fo.xsl b/doc/src/sgml/stylesheet-fo.xsl index 2aaae82..713159d 100644 --- a/doc/src/sgml/stylesheet-fo.xsl +++ b/doc/src/sgml/stylesheet-fo.xsl @@ -70,6 +70,11 @@ + + + + + diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 7a270eb..fef21bb 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1798,243 +1798,282 @@ Other String Functions - + + + + + - Function - Return Type - Description - Example - Result + Function + SignatureDescriptionExample(s) - + ascii - ascii(string) + ascii ( text ) + integer - int - - ASCII code of the first character of the - argument. For UTF8 returns the Unicode code - point of the character. For other multibyte encodings, the - argument must be an ASCII character. + + + + Returns the numeric code of the first character of the argument. + In UTF8 encoding, returns the Unicode code point + of the character. In other multibyte encodings, the argument must + be an ASCII character. + + ascii('x') + 120 - ascii('x') - 120 - + btrim - btrim(string text - , characters text) + btrim ( string text + , characters text ) + text - text - - Remove the longest string consisting only of characters + + + + Removes the longest string consisting only of characters in characters (a space by default) - from the start and end of string + from the start and end of string. + + btrim('xyxtrimyyx', 'xyz') + trim - btrim('xyxtrimyyx', 'xyz') - trim - + chr - chr(int) + chr ( integer ) + text - text - - Character with the given code. For UTF8 the - argument is treated as a Unicode code point. For other multibyte - encodings the argument must designate an - ASCII character. The NULL (0) character is not - allowed because text data types cannot store such bytes. + + + + Returns the character with the given + code. In UTF8 encoding the argument is treated as + a Unicode code point. In other multibyte encodings the argument must + designate an ASCII character. The NULL (0) + character is not allowed because text data types cannot store such + bytes. + + chr(65) + A - chr(65) - A - + concat - concat(str "any" - [, str "any" [, ...] ]) + concat ( val "any" + [, val "any" [, ...] ] ) + text - text - - Concatenate the text representations of all the arguments. + + + + Concatenates the text representations of all the arguments. NULL arguments are ignored. + + concat('abcde', 2, NULL, 22) + abcde222 - concat('abcde', 2, NULL, 22) - abcde222 - + concat_ws - concat_ws(sep text, - str "any" - [, str "any" [, ...] ]) + concat_ws ( sep text, + val "any" + [, val "any" [, ...] ] ) + text - text - - Concatenate all but the first argument with separators. The first + + + + Concatenates all but the first argument, with separators. The first argument is used as the separator string. NULL arguments are ignored. + + concat_ws(',', 'abcde', 2, NULL, 22) + abcde,2,22 - concat_ws(',', 'abcde', 2, NULL, 22) - abcde,2,22 - + format - format(formatstr text - [, formatarg "any" [, ...] ]) + format ( formatstr text + [, formatarg "any" [, ...] ] ) + text - text - - Format arguments according to a format string. + + + + Formats arguments according to a format string; + see . This function is similar to the C function sprintf. - See . + + format('Hello %s, %1$s', 'World') + Hello World, World - format('Hello %s, %1$s', 'World') - Hello World, World - + initcap - initcap(string) + initcap ( text ) + text - text - - Convert the first letter of each word to upper case and the + + + + Converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters. + + initcap('hi THOMAS') + Hi Thomas - initcap('hi THOMAS') - Hi Thomas - + left - left(string text, - n int) + left ( string text, + n integer ) + text + + + + + Returns first n characters in the + string, or when n is negative, returns + all but last |n| characters. + + left('abcde', 2) + ab - text - - Return first n characters in the - string, or when n is negative, return - all but last |n| characters - - left('abcde', 2) - ab - + length - length(string) + length ( text ) + integer - int - - Number of characters in string + + + + Returns the number of characters in the string. + + length('jose') + 4 - length('jose') - 4 - + lpad - lpad(string text, - length int - , fill text) + lpad ( string text, + length integer + , fill text ) + text - text - - Extend the string to length + + + + Extends the string to length length by prepending the characters fill (a space by default). If the string is already longer than - length then it is truncated (on the - right). + length then it is truncated (on the right). + + lpad('hi', 5, 'xy') + xyxhi - lpad('hi', 5, 'xy') - xyxhi - + ltrim - ltrim(string text - , characters text) + ltrim ( string text + , characters text ) + text - text - - Remove the longest string containing only characters from + + + + Removes the longest string containing only characters from characters (a space by default) from the start of - string + string. + + ltrim('zzzytest', 'xyz') + test - ltrim('zzzytest', 'xyz') - test - + md5 - md5(string) + md5 ( text ) + text - text - - MD5 hash, with - the result written in hexadecimal + + + + Computes MD5 hash, with + the result written in hexadecimal. + + md5('abc') + 900150983cd24fb0&zwsp;d6963f7d28e17f72 - md5('abc') - 900150983cd24fb0 d6963f7d28e17f72 - + parse_ident - parse_ident(qualified_identifier text - [, strictmode boolean DEFAULT true ] ) + parse_ident ( qualified_identifier text + [, strictmode boolean DEFAULT true ] ) + text[] - text[] - - Split qualified_identifier into an array of + + + + Splits qualified_identifier into an array of identifiers, removing any quoting of individual identifiers. By default, extra characters after the last identifier are considered an error; but if the second parameter is false, then such @@ -2042,417 +2081,513 @@ names for objects like functions.) Note that this function does not truncate over-length identifiers. If you want truncation you can cast the result to name[]. + + parse_ident('"SomeSchema".someTable') + {SomeSchema,sometable} - parse_ident('"SomeSchema".someTable') - {SomeSchema,sometable} - + pg_client_encoding - pg_client_encoding() + pg_client_encoding ( ) + name - name - - Current client encoding name + + + + Returns current client encoding name. + + pg_client_encoding() + SQL_ASCII - pg_client_encoding() - SQL_ASCII - + quote_ident - quote_ident(string text) + quote_ident ( text ) + text - text - - Return the given string suitably quoted to be used as an identifier + + + + Returns the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled. See also . + + quote_ident('Foo bar') + "Foo bar" - quote_ident('Foo bar') - "Foo bar" - + quote_literal - quote_literal(string text) + quote_literal ( text ) + text - text - - Return the given string suitably quoted to be used as a string literal + + + + Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also . + + quote_literal(E'O\'Reilly') + 'O''Reilly' - quote_literal(E'O\'Reilly') - 'O''Reilly' - quote_literal(value anyelement) - text - - Coerce the given value to text and then quote it as a literal. + + quote_literal ( anyelement ) + text + + + + + Coerces the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled. + + quote_literal(42.5) + '42.5' - quote_literal(42.5) - '42.5' - + quote_nullable - quote_nullable(string text) + quote_nullable ( text ) + text - text - - Return the given string suitably quoted to be used as a string literal + + + + Returns the given string suitably quoted to be used as a string literal in an SQL statement string; or, if the argument - is null, return NULL. + is null, returns NULL. Embedded single-quotes and backslashes are properly doubled. See also . + + quote_nullable(NULL) + NULL - quote_nullable(NULL) - NULL - quote_nullable(value anyelement) - text - - Coerce the given value to text and then quote it as a literal; - or, if the argument is null, return NULL. + + quote_nullable ( anyelement ) + text + + + + + Coerces the given value to text and then quotes it as a literal; + or, if the argument is null, returns NULL. Embedded single-quotes and backslashes are properly doubled. + + quote_nullable(42.5) + '42.5' - quote_nullable(42.5) - '42.5' - + regexp_match - regexp_match(string text, pattern text [, flags text]) + regexp_match ( string text, pattern text [, flags text ] ) + text[] - text[] - - Return captured substring(s) resulting from the first match of a POSIX - regular expression to the string (see - for more information) + + + + Returns captured substring(s) resulting from the first match of a POSIX + regular expression to the string; see + . + + regexp_match('foobarbequebaz', '(bar)(beque)') + {bar,beque} - regexp_match('foobarbequebaz', '(bar)(beque)') - {bar,beque} - + regexp_matches - regexp_matches(string text, pattern text [, flags text]) + regexp_matches ( string text, pattern text [, flags text ] ) + setof text[] - setof text[] - - Return captured substring(s) resulting from matching a POSIX regular - expression to the string (see - for more information) + + + + Returns captured substring(s) resulting from matching a POSIX regular + expression to the string; see + . + + regexp_matches('foobarbequebaz', 'ba.', 'g') + {bar}{baz}(2 rows) - regexp_matches('foobarbequebaz', 'ba.', 'g') - {bar}{baz} (2 rows) - + regexp_replace - regexp_replace(string text, pattern text, replacement text [, flags text]) + regexp_replace ( string text, pattern text, replacement text [, flags text ] ) + text - text - - Replace substring(s) matching a POSIX regular expression (see - for more information) + + + + Replaces substring(s) matching a POSIX regular expression; see + . + + regexp_replace('Thomas', '.[mN]a.', 'M') + ThM - regexp_replace('Thomas', '.[mN]a.', 'M') - ThM - + regexp_split_to_array - regexp_split_to_array(string text, pattern text [, flags text ]) + regexp_split_to_array ( string text, pattern text [, flags text ] ) + text[] - text[] - - Split string using a POSIX regular expression as - the delimiter (see for more - information) + + + + Splits string using a POSIX regular + expression as the delimiter; see + . + + regexp_split_to_array('hello world', '\s+') + {hello,world} - regexp_split_to_array('hello world', '\s+') - {hello,world} - + regexp_split_to_table - regexp_split_to_table(string text, pattern text [, flags text]) + regexp_split_to_table ( string text, pattern text [, flags text ] ) + setof text - setof text - - Split string using a POSIX regular expression as - the delimiter (see for more - information) + + + + Splits string using a POSIX regular + expression as the delimiter; see + . + + regexp_split_to_table('hello world', '\s+') + helloworld(2 rows) - regexp_split_to_table('hello world', '\s+') - helloworld (2 rows) - + repeat - repeat(string text, number int) + repeat ( string text, number integer ) + text + + + + + Repeats string the specified + number of times. + + repeat('Pg', 4) + PgPgPgPg - text - Repeat string the specified - number of times - repeat('Pg', 4) - PgPgPgPg - + replace - replace(string text, + replace ( string text, from text, - to text) + to text ) + text - text - Replace all occurrences in string of substring - from with substring to + + + + Replaces all occurrences in string of + substring from with + substring to. + + replace('abcdefabcdef', 'cd', 'XX') + abXXefabXXef - replace('abcdefabcdef', 'cd', 'XX') - abXXefabXXef - + reverse - reverse(str) + reverse ( text ) + text - text - - Reverse the order of the characters in string + + + + Reverses the order of the characters in the string. + + reverse('abcde') + edcba - reverse('abcde') - edcba - + right - right(string text, - n int) + right ( string text, + n integer ) + ) + text - text - - Return last n characters in the string, - or when n is negative, return all but - first |n| characters + + + + Returns last n characters in the string, + or when n is negative, returns all but + first |n| characters. + + right('abcde', 2) + de - right('abcde', 2) - de - + rpad - rpad(string text, - length int - , fill text) + rpad ( string text, + length integer + , fill text ) + ) + text - text - - Extend the string to length + + + + Extends the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated. + + rpad('hi', 5, 'xy') + hixyx - rpad('hi', 5, 'xy') - hixyx - + rtrim - rtrim(string text - , characters text) + rtrim ( string text + , characters text ) + text - text - - Remove the longest string containing only characters from + + + + Removes the longest string containing only characters from characters (a space by default) from the end of - string + string. + + rtrim('testxxzx', 'xyz') + test - rtrim('testxxzx', 'xyz') - test - + split_part - split_part(string text, + split_part ( string text, delimiter text, - field int) + n integer ) + text - text - Split string on delimiter - and return the given field (counting from one) + + + + Splits string on delimiter + and returns the n'th field (counting from one). + + split_part('abc~@~def~@~ghi', '~@~', 2) + def - split_part('abc~@~def~@~ghi', '~@~', 2) - def - + strpos - strpos(string, substring) + strpos ( string text, substring text ) + integer - int - - Location of specified substring (same as - position(substring in - string), but note the reversed - argument order) + + + + Returns location of specified substring + within string, or zero if it's not present. + (Same as position(substring in + string), but note the reversed + argument order.) + + strpos('high', 'ig') + 2 - strpos('high', 'ig') - 2 - + substr - substr(string, from , count) + substr ( string text, start integer , count integer ) + ) + text - text - - Extract substring (same as - substring(string from from for count)) + + + + Extracts substring starting at index start, + and extending for count characters if that is + specified. (Same + as substring(string + from start + for count).) + + substr('alphabet', 3, 2) + ph - substr('alphabet', 3, 2) - ph - + starts_with - starts_with(string, prefix) + starts_with ( string text, prefix text ) + boolean - bool - - Return true if string starts - with prefix + + + + Returns true if string starts + with prefix. + + starts_with('alphabet', 'alph') + t - starts_with('alphabet', 'alph') - t - + to_ascii - to_ascii(string text - , encoding text) + to_ascii ( string text + , encoding name or integer ) + text - text - - Convert string to ASCII from another encoding - (only supports conversion from LATIN1, LATIN2, LATIN9, - and WIN1250 encodings) + + + + Converts string to ASCII + from another encoding, which may be identified by name or number; + if encoding is omitted the database encoding + is assumed. The conversion consists primarily of dropping accents. + Conversion is only supported + from LATIN1, LATIN2, + LATIN9, and WIN1250 encodings. + + to_ascii('Karél') + Karel - to_ascii('Karel') - Karel - + to_hex - to_hex(number int - or bigint) + to_hex ( number + integer + or bigint ) + text - text - Convert number to its equivalent hexadecimal - representation + + + + Converts number to its equivalent hexadecimal + representation. + + to_hex(2147483647) + 7fffffff - to_hex(2147483647) - 7fffffff - + translate - translate(string text, + translate ( string text, from text, - to text) + to text ) + text - text - - Any character in string that matches a - character in the from set is replaced by - the corresponding character in the to + + + + Replaces each character in string that + matches a character in the from set with the + corresponding character in the to set. If from is longer than to, occurrences of the extra characters in - from are removed. + from are deleted. + + translate('12345', '143', 'ax') + a2x5 - translate('12345', '143', 'ax') - a2x5 @@ -8645,80 +8780,74 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
Enum Support Functions - - - - - - - - - + + + + + - Function - Signature - - - Description - - - Example - Example Result + Function + SignatureDescriptionExample(s) - + enum_first - enum_first + enum_first ( anyenum ) + anyenum - enum_first(anyenum) anyenum - - - Returns the first value of the input enum type - enum_first(&zwsp;null::rainbow) - red + + Returns the first value of the input enum type. + + enum_first(null::rainbow) + red + - + enum_last - enum_last + enum_last ( anyenum ) + anyenum - enum_last(anyenum) anyenum - - - Returns the last value of the input enum type - enum_last(&zwsp;null::rainbow) - purple + + Returns the last value of the input enum type. + + enum_last(null::rainbow) + purple + - + enum_range - enum_range + enum_range ( anyenum ) + anyarray - enum_range(anyenum) anyarray - - - Returns all values of the input enum type in an ordered array - enum_range(&zwsp;null::rainbow) - {red,orange,yellow,&zwsp;green,blue,purple} + + Returns all values of the input enum type in an ordered array. + + enum_range(null::rainbow) + {red,orange,yellow,&zwsp;green,blue,purple} + - enum_range - enum_range(anyenum, anyenum) anyarray + + enum_range ( anyenum, anyenum ) + anyarray + @@ -8728,20 +8857,17 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple the enum type. 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,&zwsp;yellow,green} + + enum_range('orange'::rainbow, NULL) + {orange,yellow,green,&zwsp;blue,purple} - - enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - - - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,&zwsp;green} - - - enum_range(&zwsp;'orange'::rainbow, NULL) - {orange,yellow,green,&zwsp;blue,purple} -
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl index a13565e..105ed1c 100644 --- a/doc/src/sgml/stylesheet-common.xsl +++ b/doc/src/sgml/stylesheet-common.xsl @@ -103,4 +103,11 @@ + + + + +
+ + diff --git a/doc/src/sgml/stylesheet-fo.xsl b/doc/src/sgml/stylesheet-fo.xsl index 2aaae82..713159d 100644 --- a/doc/src/sgml/stylesheet-fo.xsl +++ b/doc/src/sgml/stylesheet-fo.xsl @@ -70,6 +70,11 @@ + + + + +

Re: Poll: are people okay with function/operator table redesign?

От:
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Дата:
At Wed, 15 Apr 2020 12:04:34 -0400, Robert Haas  wrote in 
> On Wed, Apr 15, 2020 at 11:54 AM Pavel Stehule  wrote:
> > st 15. 4. 2020 v 17:43 odesílatel Isaac Morland  napsal:
> >> On Wed, 15 Apr 2020 at 11:26, Pierre Giraud  wrote:
> >>> The best way to achieve this is to use some styling (font style and color).
> >>>
> >>> Attached you will find two different options I worked on very quickly.
> >>
> >> I really like the first. Just a couple of suggestions I would make:
> >
> > yes, it is very well readable
> 
> +1.

+1.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center


Re: Poll: are people okay with function/operator table redesign?

От:
Pierre Giraud <pierre.giraud@dalibo.com>
Дата:
Вложения:


Le 16/04/2020 à 00:18, Tom Lane a écrit :
> As I threatened to do earlier, I made a pass at converting table 9.10
> to a couple of the styles under discussion.  (This is just a
> draft-quality patch, so it might have some minor bugs --- the point
> is just to see what these styles look like.)
> 
> I've concluded after looking around that the ideas involving not having
> a  at all, but just a  or the like, are not very
> well-advised.  That would eliminate, or at least greatly degrade, the
> visual distinction between the per-function material and the surrounding
> commentary.  Which does not seem like a winner to me; for example it
> would make it quite hard to skip over the detailed material when you're
> just trying to skim the docs.
> 
> We did have a number of people suggesting that just reordering things as
> "description, signature, examples" might be a good idea, so I gave that
> a try; attached is a rendition of a portion of 9.10 in that style (the
> "v1" image).  It's not bad, but there's still going to be a lot of
> wasted whitespace in tables that include even one long function name.
> (9.10's longest is "regexp_split_to_array", so it's showing this problem
> significantly.)
> 
> I also experimented with Jonathan's idea of dropping the separate
> function name and allowing the function signature to span left into
> that column -- see "v2" images.  This actually works really well,
> and would work even better (IMO) if we could get rid of the inter-row
> and inter-column rules within a function entry.  I failed to
> accomplish that with rowsep/colsep annotations, but from remarks
> upthread I suppose there might be a CSS way to accomplish it.  (But
> the rowsep/colsep annotations *do* work in PDF output, so I kept them;
> that means we only need a CSS fix and not some kind of flow-object
> magic for PDF.)
> 
> To allow direct comparison of these 9.10 images against the situation
> in HEAD, I've also attached an extract of 9.10 as rendered by my
> browser with "STYLE=website".  As you can see this is *not* quite
> identical to how it renders on postgresql.org, so there is still some
> unexplained differential in font or margins or something.  But if you
> look at those three PNGs you can see that either v1 or v2 has a pretty
> substantial advantage over HEAD in terms of the amount of space
> needed.  v2 would be even further ahead if we could eliminate some of
> the vertical space around the intra-function row split, which again
> might be doable with CSS magic.
> 
> The main disadvantage I can see to the v2 design is that we're back
> to having two  per function, which is inevitably going to result
> in PDF builds putting page breaks between those rows.  But you can't
> have everything ... and maybe we could find a way to discourage such
> breaks if we tried.

What about putting everything into one 
and use a block with some left padding/margin for description + example. This would solve the PDF page break issue as well as the column separation border one. The screenshot attached uses a
tag for the descrition/example block. > > Another issue is that v2 won't adapt real well to operator tables; > the operator name won't be at the left. I don't have a lot of faith > in the proposal to fix that with font tricks. Maybe we could stick > to something close to the layout that table 9.30 has in HEAD (ie > repeating the operator name in column 1), since we won't have long > operator names messing up the format. Again, CSS'ing our way > out of the internal lines and extra vertical space within a single > logical table cell would make that layout look nicer. > > On balance I quite like the v2 layout and would prefer to move forward > with that, assuming we can solve the remaining issues via CSS or style > sheets. > > In addition to screenshots, I've attached patches against HEAD that > convert both tables 9.10 and 9.33 into v1 and v2 styles. > > regards, tom lane >

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Pierre Giraud  writes:
> Le 16/04/2020 à 00:18, Tom Lane a écrit :
>> The main disadvantage I can see to the v2 design is that we're back
>> to having two  per function, which is inevitably going to result
>> in PDF builds putting page breaks between those rows.  But you can't
>> have everything ... and maybe we could find a way to discourage such
>> breaks if we tried.

Further experimentation shows that the PDF toolchain is perfectly willing
to put a page break *within* a multi-line ; if there is any
preference to break between rows instead, it's pretty weak.  So that
argument is a red herring and we shouldn't waste time chasing it.
However, there'd still be some advantage in not being dependent on CSS
hackery to make it look nice in HTML.

What we're down to wanting, at this point, is basically a para with
hanging indent.

> What about putting everything into one  and use a block with
> some left padding/margin for description + example.
> This would solve the PDF page break issue as well as the column
> separation border one.
> The screenshot attached uses a 
tag for the descrition/example block. That looks about right, perhaps, but could you be a little clearer about how you accomplished that? regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Pierre Giraud <pierre.giraud@dalibo.com>
Дата:
Вложения:


Le 16/04/2020 à 16:43, Tom Lane a écrit :
> Pierre Giraud  writes:
>> Le 16/04/2020 à 00:18, Tom Lane a écrit :
>>> The main disadvantage I can see to the v2 design is that we're back
>>> to having two  per function, which is inevitably going to result
>>> in PDF builds putting page breaks between those rows.  But you can't
>>> have everything ... and maybe we could find a way to discourage such
>>> breaks if we tried.
> 
> Further experimentation shows that the PDF toolchain is perfectly willing
> to put a page break *within* a multi-line ; if there is any
> preference to break between rows instead, it's pretty weak.  So that
> argument is a red herring and we shouldn't waste time chasing it.
> However, there'd still be some advantage in not being dependent on CSS
> hackery to make it look nice in HTML.
> 
> What we're down to wanting, at this point, is basically a para with
> hanging indent.
> 
>> What about putting everything into one  and use a block with
>> some left padding/margin for description + example.
>> This would solve the PDF page break issue as well as the column
>> separation border one.
>> The screenshot attached uses a 
tag for the descrition/example block. > > That looks about right, perhaps, but could you be a little clearer about > how you accomplished that? Attached you will find the HTML structure with associated styles. Sorry I haven't tried to do this from the DocBook sources. I hope this helps though. Regards

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Pierre Giraud  writes:
> Le 16/04/2020 à 16:43, Tom Lane a écrit :
>> Pierre Giraud  writes:
>>> The screenshot attached uses a 
tag for the descrition/example block. >> That looks about right, perhaps, but could you be a little clearer about >> how you accomplished that? > Attached you will find the HTML structure with associated styles. > Sorry I haven't tried to do this from the DocBook sources. > I hope this helps though. After a bit of poking at it, I couldn't find another way to do that than using a structure. Which is an annoying amount of markup to be adding to each table cell, but I guess we could live with it. A bigger problem is that docbook applies styles to the
structure that, at least by default, add a LOT of vertical space. Doesn't seem real workable unless we can undo that. regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Andreas Karlsson <andreas@proxel.se>
Дата:
On 4/14/20 4:52 PM, Tom Lane wrote:
> Andreas Karlsson  writes:
>> That said, I agree with that quite many of our tables right now are
>> ugly, but I prefer ugly to hard to read. For me the mix of having every
>> third row split into two fields makes the tables very hard to read. I
>> have a hard time seeing which rows belong to which function.
> 
> Did you look at the variants without that discussed downthread?

Yeah, I did some of them are quite readable, for example your latest two 
screenshots of table 9.10.

Andreas


Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
v1 is good.

I like your v2 even better.  If it becomes possible to remove or soften
the "inter-row" horizontal line with CSS tricks afterwards, that would
be swell, but even without that, I cast my vote to using this table
format.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Вложения:
Alvaro Herrera  writes:
> I like your v2 even better.  If it becomes possible to remove or soften
> the "inter-row" horizontal line with CSS tricks afterwards, that would
> be swell, but even without that, I cast my vote to using this table
> format.

I eventually figured out that the approved way to do per-table-entry
customization is to attach "role" properties to the DocBook elements,
and then key off the role names in applying formatting changes in
the customization layer.  So attached is a v3 that handles the desired
formatting changes by applying a hanging indent to table 
contents if the entry is marked with role="functableentry".  It may
well be possible to do this in a cleaner fashion, but this seems
good enough for discussion.

I changed table 9.30 (Date/Time Operators) to this style, doing it
exactly the same way as functions, just to see what it'd look like.
I'm not sure if this is OK or if we want a separate column with
just the operator name at the left --- it seems a little bit hard
to spot the operator you want, but not impossible.  Thoughts?

Attached are screenshots of the same segment of table 9.10 as before
and of the initial portion of 9.30, the patch against HEAD to produce
these, and a hacky patch on the website's main.css to get it to go
along.  Without the last you just get all the subsidiary stuff
left-justified if you build with STYLE=website, which isn't impossibly
unreadable but it's not the desired presentation.

I didn't include any screenshots of the PDF rendering, but it looks
fine.

			regards, tom lane

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 7a270eb..1924e06 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1798,243 +1798,240 @@
 
    
     Other String Functions
-    
+    
      
       
-       Function
-       Return Type
-       Description
-       Example
-       Result
+       
+        FunctionDescriptionExample(s)
+       
       
      
       
-       
+       
         
          ascii
         
-        ascii(string)
+        ascii ( text )
+        integer
+        
+        Returns the numeric code of the first character of the argument.
+        In UTF8 encoding, returns the Unicode code point
+        of the character.  In other multibyte encodings, the argument must
+        be an ASCII character.
+        
+        ascii('x')
+        120
        
-       int
-       
-        ASCII code of the first character of the
-        argument.  For UTF8 returns the Unicode code
-        point of the character.  For other multibyte encodings, the
-        argument must be an ASCII character.
-       
-       ascii('x')
-       120
       
 
       
-       
+       
         
          btrim
         
-        btrim(string text
-        , characters text)
-       
-       text
-       
-        Remove the longest string consisting only of characters
+        btrim ( string text
+        , characters text  )
+        text
+        
+        Removes the longest string consisting only of characters
         in characters (a space by default)
-        from the start and end of string
+        from the start and end of string.
+        
+        btrim('xyxtrimyyx', 'xyz')
+        trim
        
-       btrim('xyxtrimyyx', 'xyz')
-       trim
       
 
       
-       
+       
         
          chr
         
-        chr(int)
-       
-       text
-       
-        Character with the given code. For UTF8 the
-        argument is treated as a Unicode code point. For other multibyte
-        encodings the argument must designate an
-        ASCII character.  The NULL (0) character is not
-        allowed because text data types cannot store such bytes.
+        chr ( integer )
+        text
+        
+        Returns the character with the given
+        code. In UTF8 encoding the argument is treated as
+        a Unicode code point. In other multibyte encodings the argument must
+        designate an ASCII character.  The NULL (0)
+        character is not allowed because text data types cannot store such
+        bytes.
+        
+        chr(65)
+        A
        
-       chr(65)
-       A
       
 
       
-       
+       
         
          concat
         
-        concat(str "any"
-         [, str "any" [, ...] ])
-       
-       text
-       
-        Concatenate the text representations of all the arguments.
+        concat ( val "any"
+         [, val "any" [, ...] ] )
+        text
+        
+        Concatenates the text representations of all the arguments.
         NULL arguments are ignored.
+        
+        concat('abcde', 2, NULL, 22)
+        abcde222
        
-       concat('abcde', 2, NULL, 22)
-       abcde222
       
 
       
-       
+       
         
          concat_ws
         
-        concat_ws(sep text,
-        str "any"
-        [, str "any" [, ...] ])
-       
-       text
-       
-        Concatenate all but the first argument with separators. The first
+        concat_ws ( sep text,
+        val "any"
+        [, val "any" [, ...] ] )
+        text
+        
+        Concatenates all but the first argument, with separators. The first
         argument is used as the separator string. NULL arguments are ignored.
+        
+        concat_ws(',', 'abcde', 2, NULL, 22)
+        abcde,2,22
        
-       concat_ws(',', 'abcde', 2, NULL, 22)
-       abcde,2,22
       
 
       
-       
+       
         
          format
         
-        format(formatstr text
-        [, formatarg "any" [, ...] ])
-       
-       text
-       
-         Format arguments according to a format string.
+        format ( formatstr text
+        [, formatarg "any" [, ...] ] )
+        text
+        
+         Formats arguments according to a format string;
+         see .
          This function is similar to the C function sprintf.
-         See .
+        
+        format('Hello %s, %1$s', 'World')
+        Hello World, World
        
-       format('Hello %s, %1$s', 'World')
-       Hello World, World
       
 
       
-       
+       
         
          initcap
         
-        initcap(string)
-       
-       text
-       
-        Convert the first letter of each word to upper case and the
+        initcap ( text )
+        text
+        
+        Converts the first letter of each word to upper case and the
         rest to lower case. Words are sequences of alphanumeric
         characters separated by non-alphanumeric characters.
+        
+        initcap('hi THOMAS')
+        Hi Thomas
        
-       initcap('hi THOMAS')
-       Hi Thomas
       
 
       
-       
+       
         
          left
         
-        left(string text,
-        n int)
+        left ( string text,
+        n integer )
+        text
+        
+        Returns first n characters in the
+        string, or when n is negative, returns
+        all but last |n| characters.
+        
+        left('abcde', 2)
+        ab
        
-       text
-       
-        Return first n characters in the
-        string, or when n is negative, return
-        all but last |n| characters
-        
-       left('abcde', 2)
-       ab
       
 
       
-       
+       
         
          length
         
-        length(string)
-       
-       int
-       
-        Number of characters in string
+        length ( text )
+        integer
+        
+        Returns the number of characters in the string.
+        
+        length('jose')
+        4
        
-       length('jose')
-       4
       
 
       
-       
+       
         
          lpad
         
-        lpad(string text,
-        length int
-        , fill text)
-       
-       text
-       
-        Extend the string to length
+        lpad ( string text,
+        length integer
+        , fill text  )
+        text
+        
+        Extends the string to length
         length by prepending the characters
         fill (a space by default).  If the
         string is already longer than
-        length then it is truncated (on the
-        right).
+        length then it is truncated (on the right).
+        
+        lpad('hi', 5, 'xy')
+        xyxhi
        
-       lpad('hi', 5, 'xy')
-       xyxhi
       
 
       
-       
+       
         
          ltrim
         
-        ltrim(string text
-        , characters text)
-       
-       text
-       
-        Remove the longest string containing only characters from
+        ltrim ( string text
+        , characters text  )
+        text
+        
+        Removes the longest string containing only characters from
         characters (a space by default) from the start of
-        string
+        string.
+        
+        ltrim('zzzytest', 'xyz')
+        test
        
-       ltrim('zzzytest', 'xyz')
-       test
       
 
       
-       
+       
         
          md5
         
-        md5(string)
-       
-       text
-       
-        MD5 hash, with
-        the result written in hexadecimal
+        md5 ( text )
+        text
+        
+        Computes MD5 hash, with
+        the result written in hexadecimal.
+        
+        md5('abc')
+        900150983cd24fb0&zwsp;d6963f7d28e17f72
        
-       md5('abc')
-       900150983cd24fb0 d6963f7d28e17f72
       
 
       
-       
+       
         
          parse_ident
         
-        parse_ident(qualified_identifier text
-           [, strictmode boolean DEFAULT true ] )
-       
-       text[]
-       
-        Split qualified_identifier into an array of
+        parse_ident ( qualified_identifier text
+        [, strictmode boolean DEFAULT true ] )
+        text[]
+        
+        Splits qualified_identifier into an array of
         identifiers, removing any quoting of individual identifiers.  By
         default, extra characters after the last identifier are considered an
         error; but if the second parameter is false, then such
@@ -2042,417 +2039,441 @@
         names for objects like functions.) Note that this function does not
         truncate over-length identifiers. If you want truncation you can cast
         the result to name[].
+        
+        parse_ident('"SomeSchema".someTable')
+        {SomeSchema,sometable}
        
-       parse_ident('"SomeSchema".someTable')
-       {SomeSchema,sometable}
       
 
       
-       
+       
         
          pg_client_encoding
         
-        pg_client_encoding()
-       
-       name
-       
-        Current client encoding name
+        pg_client_encoding ( )
+        name
+        
+        Returns current client encoding name.
+        
+        pg_client_encoding()
+        SQL_ASCII
        
-       pg_client_encoding()
-       SQL_ASCII
       
 
       
-       
+       
         
          quote_ident
         
-        quote_ident(string text)
-       
-       text
-       
-        Return the given string suitably quoted to be used as an identifier
+        quote_ident ( text )
+        text
+        
+        Returns the given string suitably quoted to be used as an identifier
         in an SQL statement string.
         Quotes are added only if necessary (i.e., if the string contains
         non-identifier characters or would be case-folded).
         Embedded quotes are properly doubled.
         See also .
+        
+        quote_ident('Foo bar')
+        "Foo bar"
        
-       quote_ident('Foo bar')
-       "Foo bar"
       
 
       
-       
+       
         
          quote_literal
         
-        quote_literal(string text)
-       
-       text
-       
-        Return the given string suitably quoted to be used as a string literal
+        quote_literal ( text )
+        text
+        
+        Returns the given string suitably quoted to be used as a string literal
         in an SQL statement string.
         Embedded single-quotes and backslashes are properly doubled.
         Note that quote_literal returns null on null
         input; if the argument might be null,
         quote_nullable is often more suitable.
         See also .
+        
+        quote_literal(E'O\'Reilly')
+        'O''Reilly'
        
-       quote_literal(E'O\'Reilly')
-       'O''Reilly'
       
 
       
-       quote_literal(value anyelement)
-       text
-       
-        Coerce the given value to text and then quote it as a literal.
+       
+        quote_literal ( anyelement )
+        text
+        
+        Coerces the given value to text and then quotes it as a literal.
         Embedded single-quotes and backslashes are properly doubled.
+        
+        quote_literal(42.5)
+        '42.5'
        
-       quote_literal(42.5)
-       '42.5'
       
 
       
-       
+       
         
          quote_nullable
         
-        quote_nullable(string text)
-       
-       text
-       
-        Return the given string suitably quoted to be used as a string literal
+        quote_nullable ( text )
+        text
+        
+        Returns the given string suitably quoted to be used as a string literal
         in an SQL statement string; or, if the argument
-        is null, return NULL.
+        is null, returns NULL.
         Embedded single-quotes and backslashes are properly doubled.
         See also .
+        
+        quote_nullable(NULL)
+        NULL
        
-       quote_nullable(NULL)
-       NULL
       
 
       
-       quote_nullable(value anyelement)
-       text
-       
-        Coerce the given value to text and then quote it as a literal;
-        or, if the argument is null, return NULL.
+       
+        quote_nullable ( anyelement )
+        text
+        
+        Coerces the given value to text and then quotes it as a literal;
+        or, if the argument is null, returns NULL.
         Embedded single-quotes and backslashes are properly doubled.
+        
+        quote_nullable(42.5)
+        '42.5'
        
-       quote_nullable(42.5)
-       '42.5'
       
 
       
-       
+       
         
          regexp_match
         
-        regexp_match(string text, pattern text [, flags text])
-       
-       text[]
-       
-        Return captured substring(s) resulting from the first match of a POSIX
-        regular expression to the string (see
-         for more information)
+        regexp_match ( string text, pattern text [, flags text ] )
+        text[]
+        
+        Returns captured substring(s) resulting from the first match of a POSIX
+        regular expression to the string; see
+        .
+        
+        regexp_match('foobarbequebaz', '(bar)(beque)')
+        {bar,beque}
        
-       regexp_match('foobarbequebaz', '(bar)(beque)')
-       {bar,beque}
       
 
       
-       
+       
         
          regexp_matches
         
-        regexp_matches(string text, pattern text [, flags text])
-       
-       setof text[]
-       
-        Return captured substring(s) resulting from matching a POSIX regular
-        expression to the string (see
-         for more information)
+        regexp_matches ( string text, pattern text [, flags text ] )
+        setof text[]
+        
+        Returns captured substring(s) resulting from matching a POSIX regular
+        expression to the string; see
+        .
+        
+        regexp_matches('foobarbequebaz', 'ba.', 'g')
+        {bar}{baz}(2 rows)
        
-       regexp_matches('foobarbequebaz', 'ba.', 'g')
-       {bar}{baz} (2 rows)
       
 
       
-       
+       
         
          regexp_replace
         
-        regexp_replace(string text, pattern text, replacement text [, flags text])
+        regexp_replace ( string text, pattern text, replacement text [, flags text ] )
+        text
+        
+        Replaces substring(s) matching a POSIX regular expression; see
+        .
+        
+        regexp_replace('Thomas', '.[mN]a.', 'M')
+        ThM
        
-       text
-       
-        Replace substring(s) matching a POSIX regular expression (see
-         for more information)
-       
-       regexp_replace('Thomas', '.[mN]a.', 'M')
-       ThM
       
 
       
-       
+       
         
          regexp_split_to_array
         
-        regexp_split_to_array(string text, pattern text [, flags text ])
-       
-       text[]
-       
-        Split string using a POSIX regular expression as
-        the delimiter (see  for more
-        information)
+        regexp_split_to_array ( string text, pattern text [, flags text ] )
+        text[]
+        
+        Splits string using a POSIX regular
+        expression as the delimiter; see
+        .
+        
+        regexp_split_to_array('hello world', '\s+')
+        {hello,world}
        
-       regexp_split_to_array('hello world', '\s+')
-       {hello,world}
       
 
       
-       
+       
         
          regexp_split_to_table
         
-        regexp_split_to_table(string text, pattern text [, flags text])
-       
-       setof text
-       
-        Split string using a POSIX regular expression as
-        the delimiter (see  for more
-        information)
+        regexp_split_to_table ( string text, pattern text [, flags text ] )
+        setof text
+        
+        Splits string using a POSIX regular
+        expression as the delimiter; see
+        .
+        
+        regexp_split_to_table('hello world', '\s+')
+        helloworld(2 rows)
        
-       regexp_split_to_table('hello world', '\s+')
-       helloworld (2 rows)
       
 
       
-       
+       
         
          repeat
         
-        repeat(string text, number int)
+        repeat ( string text, number integer )
+        text
+        
+        Repeats string the specified
+        number of times.
+        
+        repeat('Pg', 4)
+        PgPgPgPg
        
-       text
-       Repeat string the specified
-       number of times
-       repeat('Pg', 4)
-       PgPgPgPg
       
 
       
-       
+       
         
          replace
         
-        replace(string text,
+        replace ( string text,
         from text,
-        to text)
-       
-       text
-       Replace all occurrences in string of substring
-        from with substring to
+        to text )
+        text
+        
+        Replaces all occurrences in string of
+        substring from with
+        substring to.
+        
+        replace('abcdefabcdef', 'cd', 'XX')
+        abXXefabXXef
        
-       replace('abcdefabcdef', 'cd', 'XX')
-       abXXefabXXef
       
 
       
-       
+       
         
          reverse
         
-        reverse(str)
+        reverse ( text )
+        text
+        
+        Reverses the order of the characters in the string.
+        
+        reverse('abcde')
+        edcba
        
-       text
-       
-        Reverse the order of the characters in string
-       
-       reverse('abcde')
-       edcba
       
 
       
-       
+       
         
          right
         
-        right(string text,
-         n int)
+        right ( string text,
+         n integer )
+ )
+        text
+        
+        Returns last n characters in the string,
+        or when n is negative, returns all but
+        first |n| characters.
+        
+        right('abcde', 2)
+        de
        
-       text
-       
-        Return last n characters in the string,
-        or when n is negative, return all but
-        first |n| characters
-       
-       right('abcde', 2)
-       de
       
 
       
-       
+       
         
          rpad
         
-        rpad(string text,
-        length int
-        , fill text)
-       
-       text
-       
-        Extend the string to length
+        rpad ( string text,
+        length integer
+        , fill text  )
+ )
+        text
+        
+        Extends the string to length
         length by appending the characters
         fill (a space by default).  If the
         string is already longer than
         length then it is truncated.
+        
+        rpad('hi', 5, 'xy')
+        hixyx
        
-       rpad('hi', 5, 'xy')
-       hixyx
       
 
       
-       
+       
         
          rtrim
         
-        rtrim(string text
-         , characters text)
-       
-       text
-       
-        Remove the longest string containing only characters from
+        rtrim ( string text
+         , characters text  )
+        text
+        
+        Removes the longest string containing only characters from
         characters (a space by default) from the end of
-        string
+        string.
+        
+        rtrim('testxxzx', 'xyz')
+        test
        
-       rtrim('testxxzx', 'xyz')
-       test
       
 
       
-       
+       
         
          split_part
         
-        split_part(string text,
+        split_part ( string text,
         delimiter text,
-        field int)
+        n integer )
+        text
+        
+        Splits string on delimiter
+        and returns the n'th field (counting from one).
+        
+        split_part('abc~@~def~@~ghi', '~@~', 2)
+        def
        
-       text
-       Split string on delimiter
-        and return the given field (counting from one)
-       
-       split_part('abc~@~def~@~ghi', '~@~', 2)
-       def
       
 
       
-       
+       
         
          strpos
         
-        strpos(string, substring)
-       
-       int
-       
-        Location of specified substring (same as
-        position(substring in
-         string), but note the reversed
-        argument order)
+        strpos ( string text, substring text )
+        integer
+        
+        Returns location of specified substring
+        within string, or zero if it's not present.
+        (Same as position(substring in
+        string), but note the reversed
+        argument order.)
+        
+        strpos('high', 'ig')
+        2
        
-       strpos('high', 'ig')
-       2
       
 
       
-       
+       
         
          substr
         
-        substr(string, from , count)
+        substr ( string text, start integer , count integer  )
+ )
+        text
+        
+        Extracts substring starting at index start,
+        and extending for count characters if that is
+        specified.  (Same
+        as substring(string
+        from start
+        for count).)
+        
+        substr('alphabet', 3, 2)
+        ph
        
-       text
-       
-        Extract substring (same as
-        substring(string from from for count))
-       
-       substr('alphabet', 3, 2)
-       ph
       
 
       
-       
+       
         
          starts_with
         
-        starts_with(string, prefix)
+        starts_with ( string text, prefix text )
+        boolean
+        
+        Returns true if string starts
+        with prefix.
+        
+        starts_with('alphabet', 'alph')
+        t
        
-       bool
-       
-        Return true if string starts
-        with prefix
-       
-       starts_with('alphabet', 'alph')
-       t
       
 
       
-       
+       
         
          to_ascii
         
-        to_ascii(string text
-        , encoding text)
+        to_ascii ( string text
+        , encoding name or integer  )
+        text
+        
+        Converts string to ASCII
+        from another encoding, which may be identified by name or number;
+        if encoding is omitted the database encoding
+        is assumed.  The conversion consists primarily of dropping accents.
+        Conversion is only supported
+        from LATIN1, LATIN2,
+        LATIN9, and WIN1250 encodings.
+        
+        to_ascii('Karél')
+        Karel
        
-       text
-       
-       Convert string to ASCII from another encoding
-       (only supports conversion from  LATIN1, LATIN2, LATIN9,
-       and WIN1250 encodings)
-       
-       to_ascii('Karel')
-       Karel
       
 
       
-       
+       
         
          to_hex
         
-        to_hex(number int
-        or bigint)
+        to_hex ( number
+        integer
+        or bigint )
+        text
+        
+        Converts number to its equivalent hexadecimal
+        representation.
+        
+        to_hex(2147483647)
+        7fffffff
        
-       text
-       Convert number to its equivalent hexadecimal
-        representation
-       
-       to_hex(2147483647)
-       7fffffff
       
 
       
-       
+       
         
          translate
         
-        translate(string text,
+        translate ( string text,
         from text,
-        to text)
-       
-       text
-       
-        Any character in string that matches a
-        character in the from set is replaced by
-        the corresponding character in the to
+        to text )
+        text
+        
+        Replaces each character in string that
+        matches a character in the from set with the
+        corresponding character in the to
         set. If from is longer than
         to, occurrences of the extra characters in
-        from are removed.
+        from are deleted.
+        
+        translate('12345', '143', 'ax')
+        a2x5
        
-       translate('12345', '143', 'ax')
-       a2x5
       
 
      
@@ -6743,257 +6764,224 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
     
Date/Time Operators - - - - - - - - - + - Operator - Signature - - - Description - - - Example - Example Result + + OperatorDescriptionExample(s) + - + - date + integer - date - - - Add a number of days to a date - - - date '2001-09-28' + 7 - 2001-10-05 + + date + integer + date + + Add a number of days to a date + + date '2001-09-28' + 7 + 2001-10-05 + - + - date + interval - timestamp - - - Add an interval to a date - - - date '2001-09-28' + interval '1 hour' - 2001-09-28 01:00:00 + + date + interval + timestamp + + Add an interval to a date + + date '2001-09-28' + interval '1 hour' + 2001-09-28 01:00:00 + - + - date + time - timestamp - - - Add a time-of-day to a date - - - date '2001-09-28' + time '03:00' - 2001-09-28 03:00:00 + + date + time + timestamp + + Add a time-of-day to a date + + date '2001-09-28' + time '03:00' + 2001-09-28 03:00:00 + - + - interval + interval - interval - - - Add intervals - - - interval '1 day' + interval '1 hour' - 1 day 01:00:00 + + interval + interval + interval + + Add intervals + + interval '1 day' + interval '1 hour' + 1 day 01:00:00 + - + - timestamp + interval - timestamp - - - Add an interval to a timestamp - - - timestamp '2001-09-28 01:00' + interval '23 hours' - 2001-09-29 00:00:00 + + timestamp + interval + timestamp + + Add an interval to a timestamp + + timestamp '2001-09-28 01:00' + interval '23 hours' + 2001-09-29 00:00:00 + - + - time + interval - time - - - Add an interval to a time - - - time '01:00' + interval '3 hours' - 04:00:00 + + time + interval + time + + Add an interval to a time + + time '01:00' + interval '3 hours' + 04:00:00 + - - - - interval - interval - - - Negate an interval - - - - interval '23 hours' - -23:00:00 + + - interval + interval + + Negate an interval + + - interval '23 hours' + -23:00:00 + - - - date - date - integer - - - Subtract dates - - - date '2001-10-01' - date '2001-09-28' - 3 + + date - date + integer + + Subtract dates + + date '2001-10-01' - date '2001-09-28' + 3 + - - - date - integer - date - - - Subtract a number of days from a date - - - date '2001-10-01' - 7 - 2001-09-24 + + date - integer + date + + Subtract a number of days from a date + + date '2001-10-01' - 7 + 2001-09-24 + - - - date - interval - timestamp - - - Subtract an interval from a date - - - date '2001-09-28' - interval '1 hour' - 2001-09-27 23:00:00 + + date - interval + timestamp + + Subtract an interval from a date + + date '2001-09-28' - interval '1 hour' + 2001-09-27 23:00:00 + - - - time - time - interval - - - Subtract times - - - time '05:00' - time '03:00' - 02:00:00 + + time - time + interval + + Subtract times + + time '05:00' - time '03:00' + 02:00:00 + - - - time - interval - time - - - Subtract an interval from a time - - - time '05:00' - interval '2 hours' - 03:00:00 + + time - interval + time + + Subtract an interval from a time + + time '05:00' - interval '2 hours' + 03:00:00 + - - - timestamp - interval - timestamp - - - Subtract an interval from a timestamp - - - timestamp '2001-09-28 23:00' - interval '23 hours' - 2001-09-28 00:00:00 + + timestamp - interval + timestamp + + Subtract an interval from a timestamp + + timestamp '2001-09-28 23:00' - interval '23 hours' + 2001-09-28 00:00:00 + - - - interval - interval - interval - - - Subtract intervals - - - interval '1 day' - interval '1 hour' - 1 day -01:00:00 + + interval - interval + interval + + Subtract intervals + + interval '1 day' - interval '1 hour' + 1 day -01:00:00 + - - - timestamp - timestamp - interval - - - Subtract timestamps - - - timestamp '2001-09-29 03:00' - timestamp '2001-09-27 12:00' - 1 day 15:00:00 + + timestamp - timestamp + interval + + Subtract timestamps + + timestamp '2001-09-29 03:00' - timestamp '2001-09-27 12:00' + 1 day 15:00:00 + - * - double precision * interval - interval - - - Multiply an interval by a scalar - - - 900 * interval '1 second' - 00:15:00 - - - 21 * interval '1 day' - 21 days - - - 3.5 * interval '1 hour' - 03:30:00 + + interval * double precision + interval + + Multiply an interval by a scalar + + interval '1 second' * 900 + 00:15:00 + + interval '1 day' * 21 + 21 days + + interval '1 hour' * 3.5 + 03:30:00 + - / - interval / double precision - interval - - - Divide an interval by a scalar - - - interval '1 hour' / 1.5 - 00:40:00 + + interval / double precision + interval + + Divide an interval by a scalar + + interval '1 hour' / 1.5 + 00:40:00 + @@ -8645,103 +8633,79 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
Enum Support Functions - - - - - - - - - + - Function - Signature - - - Description - - - Example - Example Result + + FunctionDescriptionExample(s) + - + enum_first - enum_first + enum_first ( anyenum ) + anyenum + + Returns the first value of the input enum type. + + enum_first(null::rainbow) + red - enum_first(anyenum) anyenum - - - Returns the first value of the input enum type - enum_first(&zwsp;null::rainbow) - red - - - + enum_last - enum_last + enum_last ( anyenum ) + anyenum + + Returns the last value of the input enum type. + + enum_last(null::rainbow) + purple - enum_last(anyenum) anyenum - Returns the last value of the input enum type - - - enum_last(&zwsp;null::rainbow) - purple - - - + enum_range - enum_range + enum_range ( anyenum ) + anyarray + + Returns all values of the input enum type in an ordered array. + + enum_range(null::rainbow) + {red,orange,yellow,&zwsp;green,blue,purple} - enum_range(anyenum) anyarray - - - Returns all values of the input enum type in an ordered array - - - enum_range(&zwsp;null::rainbow) - {red,orange,yellow,&zwsp;green,blue,purple} - - - enum_range - enum_range(anyenum, anyenum) anyarray - + + enum_range ( anyenum, anyenum ) + 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 the enum type. 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,&zwsp;yellow,green} + + enum_range('orange'::rainbow, NULL) + {orange,yellow,green,&zwsp;blue,purple} - - enum_range(&zwsp;'orange'::rainbow, 'green'::rainbow) - {orange,yellow,green} - - - enum_range(NULL, 'green'::rainbow) - {red,orange,yellow,&zwsp;green} - - - enum_range(&zwsp;'orange'::rainbow, NULL) - {orange,yellow,green,&zwsp;blue,purple} -
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl index a13565e..105ed1c 100644 --- a/doc/src/sgml/stylesheet-common.xsl +++ b/doc/src/sgml/stylesheet-common.xsl @@ -103,4 +103,11 @@ + + + + +
+ + diff --git a/doc/src/sgml/stylesheet-fo.xsl b/doc/src/sgml/stylesheet-fo.xsl index 2aaae82..cf6a420 100644 --- a/doc/src/sgml/stylesheet-fo.xsl +++ b/doc/src/sgml/stylesheet-fo.xsl @@ -63,6 +63,31 @@ + + + + + + bold + + + + bold + + + + + + 5em + -5em + left + + + + @@ -70,6 +95,11 @@ + + + + + diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css index 1a66c78..7951881 100644 --- a/doc/src/sgml/stylesheet.css +++ b/doc/src/sgml/stylesheet.css @@ -76,6 +76,20 @@ div.example { margin: 0.5ex; } +/* formatting for entries in tables of functions: indent all but first line */ + +th.functableentry { + padding-left: 5em; + text-indent: -5em; + text-align: left; +} + +td.functableentry { + padding-left: 5em; + text-indent: -5em; + text-align: left; +} + /* Put these here instead of inside the HTML (see unsetting of admon.style in XSL) so that the web site stylesheet can set its own style. */ --- main.css.orig 2020-04-16 18:46:26.040658279 -0400 +++ main.css 2020-04-16 19:18:15.689371719 -0400 @@ -791,6 +791,20 @@ word-break: unset; } +/* formatting for entries in tables of functions: indent all but first line */ + +#docContent table.table th.functableentry { + padding-left: 5em; + text-indent: -5em; + text-align: left; +} + +#docContent table.table td.functableentry { + padding-left: 5em; + text-indent: -5em; + text-align: left; +} + /** * Titles, Navigation */

Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Thu, Apr 16, 2020 at 8:25 PM Tom Lane  wrote:
> Attached are screenshots of the same segment of table 9.10 as before
> and of the initial portion of 9.30, the patch against HEAD to produce
> these, and a hacky patch on the website's main.css to get it to go
> along.  Without the last you just get all the subsidiary stuff
> left-justified if you build with STYLE=website, which isn't impossibly
> unreadable but it's not the desired presentation.

These seem very nice, and way more readable than the version with
which you started the thread.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> On Thu, Apr 16, 2020 at 8:25 PM Tom Lane  wrote:
>> Attached are screenshots of the same segment of table 9.10 as before
>> and of the initial portion of 9.30, the patch against HEAD to produce
>> these, and a hacky patch on the website's main.css to get it to go
>> along.  Without the last you just get all the subsidiary stuff
>> left-justified if you build with STYLE=website, which isn't impossibly
>> unreadable but it's not the desired presentation.

> These seem very nice, and way more readable than the version with
> which you started the thread.

Glad you like 'em ;-).  Do you have an opinion about what to do
with the operator tables --- ie do we need a column with the operator
name at the left?

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 2:38 PM Tom Lane  wrote:
> Glad you like 'em ;-).  Do you have an opinion about what to do
> with the operator tables --- ie do we need a column with the operator
> name at the left?

Well, if the first row says date + date -> date, then I don't think we
also need another column to say that we're talking about +

Seems redundant.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> On Fri, Apr 17, 2020 at 2:38 PM Tom Lane  wrote:
>> Glad you like 'em ;-).  Do you have an opinion about what to do
>> with the operator tables --- ie do we need a column with the operator
>> name at the left?

> Well, if the first row says date + date -> date, then I don't think we
> also need another column to say that we're talking about +

> Seems redundant.

Well, sure it's redundant, the same way an index is redundant.
Question is whether it makes it easier to find what you're after.

Comparing this to what is in table 9.30 as of HEAD [1], it does
seem like the operator column in the latter is a bit busy/redundant.
Perhaps it'd be less so if we used the morerows trick to have only
one occurrence of each operator name in the first column.  But that
would be a little bit of a pain to maintain, so I'm not sure it's
worth the trouble.

Another advantage of handling functions and operators in exactly
the same format is that we won't need to do something weird for
tables 9.9 and 9.11, which include both.

For the moment I'll press on without including that column; we can
add it later without a huge amount of pain if we decide we want it.

On the other point of dispute about the operator tables: for the
moment I'm leaning towards keeping the text descriptions.  Surveying
the existing tables, the *only* two that lack text descriptions now
are this one and the as-yet-unnumbered table in 9.1 for AND/OR/NOT.
(Actually, that one calls itself a truth table not an operator
definition table, so maybe we should leave it alone.)  While there
is a reasonable argument that 9.1 Comparison Operators' descriptions
are all obvious, it's hard to make that argument for any other tables.
So I think the fact that 9.30 lacked such up to now is an aberration
not a good principle to follow.  Even in 9.30, the fact that, say,
date + integer interprets the integer as so-many-days isn't really
so blindingly obvious that it doesn't need documented.  In another
universe we might've made that count as seconds and had the result
type be timestamp, the way it works for date + interval.

			regards, tom lane

[1] https://www.postgresql.org/docs/devel/functions-datetime.html


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 3:58 PM Tom Lane  wrote:
> On the other point of dispute about the operator tables: for the
> moment I'm leaning towards keeping the text descriptions.

I mostly suggested nuking them just to try to make the table more
readable. But since you've found another (and better) solution to that
problem, I withdraw that suggestion.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Robert Haas  writes:
> On Fri, Apr 17, 2020 at 3:58 PM Tom Lane  wrote:
>> On the other point of dispute about the operator tables: for the
>> moment I'm leaning towards keeping the text descriptions.

> I mostly suggested nuking them just to try to make the table more
> readable. But since you've found another (and better) solution to that
> problem, I withdraw that suggestion.

Cool, then we're all on the same page.  I shall press forward.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 11:38 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Apr 16, 2020 at 8:25 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Attached are screenshots of the same segment of table 9.10 as before
>> and of the initial portion of 9.30, the patch against HEAD to produce
>> these, and a hacky patch on the website's main.css to get it to go
>> along.  Without the last you just get all the subsidiary stuff
>> left-justified if you build with STYLE=website, which isn't impossibly
>> unreadable but it's not the desired presentation.

> These seem very nice, and way more readable than the version with
> which you started the thread.


I too like the layout result.
Glad you like 'em ;-).  Do you have an opinion about what to do
with the operator tables --- ie do we need a column with the operator
name at the left?


I feel like writing them as:

+ (date, integer) -> date

makes more sense as they are mainly sorted on the operator symbol as opposed to the left operand.

I think the description line is beneficial, and easy enough to skim over for the trained eye just looking for a refresher on the example syntax.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"David G. Johnston"  writes:
> I feel like writing them as:
> + (date, integer) -> date
> makes more sense as they are mainly sorted on the operator symbol as
> opposed to the left operand.

Hmm ... we do use that syntax in some fairly-obscure places like
ALTER OPERATOR, but I'm afraid that novice users would just be
completely befuddled.  Maybe the examples would be enough to clarify,
but I'm not convinced.  Especially not for unary operators, where
ALTER OPERATOR would have us write "- (NONE, integer)".

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 4:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: 
Especially not for unary operators, where
ALTER OPERATOR would have us write "- (NONE, integer)".

I'd drop the parens for unary and just write "- integer"

It is a bit geeky but then again SQL writers are not typically computer language novices so operators should be comfortable for them and this isn't that off-the-wall.  But I agree with the concern.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"David G. Johnston"  writes:
> On Fri, Apr 17, 2020 at 4:04 PM Tom Lane  wrote:
>> Especially not for unary operators, where
>> ALTER OPERATOR would have us write "- (NONE, integer)".

> I'd drop the parens for unary and just write "- integer"

We do have some postfix operators still ... although it looks like
there's only one in core.  In any case, the signature line is *the*
thing that is supposed to specify what the syntax is, so I'm not
too pleased with using an ambiguous notation for it.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 4:17 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Apr 17, 2020 at 4:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Especially not for unary operators, where
>> ALTER OPERATOR would have us write "- (NONE, integer)".

> I'd drop the parens for unary and just write "- integer"

We do have some postfix operators still ... although it looks like
there's only one in core.  In any case, the signature line is *the*
thing that is supposed to specify what the syntax is, so I'm not
too pleased with using an ambiguous notation for it.

Neither:

- (NONE, integer) 

nor 

! (integer, NONE) 

seem bad, and do make very obvious how they are different.

The left margin scanning ability for the symbol (hey, I have an expression here that uses @>, what does that do?) seems worth the bit of novelty required.

David J.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"David G. Johnston"  writes:
> On Fri, Apr 17, 2020 at 4:17 PM Tom Lane  wrote:
>> We do have some postfix operators still ... although it looks like
>> there's only one in core.  In any case, the signature line is *the*
>> thing that is supposed to specify what the syntax is, so I'm not
>> too pleased with using an ambiguous notation for it.

> Neither:
> - (NONE, integer)
> nor
> ! (integer, NONE)
> seem bad, and do make very obvious how they are different.

> The left margin scanning ability for the symbol (hey, I have an expression
> here that uses @>, what does that do?) seems worth the bit of novelty
> required.

Meh.  If we're worried about that, personally I'd much rather put
back the separate left-hand column with just the operator name.

We could also experiment with bold-facing the operator names,
as somebody suggested upthread.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 6:30 PM David G. Johnston
 wrote:
> I feel like writing them as:
>
> + (date, integer) -> date
>
> makes more sense as they are mainly sorted on the operator symbol as opposed to the left operand.

I thought about that, too, but I think the way Tom did it is better.
It's much more natural to see it using the syntax with which it will
actually be invoked.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Вложения:
Robert Haas  writes:
> On Fri, Apr 17, 2020 at 6:30 PM David G. Johnston
>  wrote:
>> I feel like writing them as:
>> + (date, integer) -> date
>> makes more sense as they are mainly sorted on the operator symbol as opposed to the left operand.

> I thought about that, too, but I think the way Tom did it is better.
> It's much more natural to see it using the syntax with which it will
> actually be invoked.

Just for the record, I experimented with putting back an "operator name"
column, as attached.  I think it could be argued either way whether this
is an improvement or not.

Some notes:

* The column seems annoyingly wide, but the only way to make it narrower
is to narrow or eliminate the column title, which could be confusing.
Also, if there's not a fair amount of whitespace, it looks as if the
initial name is part of the signature, which is *really* confusing,
cf second screenshot.  (I'm not sure why the vertical rule is rendered
so much more weakly in this case, but it is.)

* I also tried it with valign="middle" to center the operator name among
its entries.  This was *not* an improvement, it largely breaks the
ability to see which entries belong to the name.

			regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Pavel Stehule <pavel.stehule@gmail.com>
Дата:


so 18. 4. 2020 v 22:36 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Apr 17, 2020 at 6:30 PM David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>> I feel like writing them as:
>> + (date, integer) -> date
>> makes more sense as they are mainly sorted on the operator symbol as opposed to the left operand.

> I thought about that, too, but I think the way Tom did it is better.
> It's much more natural to see it using the syntax with which it will
> actually be invoked.

Just for the record, I experimented with putting back an "operator name"
column, as attached.  I think it could be argued either way whether this
is an improvement or not.

Some notes:

* The column seems annoyingly wide, but the only way to make it narrower
is to narrow or eliminate the column title, which could be confusing.
Also, if there's not a fair amount of whitespace, it looks as if the
initial name is part of the signature, which is *really* confusing,
cf second screenshot.  (I'm not sure why the vertical rule is rendered
so much more weakly in this case, but it is.)

* I also tried it with valign="middle" to center the operator name among
its entries.  This was *not* an improvement, it largely breaks the
ability to see which entries belong to the name.

first variant looks better, because column with operator is wider.

Maybe it can look better if a content will be places to mid point. In left upper corner it is less readable.

Regards

Pavel


                        regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 2020-04-13 22:33, Tom Lane wrote:
>> Maybe we're just trying to shoehorn too much information into a single
>> table.
> Yeah, back at the beginning of this exercise, Alvaro wondered aloud
> if we should go to something other than tables altogether.  I dunno
> what that'd look like though.

Yeah, after reading all this, my conclusion is also, probably tables are 
not the right solution.

A variablelist/definition list would be the next thing to try in my mind.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 2020-04-16 08:26, Pierre Giraud wrote:
> The screenshot attached uses a 
tag for the descrition/example block. I like this better, but then you don't really need the table because you can just make the whole thing a definition list. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Re: Poll: are people okay with function/operator table redesign?

От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 2020-04-17 02:25, Tom Lane wrote:
> I eventually figured out that the approved way to do per-table-entry
> customization is to attach "role" properties to the DocBook elements,
> and then key off the role names in applying formatting changes in
> the customization layer.  So attached is a v3 that handles the desired
> formatting changes by applying a hanging indent to table 
> contents if the entry is marked with role="functableentry".  It may
> well be possible to do this in a cleaner fashion, but this seems
> good enough for discussion.

This scares me in terms of maintainability of both the toolchain and the 
markup.  Table formatting is already incredibly fragile, and here we 
just keep poking it until it looks a certain way instead of thinking 
about semantic markup.

A good old definition list of the kind

synopsis

     explanation

     example or two

would be much easier to maintain on all fronts.  And we could for 
example link directly to a function, which is currently not really possible.

If we want to draw a box around this and change the spacing, we can do 
that with CSS.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut  writes:
> This scares me in terms of maintainability of both the toolchain and the 
> markup.  Table formatting is already incredibly fragile, and here we 
> just keep poking it until it looks a certain way instead of thinking 
> about semantic markup.

That's a fair criticism, but ...

> A good old definition list of the kind
> synopsis
>      explanation
>      example or two
> would be much easier to maintain on all fronts.  And we could for 
> example link directly to a function, which is currently not really possible.
> If we want to draw a box around this and change the spacing, we can do 
> that with CSS.

... "we can fix it with CSS" is just as much reliance on toolchain.

In any case, I reject the idea that we should just drop the table
markup altogether and use inline variablelists.  In most of these
sections there is a very clear separation between the table contents
(with per-function or per-operator details) and the surrounding
commentary, which deals with more general concerns.  That's a useful
separation for both readers and authors, so we need to preserve it
in some form, but the standard rendering of variablelists won't.
(Our existing major use of variablelists, in the GUC chapter, works
around this basically by not having any "surrounding commentary"
... but that solution doesn't work here.)

There is also value in being able to say things like "see Table m.n
for the available operators for type foo".

If somebody's got an idea how to obtain this painfully-agreed-to
visual appearance from more robust markup, I'm all ears.  This
stuff is a bit outside my skill set, so I don't claim to have
found the best possible implementation.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Isaac Morland <isaac.morland@gmail.com>
Дата:
On Sun, 19 Apr 2020 at 09:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:
 
In any case, I reject the idea that we should just drop the table
markup altogether and use inline variablelists.  In most of these
sections there is a very clear separation between the table contents
(with per-function or per-operator details) and the surrounding
commentary, which deals with more general concerns.  That's a useful
separation for both readers and authors, so we need to preserve it
in some form, but the standard rendering of variablelists won't.
(Our existing major use of variablelists, in the GUC chapter, works
around this basically by not having any "surrounding commentary"
... but that solution doesn't work here.)

There is also value in being able to say things like "see Table m.n
for the available operators for type foo".

The HTML definition list under discussion looks like this:

<dl>
    <dt> term 1 </dt>
    <dd> description 1 </dd>
    <dt> term 2 </dt>
    <dd> description 2a </dd>
    <dd> description 2b </dd>
</dl>

So the enclosing <dl> element has the same role in the overall document as the <table>, and could be styled to set it apart from the main text and make it clear that it is a single unit (and at least in principle could be included in the "table" numbering). In the function/operator listing use case, there would be one <dd> for the description and a <dd> for each example. See:


If we were only concerned with HTML output then based on the desired semantics and appearance I would recommend <dl> without hesitation. Because of the need to produce PDF as well and my lack of knowledge of the Postgres documentation build process, I can't be so certain but I still suspect <dl> to be the best approach.

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Isaac Morland  writes:
> If we were only concerned with HTML output then based on the desired
> semantics and appearance I would recommend 
without hesitation. Because > of the need to produce PDF as well and my lack of knowledge of the Postgres > documentation build process, I can't be so certain but I still suspect
> to be the best approach. Yeah ... so a part of this problem is to persuade DocBook to generate that. As I mentioned upthread, I did experiment with putting a single-item in each table cell. That works out to an annoying amount of markup overhead, since variablelist is a rather overengineered construct, but I imagine we could live with it. The real problem was the amount of whitespace it wanted to add. We could probably hack our way out of that with CSS for HTML output, but it was quite unclear whether the PDF toolchain could be made to render it reasonably. A desirable solution, perhaps, would be a corresponding to the entire table with rendering customization that produces table-like dividing lines around s. I'm not volunteering to figure out how to do that though, especially not for PDF. In the meantime I plan to push forward with the markup approach we've got. The editorial content should still work if we find a better markup answer, and I'm willing to do the work of replacing the markup as long as somebody else figures out what it should be. regards, tom lane

Re: Poll: are people okay with function/operator table redesign?

От:
Victor Yegorov <vyegorov@gmail.com>
Дата:
вс, 19 апр. 2020 г. в 20:00, Tom Lane <tgl@sss.pgh.pa.us>:
In the meantime I plan to push forward with the markup approach we've
got.  The editorial content should still work if we find a better
markup answer, and I'm willing to do the work of replacing the markup
as long as somebody else figures out what it should be.

I am following this thread as a frequent documentation user.

While table 9.5 with functions looks quite nice, I quite dislike 9.4 with operators.
Previously, I could lookup operator in the leftmost column and read on. Right now I have to look through the whole table (well, not really, but still) to find the operator.
 
--
Victor Yegorov

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Victor Yegorov  writes:
> While table 9.5 with functions looks quite nice, I quite dislike 9.4 with
> operators.
> Previously, I could lookup operator in the leftmost column and read on.
> Right now I have to look through the whole table (well, not really, but
> still) to find the operator.

Aside from the alternatives already discussed, the only other idea
that's come to my mind is to write operator entries in a style like

	|| as in: text || text → text
		Concatenates the two strings.
		'Post' || 'greSQL' → PostgreSQL

Not sure that that's any better, but it is another alternative.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Victor Yegorov  writes:
> While table 9.5 with functions looks quite nice, I quite dislike 9.4 with
> operators.

BTW, I think a big part of the problem with table 9.4 as it's being
rendered in the web style right now is that the type placeholders
(numeric_type etc) are being rendered in a ridiculously overemphasized
fashion, causing them to overwhelm all else.  Do we really want
 to be rendered that way?  I'd think plain italic,
comparable to the rendering of , would be more appropriate.

I could make this page use  for that purpose of course,
but it seems like semantically the wrong thing.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2020-Apr-20, Tom Lane wrote:

> Victor Yegorov  writes:
> > While table 9.5 with functions looks quite nice, I quite dislike 9.4 with
> > operators.
> > Previously, I could lookup operator in the leftmost column and read on.
> > Right now I have to look through the whole table (well, not really, but
> > still) to find the operator.
> 
> Aside from the alternatives already discussed,

There's one with a separate column for the operator, without types, at
the left (the "with names" example at
https://postgr.es/m/14380.1587242177@sss.pgh.pa.us ).  That seemed
pretty promising -- not sure why it was discarded.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alvaro Herrera  writes:
> There's one with a separate column for the operator, without types, at
> the left (the "with names" example at
> https://postgr.es/m/14380.1587242177@sss.pgh.pa.us ).  That seemed
> pretty promising -- not sure why it was discarded.

Well, I wouldn't say it was discarded --- but there sure wasn't
a groundswell of support.

Looking at it again, I'd be inclined not to bother with the
morerows trick but just to have an operator name entry in each row.
This table is a bit of an outlier anyway, I'm finding --- very few
of the operator tables have multiple entries per operator name.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2020-Apr-20, Tom Lane wrote:

> Alvaro Herrera  writes:
> > There's one with a separate column for the operator, without types, at
> > the left (the "with names" example at
> > https://postgr.es/m/14380.1587242177@sss.pgh.pa.us ).  That seemed
> > pretty promising -- not sure why it was discarded.
> 
> Well, I wouldn't say it was discarded --- but there sure wasn't
> a groundswell of support.

Ah.

> Looking at it again, I'd be inclined not to bother with the
> morerows trick but just to have an operator name entry in each row.
> This table is a bit of an outlier anyway, I'm finding --- very few
> of the operator tables have multiple entries per operator name.

No disagreement here.  'morerows' attribs are always a messy business.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 2020-04-19 15:23, Tom Lane wrote:
> If somebody's got an idea how to obtain this painfully-agreed-to
> visual appearance from more robust markup, I'm all ears.  This
> stuff is a bit outside my skill set, so I don't claim to have
> found the best possible implementation.

I've played with this a bit, and there are certainly a lot of 
interesting things that you can do with CSS nowadays that would preserve 
some semblance of semantic markup on both the DocBook side and the HTML 
side.  We haven't even considered what this new markup would do to 
non-visual consumers.

But my conclusion is that this new direction is bad and the old way was 
much better.  My vote is to keep what we had in PG12.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut  writes:
> I've played with this a bit, and there are certainly a lot of 
> interesting things that you can do with CSS nowadays that would preserve 
> some semblance of semantic markup on both the DocBook side and the HTML 
> side.

As I said, I'm happy to do the legwork of improving the markup if someone
will point me in the right direction.  But I know next to zip about CSS,
so it would not be productive for me to do the basic design there ---
it would take too long and there would probably still be lots to criticize
in whatever I came up with.

(I note ruefully that my original design in e894c6183 *was* pretty decent
semantic markup, especially if you're willing to accept spanspec
identifiers as semantic annotation.  But people didn't like the visual
result, so now we have better visuals and uglier markup.)

> But my conclusion is that this new direction is bad and the old way was 
> much better.  My vote is to keep what we had in PG12.

I'm not willing to accept that conclusion.  Why are we even bothering
to support PDF output, if lots of critical information is going to be
illegible?  (And even if you figure PDFs should go the way of the dodo,
almost any narrow-window presentation has got problems with these tables.)
Also, as I've been going through this, I've realized that there are many
places in chapter 9 where the documentation is well south of adequate, if
not flat-out wrong.  Some of it is just that nobody's gone through this
material in decades, and some of it is that the existing table layout is
so unfriendly to writing more than a couple words of explanation per item.
But I'm not willing to abandon the work I've done so far and just hope
that in another twenty years somebody will be brave or foolish enough to
try again.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Bruce Momjian <bruce@momjian.us>
Дата:
On Thu, Apr 23, 2020 at 12:04:01PM -0400, Tom Lane wrote:
> Peter Eisentraut  writes:
> > I've played with this a bit, and there are certainly a lot of 
> > interesting things that you can do with CSS nowadays that would preserve 
> > some semblance of semantic markup on both the DocBook side and the HTML 
> > side.
> 
> As I said, I'm happy to do the legwork of improving the markup if someone
> will point me in the right direction.  But I know next to zip about CSS,
> so it would not be productive for me to do the basic design there ---
> it would take too long and there would probably still be lots to criticize
> in whatever I came up with.

I can do the CSS if you tell me what you want.

-- 
  Bruce Momjian          https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> On Thu, Apr 23, 2020 at 12:04:01PM -0400, Tom Lane wrote:
>> As I said, I'm happy to do the legwork of improving the markup if someone
>> will point me in the right direction.  But I know next to zip about CSS,
>> so it would not be productive for me to do the basic design there ---
>> it would take too long and there would probably still be lots to criticize
>> in whatever I came up with.

> I can do the CSS if you tell me what you want.

I think the existing visual appearance is more or less agreed to, so
what we want is to reproduce that as closely as possible from some
saner markup.  The first problem is to agree on what "saner markup"
is exactly.

We could possibly use margin and vertical-space CSS adjustments starting
from just using several s within each table cell (one  for
signature, one for description, one for each example).  I'm not sure
whether that meets Peter's desire for "semantic" markup though.  It's not
any worse than the old way with otherwise-unlabeled s, but it's not
better either.  Do we want, say, to distinguish descriptions from examples
in the markup?  If so, will paras with a role attribute do, or does it
need to be something else?

I'm also not sure whether or not Peter is objecting to the way I used
.  That seems reasonably semantically-based to me, but since
he hasn't stated what his criteria are, I don't know if he thinks so.
(I'll admit that it's a bit of an abuse to use that for both function
return types and example results.)  If that's out then we need some other
design for getting the right arrows into place.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
If we're doing nicer markup+CSS for this, then it might make sense to
find a better solution for this kind of entry with multiple signatures
(which was already an issue in the previous version):

text || anynonarray or anynonarray || text → text
	Converts the non-string input to text, then concatenates the two
	strings. (The non-string input cannot be of an array type, because that
	would create ambiguity with the array || operators. If you want to
	concatenate an array's text equivalent, cast it to text explicitly.)
	'Value: ' || 42 → Value: 42

I think it would make sense to split the first line to put each of the
two signatures on their own line.  So it would look like this:

text || anynonarray
anynonarray || text → text
	Converts the non-string input to text, then concatenates the two
	strings. (The non-string input cannot be of an array type, because that
	would create ambiguity with the array || operators. If you want to
	concatenate an array's text equivalent, cast it to text explicitly.)
	'Value: ' || 42 → Value: 42


Another example:

to_ascii ( string text [, encoding name or integer ] ) → text

should be (I think):

to_ascii ( string text [, encoding name ] ) → text
to_ascii ( string text [, integer ] ) → text


-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alvaro Herrera  writes:
> If we're doing nicer markup+CSS for this, then it might make sense to
> find a better solution for this kind of entry with multiple signatures
> (which was already an issue in the previous version):

Yeah, agreed.  I would like to be able to have multiple signature blocks
in one table cell, which the current hack can't handle.  There aren't
quite enough cases to make this mandatory, but it would be nicer.

It seems do-able if we explicitly mark signature blocks with their
own role, say

       
        
         text || anynonarray → text
        
        
         anynonarray || text → text
        
        
          description ...

Then the CSS can key off of the role to decide what indentation to apply
to the para.  While I mostly see how that would work, I'm not very sure
about whether we can make it work in the PDF chain too.

Not sure whether it'd be worth inventing additional roles to apply to
description and example paras, or whether that's just inducing carpal
tunnel syndrome to no purpose.  We'd want to keep the role label on the
s anyway I think, and that context should be enough as long as
we don't need different formatting for descriptions and examples.
But maybe Peter's notion of "semantic markup" requires it anyway.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Вложения:
I wrote:
> Alvaro Herrera  writes:
>> If we're doing nicer markup+CSS for this, then it might make sense to
>> find a better solution for this kind of entry with multiple signatures
>> (which was already an issue in the previous version):

> Yeah, agreed.  I would like to be able to have multiple signature blocks
> in one table cell, which the current hack can't handle.  There aren't
> quite enough cases to make this mandatory, but it would be nicer.
> It seems do-able if we explicitly mark signature blocks with their
> own role, say ...

Hearing no comments, I went ahead and experimented with that.
Attached is a POC patch that changes just the header and first few
entries in table 9.9, just to see what it'd look like.  This does
nicely reproduce the existing visual appearance.  (With the margin
parameters I used, there is a teensy bit more vertical space, but
I think it looks better this way.  That could be adjusted either
way of course.)

There is a small problem with getting this to work in the webstyle
HTML: somebody decided it would be a great idea to have a global
override on paragraph margin-bottom settings.  For the purposes of
this test I just deleted that from main.css, but I suppose we want
some more-nuanced solution in reality.



One thing I couldn't help noticing while fooling with this is what
seems to be a bug in the PDF toolchain: any place you try to put
an , you get extra whitespace.  Not a lot, but once you
see it, you can't un-see it.  It's particularly obvious if one of
two adjacent lines has the extra indentation and the other doesn't.
In the attached, I added an  to one of the signature
entries for "text || anynonarray", and you can see what I'm unhappy
about in the PDF screenshot.  The problem already exists in our
previous markup, at least in places where people put indexterms
inside function-table entries, but it'll be more obvious anyplace
we choose to have two signature entries in one table cell.

I tried putting the s outside the  elements, but
that makes it worse not better: instead of a little bit of extra
horizontal whitespace, you get a lot of extra vertical whitespace.

The only "fix" I've found is to place the  at the end
of the signature  instead of the beginning.  That's not included
in the attached but it does hide the existence of the extra space
quite effectively.  I'm not sure though whether it might result in
odd behavior of cross-reference links to the function entry.
In any case it feels like a hack.



It seems to me that this way is better than the markup I've been
using --- one thing I've observed is that Emacs' sgml mode is a
bit confused by the  hacks, and it's happier with this.
But it's not clear to me whether this is sufficient to resolve
Peter's unhappiness.

			regards, tom lane

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index b0afaeb..ffcb0ae 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -2067,48 +2067,64 @@ repeat('Pg', 4) PgPgPgPg
     
      
       
-       
-        Function/OperatorDescriptionExample(s)
-       
+       
+        Function/Operator
+       
+       
+        Description
+       
+       
+        Example(s)
+       
       
      
 
      
       
-       
+       
         
          character string
          concatenation
         
         text || text
         text
-       
+       
+       
         Concatenates the two strings.
-       
+       
+       
         'Post' || 'greSQL'
         PostgreSQL
-       
+       
       
 
       
-       
+       
+
+         character string test
+
         text || anynonarray
-        or anynonarray || text
         text
-       
+       
+       
+        anynonarray || text
+        text
+       
+       
         Converts the non-string input to text, then concatenates the two
         strings.  (The non-string input cannot be of an array type, because
         that would create ambiguity with the array ||
         operators.  If you want to concatenate an array's text equivalent,
         cast it to text explicitly.)
-       
+       
+       
         'Value: ' || 42
         Value: 42
-       
+       
       
 
       
-       
+       
         
          normalized
         
@@ -2117,7 +2133,8 @@ repeat('Pg', 4) PgPgPgPg
         
          text IS NOT form NORMALIZED
         boolean
-       
+       
+       
         Checks whether the string is in the specified Unicode normalization
         form.  The optional form key word specifies the
         form: NFC (the default), NFD,
@@ -2125,10 +2142,11 @@ repeat('Pg', 4) PgPgPgPg
         only be used when the server encoding is UTF8.  Note
         that checking for normalization using this expression is often faster
         than normalizing possibly already normalized strings.
-       
+       
+       
         U&'\0061\0308bc' IS NFD NORMALIZED
         t
-       
+       
       
 
       
diff --git a/doc/src/sgml/stylesheet-fo.xsl b/doc/src/sgml/stylesheet-fo.xsl
index 6797e06..e923b00 100644
--- a/doc/src/sgml/stylesheet-fo.xsl
+++ b/doc/src/sgml/stylesheet-fo.xsl
@@ -89,6 +89,16 @@
   
 
 
+
+
+  
+    
+      -3.5em
+    
+    
+  
+
+
 
 
 
diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css
index f369e12..d28cec4 100644
--- a/doc/src/sgml/stylesheet.css
+++ b/doc/src/sgml/stylesheet.css
@@ -85,6 +85,18 @@ td.functableentry {
 	text-align: left;
 }
 
+th.func_table_entry p,
+td.func_table_entry p {
+	margin-top: 0.1em;
+	margin-bottom: 0.1em;
+	padding-left: 4em;
+	text-align: left;
+}
+
+p.func_signature {
+	text-indent: -3.5em;
+}
+
 /* Put these here instead of inside the HTML (see unsetting of
    admon.style in XSL) so that the web site stylesheet can set its own
    style. */
--- main.css~	2020-04-26 12:45:29.646286775 -0400
+++ main.css	2020-04-26 12:54:04.605046657 -0400
@@ -624,9 +624,11 @@
   margin-top: 1rem;
 }
 
+/*
 #docContent p {
   margin-bottom: 1rem !important;
 }
+*/
 
 #docContent hr {
   margin: 0 0 0.5em 0;
@@ -799,6 +801,18 @@
 	text-align: left;
 }
 
+#docContent table.table th.func_table_entry p,
+#docContent table.table td.func_table_entry p {
+	margin-top: 0.1em;
+	margin-bottom: 0.1em;
+	padding-left: 4em;
+	text-align: left;
+}
+
+#docContent table.table p.func_signature {
+	text-indent: -3.5em;
+}
+
 /**
  * Titles, Navigation
  */

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/26/20 1:40 PM, Tom Lane wrote:
> I wrote:
>> Alvaro Herrera  writes:

> There is a small problem with getting this to work in the webstyle
> HTML: somebody decided it would be a great idea to have a global
> override on paragraph margin-bottom settings.  For the purposes of
> this test I just deleted that from main.css, but I suppose we want
> some more-nuanced solution in reality.

I have to see why that is. I traced it back to the original "bring doc
styles up to modern website" patch (66798351) and there is missing
context. Anyway, I'd like to test it before a wholesale removal (there
is often a strong correlation between "!important" and "hack", so I'll
want to further dive into it).

I'll have some time to play around with the CSS tonight.

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/26/20 3:21 PM, Jonathan S. Katz wrote:
> On 4/26/20 1:40 PM, Tom Lane wrote:
>> I wrote:
>>> Alvaro Herrera  writes:
> 
>> There is a small problem with getting this to work in the webstyle
>> HTML: somebody decided it would be a great idea to have a global
>> override on paragraph margin-bottom settings.  For the purposes of
>> this test I just deleted that from main.css, but I suppose we want
>> some more-nuanced solution in reality.
> 
> I have to see why that is. I traced it back to the original "bring doc
> styles up to modern website" patch (66798351) and there is missing
> context. Anyway, I'd like to test it before a wholesale removal (there
> is often a strong correlation between "!important" and "hack", so I'll
> want to further dive into it).
> 
> I'll have some time to play around with the CSS tonight.

Can you try

 #docContent p {
-  margin-bottom: 1rem !important;
+  margin-bottom: 1rem;
 }

and see how it looks?

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> Can you try

>  #docContent p {
> -  margin-bottom: 1rem !important;
> +  margin-bottom: 1rem;
>  }

> and see how it looks?

In some desultory looking around, I couldn't find anyplace in the
existing text that that changes at all.  And it does make the
revised table markup render the way I want ... so +1.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/26/20 9:44 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> Can you try
> 
>>  #docContent p {
>> -  margin-bottom: 1rem !important;
>> +  margin-bottom: 1rem;
>>  }
> 
>> and see how it looks?
> 
> In some desultory looking around, I couldn't find anyplace in the
> existing text that that changes at all.  And it does make the
> revised table markup render the way I want ... so +1.

Great. I do want to do a bit more desultory testing in the older
versions of the docs, but it can be committed whenever the -docs side is
ready.

Thanks,

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> Great. I do want to do a bit more desultory testing in the older
> versions of the docs, but it can be committed whenever the -docs side is
> ready.

Other than that point, the main.css patch as I presented it just adds
some rules that aren't used yet, so it could be pushed as soon as you're
satisfied about the !important change.  It'd probably make sense to
push it in advance of making the markup changes, so we don't have an
interval of near-unreadable devel docs.

Still waiting to hear whether this markup approach satisfies
Peter's concerns, though.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/27/20 8:49 AM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> Great. I do want to do a bit more desultory testing in the older
>> versions of the docs, but it can be committed whenever the -docs side is
>> ready.
> 
> Other than that point, the main.css patch as I presented it just adds
> some rules that aren't used yet, so it could be pushed as soon as you're
> satisfied about the !important change.  It'd probably make sense to
> push it in advance of making the markup changes, so we don't have an
> interval of near-unreadable devel docs.

*nods* I'll ensure to test again and hopefully commit later today.

I forget what I was looking at, but I did see a similar pattern in some
other modern software docs, so it seems like this is trending in the
right direction. Looking forward to the rollout!

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> On 4/27/20 8:49 AM, Tom Lane wrote:
>> Other than that point, the main.css patch as I presented it just adds
>> some rules that aren't used yet, so it could be pushed as soon as you're
>> satisfied about the !important change.  It'd probably make sense to
>> push it in advance of making the markup changes, so we don't have an
>> interval of near-unreadable devel docs.

> *nods* I'll ensure to test again and hopefully commit later today.

After looking at the JSON function tables, I've concluded that the
ability to have more than one function signature per table cell is
really rather essential not optional.  So I'm going to go ahead and
convert all the existing markup to the -based style I proposed
on Sunday.  Please push the main.css change when you can.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I wrote:
> One thing I couldn't help noticing while fooling with this is what
> seems to be a bug in the PDF toolchain: any place you try to put
> an , you get extra whitespace.  Not a lot, but once you
> see it, you can't un-see it.  It's particularly obvious if one of
> two adjacent lines has the extra indentation and the other doesn't.
> ...
> The only "fix" I've found is to place the  at the end
> of the signature  instead of the beginning.

I spent some more time experimenting with this today, and determined
that there's no way to fix it by messing with FO layout attributes.
The basic problem seems to be that if you write

       
        
         ceiling
        
        ceiling ( numeric )

then what you get in the .fo file is

        
        
        ceiling ( numeric )

where the  apparently is used as a cross-reference anchor.
The trouble with this is that the rules for collapsing adjacent whitespace
don't work across the , so no matter what you do you will end
up with two spaces not one before the visible text "ceiling".  The only
way to hide the effects of that with layout attributes is to set
whitespace to be ignored altogether within the block, which is quite
undesirable.

The fix I'm currently considering is to eliminate the extra whitespace
run(s) by formatting s within tables this way:

      
       
         char_length
        
         character string
         length
        
         length
         of a character string
         character string, length
        
        char_length ( text )
        integer
       

Perhaps it's only worth being anal about this in table cells with multiple
function signatures and/or multiple s; in other places the
whitespace variation just isn't that noticeable.  On the other hand,
there's something to be said for having uniform layout of the XML source,
which'd suggest having a uniform rule "no whitespace before an 
within a table cell".

Or we could put the s at the end.  Or just ignore it, reasoning
that the PDF output is never going to look all that great anyway.

Thoughts?

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
After further fooling with this issue, I've determined that

(1) I need to be able to use  environments within the
func_table_entry cells and have them render more-or-less normally.
There doesn't seem to be any other good way to render multiline
example results for set-returning functions ... but marking such
environments up to the extent that the website style normally does
is very distracting.

(2) I found that adding !important to the func_table_entry rules
is enough to override less-general !important rules.  So it'd be
possible to leave all the existing CSS rules alone, if that makes
you feel more comfortable.

The attached updated patch reflects both of these conclusions.
We could take out some of the !important annotations here if
you're willing to delete !important annotations in more-global
rules for 

and/or

, but maybe that's something to fool
with later.  I'd like to get this done sooner ...

			regards, tom lane

--- main.css.orig	2020-04-29 17:19:24.089511785 -0400
+++ main.css	2020-04-29 19:18:28.082138095 -0400
@@ -799,6 +799,27 @@
 	text-align: left;
 }
 
+#docContent table.table th.func_table_entry p,
+#docContent table.table td.func_table_entry p {
+	margin-top: 0.1em;
+	margin-bottom: 0.1em !important;
+	padding-left: 4em;
+	text-align: left;
+}
+
+#docContent table.table p.func_signature {
+	text-indent: -3.5em;
+}
+
+#docContent table.table td.func_table_entry pre.programlisting {
+	margin-top: 0.1em !important;
+	margin-bottom: 0.1em !important;
+	padding: 0 !important;
+	padding-left: 4em !important;
+	background-color: inherit !important;
+	border: 0;
+}
+
 /**
  * Titles, Navigation
  */

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 7:29 PM, Tom Lane wrote:
> After further fooling with this issue, I've determined that
> 
> (1) I need to be able to use  environments within the
> func_table_entry cells and have them render more-or-less normally.
> There doesn't seem to be any other good way to render multiline
> example results for set-returning functions ... but marking such
> environments up to the extent that the website style normally does
> is very distracting.
> 
> (2) I found that adding !important to the func_table_entry rules
> is enough to override less-general !important rules.  So it'd be
> possible to leave all the existing CSS rules alone, if that makes
> you feel more comfortable.
> 
> The attached updated patch reflects both of these conclusions.
> We could take out some of the !important annotations here if
> you're willing to delete !important annotations in more-global
> rules for 

and/or

, but maybe that's something to fool
> with later.  I'd like to get this done sooner ...

My preference would be to figure out the CSS rules that are causing you
to rely on !important at the table level and just fix that up, rather
than hacking in too many !important.

I'll compromise on the temporary importants, but first I want to see
what's causing the need for it. Do you have a suggestion on a page to test?

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 7:40 PM, Jonathan S. Katz wrote:
> On 4/29/20 7:29 PM, Tom Lane wrote:
>> After further fooling with this issue, I've determined that
>>
>> (1) I need to be able to use  environments within the
>> func_table_entry cells and have them render more-or-less normally.
>> There doesn't seem to be any other good way to render multiline
>> example results for set-returning functions ... but marking such
>> environments up to the extent that the website style normally does
>> is very distracting.
>>
>> (2) I found that adding !important to the func_table_entry rules
>> is enough to override less-general !important rules.  So it'd be
>> possible to leave all the existing CSS rules alone, if that makes
>> you feel more comfortable.
>>
>> The attached updated patch reflects both of these conclusions.
>> We could take out some of the !important annotations here if
>> you're willing to delete !important annotations in more-global
>> rules for 

and/or

, but maybe that's something to fool
>> with later.  I'd like to get this done sooner ...
> 
> My preference would be to figure out the CSS rules that are causing you
> to rely on !important at the table level and just fix that up, rather
> than hacking in too many !important.
> 
> I'll compromise on the temporary importants, but first I want to see
> what's causing the need for it. Do you have a suggestion on a page to test?

From real quick I got it to here. With the latest copy of the doc builds
it appears to still work as expected, but I need a section with the new
"pre" block to test.

I think the "background-color: inherit !important" is a bit odd, and
would like to trace that one down a bit more, but I did not see anything
obvious on my glance through it.

How does it look on your end?

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> On 4/29/20 7:40 PM, Jonathan S. Katz wrote:
>> I'll compromise on the temporary importants, but first I want to see
>> what's causing the need for it. Do you have a suggestion on a page to test?

I haven't yet pushed anything dependent on the new markup, but
attached is a draft revision for the JSON section; if you look at
the SRFs such as json_array_elements you'll see the issue.

> From real quick I got it to here. With the latest copy of the doc builds
> it appears to still work as expected, but I need a section with the new
> "pre" block to test.

Yeah, I see you found the same 

and

 settings I did.

> I think the "background-color: inherit !important" is a bit odd, and
> would like to trace that one down a bit more, but I did not see anything
> obvious on my glance through it.

I think it's coming from this bit at about main.css:660:

pre,
code,
#docContent kbd,
#docContent tt.LITERAL,
#docContent tt.REPLACEABLE {
  font-size: 0.9rem !important;
  color: inherit !important;
  background-color: #f8f9fa !important;
  border-radius: .25rem;
  margin: .6rem 0;
  font-weight: 300;
}

I had to override most of that.

			regards, tom lane

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 68c08c5..1d3c281 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -14368,1461 +14423,2322 @@ table2-mapping
     shows the operators that
    are available for use with JSON data types (see ).
-  
-
-  
-     <type>json</type> and <type>jsonb</type> Operators
-     
-      
-       
-        Operator
-        Right Operand Type
-        Return type
-        Description
-        Example
-        Example Result
-       
-      
-      
-       
-        ->
-        int
-        json or jsonb
-        Get JSON array element (indexed from zero, negative
-        integers count from the end)
-        '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json->2
-        {"c":"baz"}
-       
-       
-        ->
-        text
-        json or jsonb
-        Get JSON object field by key
-        '{"a": {"b":"foo"}}'::json->'a'
-        {"b":"foo"}
-       
-        
-        ->>
-        int
-        text
-        Get JSON array element as text
-        '[1,2,3]'::json->>2
-        3
-       
-       
-        ->>
-        text
-        text
-        Get JSON object field as text
-        '{"a":1,"b":2}'::json->>'b'
-        2
-       
-       
-        #>
-        text[]
-        json or jsonb
-        Get JSON object at the specified path
-        '{"a": {"b":{"c": "foo"}}}'::json#>'{a,b}'
-        {"c": "foo"}
-       
-       
-        #>>
-        text[]
-        text
-        Get JSON object at the specified path as text
-        '{"a":[1,2,3],"b":[4,5,6]}'::json#>>'{a,2}'
-        3
-       
-      
-     
-   
- - - - There are parallel variants of these operators for both the - json and jsonb types. - The field/element/path extraction operators - return the same type as their left-hand input (either json - or jsonb), except for those specified as - returning text, which coerce the value to text. - The field/element/path extraction operators return NULL, rather than - failing, if the JSON input does not have the right structure to match - the request; for example if no such element exists. The - field/element/path extraction operators that accept integer JSON - array subscripts all support negative subscripting from the end of - arrays. - - - - The standard comparison operators shown in are available for - jsonb, but not for json. They follow the - ordering rules for B-tree operations outlined at . - - - Some further operators also exist only for jsonb, as shown - in . - Many of these operators can be indexed by - jsonb operator classes. For a full description of - jsonb containment and existence semantics, see . - describes how these operators can be used to effectively index - jsonb data. - - - Additional <type>jsonb</type> Operators - - - - Operator - Right Operand Type - Description - Example - - - - - @> - jsonb - Does the left JSON value contain the right JSON - path/value entries at the top level? - '{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb - - - <@ - jsonb - Are the left JSON path/value entries contained at the top level within - the right JSON value? - '{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb - - - ? - text - Does the string exist as a top-level - key within the JSON value? - '{"a":1, "b":2}'::jsonb ? 'b' - - - ?| - text[] - Do any of these array strings - exist as top-level keys? - '{"a":1, "b":2, "c":3}'::jsonb ?| array['b', 'c'] - - - ?& - text[] - Do all of these array strings exist - as top-level keys? - '["a", "b"]'::jsonb ?& array['a', 'b'] - - - || - jsonb - Concatenate two jsonb values into a new jsonb value - '["a", "b"]'::jsonb || '["c", "d"]'::jsonb - - - - - text - Delete key/value pair or string - element from left operand. Key/value pairs are matched based - on their key value. - '{"a": "b"}'::jsonb - 'a' - - - - - text[] - Delete multiple key/value pairs or string - elements from left operand. Key/value pairs are matched based - on their key value. - '{"a": "b", "c": "d"}'::jsonb - '{a,c}'::text[] - - - - - integer - Delete the array element with specified index (Negative - integers count from the end). Throws an error if top level - container is not an array. - '["a", "b"]'::jsonb - 1 - - - #- - text[] - Delete the field or element with specified path (for - JSON arrays, negative integers count from the end) - '["a", {"b":1}]'::jsonb #- '{1,b}' - - - @? - jsonpath - Does JSON path return any item for the specified JSON value? - '{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)' - - - @@ - jsonpath - Returns the result of JSON path predicate check for the specified JSON value. - Only the first item of the result is taken into account. If the - result is not Boolean, then null is returned. - '{"a":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2' - - - -
- - - - The || operator concatenates the elements at the top level of - each of its operands. It does not operate recursively. For example, if - both operands are objects with a common key field name, the value of the - field in the result will just be the value from the right hand operand. - - - - - - The @? and @@ operators suppress - the following errors: lacking object field or array element, unexpected - JSON item type, datetime and numeric errors. - This behavior might be helpful while searching over JSON document - collections of varying structure. - - - - - shows the functions that are - available for creating json and jsonb values. - (There are no equivalent functions for jsonb, of the row_to_json - and array_to_json functions. However, the to_jsonb - function supplies much the same functionality as these functions would.) + jsonb, though not for json. The comparison + operators follow the ordering rules for B-tree operations outlined in + . - - to_json - - - array_to_json - - - row_to_json - - - json_build_array - - - json_build_object - - - json_object - - - to_jsonb - - - jsonb_build_array - - - jsonb_build_object - - - jsonb_object - - - - JSON Creation Functions - +
+ <type>json</type> and <type>jsonb</type> Operators + - Function - Description - Example - Example Result + + Operator + + + Description + + + Example(s) + + - to_json(anyelement) - to_jsonb(anyelement) + + json -> integer + json + + + jsonb -> integer + jsonb + + + Extracts n'th element of JSON array + (array elements are indexed from zero, but negative integers count + from the end). + + + '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json -> 2 + {"c":"baz"} + + + '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json -> -3 + {"a":"foo"} - - Returns the value as json or jsonb. - Arrays and composites are converted - (recursively) to arrays and objects; otherwise, if there is a cast - from the type to json, the cast function will be used to - perform the conversion; otherwise, a scalar value is produced. - For any scalar type other than a number, a Boolean, or a null value, - the text representation will be used, in such a fashion that it is a - valid json or jsonb value. - - to_json('Fred said "Hi."'::text) - "Fred said \"Hi.\"" - - - - array_to_json(anyarray [, pretty_bool]) - - - Returns the array as a JSON array. A PostgreSQL multidimensional array - becomes a JSON array of arrays. Line feeds will be added between - dimension-1 elements if pretty_bool is true. - - array_to_json('{{1,5},{99,100}}'::int[]) - [[1,5],[99,100]] + - - row_to_json(record [, pretty_bool]) - - - Returns the row as a JSON object. Line feeds will be added between - level-1 elements if pretty_bool is true. - - row_to_json(row(1,'foo')) - {"f1":1,"f2":"foo"} + + json -> text + json + + + jsonb -> text + jsonb + + + Extracts JSON object field with the given key. + + + '{"a": {"b":"foo"}}'::json -> 'a' + {"b":"foo"} + + - json_build_array(VARIADIC "any") - jsonb_build_array(VARIADIC "any") + + json ->> integer + text + + + jsonb ->> integer + text + + + Extracts n'th element of JSON array, + as text. + + + '[1,2,3]'::json ->> 2 + 3 - - Builds a possibly-heterogeneously-typed JSON array out of a variadic - argument list. - - json_build_array(1,2,'3',4,5) - [1, 2, "3", 4, 5] + - json_build_object(VARIADIC "any") - jsonb_build_object(VARIADIC "any") + + json ->> text + text + + + jsonb ->> text + text + + + Extracts JSON object field with the given key, as text. + + + '{"a":1,"b":2}'::json ->> 'b' + 2 - - Builds a JSON object out of a variadic argument list. By - convention, the argument list consists of alternating - keys and values. - - json_build_object('foo',1,'bar',2) - {"foo": 1, "bar": 2} + - json_object(text[]) - jsonb_object(text[]) + + json #> text[] + json + + + jsonb #> text[] + jsonb + + + Extracts JSON sub-object at the specified path, where path elements + can be either field keys or array indexes. + + + '{"a": {"b": ["foo","bar"]}}'::json #> '{a,b,1}' + "bar" - - Builds a JSON object out of a text array. The array must have either - exactly one dimension with an even number of members, in which case - they are taken as alternating key/value pairs, or two dimensions - such that each inner array has exactly two elements, which - are taken as a key/value pair. - - json_object('{a, 1, b, "def", c, 3.5}') - json_object('{{a, 1},{b, "def"},{c, 3.5}}') - {"a": "1", "b": "def", "c": "3.5"} + - json_object(keys text[], values text[]) - jsonb_object(keys text[], values text[]) + + json #>> text[] + text + + + jsonb #>> text[] + text + + + Extracts JSON sub-object at the specified path as text. + + + '{"a": {"b": ["foo","bar"]}}'::json #>> '{a,b,1}' + bar - - This form of json_object takes keys and values pairwise from two separate - arrays. In all other respects it is identical to the one-argument form. - - json_object('{a, b}', '{1,2}') - {"a": "1", "b": "2"}
- - array_to_json and row_to_json have the same - behavior as to_json except for offering a pretty-printing - option. The behavior described for to_json likewise applies - to each individual value converted by the other JSON creation functions. - - - - - - The extension has a cast - from hstore to json, so that - hstore values converted via the JSON creation functions - will be represented as JSON objects, not as primitive string values. - + + The field/element/path extraction operators return NULL, rather than + failing, if the JSON input does not have the right structure to match + the request; for example if no such key or array element exists. + - shows the functions that - are available for processing json and jsonb values. + Some further operators exist only for jsonb, as shown + in . + + describes how these operators can be used to effectively search indexed + jsonb data. - - json_array_length - - - jsonb_array_length - - - json_each - - - jsonb_each - - - json_each_text - - - jsonb_each_text - - - json_extract_path - - - jsonb_extract_path - - - json_extract_path_text - - - jsonb_extract_path_text - - - json_object_keys - - - jsonb_object_keys - - - json_populate_record - - - jsonb_populate_record - - - json_populate_recordset - - - jsonb_populate_recordset - - - json_array_elements - - - jsonb_array_elements - - - json_array_elements_text - - - jsonb_array_elements_text - - - json_typeof - - - jsonb_typeof - - - json_to_record - - - jsonb_to_record - - - json_to_recordset - - - jsonb_to_recordset - - - json_strip_nulls - - - jsonb_strip_nulls - - - jsonb_set - - - jsonb_set_lax - - - jsonb_insert - - - jsonb_pretty - - - jsonb_path_exists - - - jsonb_path_exists_tz - - - jsonb_path_match - - - jsonb_path_match_tz - - - jsonb_path_query - - - jsonb_path_query_tz - - - jsonb_path_query_array - - - jsonb_path_query_array_tz - - - jsonb_path_query_first - - - jsonb_path_query_first_tz - - - - JSON Processing Functions - +
+ Additional <type>jsonb</type> Operators + - Function - Return Type - Description - Example - Example Result + + Operator + + + Description + + + Example(s) + + - json_array_length(json) - jsonb_array_length(jsonb) + + jsonb @> jsonb + boolean + + + Does the first JSON value contain the second? + (See for details about containment.) + + + '{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb + t - int - - Returns the number of elements in the outermost JSON array. - - json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') - 5 + - json_each(json) - jsonb_each(jsonb) - - setof key text, value json - setof key text, value jsonb + + jsonb <@ jsonb + boolean + + + Is the first JSON value contained in the second? + + + '{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb + t - - Expands the outermost JSON object into a set of key/value pairs. - - select * from json_each('{"a":"foo", "b":"bar"}') - - - key | value ------+------- - a | "foo" - b | "bar" - - + - json_each_text(json) - jsonb_each_text(jsonb) + + jsonb ? text + boolean + + + Does the text string exist as a top-level key or array element within + the JSON value? + + + '{"a":1, "b":2}'::jsonb ? 'b' + t + + + '["a", "b", "c"]'::jsonb ? 'b' + t - setof key text, value text - - Expands the outermost JSON object into a set of key/value pairs. The - returned values will be of type text. - - select * from json_each_text('{"a":"foo", "b":"bar"}') - - - key | value ------+------- - a | foo - b | bar - - + - json_extract_path(from_json json, VARIADIC path_elems text[]) - jsonb_extract_path(from_json jsonb, VARIADIC path_elems text[]) - - jsonjsonb + + jsonb ?| text[] + boolean + + + Do any of the strings in the text array exist as top-level keys or + array elements? + + + '{"a":1, "b":2, "c":3}'::jsonb ?| array['b', 'd'] + t - - Returns JSON value pointed to by path_elems - (equivalent to #> operator). - - json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}','f4') - {"f5":99,"f6":"foo"} + - json_extract_path_text(from_json json, VARIADIC path_elems text[]) - jsonb_extract_path_text(from_json jsonb, VARIADIC path_elems text[]) + + jsonb ?& text[] + boolean + + + Do all of the strings in the text array exist as top-level keys or + array elements? + + + '["a", "b", "c"]'::jsonb ?& array['a', 'b'] + t - text - - Returns JSON value pointed to by path_elems - as text - (equivalent to #>> operator). - - json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}','f4', 'f6') - foo + - json_object_keys(json) - jsonb_object_keys(jsonb) + + jsonb || jsonb + jsonb + + + Concatenates two jsonb values. + Concatenating two objects generates an object with the union of their + keys, taking the second object's value when there are duplicate keys. + Does not operate recursively: only the top-level array or object + structure is merged. + + + '["a", "b"]'::jsonb || '["a", "d"]'::jsonb + ["a", "b", "a", "d"] + + + '{"a": "b"}'::jsonb || '{"c": "d"}'::jsonb + {"a": "b", "c": "d"} - setof text - - Returns set of keys in the outermost JSON object. - - json_object_keys('{"f1":"abc","f2":{"f3":"a", "f4":"b"}}') - - - json_object_keys ------------------- - f1 - f2 - - + - json_populate_record(base anyelement, from_json json) - jsonb_populate_record(base anyelement, from_json jsonb) + + jsonb - text + jsonb + + + Deletes a key (and its value) from a JSON object, or matching string + value(s) from a JSON array. + + + '{"a": "b", "c": "d"}'::jsonb - 'a' + {"c": "d"} + + + '["a", "b", "c", "b"]'::jsonb - 'b' + ["a", "c"] - anyelement - - Expands the object in from_json to a row - whose columns match the record type defined by base - (see note below). - - select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}') - - - a | b | c ----+-----------+------------- - 1 | {2,"a b"} | (4,"a b c") - - + - json_populate_recordset(base anyelement, from_json json) - jsonb_populate_recordset(base anyelement, from_json jsonb) + + jsonb - text[] + jsonb + + + Deletes all matching keys or array elements from the left operand. + + + '{"a": "b", "c": "d"}'::jsonb - '{a,c}'::text[] + {} - setof anyelement - - Expands the outermost array of objects - in from_json to a set of rows whose - columns match the record type defined by base (see - note below). - - select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]') - - - a | b ----+--- - 1 | 2 - 3 | 4 - - + - json_array_elements(json) - jsonb_array_elements(jsonb) - - setof json - setof jsonb + + jsonb - integer + jsonb + + + Deletes the array element with specified index (negative + integers count from the end). Throws an error if JSON value + is not an array. + + + '["a", "b"]'::jsonb - 1 + ["a"] - - Expands a JSON array to a set of JSON values. - - select * from json_array_elements('[1,true, [2,false]]') - - - value ------------ - 1 - true - [2,false] - - + - json_array_elements_text(json) - jsonb_array_elements_text(jsonb) - - setof text - - Expands a JSON array to a set of text values. - - select * from json_array_elements_text('["foo", "bar"]') - - - value ------------ - foo - bar - - - - - json_typeof(json) - jsonb_typeof(jsonb) + + jsonb #- text[] + jsonb + + + Deletes the field or array element at the specified path, where path + elements can be either field keys or array indexes. + + + '["a", {"b":1}]'::jsonb #- '{1,b}' + ["a", {}] - text - - Returns the type of the outermost JSON value as a text string. - Possible types are - object, array, string, number, - boolean, and null. - - json_typeof('-123.4') - number + - json_to_record(json) - jsonb_to_record(jsonb) + + jsonb @? jsonpath + boolean + + + Does JSON path return any item for the specified JSON value? + + + '{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)' + t - record - - Builds an arbitrary record from a JSON object (see note below). As - with all functions returning record, the caller must - explicitly define the structure of the record with an AS - clause. - - select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype) - - - a | b | c | d | r ----+---------+---------+---+--------------- - 1 | [1,2,3] | {1,2,3} | | (123,"a b c") - - + - json_to_recordset(json) - jsonb_to_recordset(jsonb) + + jsonb @@ jsonpath + boolean + + + Returns the result of a JSON path predicate check for the + specified JSON value. Only the first item of the result is taken into + account. If the result is not Boolean, then NULL + is returned. + + + '{"a":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2' + t - setof record - - Builds an arbitrary set of records from a JSON array of objects (see - note below). As with all functions returning record, the - caller must explicitly define the structure of the record with - an AS clause. - - select * from json_to_recordset('[{"a":1,"b":"foo"},{"a":"2","c":"bar"}]') as x(a int, b text); - - - a | b ----+----- - 1 | foo - 2 | - - - - json_strip_nulls(from_json json) - jsonb_strip_nulls(from_json jsonb) - - jsonjsonb - - Returns from_json - with all object fields that have null values omitted. Other null values - are untouched. - - json_strip_nulls('[{"f1":1,"f2":null},2,null,3]') - [{"f1":1},2,null,3] - - - jsonb_set(target jsonb, path text[], new_value jsonb , create_missing boolean) - - jsonb - - Returns target - with the section designated by path - replaced by new_value, or with - new_value added if - create_missing is true (default is - true) and the item - designated by path does not exist. - As with the path oriented operators, negative integers that - appear in path count from the end - of JSON arrays. - - jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0,f1}','[2,3,4]', false) - jsonb_set('[{"f1":1,"f2":null},2]', '{0,f3}','[2,3,4]') - - [{"f1":[2,3,4],"f2":null},2,null,3] - [{"f1": 1, "f2": null, "f3": [2, 3, 4]}, 2] - - - - jsonb_set_lax(target jsonb, path text[], new_value jsonb , create_missing boolean , null_value_treatment text) - - jsonb - - If new_value is not null, - behaves identically to jsonb_set. Otherwise behaves - according to the value of null_value_treatment - which must be one of 'raise_exception', - 'use_json_null', 'delete_key', or - 'return_target'. The default is - 'use_json_null'. - - jsonb_set_lax('[{"f1":1,"f2":null},2,null,3]', '{0,f1}',null) - jsonb_set_lax('[{"f1":99,"f2":null},2]', '{0,f3}',null, true, 'return_target') - - [{"f1":null,"f2":null},2,null,3] - [{"f1": 99, "f2": null}, 2] - - - - - - jsonb_insert(target jsonb, path text[], new_value jsonb , insert_after boolean) - - - jsonb - - Returns target with - new_value inserted. If - target section designated by - path is in a JSONB array, - new_value will be inserted before target or - after if insert_after is true (default is - false). If target section - designated by path is in JSONB object, - new_value will be inserted only if - target does not exist. As with the path - oriented operators, negative integers that appear in - path count from the end of JSON arrays. - - - - jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"') - - - jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"', true) - - - {"a": [0, "new_value", 1, 2]} - {"a": [0, 1, "new_value", 2]} - - - - jsonb_pretty(from_json jsonb) - - text - - Returns from_json - as indented JSON text. - - jsonb_pretty('[{"f1":1,"f2":null},2,null,3]') - - -[ - { - "f1": 1, - "f2": null - }, - 2, - null, - 3 -] - - - - - - - jsonb_path_exists(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb_path_exists_tz(target jsonb, path jsonpath , vars jsonb , silent bool) - - - boolean - - Checks whether JSON path returns any item for the specified JSON - value. - - - - jsonb_path_exists('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') - - - - true - - - - - - jsonb_path_match(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb_path_match_tz(target jsonb, path jsonpath , vars jsonb , silent bool) - - - boolean - - Returns the result of JSON path predicate check for the specified JSON value. - Only the first item of the result is taken into account. If the - result is not Boolean, then null is returned. - - - - jsonb_path_match('{"a":[1,2,3,4,5]}', 'exists($.a[*] ? (@ >= $min && @ <= $max))', '{"min":2,"max":4}') - - - - true - - - - - - jsonb_path_query(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb_path_query_tz(target jsonb, path jsonpath , vars jsonb , silent bool) - - - setof jsonb - - Gets all JSON items returned by JSON path for the specified JSON - value. - - - - select * from jsonb_path_query('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}'); - - - - - - jsonb_path_query ------------------- - 2 - 3 - 4 - - - - - - - - jsonb_path_query_array(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb_path_query_array_tz(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb - - Gets all JSON items returned by JSON path for the specified JSON - value and wraps result into an array. - - - - jsonb_path_query_array('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') - - - - [2, 3, 4] - - - - - - jsonb_path_query_first(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb_path_query_first_tz(target jsonb, path jsonpath , vars jsonb , silent bool) - - - jsonb - - Gets the first JSON item returned by JSON path for the specified JSON - value. Returns NULL on no results. - - - - jsonb_path_query_first('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') - - - - 2 - -
- - Many of these functions and operators will convert Unicode escapes in - JSON strings to the appropriate single character. This is a non-issue - if the input is type jsonb, because the conversion was already - done; but for json input, this may result in throwing an error, - as noted in . - - - - - - The functions - json[b]_populate_record, - json[b]_populate_recordset, - json[b]_to_record and - json[b]_to_recordset - operate on a JSON object, or array of objects, and extract the values - associated with keys whose names match column names of the output row - type. - Object fields that do not correspond to any output column name are - ignored, and output columns that do not match any object field will be - filled with nulls. - To convert a JSON value to the SQL type of an output column, the - following rules are applied in sequence: - - - - A JSON null value is converted to a SQL null in all cases. - - - - - If the output column is of type json - or jsonb, the JSON value is just reproduced exactly. - - - - - If the output column is a composite (row) type, and the JSON value is - a JSON object, the fields of the object are converted to columns of - the output row type by recursive application of these rules. - - - - - Likewise, if the output column is an array type and the JSON value is - a JSON array, the elements of the JSON array are converted to elements - of the output array by recursive application of these rules. - - - - - Otherwise, if the JSON value is a string literal, the contents of the - string are fed to the input conversion function for the column's data - type. - - - - - Otherwise, the ordinary text representation of the JSON value is fed - to the input conversion function for the column's data type. - - - - - - - While the examples for these functions use constants, the typical use - would be to reference a table in the FROM clause - and use one of its json or jsonb columns - as an argument to the function. Extracted key values can then be - referenced in other parts of the query, like WHERE - clauses and target lists. Extracting multiple values in this - way can improve performance over extracting them separately with - per-key operators. - - - - - - All the items of the path parameter of jsonb_set - as well as jsonb_insert except the last item must be present - in the target. If create_missing is false, all - items of the path parameter of jsonb_set must be - present. If these conditions are not met the target is - returned unchanged. - - - If the last path item is an object key, it will be created if it - is absent and given the new value. If the last path item is an array - index, if it is positive the item to set is found by counting from - the left, and if negative by counting from the right - -1 - designates the rightmost element, and so on. - If the item is out of the range -array_length .. array_length -1, - and create_missing is true, the new value is added at the beginning - of the array if the item is negative, and at the end of the array if - it is positive. - - - - - - The json_typeof function's null return value - should not be confused with a SQL NULL. While - calling json_typeof('null'::json) will - return null, calling json_typeof(NULL::json) - will return a SQL NULL. - - - - - - If the argument to json_strip_nulls contains duplicate - field names in any object, the result could be semantically somewhat - different, depending on the order in which they occur. This is not an - issue for jsonb_strip_nulls since jsonb values never have - duplicate object field names. - - - - - - The jsonb_path_* functions have optional - vars and silent arguments. - - - If the vars argument is specified, it provides an - object containing named variables to be substituted into a - jsonpath expression. - - - If the silent argument is specified and has the - true value, these functions suppress the same errors - as the @? and @@ operators. - - - - - Some of the jsonb_path_* functions have a - _tz suffix. These functions have been implemented to - support comparison of date/time values that involves implicit - timezone-aware casts. Since operations with time zones are not immutable, - these functions are qualified as stable. Their counterparts without the - suffix do not support such casts, so they are immutable and can be used for - such use-cases as expression indexes - (see ). There is no difference - between these functions for other jsonpath operations. + The jsonpath operators @? + and @@ suppress the following errors: missing object + field or array element, unexpected JSON item type, datetime and numeric + errors. The jsonpath-related functions described below can + also be told to suppress these types of errors. This behavior might be + helpful when searching JSON document collections of varying structure. - See also for the aggregate - function json_agg which aggregates record - values as JSON, and the aggregate function - json_object_agg which aggregates pairs of values - into a JSON object, and their jsonb equivalents, - jsonb_agg and jsonb_object_agg. + shows the functions that are + available for constructing json and jsonb values. - - - - The SQL/JSON Path Language - - SQL/JSON path language - + + JSON Creation Functions + + + + + Function + + + Description + + + Example(s) + + + - - SQL/JSON path expressions specify the items to be retrieved - from the JSON data, similar to XPath expressions used - for SQL access to XML. In PostgreSQL, - path expressions are implemented as the jsonpath - data type and can use any elements described in - . - + + + + + to_json + + to_json ( anyelement ) + json + + + + to_jsonb + + to_jsonb ( anyelement ) + jsonb + + + Converts any SQL value to json or jsonb. + Arrays and composites are converted recursively to arrays and + objects (multidimensional arrays become arrays of arrays in JSON). + Otherwise, if there is a cast from the SQL data type + to json, the cast function will be used to perform the + conversion; + + For example, the extension has a cast + from hstore to json, so that + hstore values converted via the JSON creation functions + will be represented as JSON objects, not as primitive string values. + + + otherwise, a scalar JSON value is produced. For any scalar other than + a number, a Boolean, or a null value, the text representation will be + used, with escaping as necessary to make it a valid JSON string value. + + + to_json('Fred said "Hi."'::text) + "Fred said \"Hi.\"" + + + to_jsonb(row(42, 'Fred said "Hi."'::text)) + {"f1": 42, "f2": "Fred said \"Hi.\""} + + - JSON query functions and operators - pass the provided path expression to the path engine - for evaluation. If the expression matches the queried JSON data, - the corresponding SQL/JSON item is returned. - Path expressions are written in the SQL/JSON path language - and can also include arithmetic expressions and functions. - Query functions treat the provided expression as a - text string, so it must be enclosed in single quotes. - + + + + array_to_json + + array_to_json ( anyarray , boolean ) + json + + + Converts a SQL array to a JSON array. The behavior is the same + as to_json except that line feeds will be added + between top-level array elements if the optional boolean parameter is + true. + + + array_to_json('{{1,5},{99,100}}'::int[]) + [[1,5],[99,100]] + + - - A path expression consists of a sequence of elements allowed - by the jsonpath data type. - The path expression is evaluated from left to right, but - you can use parentheses to change the order of operations. - If the evaluation is successful, a sequence of SQL/JSON items - (SQL/JSON sequence) is produced, - and the evaluation result is returned to the JSON query function - that completes the specified computation. - + + + + row_to_json + + row_to_json ( record , boolean ) + json + + + Converts a SQL composite value to a JSON object. The behavior is the + same as to_json except that line feeds will be + added between top-level elements if the optional boolean parameter is + true. + + + row_to_json(row(1,'foo')) + {"f1":1,"f2":"foo"} + + - - To refer to the JSON data to be queried (the - context item), use the $ sign - in the path expression. It can be followed by one or more - accessor operators, - which go down the JSON structure level by level to retrieve the - content of context item. Each operator that follows deals with the - result of the previous evaluation step. - + + + + json_build_array + + json_build_array ( VARIADIC "any" ) + json + + + + jsonb_build_array + + jsonb_build_array ( VARIADIC "any" ) + jsonb + + + Builds a possibly-heterogeneously-typed JSON array out of a variadic + argument list. Each argument is converted as + per to_json or to_jsonb. + + + json_build_array(1,2,'foo',4,5) + [1, 2, "foo", 4, 5] + + - - For example, suppose you have some JSON data from a GPS tracker that you - would like to parse, such as: - -{ - "track": { - "segments": [ - { - "location": [ 47.763, 13.4034 ], - "start time": "2018-10-14 10:05:14", - "HR": 73 - }, - { - "location": [ 47.706, 13.2635 ], - "start time": "2018-10-14 10:39:21", - "HR": 135 - } - ] - } -} - - + + + + json_build_object + + json_build_object ( VARIADIC "any" ) + json + + + + jsonb_build_object + + jsonb_build_object ( VARIADIC "any" ) + jsonb + + + Builds a JSON object out of a variadic argument list. By convention, + the argument list consists of alternating keys and values. Key + arguments are coerced to text; value arguments are converted as + per to_json or to_jsonb. + + + json_build_object('foo',1,2,row(3,'bar')) + {"foo" : 1, "2" : {"f1":3,"f2":"bar"}} + + - - To retrieve the available track segments, you need to use the - .key accessor - operator for all the preceding JSON objects: - -'$.track.segments' - - + + + + json_object + + json_object ( text[] ) + json + + + + jsonb_object + + jsonb_object ( text[] ) + jsonb + + + Builds a JSON object out of a text array. The array must have either + exactly one dimension with an even number of members, in which case + they are taken as alternating key/value pairs, or two dimensions + such that each inner array has exactly two elements, which + are taken as a key/value pair. All values are converted to JSON + strings. + + + json_object('{a, 1, b, "def", c, 3.5}') + {"a" : "1", "b" : "def", "c" : "3.5"} + + json_object('{{a, 1},{b, "def"},{c, 3.5}}') + {"a" : "1", "b" : "def", "c" : "3.5"} + + + + + + json_object ( keys text[], values text[] ) + json + + + jsonb_object ( keys text[], values text[] ) + jsonb + + + This form of json_object takes keys and values + pairwise from separate text arrays. Otherwise it is identical to + the one-argument form. + + + json_object('{a, b}', '{1,2}') + {"a": "1", "b": "2"} + + + + +
- If the item to retrieve is an element of an array, you have - to unnest this array using the [*] operator. For example, - the following path will return location coordinates for all - the available track segments: - -'$.track.segments[*].location' - + shows the functions that + are available for processing json and jsonb values. - - To return the coordinates of the first segment only, you can - specify the corresponding subscript in the [] - accessor operator. Note that the SQL/JSON arrays are 0-relative: + + JSON Processing Functions + + + + + Function + + + Description + + + Example(s) + + + + + + + + + json_array_elements + + json_array_elements ( json ) + setof json + + + + jsonb_array_elements + + jsonb_array_elements ( jsonb ) + setof jsonb + + + Expands the top-level JSON array into a set of JSON values. + + + select * from json_array_elements('[1,true, [2,false]]') + -'$.track.segments[0].location' + value +----------- + 1 + true + [2,false] - +
+ - - The result of each path evaluation step can be processed - by one or more jsonpath operators and methods - listed in . - Each method name must be preceded by a dot. For example, - you can get an array size: + + + + json_array_elements_text + + json_array_elements_text ( json ) + setof text + + + + jsonb_array_elements_text + + jsonb_array_elements_text ( jsonb ) + setof text + + + Expands the top-level JSON array into a set of text values. + + + select * from json_array_elements_text('["foo", "bar"]') + -'$.track.segments.size()' + value +----------- + foo + bar - For more examples of using jsonpath operators - and methods within path expressions, see - . - + + - - When defining the path, you can also use one or more - filter expressions that work similar to the - WHERE clause in SQL. A filter expression begins with - a question mark and provides a condition in parentheses: + + + + json_array_length + + json_array_length ( json ) + integer + + + + jsonb_array_length + + jsonb_array_length ( jsonb ) + integer + + + Returns the number of elements in the top-level JSON array. + + + json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') + 5 + + + + + + json_each + + json_each ( json ) + setof key text, + value json + + + + jsonb_each + + jsonb_each ( jsonb ) + setof key text, + value jsonb + + + Expands the top-level JSON object into a set of key/value pairs. + + + select * from json_each('{"a":"foo", "b":"bar"}') + -? (condition) + key | value +-----+------- + a | "foo" + b | "bar" - - - - Filter expressions must be specified right after the path evaluation step - to which they are applied. The result of this step is filtered to include - only those items that satisfy the provided condition. SQL/JSON defines - three-valued logic, so the condition can be true, false, - or unknown. The unknown value - plays the same role as SQL NULL and can be tested - for with the is unknown predicate. Further path - evaluation steps use only those items for which filter expressions - return true. - - - - Functions and operators that can be used in filter expressions are listed - in . The path - evaluation result to be filtered is denoted by the @ - variable. To refer to a JSON element stored at a lower nesting level, - add one or more accessor operators after @. - + + - - Suppose you would like to retrieve all heart rate values higher - than 130. You can achieve this using the following expression: + + + + json_each_text + + json_each_text ( json ) + setof key text, + value text + + + + jsonb_each_text + + jsonb_each_text ( jsonb ) + setof key text, + value text + + + Expands the top-level JSON object into a set of key/value pairs. + The returned values will be of + type text. + + + select * from json_each_text('{"a":"foo", "b":"bar"}') + -'$.track.segments[*].HR ? (@ > 130)' + key | value +-----+------- + a | foo + b | bar - + + - - To get the start time of segments with such values instead, you have to - filter out irrelevant segments before returning the start time, so the - filter expression is applied to the previous step, and the path used - in the condition is different: + + + + json_extract_path + + json_extract_path ( from_json json, VARIADIC path_elems text[] ) + json + + + + jsonb_extract_path + + jsonb_extract_path ( from_json jsonb, VARIADIC path_elems text[] ) + jsonb + + + Extracts JSON sub-object at the specified path. + (This is functionally equivalent to the #> + operator, but writing the path out as a variadic list can be more + convenient in some cases.) + + + json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}', 'f4', 'f6') + "foo" + + + + + + + json_extract_path_text + + json_extract_path_text ( from_json json, VARIADIC path_elems text[] ) + text + + + + jsonb_extract_path_text + + jsonb_extract_path_text ( from_json jsonb, VARIADIC path_elems text[] ) + text + + + Extracts JSON sub-object at the specified path as text. + (This is functionally equivalent to the #>> + operator.) + + + json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}', 'f4', 'f6') + foo + + + + + + + json_object_keys + + json_object_keys ( json ) + setof text + + + + jsonb_object_keys + + jsonb_object_keys ( jsonb ) + setof text + + + Returns the set of keys in the top-level JSON object. + + + select * from json_object_keys('{"f1":"abc","f2":{"f3":"a", "f4":"b"}}') + -'$.track.segments[*] ? (@.HR > 130)."start time"' + json_object_keys +------------------ + f1 + f2 - + + - - You can use several filter expressions on the same nesting level, if - required. For example, the following expression selects all segments - that contain locations with relevant coordinates and high heart rate values: + + + + json_populate_record + + json_populate_record ( base anyelement, from_json json ) + anyelement + + + + jsonb_populate_record + + jsonb_populate_record ( base anyelement, from_json jsonb ) + anyelement + + + Expands the top-level JSON object to a row having the composite type + of the base argument. The JSON object + is scanned for fields whose names match column names of the output row + type, and their values are inserted into those columns of the output. + (Fields that do not correspond to any output column name are ignored.) + In typical use, the value of base is just + NULL, which means that any output columns that do + not match any object field will be filled with nulls. However, + if base isn't NULL then + the values it contains will be used for unmatched columns. + + + To convert a JSON value to the SQL type of an output column, the + following rules are applied in sequence: + + + + A JSON null value is converted to a SQL null in all cases. + + + + + If the output column is of type json + or jsonb, the JSON value is just reproduced exactly. + + + + + If the output column is a composite (row) type, and the JSON value + is a JSON object, the fields of the object are converted to columns + of the output row type by recursive application of these rules. + + + + + Likewise, if the output column is an array type and the JSON value + is a JSON array, the elements of the JSON array are converted to + elements of the output array by recursive application of these + rules. + + + + + Otherwise, if the JSON value is a string, the contents of the + string are fed to the input conversion function for the column's + data type. + + + + + Otherwise, the ordinary text representation of the JSON value is + fed to the input conversion function for the column's data type. + + + + + + While the example below uses a constant JSON value, typical use would + be to reference a json or jsonb column + laterally from another table in the query's FROM + clause. Writing json_populate_record in + the FROM clause is good practice, since all of the + extracted columns are available for use without duplicate function + calls. + + + select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}') + -'$.track.segments[*] ? (@.location[1] < 13.4) ? (@.HR > 130)."start time"' + a | b | c +---+-----------+------------- + 1 | {2,"a b"} | (4,"a b c") - + + - - Using filter expressions at different nesting levels is also allowed. - The following example first filters all segments by location, and then - returns high heart rate values for these segments, if available: + + + + json_populate_recordset + + json_populate_recordset ( base anyelement, from_json json ) + setof anyelement + + + + jsonb_populate_recordset + + jsonb_populate_recordset ( base anyelement, from_json jsonb ) + setof anyelement + + + Expands the top-level JSON array of objects to a set of rows having + the composite type of the base argument. + Each element of the JSON array is processed as described above + for json[b]_populate_record. + + + select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]') + -'$.track.segments[*] ? (@.location[1] < 13.4).HR ? (@ > 130)' + a | b +---+--- + 1 | 2 + 3 | 4 - + + - - You can also nest filter expressions within each other: + + + + json_to_record + + json_to_record ( json ) + record + + + + jsonb_to_record + + jsonb_to_record ( jsonb ) + record + + + Expands the top-level JSON object to a row having the composite type + defined by an AS clause. (As with all functions + returning record, the calling query must explicitly + define the structure of the record with an AS + clause.) The output record is filled from fields of the JSON object, + in the same way as described above + for json[b]_populate_record. Since there is no + input record value, unmatched columns are always filled with nulls. + + + select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype) + -'$.track ? (exists(@.segments[*] ? (@.HR > 130))).segments.size()' + a | b | c | d | r +---+---------+---------+---+--------------- + 1 | [1,2,3] | {1,2,3} | | (123,"a b c") - This expression returns the size of the track if it contains any - segments with high heart rate values, or an empty sequence otherwise. - - - - PostgreSQL's implementation of SQL/JSON path - language has the following deviations from the SQL/JSON standard: - + + - - - - A path expression can be a Boolean predicate, although the SQL/JSON - standard allows predicates only in filters. This is necessary for - implementation of the @@ operator. For example, - the following jsonpath expression is valid in - PostgreSQL: + + + + json_to_recordset + + json_to_recordset ( json ) + setof record + + + + jsonb_to_recordset + + jsonb_to_recordset ( jsonb ) + setof record + + + Expands the top-level JSON array of objects to a set of rows having + the composite type defined by an AS clause. (As + with all functions returning record, the calling query + must explicitly define the structure of the record with + an AS clause.) Each element of the JSON array is + processed as described above + for json[b]_populate_record. + + + select * from json_to_recordset('[{"a":1,"b":"foo"},{"a":"2","c":"bar"}]') as x(a int, b text) + -'$.track.segments[*].HR < 70' + a | b +---+----- + 1 | foo + 2 | - - + + - - - There are minor differences in the interpretation of regular - expression patterns used in like_regex filters, as - described in . - - - + + + + jsonb_set + + jsonb_set ( target jsonb, path text[], new_value jsonb , create_if_missing boolean ) + jsonb + + + Returns target + with the item designated by path + replaced by new_value, or with + new_value added if + create_if_missing is true (which is the + default) and the item designated by path + does not exist. + All earlier steps in the path must exist, or + the target is returned unchanged. + As with the path oriented operators, negative integers that + appear in the path count from the end + of JSON arrays. + If the last path step is an array index that is out of range, + and create_if_missing is true, the new + value is added at the beginning of the array if the index is negative, + or at the end of the array if it is positive. + + + jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0,f1}','[2,3,4]', false) + [{"f1": [2, 3, 4], "f2": null}, 2, null, 3] + + + jsonb_set('[{"f1":1,"f2":null},2]', '{0,f3}','[2,3,4]') + [{"f1": 1, "f2": null, "f3": [2, 3, 4]}, 2] + + - - Strict and Lax Modes - - When you query JSON data, the path expression may not match the - actual JSON data structure. An attempt to access a non-existent - member of an object or element of an array results in a - structural error. SQL/JSON path expressions have two modes - of handling structural errors: - + + + + jsonb_set_lax + + jsonb_set_lax ( target jsonb, path text[], new_value jsonb , create_if_missing boolean , null_value_treatment text ) + jsonb + + + If new_value is not null, + behaves identically to jsonb_set. Otherwise behaves + according to the value + of null_value_treatment which must be one + of 'raise_exception', + 'use_json_null', 'delete_key', or + 'return_target'. The default is + 'use_json_null'. + + + jsonb_set_lax('[{"f1":1,"f2":null},2,null,3]', '{0,f1}',null) + [{"f1":null,"f2":null},2,null,3] + + + jsonb_set_lax('[{"f1":99,"f2":null},2]', '{0,f3}',null, true, 'return_target') + [{"f1": 99, "f2": null}, 2] + + + + + + + jsonb_insert + + jsonb_insert ( target jsonb, path text[], new_value jsonb , insert_after boolean ) + jsonb + + + Returns target + with new_value inserted. If the item + designated by the path is an array + element, new_value will be inserted before + that item if insert_after is false (which + is the default), or after it + if insert_after is true. If the item + designated by the path is an object + field, new_value will be inserted only if + the object does not already contain that key. + All earlier steps in the path must exist, or + the target is returned unchanged. + As with the path oriented operators, negative integers that + appear in the path count from the end + of JSON arrays. + If the last path step is an array index that is out of range, the new + value is added at the beginning of the array if the index is negative, + or at the end of the array if it is positive. + + + jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"') + {"a": [0, "new_value", 1, 2]} + + + jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"', true) + {"a": [0, 1, "new_value", 2]} + + + + + + + json_strip_nulls + + json_strip_nulls ( json ) + json + + + + jsonb_strip_nulls + + jsonb_strip_nulls ( jsonb ) + jsonb + + + Deletes all object fields that have null values from the given JSON + value, recursively. Null values that are not object fields are + untouched. + + + json_strip_nulls('[{"f1":1,"f2":null},2,null,3]') + [{"f1":1},2,null,3] + + + + + + + jsonb_path_exists + + jsonb_path_exists ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + boolean + + + Checks whether the JSON path returns any item for the specified JSON + value. + If the vars argument is specified, it must + be a JSON object, and its fields provide named values to be + substituted into the jsonpath expression. + If the silent argument is specified and + is true, the function suppresses the same errors + as the @? and @@ operators do. + + + jsonb_path_exists('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') + t + + + + + + + jsonb_path_match + + jsonb_path_match ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + boolean + + + Returns the result of a JSON path predicate check for the specified + JSON value. Only the first item of the result is taken into account. + If the result is not Boolean, then NULL is returned. + The optional vars + and silent arguments act the same as + for jsonb_path_exists. + + + jsonb_path_match('{"a":[1,2,3,4,5]}', 'exists($.a[*] ? (@ >= $min && @ <= $max))', '{"min":2,"max":4}') + t + + + + + + + jsonb_path_query + + jsonb_path_query ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + setof jsonb + + + Returns all JSON items returned by the JSON path for the specified + JSON value. + The optional vars + and silent arguments act the same as + for jsonb_path_exists. + + + select * from jsonb_path_query('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') + + + jsonb_path_query +------------------ + 2 + 3 + 4 + + + + + + + + jsonb_path_query_array + + jsonb_path_query_array ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + jsonb + + + Returns all JSON items returned by the JSON path for the specified + JSON value, as a JSON array. + The optional vars + and silent arguments act the same as + for jsonb_path_exists. + + + jsonb_path_query_array('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') + [2, 3, 4] + + + + + + + jsonb_path_query_first + + jsonb_path_query_first ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + jsonb + + + Returns the first JSON item returned by the JSON path for the + specified JSON value. Returns NULL if there are no + results. + The optional vars + and silent arguments act the same as + for jsonb_path_exists. + + + jsonb_path_query_first('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= $min && @ <= $max)', '{"min":2,"max":4}') + 2 + + + + + + + jsonb_path_exists_tz + + jsonb_path_exists_tz ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + boolean + + + + jsonb_path_match_tz + + jsonb_path_match_tz ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + boolean + + + + jsonb_path_query_tz + + jsonb_path_query_tz ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + setof jsonb + + + + jsonb_path_query_array_tz + + jsonb_path_query_array_tz ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + jsonb + + + + jsonb_path_query_first_tz + + jsonb_path_query_first_tz ( target jsonb, path jsonpath , vars jsonb , silent boolean ) + jsonb + + + These functions act like their counterparts described above without + the _tz suffix, except that these functions support + comparisons of date/time values that require timezone-aware + conversions. The example below requires interpretation of the + date-only value 2015-08-02 as a timestamp with time + zone, so the result depends on the current + setting. Due to this dependency, these + functions are marked as stable, which means these functions cannot be + used in indexes. Their counterparts are immutable, and so can be used + in indexes; but they will throw errors if asked to make such + comparisons. + + + jsonb_path_exists_tz('["2015-08-01 12:00:00 -05"]', '$[*] ? (@.datetime() < "2015-08-02".datetime())') + t + + + + + + + jsonb_pretty + + jsonb_pretty ( jsonb ) + text + + + Converts the given JSON value to pretty-printed, indented text. + + + jsonb_pretty('[{"f1":1,"f2":null},2]') + + +[ + { + "f1": 1, + "f2": null + }, + 2 +] + + + + + + + + json_typeof + + json_typeof ( json ) + text + + + + jsonb_typeof + + jsonb_typeof ( jsonb ) + text + + + Returns the type of the top-level JSON value as a text string. + Possible types are + object, array, + string, number, + boolean, and null. + (The null result should not be confused + with a SQL NULL; see the examples.) + + + json_typeof('-123.4') + number + + + json_typeof('null'::json) + null + + + json_typeof(NULL::json) IS NULL + t + + + + + + + + See also for the aggregate + function json_agg which aggregates record + values as JSON, the aggregate function + json_object_agg which aggregates pairs of values + into a JSON object, and their jsonb equivalents, + jsonb_agg and jsonb_object_agg. + + + + + The SQL/JSON Path Language + + + SQL/JSON path language + + + + SQL/JSON path expressions specify the items to be retrieved + from the JSON data, similar to XPath expressions used + for SQL access to XML. In PostgreSQL, + path expressions are implemented as the jsonpath + data type and can use any elements described in + . + + + + JSON query functions and operators + pass the provided path expression to the path engine + for evaluation. If the expression matches the queried JSON data, + the corresponding JSON item, or set of items, is returned. + Path expressions are written in the SQL/JSON path language + and can include arithmetic expressions and functions. + + + + A path expression consists of a sequence of elements allowed + by the jsonpath data type. + The path expression is normally evaluated from left to right, but + you can use parentheses to change the order of operations. + If the evaluation is successful, a sequence of JSON items is produced, + and the evaluation result is returned to the JSON query function + that completes the specified computation. + + + + To refer to the JSON value being queried (the + context item), use the $ variable + in the path expression. It can be followed by one or more + accessor operators, + which go down the JSON structure level by level to retrieve sub-items + of the context item. Each operator that follows deals with the + result of the previous evaluation step. + + + + For example, suppose you have some JSON data from a GPS tracker that you + would like to parse, such as: + +{ + "track": { + "segments": [ + { + "location": [ 47.763, 13.4034 ], + "start time": "2018-10-14 10:05:14", + "HR": 73 + }, + { + "location": [ 47.706, 13.2635 ], + "start time": "2018-10-14 10:39:21", + "HR": 135 + } + ] + } +} + + + + + To retrieve the available track segments, you need to use the + .key accessor + operator to descend through surrounding JSON objects: + +$.track.segments + + + + + To retrieve the contents of an array, you typically use the + [*] operator. For example, + the following path will return the location coordinates for all + the available track segments: + +$.track.segments[*].location + + + + + To return the coordinates of the first segment only, you can + specify the corresponding subscript in the [] + accessor operator. Recall that JSON array indexes are 0-relative: + +$.track.segments[0].location + + + + + The result of each path evaluation step can be processed + by one or more jsonpath operators and methods + listed in . + Each method name must be preceded by a dot. For example, + you can get the size of an array: + +$.track.segments.size() + + More examples of using jsonpath operators + and methods within path expressions appear below in + . + + + + When defining a path, you can also use one or more + filter expressions that work similarly to the + WHERE clause in SQL. A filter expression begins with + a question mark and provides a condition in parentheses: + + +? (condition) + + + + + Filter expressions must be written just after the path evaluation step + to which they should apply. The result of that step is filtered to include + only those items that satisfy the provided condition. SQL/JSON defines + three-valued logic, so the condition can be true, false, + or unknown. The unknown value + plays the same role as SQL NULL and can be tested + for with the is unknown predicate. Further path + evaluation steps use only those items for which the filter expression + returned true. + + + + The functions and operators that can be used in filter expressions are + listed in . Within a + filter expression, the @ variable denotes the value + being filtered (i.e., one result of the preceding path step). You can + write accessor operators after @ to retrieve component + items. + + + + For example, suppose you would like to retrieve all heart rate values higher + than 130. You can achieve this using the following expression: + +$.track.segments[*].HR ? (@ > 130) + + + + + To get the start times of segments with such values, you have to + filter out irrelevant segments before returning the start times, so the + filter expression is applied to the previous step, and the path used + in the condition is different: + +$.track.segments[*] ? (@.HR > 130)."start time" + + + + + You can use several filter expressions in sequence, if required. For + example, the following expression selects start times of all segments that + contain locations with relevant coordinates and high heart rate values: + +$.track.segments[*] ? (@.location[1] < 13.4) ? (@.HR > 130)."start time" + + + + + Using filter expressions at different nesting levels is also allowed. + The following example first filters all segments by location, and then + returns high heart rate values for these segments, if available: + +$.track.segments[*] ? (@.location[1] < 13.4).HR ? (@ > 130) + + + + + You can also nest filter expressions within each other: + +$.track ? (exists(@.segments[*] ? (@.HR > 130))).segments.size() + + This expression returns the size of the track if it contains any + segments with high heart rate values, or an empty sequence otherwise. + + + + PostgreSQL's implementation of the SQL/JSON path + language has the following deviations from the SQL/JSON standard: + + + + + + A path expression can be a Boolean predicate, although the SQL/JSON + standard allows predicates only in filters. This is necessary for + implementation of the @@ operator. For example, + the following jsonpath expression is valid in + PostgreSQL: + +$.track.segments[*].HR < 70 + + + + + + + There are minor differences in the interpretation of regular + expression patterns used in like_regex filters, as + described in . + + + + + + Strict and Lax Modes + + When you query JSON data, the path expression may not match the + actual JSON data structure. An attempt to access a non-existent + member of an object or element of an array results in a + structural error. SQL/JSON path expressions have two modes + of handling structural errors: + + + + + + lax (default) — the path engine implicitly adapts + the queried data to the specified path. + Any remaining structural errors are suppressed and converted + to empty SQL/JSON sequences. + + + + + strict — if a structural error occurs, an error is raised. + + + + + + The lax mode facilitates matching of a JSON document structure and path + expression if the JSON data does not conform to the expected schema. + If an operand does not match the requirements of a particular operation, + it can be automatically wrapped as an SQL/JSON array or unwrapped by + converting its elements into an SQL/JSON sequence before performing + this operation. Besides, comparison operators automatically unwrap their + operands in the lax mode, so you can compare SQL/JSON arrays + out-of-the-box. An array of size 1 is considered equal to its sole element. + Automatic unwrapping is not performed only when: + + + + The path expression contains type() or + size() methods that return the type + and the number of elements in the array, respectively. + + + + + The queried JSON data contain nested arrays. In this case, only + the outermost array is unwrapped, while all the inner arrays + remain unchanged. Thus, implicit unwrapping can only go one + level down within each path evaluation step. + + + + + + + For example, when querying the GPS data listed above, you can + abstract from the fact that it stores an array of segments + when using the lax mode: + +lax $.track.segments.location + + + + + In the strict mode, the specified path must exactly match the structure of + the queried JSON document to return an SQL/JSON item, so using this + path expression will cause an error. To get the same result as in + the lax mode, you have to explicitly unwrap the + segments array: + +strict $.track.segments[*].location + + + + + + + SQL/JSON Path Operators and Methods + + + shows the operators and + methods available in jsonpath. Note that while the unary + operators and methods can be applied to multiple values resulting from a + preceding path step, the binary operators (addition etc.) can only be + applied to single values. + + + + <type>jsonpath</type> Operators and Methods + + + + + Operator/Method + + + Description + + + Example(s) + + + + + + + + number + number + number + + + Addition + + + jsonb_path_query('[2]', '$[0] + 3') + 5 + + + + + + + number + number + + + Unary plus (no operation); unlike addition, this can iterate over + multiple values + + + jsonb_path_query_array('{"x": [2,3,4]}', '+ $.x') + [2, 3, 4] + + + + + + number - number + number + + + Subtraction + + + jsonb_path_query('[2]', '7 - $[0]') + 5 + + + + + + - number + number + + + Negation; unlike subtraction, this can iterate over + multiple values + + + jsonb_path_query_array('{"x": [2,3,4]}', '- $.x') + [-2, -3, -4] + + + + + + number * number + number + + + Multiplication + + + jsonb_path_query('[4]', '2 * $[0]') + 8 + + + + + + number / number + number + + + Division + + + jsonb_path_query('[8.5]', '$[0] / 2') + 4.2500000000000000 + + + + + + number % number + number + + + Modulo (remainder) + + + jsonb_path_query('[32]', '$[0] % 10') + 2 + + + + + + value . type() + string + + + Type of the JSON item (see json_typeof) + + + jsonb_path_query_array('[1, "2", {}]', '$[*].type()') + ["number", "string", "object"] + + + + + + value . size() + number + + + Size of the JSON item (number of array elements, or 1 if not an + array) + + + jsonb_path_query('{"m": [11, 15]}', '$.m.size()') + 2 + + + + + + value . double() + number + + + Approximate floating-point number converted from a JSON number or + string + + + jsonb_path_query('{"len": "1.9"}', '$.len.double() * 2') + 3.8 + + + + + + number . ceiling() + number + + + Nearest integer greater than or equal to the given number + + + jsonb_path_query('{"h": 1.3}', '$.h.ceiling()') + 2 + + + + + + number . floor() + number + + + Nearest integer less than or equal to the given number + + + jsonb_path_query('{"h": 1.7}', '$.h.floor()') + 1 + + + + + + number . abs() + number + + + Absolute value of the given number + + + jsonb_path_query('{"z": -0.3}', '$.z.abs()') + 0.3 + + + + + + string . datetime() + datetime_type + (see note) + + + Date/time value converted from a string + + + jsonb_path_query('["2015-8-1", "2015-08-12"]', '$[*] ? (@.datetime() < "2015-08-2".datetime())') + "2015-8-1" + + + + + + string . datetime(template) + datetime_type + (see note) + + + Date/time value converted from a string using the + specified to_timestamp template + + + jsonb_path_query_array('["12:30", "18:40"]', '$[*].datetime("HH24:MI")') + ["12:30:00", "18:40:00"] + + + + + + object . keyvalue() + array + + + The object's key-value pairs, represented as an array of objects + containing three fields: "key", + "value", and "id"; + "id" is a unique identifier of the object the + key-value pair belongs to + + + jsonb_path_query_array('{"x": "20", "y": 32}', '$.keyvalue()') + [{"id": 0, "key": "x", "value": "20"}, {"id": 0, "key": "y", "value": 32}] + + + + +
+ + + + The result type of the datetime() and + datetime(template) + methods can be date, timetz, time, + timestamptz, or timestamp. + Both methods determine their result type dynamically. + + + The datetime() method sequentially tries to + match its input string to the ISO formats + for date, timetz, time, + timestamptz, and timestamp. It stops on + the first matching format and emits the corresponding data type. + + + The datetime(template) + method determines the result type according to the fields used in the + provided template string. + + + The datetime() and + datetime(template) methods + use the same parsing rules as the to_timestamp SQL + function does (see ), with three + exceptions. First, these methods don't allow unmatched template + patterns. Second, only the following separators are allowed in the + template string: minus sign, period, solidus (slash), comma, apostrophe, + semicolon, colon and space. Third, separators in the template string + must exactly match the input string. + + + If different date/time types need to be compared, an implicit cast is + applied. A date value can be cast to timestamp + or timestamptz, timestamp can be cast to + timestamptz, and time to timetz. + However, all but the first of these conversions depend on the current + setting, and thus can only be performed + within timezone-aware jsonpath functions. + + + + + shows the available + filter expression elements. + + + + <type>jsonpath</type> Filter Expression Elements + + + + + Predicate/Value + + + Description + + + Example(s) + + + + + + + + value == value + boolean + + + Equality comparison (this, and the other comparison operators, work on + all JSON scalar values) + + + jsonb_path_query_array('[1, "a", 1, 3]', '$[*] ? (@ == 1)') + [1, 1] + + + jsonb_path_query_array('[1, "a", 1, 3]', '$[*] ? (@ == "a")') + ["a"] + + + + + + value != value + boolean + + + value <> value + boolean + + + Non-equality comparison + + + jsonb_path_query_array('[1, 2, 1, 3]', '$[*] ? (@ != 1)') + [2, 3] + + + jsonb_path_query_array('["a", "b", "c"]', '$[*] ? (@ <> "b")') + ["a", "c"] + + + + + + value < value + boolean + + + Less-than comparison + + + jsonb_path_query_array('[1, 2, 3]', '$[*] ? (@ < 2)') + [1] + + + + + + value <= value + boolean + + + Less-than-or-equal-to comparison + + + jsonb_path_query_array('["a", "b", "c"]', '$[*] ? (@ <= "b")') + ["a", "b"] + + + + + + value > value + boolean + + + Greater-than comparison + + + jsonb_path_query_array('[1, 2, 3]', '$[*] ? (@ > 2)') + [3] + + + + + + value >= value + boolean + + + Greater-than-or-equal-to comparison + + + jsonb_path_query_array('[1, 2, 3]', '$[*] ? (@ >= 2)') + [2, 3] + + + + + + true + boolean + + + JSON constant true + + + jsonb_path_query('[{"name": "John", "parent": false}, {"name": "Chris", "parent": true}]', '$[*] ? (@.parent == true)') + {"name": "Chris", "parent": true} + + + + + + false + boolean + + + JSON constant false + + + jsonb_path_query('[{"name": "John", "parent": false}, {"name": "Chris", "parent": true}]', '$[*] ? (@.parent == false)') + {"name": "John", "parent": false} + + + + + + null + value + + + JSON constant null (note that, unlike in SQL, + comparison to null works normally) + + + jsonb_path_query('[{"name": "Mary", "job": null}, {"name": "Michael", "job": "driver"}]', '$[*] ? (@.job == null) .name') + "Mary" + + + + + + boolean && boolean + boolean + + + Boolean AND + + + jsonb_path_query('[1, 3, 7]', '$[*] ? (@ > 1 && @ < 5)') + 3 + + + + + + boolean || boolean + boolean + + + Boolean OR + + + jsonb_path_query('[1, 3, 7]', '$[*] ? (@ < 1 || @ > 5)') + 7 + + + + + + ! boolean + boolean + + + Boolean NOT + + + jsonb_path_query('[1, 3, 7]', '$[*] ? (!(@ < 5))') + 7 + + - - - - lax (default) — the path engine implicitly adapts - the queried data to the specified path. - Any remaining structural errors are suppressed and converted - to empty SQL/JSON sequences. - - - - - strict — if a structural error occurs, an error is raised. - - - + + + boolean is unknown + boolean + + + Tests whether a Boolean condition is unknown. + + + jsonb_path_query('[-1, 2, 7, "foo"]', '$[*] ? ((@ > 0) is unknown)') + "foo" + + - - The lax mode facilitates matching of a JSON document structure and path - expression if the JSON data does not conform to the expected schema. - If an operand does not match the requirements of a particular operation, - it can be automatically wrapped as an SQL/JSON array or unwrapped by - converting its elements into an SQL/JSON sequence before performing - this operation. Besides, comparison operators automatically unwrap their - operands in the lax mode, so you can compare SQL/JSON arrays - out-of-the-box. An array of size 1 is considered equal to its sole element. - Automatic unwrapping is not performed only when: - - - - The path expression contains type() or - size() methods that return the type - and the number of elements in the array, respectively. - - - - - The queried JSON data contain nested arrays. In this case, only - the outermost array is unwrapped, while all the inner arrays - remain unchanged. Thus, implicit unwrapping can only go one - level down within each path evaluation step. - - - - + + + string like_regex string flag string + boolean + + + Tests whether the first operand matches the regular expression + given by the second operand, optionally with modifications + described by a string of flag characters (see + ). + + + jsonb_path_query_array('["abc", "abd", "aBdC", "abdacb", "babc"]', '$[*] ? (@ like_regex "^ab.*c")') + ["abc", "abdacb"] + + + jsonb_path_query_array('["abc", "abd", "aBdC", "abdacb", "babc"]', '$[*] ? (@ like_regex "^ab.*c" flag "i")') + ["abc", "aBdC", "abdacb"] + + - - For example, when querying the GPS data listed above, you can - abstract from the fact that it stores an array of segments - when using the lax mode: - -'lax $.track.segments.location' - - + + + string starts with string + boolean + + + Tests whether the second operand is an initial substring of the first + operand. + + + jsonb_path_query('["John Smith", "Mary Stone", "Bob Johnson"]', '$[*] ? (@ starts with "John")') + "John Smith" + + - - In the strict mode, the specified path must exactly match the structure of - the queried JSON document to return an SQL/JSON item, so using this - path expression will cause an error. To get the same result as in - the lax mode, you have to explicitly unwrap the - segments array: - -'strict $.track.segments[*].location' - - + + + exists ( path_expression ) + boolean + + + Tests whether a path expression matches at least one SQL/JSON item. + Returns unknown if the path expression would result + in an error; the second example uses this to avoid a no-such-key error + in strict mode. + + + jsonb_path_query('{"x": [1, 2], "y": [2, 4]}', 'strict $.* ? (exists (@ ? (@[*] > 2)))') + [2, 4] + + + jsonb_path_query_array('{"value": 41}', 'strict $ ? (exists (@.name)) .name') + [] + + + + +
- Regular Expressions + SQL/JSON Regular Expressions LIKE_REGEX @@ -15835,7 +16751,7 @@ table2-mapping following SQL/JSON path query would case-insensitively match all strings in an array that start with an English vowel: -'$[*] ? (@ like_regex "^[aeiou]" flag "i")' +$[*] ? (@ like_regex "^[aeiou]" flag "i") @@ -15872,340 +16788,9 @@ table2-mapping backslashes you want to use in the regular expression must be doubled. For example, to match strings that contain only digits: -'$ ? (@ like_regex "^\\d+$")' +$ ? (@ like_regex "^\\d+$") - - - - - SQL/JSON Path Operators and Methods - - - shows the operators and - methods available in jsonpath. shows the available filter - expression elements. - - - - <type>jsonpath</type> Operators and Methods - - - - Operator/Method - Description - Example JSON - Example Query - Result - - - - - + (unary) - Plus operator that iterates over the SQL/JSON sequence - {"x": [2.85, -14.7, -9.4]} - + $.x.floor() - 2, -15, -10 - - - - (unary) - Minus operator that iterates over the SQL/JSON sequence - {"x": [2.85, -14.7, -9.4]} - - $.x.floor() - -2, 15, 10 - - - + (binary) - Addition - [2] - 2 + $[0] - 4 - - - - (binary) - Subtraction - [2] - 4 - $[0] - 2 - - - * - Multiplication - [4] - 2 * $[0] - 8 - - - / - Division - [8] - $[0] / 2 - 4 - - - % - Modulus - [32] - $[0] % 10 - 2 - - - type() - Type of the SQL/JSON item - [1, "2", {}] - $[*].type() - "number", "string", "object" - - - size() - Size of the SQL/JSON item - {"m": [11, 15]} - $.m.size() - 2 - - - double() - Approximate floating-point number converted from an SQL/JSON number or a string - {"len": "1.9"} - $.len.double() * 2 - 3.8 - - - ceiling() - Nearest integer greater than or equal to the SQL/JSON number - {"h": 1.3} - $.h.ceiling() - 2 - - - floor() - Nearest integer less than or equal to the SQL/JSON number - {"h": 1.3} - $.h.floor() - 1 - - - abs() - Absolute value of the SQL/JSON number - {"z": -0.3} - $.z.abs() - 0.3 - - - datetime() - Date/time value converted from a string - ["2015-8-1", "2015-08-12"] - $[*] ? (@.datetime() < "2015-08-2". datetime()) - 2015-8-1 - - - datetime(template) - Date/time value converted from a string using the specified template - ["12:30", "18:40"] - $[*].datetime("HH24:MI") - "12:30:00", "18:40:00" - - - keyvalue() - - Sequence of object's key-value pairs represented as array of items - containing three fields ("key", - "value", and "id"). - "id" is a unique identifier of the object - key-value pair belongs to. - - {"x": "20", "y": 32} - $.keyvalue() - {"key": "x", "value": "20", "id": 0}, {"key": "y", "value": 32, "id": 0} - - - -
- - - - The result type of datetime() and - datetime(template) - methods can be date, timetz, time, - timestamptz, or timestamp. - Both methods determine the result type dynamically. - - - The datetime() method sequentially tries ISO formats - for date, timetz, time, - timestamptz, and timestamp. It stops on - the first matching format and the corresponding data type. - - - The datetime(template) - method determines the result type by the provided template string. - - - The datetime() and - datetime(template) methods - use the same parsing rules as the to_timestamp SQL - function does (see ), with three - exceptions. First, these methods don't allow unmatched template - patterns. Second, only the following separators are allowed in the - template string: minus sign, period, solidus (slash), comma, apostrophe, - semicolon, colon and space. Third, separators in the template string - must exactly match the input string. - - - - - <type>jsonpath</type> Filter Expression Elements - - - - Value/Predicate - Description - Example JSON - Example Query - Result - - - - - == - Equality operator - [1, 2, 1, 3] - $[*] ? (@ == 1) - 1, 1 - - - != - Non-equality operator - [1, 2, 1, 3] - $[*] ? (@ != 1) - 2, 3 - - - <> - Non-equality operator (same as !=) - [1, 2, 1, 3] - $[*] ? (@ <> 1) - 2, 3 - - - < - Less-than operator - [1, 2, 3] - $[*] ? (@ < 2) - 1 - - - <= - Less-than-or-equal-to operator - [1, 2, 3] - $[*] ? (@ <= 2) - 1, 2 - - - > - Greater-than operator - [1, 2, 3] - $[*] ? (@ > 2) - 3 - - - >= - Greater-than-or-equal-to operator - [1, 2, 3] - $[*] ? (@ >= 2) - 2, 3 - - - true - Value used to perform comparison with JSON true literal - [{"name": "John", "parent": false}, - {"name": "Chris", "parent": true}] - $[*] ? (@.parent == true) - {"name": "Chris", "parent": true} - - - false - Value used to perform comparison with JSON false literal - [{"name": "John", "parent": false}, - {"name": "Chris", "parent": true}] - $[*] ? (@.parent == false) - {"name": "John", "parent": false} - - - null - Value used to perform comparison with JSON null value - [{"name": "Mary", "job": null}, - {"name": "Michael", "job": "driver"}] - $[*] ? (@.job == null) .name - "Mary" - - - && - Boolean AND - [1, 3, 7] - $[*] ? (@ > 1 && @ < 5) - 3 - - - || - Boolean OR - [1, 3, 7] - $[*] ? (@ < 1 || @ > 5) - 7 - - - ! - Boolean NOT - [1, 3, 7] - $[*] ? (!(@ < 5)) - 7 - - - like_regex - - Tests whether the first operand matches the regular expression - given by the second operand, optionally with modifications - described by a string of flag characters (see - ) - - ["abc", "abd", "aBdC", "abdacb", "babc"] - $[*] ? (@ like_regex "^ab.*c" flag "i") - "abc", "aBdC", "abdacb" - - - starts with - Tests whether the second operand is an initial substring of the first operand - ["John Smith", "Mary Stone", "Bob Johnson"] - $[*] ? (@ starts with "John") - "John Smith" - - - exists - Tests whether a path expression matches at least one SQL/JSON item - {"x": [1, 2], "y": [2, 4]} - strict $.* ? (exists (@ ? (@[*] > 2))) - 2, 4 - - - is unknown - Tests whether a Boolean condition is unknown - [-1, 2, 7, "infinity"] - $[*] ? ((@ > 0) is unknown) - "infinity" - - - -
- - - - When different date/time values are compared, an implicit cast is - applied. A date value can be cast to timestamp - or timestamptz, timestamp can be cast to - timestamptz, and time — to timetz. - -

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 8:15 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> On 4/29/20 7:40 PM, Jonathan S. Katz wrote:
>>> I'll compromise on the temporary importants, but first I want to see
>>> what's causing the need for it. Do you have a suggestion on a page to test?
> 
> I haven't yet pushed anything dependent on the new markup, but
> attached is a draft revision for the JSON section; if you look at
> the SRFs such as json_array_elements you'll see the issue.
> 
>> From real quick I got it to here. With the latest copy of the doc builds
>> it appears to still work as expected, but I need a section with the new
>> "pre" block to test.
> 
> Yeah, I see you found the same 

and

 settings I did.
> 
>> I think the "background-color: inherit !important" is a bit odd, and
>> would like to trace that one down a bit more, but I did not see anything
>> obvious on my glance through it.
> 
> I think it's coming from this bit at about main.css:660:
> 
> pre,
> code,
> #docContent kbd,
> #docContent tt.LITERAL,
> #docContent tt.REPLACEABLE {
>   font-size: 0.9rem !important;
>   color: inherit !important;
>   background-color: #f8f9fa !important;
>   border-radius: .25rem;
>   margin: .6rem 0;
>   font-weight: 300;
> }
> 
> I had to override most of that.

Yeah, I had started toying with that and saw no differences, but I would
need to test against anything in particular. I'm pretty confident we can
remove those importants, based on my desultory testing.

I'll try and get the patch built + docs loaded, and see if we can safely
remove those.

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 9:22 PM, Jonathan S. Katz wrote:
> On 4/29/20 8:15 PM, Tom Lane wrote:
>> "Jonathan S. Katz"  writes:
>>> On 4/29/20 7:40 PM, Jonathan S. Katz wrote:
>>>> I'll compromise on the temporary importants, but first I want to see
>>>> what's causing the need for it. Do you have a suggestion on a page to test?
>>
>> I haven't yet pushed anything dependent on the new markup, but
>> attached is a draft revision for the JSON section; if you look at
>> the SRFs such as json_array_elements you'll see the issue.

^ This was super helpful. Built locally, and made it really easy to
test. Thanks!

>>> From real quick I got it to here. With the latest copy of the doc builds
>>> it appears to still work as expected, but I need a section with the new
>>> "pre" block to test.
>>
>> Yeah, I see you found the same 

and

 settings I did.
>>
>>> I think the "background-color: inherit !important" is a bit odd, and
>>> would like to trace that one down a bit more, but I did not see anything
>>> obvious on my glance through it.
>>
>> I think it's coming from this bit at about main.css:660:
>>
>> pre,
>> code,
>> #docContent kbd,
>> #docContent tt.LITERAL,
>> #docContent tt.REPLACEABLE {
>>   font-size: 0.9rem !important;
>>   color: inherit !important;
>>   background-color: #f8f9fa !important;
>>   border-radius: .25rem;
>>   margin: .6rem 0;
>>   font-weight: 300;
>> }
>>
>> I had to override most of that.
> 
> Yeah, I had started toying with that and saw no differences, but I would
> need to test against anything in particular. I'm pretty confident we can
> remove those importants, based on my desultory testing.
> 
> I'll try and get the patch built + docs loaded, and see if we can safely
> remove those.

Please see latest attached. I've eliminated the !important, condensed
the CSS, and the desultory (yes, my word of the week) testing did not
find issues in devel or earlier versions.

Please let me know if this works for you. If it does, I'll push it up to
pgweb.

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> Please see latest attached. I've eliminated the !important, condensed
> the CSS, and the desultory (yes, my word of the week) testing did not
> find issues in devel or earlier versions.

> Please let me know if this works for you. If it does, I'll push it up to
> pgweb.

NAK ... that does *not* work for me.

It looks to me like you are expecting that "margin" with four parameters
will override an outer-level setting of margin-bottom, but that is not
how my browser is responding.  ISTM you need to explicitly set the very
same parameters in the more-specific rule as in the less-specific rule
that you want to override.

I get reasonable results with these settings, but not with
anything more abbreviated:

#docContent table.table th.func_table_entry p,
#docContent table.table td.func_table_entry p {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
  padding-left: 4em;
  text-align: left;
}

#docContent table.table p.func_signature {
  text-indent: -3.5em;
}

#docContent table.table td.func_table_entry pre.programlisting {
  background-color: inherit;
  border: 0;
  margin-top: 0.1em;
  margin-bottom: 0.1em;
  padding: 0;
  padding-left: 4em;
}

In particular, it might look like the multiple padding settings
in the pre.programlisting rule are redundant ... but they are not, at
least not with Safari.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 10:38 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> Please see latest attached. I've eliminated the !important, condensed
>> the CSS, and the desultory (yes, my word of the week) testing did not
>> find issues in devel or earlier versions.
> 
>> Please let me know if this works for you. If it does, I'll push it up to
>> pgweb.
> 
> NAK ... that does *not* work for me.

Learned a new acronym...

> It looks to me like you are expecting that "margin" with four parameters
> will override an outer-level setting of margin-bottom, but that is not
> how my browser is responding.  ISTM you need to explicitly set the very
> same parameters in the more-specific rule as in the less-specific rule
> that you want to override.
> 
> I get reasonable results with these settings, but not with
> anything more abbreviated:

> In particular, it might look like the multiple padding settings
> in the pre.programlisting rule are redundant ... but they are not, at
> least not with Safari.

Clearly I was caught doing a single browser test (Chrome).

Reverted back to the verbose way sans !important, attached, which
appears to be the consensus. If you can ACK this, I'll commit.

Thanks,

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> Clearly I was caught doing a single browser test (Chrome).

Well, I've not tested anything but Safari, either ...

> Reverted back to the verbose way sans !important, attached, which
> appears to be the consensus. If you can ACK this, I'll commit.

This one works for me.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 4/29/20 11:26 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> Clearly I was caught doing a single browser test (Chrome).
> 
> Well, I've not tested anything but Safari, either ...
> 
>> Reverted back to the verbose way sans !important, attached, which
>> appears to be the consensus. If you can ACK this, I'll commit.
> 
> This one works for me.

Pushed. Thanks!

Jonathan

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I've now completed updating chapter 9 for the new layout,
and the results are visible at 
https://www.postgresql.org/docs/devel/functions.html
There is more to do --- for instance, various contrib modules
have function/operator tables that should be synced with this
design.  But this seemed like a good place to pause and reflect.

After working through the whole chapter, the only aspect of the
new markup that really doesn't seem to work so well is the use
of  for function result types and example results.
While I don't think that that's broken in concept, DocBook has
restrictions on the contents of  that are problematic:

* It won't let you put any verbatim-layout environment, such
as , inside .  This is an issue for
examples for set-returning functions in particular.  I've done
those like this:

       
        regexp_matches('foobarbequebaz', 'ba.', 'g')
        

 {bar}
 {baz}

        (2 rows in result)
       

where the empty  environment is just serving to generate a
right arrow.  It looks all right, but it's hardly semantically-based
markup.

*  is also quite sticky about inserting other sorts
of font-changing environments inside it.  As an example, it'll let
you include  but not , which seems pretty weird
to me.  This is problematic in some places where it's desirable to
have text rather than just a type name, for example

        stddev ( numeric_type )
         double precision
        for real or double precision,
        otherwise numeric

Now I could have done this example by spelling out all six varieties of
stddev() separately, and maybe I should've, but it seemed overly bulky
that way.  So again  is just generating the right arrow.

* After experimenting with a few different ways to handle functions with
multiple OUT parameters, I settled on doing it like this:

        pg_partition_tree ( regclass )
        setof record
        ( relid regclass,
        parentrelid regclass,
        isleaf boolean,
        level integer )

This looks nice and I think it's much more intelligible than other
things I tried --- in particular, including the OUT parameters in
the function signature seems to me to be mostly confusing.  But,
once again, it's abusing the concept that  contains
the result type.  Ideally the output-column list would be inside
the  environment, but DocBook won't allow that
because of the  tags.

So at this point I'm tempted to abandon  and go back
to using a custom entity to generate the right arrow, so that
the markup would just look like, say,

        stddev ( numeric_type )
        &returns; double precision
        for real or double precision,
        otherwise numeric

Does anyone have a preference on that, or a better alternative?

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 5/4/20 5:22 PM, Tom Lane wrote:
> I've now completed updating chapter 9 for the new layout,
> and the results are visible at 
> https://www.postgresql.org/docs/devel/functions.html
> There is more to do --- for instance, various contrib modules
> have function/operator tables that should be synced with this
> design.  But this seemed like a good place to pause and reflect.

This is already much better. I've skimmed through a few of the pages, I
can say that the aggregates page[1] is WAY easier to read. Yay!

> 
> After working through the whole chapter, the only aspect of the
> new markup that really doesn't seem to work so well is the use
> of  for function result types and example results.
> While I don't think that that's broken in concept, DocBook has
> restrictions on the contents of  that are problematic:
> 
> * It won't let you put any verbatim-layout environment, such
> as , inside .  This is an issue for
> examples for set-returning functions in particular.  I've done
> those like this:
> 
>        
>         regexp_matches('foobarbequebaz', 'ba.', 'g')
>         
> 
>  {bar}
>  {baz}
> 
>         (2 rows in result)
>        
> 
> where the empty  environment is just serving to generate a
> right arrow.  It looks all right, but it's hardly semantically-based
> markup.

We could apply some CSS on the pgweb front perhaps to help distinguish
at least the results? For the above example, it would be great to
capture the program listing + "2 rows in result" output and format them
similarly, though it appears the "(2 rows in result)" is in its own block.

Anyway, likely not that hard to apply some CSS and make it appear a bit
more distinguished, if that's the general idea.

> *  is also quite sticky about inserting other sorts
> of font-changing environments inside it.  As an example, it'll let
> you include  but not , which seems pretty weird
> to me.  This is problematic in some places where it's desirable to
> have text rather than just a type name, for example
> 
>         stddev ( numeric_type )
>          double precision
>         for real or double precision,
>         otherwise numeric
> 
> Now I could have done this example by spelling out all six varieties of
> stddev() separately, and maybe I should've, but it seemed overly bulky
> that way.  So again  is just generating the right arrow.
> 
> * After experimenting with a few different ways to handle functions with
> multiple OUT parameters, I settled on doing it like this:
> 
>         pg_partition_tree ( regclass )
>         setof record
>         ( relid regclass,
>         parentrelid regclass,
>         isleaf boolean,
>         level integer )
> 
> This looks nice and I think it's much more intelligible than other
> things I tried --- in particular, including the OUT parameters in
> the function signature seems to me to be mostly confusing.  But,
> once again, it's abusing the concept that  contains
> the result type.  Ideally the output-column list would be inside
> the  environment, but DocBook won't allow that
> because of the  tags.

It does look better, but things look a bit smushed together on the pgweb
front. It seems like there's enough structure where one can make some
not-too-zany CSS rules to put a bit more space between elements, but
perhaps wait to hear the decision on the rest of the structural questions.

> So at this point I'm tempted to abandon  and go back
> to using a custom entity to generate the right arrow, so that
> the markup would just look like, say,
> 
>         stddev ( numeric_type )
>         &returns; double precision
>         for real or double precision,
>         otherwise numeric
> 
> Does anyone have a preference on that, or a better alternative?

As long as we can properly style without zany CSS rules, I'm +0 :)

Jonathan

[1] https://www.postgresql.org/docs/devel/functions-aggregate.html

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Jonathan S. Katz"  writes:
> On 5/4/20 5:22 PM, Tom Lane wrote:
>> I've now completed updating chapter 9 for the new layout,
>> and the results are visible at 
>> https://www.postgresql.org/docs/devel/functions.html

> This is already much better. I've skimmed through a few of the pages, I
> can say that the aggregates page[1] is WAY easier to read. Yay!

Thanks!

>> * After experimenting with a few different ways to handle functions with
>> multiple OUT parameters, I settled on doing it like this:
>> pg_partition_tree ( regclass )
>> setof record
>> ( relid regclass,
>> parentrelid regclass,
>> isleaf boolean,
>> level integer )
>> 
>> This looks nice and I think it's much more intelligible than other
>> things I tried --- in particular, including the OUT parameters in
>> the function signature seems to me to be mostly confusing.  But,
>> once again, it's abusing the concept that  contains
>> the result type.  Ideally the output-column list would be inside
>> the  environment, but DocBook won't allow that
>> because of the  tags.

> It does look better, but things look a bit smushed together on the pgweb
> front.

Yeah.  There's less smushing of function signatures when building the
docs without STYLE=website, so there's something specific to the
website style.  I think you'd mentioned that we were intentionally
crimping the space and/or font size within tables?  Maybe that could
get un-done now.  I hadn't bothered to worry about such details until
we had a reasonable sample of cases to look at, but now would be a
good time.


Another rendering oddity that I'd not bothered to chase down is
the appearance of  environments within table cells.
We have a few of those now as a result of migration of material
that had been out-of-line into the table cells; one example is
in json_populate_record, about halfway down this page:

https://www.postgresql.org/docs/devel/functions-json.html

The text of the list items seems to be getting indented to the
same extent as a not-in-a-table  list does ---
but the bullets aren't indented nearly as much, making for
weird spacing.  (There's a short  at the top of
the same page that you can compare to.)

The same weird spacing is visible in a non STYLE=website build,
so I think this might be less a CSS issue and more a DocBook
issue.  On the other hand, it looks fine in the PDF build.
So I'm not sure where to look for the cause.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
"Jonathan S. Katz" <jkatz@postgresql.org>
Дата:
Вложения:
On 5/4/20 6:39 PM, Tom Lane wrote:
> "Jonathan S. Katz"  writes:
>> On 5/4/20 5:22 PM, Tom Lane wrote:

>> It does look better, but things look a bit smushed together on the pgweb
>> front.
> 
> Yeah.  There's less smushing of function signatures when building the
> docs without STYLE=website, so there's something specific to the
> website style.  I think you'd mentioned that we were intentionally
> crimping the space and/or font size within tables?  Maybe that could
> get un-done now.  I hadn't bothered to worry about such details until
> we had a reasonable sample of cases to look at, but now would be a
> good time.

IIRC this was the monospace issue[1], but there are some other things
I'm seeing (e.g. the italics) that may be pushing things closer together
htan not. Now that round 1 of commits are in, I can take a whack at
tightening it up this week.

> Another rendering oddity that I'd not bothered to chase down is
> the appearance of  environments within table cells.
> We have a few of those now as a result of migration of material
> that had been out-of-line into the table cells; one example is
> in json_populate_record, about halfway down this page:
> 
> https://www.postgresql.org/docs/devel/functions-json.html
> 
> The text of the list items seems to be getting indented to the
> same extent as a not-in-a-table  list does ---
> but the bullets aren't indented nearly as much, making for
> weird spacing.  (There's a short  at the top of
> the same page that you can compare to.)

Looking at the code, I believe this is a pretty straightforward
adjustment. I can include it with the aforementioned changes.

Jonathan

[1]
https://www.postgresql.org/message-id/3f8560a6-9044-bdb8-6b3b-68842570db18@postgresql.org

Re: Poll: are people okay with function/operator table redesign?

От:
Dean Rasheed <dean.a.rasheed@gmail.com>
Дата:
On Mon, 4 May 2020 at 22:22, Tom Lane  wrote:
>
> *  is also quite sticky about inserting other sorts
> of font-changing environments inside it.  As an example, it'll let
> you include  but not , which seems pretty weird
> to me.  This is problematic in some places where it's desirable to
> have text rather than just a type name, for example
>
>         stddev ( numeric_type )
>          double precision
>         for real or double precision,
>         otherwise numeric
>
> Now I could have done this example by spelling out all six varieties of
> stddev() separately, and maybe I should've, but it seemed overly bulky
> that way.

FWIW, I prefer having each variety spelled out separately. For
example, I really like the new way that aggregates like sum() and
avg() are displayed. To me, having all the types listed like that is
much more readable than having to read and interpret a piece of free
text.

Similarly, for other functions like gcd(), lcm() and mod(). I think it
would be better to get rid of numeric_type, and just list all the
variants of each function.

Regards,
Dean


Re: Poll: are people okay with function/operator table redesign?

От:
Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Дата:
Вложения:
On Mon, May 4, 2020 at 11:22 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've now completed updating chapter 9 for the new layout,
and the results are visible at
https://www.postgresql.org/docs/devel/functions.html
There is more to do --- for instance, various contrib modules
have function/operator tables that should be synced with this
design.  But this seemed like a good place to pause and reflect.

Would it be premature to complain about the not-that-great look of Table 9.1 now?

Compare the two attached images: the screenshot from
vs the GIMP-assisted pipe dream of mine to align it to the right edge of the table cell.

I don't have the faintest idea how to achieve that using SGML at the moment, but it just looks so much nicer to me. ;-)

Regards,
--
Alex

Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Dean Rasheed  writes:
> On Mon, 4 May 2020 at 22:22, Tom Lane  wrote:
>> Now I could have done this example by spelling out all six varieties of
>> stddev() separately, and maybe I should've, but it seemed overly bulky
>> that way.

> FWIW, I prefer having each variety spelled out separately. For
> example, I really like the new way that aggregates like sum() and
> avg() are displayed. To me, having all the types listed like that is
> much more readable than having to read and interpret a piece of free
> text.

> Similarly, for other functions like gcd(), lcm() and mod(). I think it
> would be better to get rid of numeric_type, and just list all the
> variants of each function.

I had had the same idea to start with, but it didn't survive first contact
with table 9.4 (Mathematical Operators).  It's not really reasonable to
spell out all the variants of + ... especially not if you want to be
precise, because then you'd have to list the cross-type variants too.
If I counted correctly, there are fourteen variants of binary + that
would have to be listed in that table, never mind the other common
operators.

max() and min() have a similar sort of problem --- the list of variants
is just dauntingly long, and it's not that interesting either.
I wrote out sum() and avg() the way I did because they have a somewhat
irregular mapping from input to output types, so it seemed better to
just list the alternatives explicitly.

I don't object too much to spelling out the variants of stddev()
and variance(), if there's a consensus for that.  But getting rid
of "numeric_type" entirely seems impractical.

			regards, tom lane


Re: Poll: are people okay with function/operator table redesign?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Oleksandr Shulgin  writes:
> Would it be premature to complain about the not-that-great look of Table
> 9.1 now?
> Compare the two attached images: the screenshot from
> https://www.postgresql.org/docs/devel/functions-comparison.html
> vs the GIMP-assisted pipe dream of mine to align it to the right edge of
> the table cell.

Hmph.  I experimented with the attached patch, but at least in my browser
it only reduces the spacing inconsistency, it doesn't eliminate it.
And from a semantic standpoint, this is not nice markup.

Doing better would require substantial foolery with sub-columns and I'm
not even sure that it's possible to fix that way.  (We don't have huge
control over inter-column spacing, I don't think.)

On the whole, if this is our worst table problem, I'm happy ;-)

			regards, tom lane

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index d9b3598..557a3ac 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -222,7 +222,7 @@ repeat('Pg', 4) PgPgPgPg
      
       
        
-        datatype < datatype
+        datatype <  datatype
         boolean
        
        Less than
@@ -230,7 +230,7 @@ repeat('Pg', 4) PgPgPgPg
 
       
        
-        datatype > datatype
+        datatype >  datatype
         boolean
        
        Greater than
@@ -254,7 +254,7 @@ repeat('Pg', 4) PgPgPgPg
 
       
        
-        datatype = datatype
+        datatype =  datatype
         boolean
        
        Equal
FAQ