On 2021-Apr-15, Vik Fearing wrote:
> CREATE DOMAIN earth AS "$extension".cube.cube
> CONSTRAINT not_point check("$extension".cube.cube_is_point(value))
> CONSTRAINT not_3d check("$extension".cube.cube_dim(value <= 3)
> ...;
I find this syntax pretty weird -- here, the ".cube." part of the
identifier is acting as an argument of sorts for the preceding
$extension thingy. This looks very surprising.
Something similar to OPERATOR() syntax may be more palatable:
CREATE DOMAIN earth AS PG_EXTENSION_SCHEMA(cube).cube
CONSTRAINT not_point check(PG_EXTENSION_SCHEMA(cube).cube_is_point(value))
CONSTRAINT not_3d check(PG_EXTENSION_SCHEMA(cube).cube_dim(value <= 3)
...;
Here, the PG_EXTENSION_SCHEMA() construct expands into the schema of the
given extension. This looks more natural to me, since the extension
that acts as argument to PG_EXTENSION_SCHEMA() does look like an
argument.
I don't know if the parser would like this, though.
--
Álvaro Herrera Valdivia, Chile