three small improvements for "Composite Types" page

Started by Anton Voloshinover 2 years ago3 messagesdocs
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t77619
psql -h localhost -U postgres

Built from patchset v3 (message #3), October 06, 2026 at 07:46 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t77619_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t77619_3 && git checkout t77619_3

Patchset v3 (message #3) is on t77619_3

Jump to latest
#1Anton Voloshin
a.voloshin@postgrespro.ru

Hello,

While reading "Composite Types" manual page I've noticed that it is
somewhat hard to follow by trying out given examples. I suggest three
small changes which would make this page a little easier to follow for
me:

1. Clarify "different kind" by adding a link to a section of "create
type" page

Note that the AS keyword is essential; without it, the system will

think a different kind of CREATE TYPE command is meant, and you will get
odd syntax errors.

Here there is no link to CREATE TYPE, so it's not so easy to go there to
see what is that "different kind" of CREATE TYPE. I suggest to add an
anchor for the "Base Types" section there and link the words "different
kind" there.

2. make first mention of CREATE TABLE a link

The syntax is comparable to CREATE TABLE, except ...

It would be useful if this CREATE TABLE (first on this page) would
become a link.

3. Simplify CREATE TABLE example to make it self-sufficient

One of the examples on the same "Composite Types" page is an example of
CREATE TABLE:

CREATE TABLE inventory_item (
name text,
supplier_id integer REFERENCES suppliers,
price numeric CHECK (price > 0)
);

This example is not self-sufficient: it requires one to have "suppliers"
table with specific column to work as given. This table is actively used
in examples below, like
SELECT * FROM inventory_item c ORDER BY c;
and many others, so I think it's important to make this example easy to
reproduce. It seems to me that loosing "REFERENCES suppliers", while
loses something a bit interesting, adds something more important:
simplicity for the newcomers. So I suggest removing this part.

Please see attached patches as an example of these three changes.

Any comments? Do you think this is an improvement?

--
Anton Voloshin
Postgres Professional, The Russian Postgres Company
https://postgrespro.ru

Attachments:

0001-clarify-different-kind-by-adding-a-link-to-a-section.patchtext/x-patch; charset=UTF-8; name=0001-clarify-different-kind-by-adding-a-link-to-a-section.patchDownload+3-3
0002-composite-types-make-first-mention-of-CREATE-TABLE-a.patchtext/x-patch; charset=UTF-8; name=0002-composite-types-make-first-mention-of-CREATE-TABLE-a.patchDownload+1-2
0003-Composite-Types-simplify-CREATE-TABLE-example-to-mak.patchtext/x-patch; charset=UTF-8; name=0003-Composite-Types-simplify-CREATE-TABLE-example-to-mak.patchDownload+1-2
#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Anton Voloshin (#1)
Re: three small improvements for "Composite Types" page

On Fri, Apr 12, 2024 at 1:20 PM Anton Voloshin <a.voloshin@postgrespro.ru>
wrote:

Hello,

While reading "Composite Types" manual page I've noticed that it is
somewhat hard to follow by trying out given examples. I suggest three
small changes which would make this page a little easier to follow for
me:

1. Clarify "different kind" by adding a link to a section of "create
type" page

Note that the AS keyword is essential; without it, the system will

think a different kind of CREATE TYPE command is meant, and you will get
odd syntax errors.

Here there is no link to CREATE TYPE, so it's not so easy to go there to
see what is that "different kind" of CREATE TYPE. I suggest to add an
anchor for the "Base Types" section there and link the words "different
kind" there.

I'd much prefer to leave "different kind" alone and turn the immediately
following, first-on-the-page, instance of CREATE TYPE into a link.

2. make first mention of CREATE TABLE a link

The syntax is comparable to CREATE TABLE, except ...

It would be useful if this CREATE TABLE (first on this page) would
become a link.

I'm not all that convinced of that particular usefulness but also don't see
it hurting either.

3. Simplify CREATE TABLE example to make it self-sufficient

One of the examples on the same "Composite Types" page is an example of
CREATE TABLE:

CREATE TABLE inventory_item (
name text,
supplier_id integer REFERENCES suppliers,
price numeric CHECK (price > 0)
);

This example is not self-sufficient: it requires one to have "suppliers"
table with specific column to work as given.

Agreed.

David J.

#3Anton Voloshin
a.voloshin@postgrespro.ru
In reply to: David G. Johnston (#2)
Re: three small improvements for "Composite Types" page

On 12/04/2024 23:44, David G. Johnston wrote:

I'd much prefer to leave "different kind" alone and turn the immediately
following, first-on-the-page, instance of CREATE TYPE into a link.

Good, I'm fine with that too.

 2. make first mention of CREATE TABLE a link
[...] > I'm not all that convinced of that particular usefulness but also don't
see it hurting either.

Thanks. I do think it's useful when one reads this page separately (not
as a part of sequential read-through).

3. Simplify CREATE TABLE example to make it self-sufficient
[...]
Agreed.

Thanks. I've updated the patches correspondingly.

--
Anton Voloshin
Postgres Professional, The Russian Postgres Company
https://postgrespro.ru

Attachments:

t77619_3
0001-Composite-Types-clarify-different-kind-by-linking-to.patchtext/x-patch; charset=UTF-8; name=0001-Composite-Types-clarify-different-kind-by-linking-to.patchDownload+1-2
0002-Composite-Types-make-first-mention-of-CREATE-TABLE-a.patchtext/x-patch; charset=UTF-8; name=0002-Composite-Types-make-first-mention-of-CREATE-TABLE-a.patchDownload+1-2
0003-Composite-Types-simplify-CREATE-TABLE-example-to-mak.patchtext/x-patch; charset=UTF-8; name=0003-Composite-Types-simplify-CREATE-TABLE-example-to-mak.patchDownload+1-2