plpgsql-trigger.html: Format TG_ variables as table (patch)

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

plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Hi,

I found the list of TG_ variables on
https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-DML-TRIGGER
hard to read for several reasons: too much whitespace, all the lines
start with "Data type", and even after that, the actual content is
hiding behind some extra "variable that..." boilerplate.

The attached patch formats the list as a table, and removes some of
the clutter from the text.

I reused the catalog_table_entry table machinery, that is probably not
quite the correct thing, but I didn't find a better variant, and the
result looks ok.

Thanks to ilmari for the idea and some initial reviews.

Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Дата:
On 30.08.22 15:16, Christoph Berg wrote:
> I found the list of TG_ variables on
> https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-DML-TRIGGER
> hard to read for several reasons: too much whitespace, all the lines
> start with "Data type", and even after that, the actual content is
> hiding behind some extra "variable that..." boilerplate.
> 
> The attached patch formats the list as a table, and removes some of
> the clutter from the text.
> 
> I reused the catalog_table_entry table machinery, that is probably not
> quite the correct thing, but I didn't find a better variant, and the
> result looks ok.

I find the new version even harder to read.  The catalog_table_entry 
stuff doesn't really make sense here, since what you have before is 
already a definition list, and afterwards you have the same, just marked 
up "incorrectly".

We could move the data type in the , similar to how you did it in 
your patch.

I agree the whitespace layout is weird, but that's a problem of the 
website CSS stylesheet.  I think it looks a bit better with the local 
stylesheet, but that can all be tweaked.



Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 31 Aug 2022, at 11:35, Peter Eisentraut  wrote:
> 
> On 30.08.22 15:16, Christoph Berg wrote:
>> I found the list of TG_ variables on
>> https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-DML-TRIGGER
>> hard to read for several reasons: too much whitespace, all the lines
>> start with "Data type", and even after that, the actual content is
>> hiding behind some extra "variable that..." boilerplate.
>> The attached patch formats the list as a table, and removes some of
>> the clutter from the text.
>> I reused the catalog_table_entry table machinery, that is probably not
>> quite the correct thing, but I didn't find a better variant, and the
>> result looks ok.
> 
> I find the new version even harder to read.  The catalog_table_entry stuff doesn't really make sense here, since what you have before is already a definition list, and afterwards you have the same, just marked up "incorrectly".

If we change variable lists they should get their own formatting in the xsl
and css stylesheets.

> We could move the data type in the , similar to how you did it in your patch.

That will make this look different from the trigger variable lists for other
languages (which typically don't list type), but I think it's worth it to avoid
the boilerplate which is a bit annoying.

Another thing we should change while there (but it's not directly related to
this patch) is that we document TG_RELID and $TG_relid as "object ID" but
TD["relid"] and $_TD->{relid} as "OID".  Punctuation of item descriptions is
also not consistent.

--
Daniel Gustafsson		https://vmware.com/



Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Re: Peter Eisentraut
> I find the new version even harder to read.  The catalog_table_entry stuff
> doesn't really make sense here, since what you have before is already a
> definition list, and afterwards you have the same, just marked up
> "incorrectly".

Fair enough. For comparison, this is what yesterday's patch looked
like: https://www.df7cb.de/s/2022-08-31.115813.w5UvAS.png

> We could move the data type in the , similar to how you did it in your
> patch.

The new version of the patch just moves up the data types, and removes
the extra clutter from the beginnings of each description:

https://www.df7cb.de/s/2022-08-31.115857.LkkKl8.png

Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Re: To Peter Eisentraut
> The new version of the patch just moves up the data types, and removes
> the extra clutter from the beginnings of each description:

The last version had the brackets in TG_ARGV[] (text[]) duplicated.

Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 31 Aug 2022, at 13:55, Christoph Berg  wrote:
> 
> Re: To Peter Eisentraut
>> The new version of the patch just moves up the data types, and removes
>> the extra clutter from the beginnings of each description:
> 
> The last version had the brackets in TG_ARGV[] (text[]) duplicated.

This, and the other string variables, now reads a bit strange IMO:

-       Data type text; a string of
+       string
        INSERT, UPDATE,
        DELETE, or TRUNCATE

Wouldn't it be better with "string containing INSERT.." or something
similar?

--
Daniel Gustafsson		https://vmware.com/



Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Re: Daniel Gustafsson
> This, and the other string variables, now reads a bit strange IMO:
> 
> -       Data type text; a string of
> +       string
>         INSERT, UPDATE,
>         DELETE, or TRUNCATE
> 
> Wouldn't it be better with "string containing INSERT.." or something
> similar?

Right, that felt strange to me as well, but I couldn't think of
something better.

"string containing" is again pretty boilerplatish, how about just
"contains"?

Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Re: To Daniel Gustafsson
> "string containing" is again pretty boilerplatish, how about just
> "contains"?

Actually, just omitting the whole prefix works best.

TG_WHEN (text)

    BEFORE, AFTER, or INSTEAD OF, depending on the trigger's definition.

I also shortened some "name of table" to just "table". Since the data
type is "name", it's clear what "table" means.

Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Дата:
Christoph Berg  writes:

> Re: To Daniel Gustafsson
>> "string containing" is again pretty boilerplatish, how about just
>> "contains"?
>
> Actually, just omitting the whole prefix works best.
>
> TG_WHEN (text)
>
>     BEFORE, AFTER, or INSTEAD OF, depending on the trigger's definition.

The attached patch does not reflect this, did you attach an old version?

> I also shortened some "name of table" to just "table". Since the data
> type is "name", it's clear what "table" means.

I think it reads better with the definite article and initial capital,
e.g. "The table that triggered ….".

>     
>      
> -     NEW
> +     NEW (record)

The type names should still be wrapped in , like they were before.

- ilmari


Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Christoph Berg <myon@debian.org>
Дата:
Вложения:
Re: Dagfinn Ilmari Mannsåker
> > Actually, just omitting the whole prefix works best.
> >
> > TG_WHEN (text)
> >
> >     BEFORE, AFTER, or INSTEAD OF, depending on the trigger's definition.
> 
> The attached patch does not reflect this, did you attach an old version?

Forgot to git commit before exporting the patch, thanks for catching!

> > I also shortened some "name of table" to just "table". Since the data
> > type is "name", it's clear what "table" means.
> 
> I think it reads better with the definite article and initial capital,
> e.g. "The table that triggered ….".

Since that's not a complete sentence anyway, I think "The" isn't
necessary.

> > -     NEW
> > +     NEW (record)
> 
> The type names should still be wrapped in , like they were before.

Updated.

Thanks,
Christoph

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
Вложения:
> On 1 Sep 2022, at 15:07, Christoph Berg  wrote:
> Re: Dagfinn Ilmari Mannsåker

>>> I also shortened some "name of table" to just "table". Since the data
>>> type is "name", it's clear what "table" means.
>> 
>> I think it reads better with the definite article and initial capital,
>> e.g. "The table that triggered ….".
> 
> Since that's not a complete sentence anyway, I think "The" isn't
> necessary.

Looking at the docs for the other PLs there is quite a lot of variation on how
we spell this, fixing that inconsistency is for another patch though.

The patch missed to update the corresponding list for TG_ event trigger vars,
fixed in the attached.

--
Daniel Gustafsson		https://vmware.com/

Re: plpgsql-trigger.html: Format TG_ variables as table (patch)

От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 2 Sep 2022, at 11:19, Daniel Gustafsson  wrote:

> The patch missed to update the corresponding list for TG_ event trigger vars,
> fixed in the attached.

I took another look at this, and pushed it with a few small tweaks. Thanks!

--
Daniel Gustafsson		https://vmware.com/



FAQ