Thoughts on user-defined types for talk at Postgres conference?

From: Guyren Howe <guyren(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Thoughts on user-defined types for talk at Postgres conference?
Date: 2024-03-03 00:40:06
Message-ID: 506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michał Kłeczek 2024-03-03 09:34:08 postgres_fdw aggregate pushdown for group by with expressions
Previous Message Baziotis, Stefanos 2024-03-02 22:29:00 Re: Guarantees/Semantics of pg_stats