Thoughts on user-defined types for talk at Postgres conference? - Mailing list pgsql-general

From Guyren Howe
Subject Thoughts on user-defined types for talk at Postgres conference?
Date
Msg-id 506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark
Whole thread Raw
Responses Re: Thoughts on user-defined types for talk at Postgres conference?
List pgsql-general
I am doing a talk at Postgres Conf about Postgres’s type system. I already asked about this and got some great responses: 

https://www.postgresql.org/message-id/flat/b82f8886db61a3395e6eab94981258274cdbacd3.camel%40cybertec.at#f13288b72bd2d564ee758c1a273652ad

Those responses discussed mostly gotchas with built-in types. Lots of good stuff, thanks, all!

But what *really* sets Postgres apart from comparable systems is user defined types. I would like to carefully lay out how to define and use a user-defined type (I don’t think I have time to dig into doing fancy stuff with C functions, so just the basic “user defined sum type”), but also any gotchas.

And I’d like to finish with some thoughts about when and how to use user-defined types. My feeling is that this feature is greatly under-used, mostly because it’s so non-standard. But AFAICT, user-defined types are fine and other than some ugliness due to SQL (mainly needing parentheses in some unexpected places), fields in a user defined type work perfectly well in Postgres’s SQL. I guess you’d need to pull them apart for values returned to clients, but that isn’t difficult.

So, any gotchas with user defined types? Any thoughts about designing with them?

pgsql-general by date:

Previous
From: "Baziotis, Stefanos"
Date:
Subject: Re: Guarantees/Semantics of pg_stats
Next
From: Michał Kłeczek
Date:
Subject: postgres_fdw aggregate pushdown for group by with expressions