Thread: [DOCS] CREATE DOMAIN should also include an example of use with functions

[DOCS] CREATE DOMAIN should also include an example of use with functions

From
postgresql@eric.brechemier.name
Date:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/sql-createdomain.html
Description:

The documentation of CREATE DOMAIN currently describes how optional
constraints can be useful for the fields of a table. There is no mention of
functions in this page.

I have recently found two use cases for domains with functions:

1. validation of the format of user inputs (mobile phone number, email
address, etc.) before any further processing in the function.

2. provide CURRENT_USER to a SECURITY DEFINER function (more details here:
http://stackoverflow.com/a/42011279/207968)

Re: CREATE DOMAIN should also include an example of use withfunctions

From
Peter Eisentraut
Date:
On 2/2/17 15:49, postgresql@eric.brechemier.name wrote:
> Page: https://www.postgresql.org/docs/9.6/static/sql-createdomain.html
> Description:
>
> The documentation of CREATE DOMAIN currently describes how optional
> constraints can be useful for the fields of a table. There is no mention of
> functions in this page.

There is an example using operators, which is pretty much the same thing.

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


Re: CREATE DOMAIN should also include an example of use withfunctions

From
Peter Eisentraut
Date:
On 4/5/17 06:09, Eric Bréchemier wrote:
> Hi Peter,
>
> I find no mention of operators on this page:
>
> "This example creates the us_postal_code data type and then uses the
> type in a table definition."
> https://www.postgresql.org/docs/9.6/static/sql-createdomain.html#AEN79068

It uses the ~ operator in the domain definition in the example.

Perhaps you should send in an example of your own to explain what you mean.

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