pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guyren Howe <guyren@gmail.com>
To: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Thoughts on user-defined types for talk at Postgres conference?
Date: Sat, 2 Mar 2024 16:40:06 -0800
Message-ID: <506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark> (raw)

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...

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?

view thread (7+ messages)  latest in thread

Message-ID: <506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark>
Permalink:  ../506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark/
Also on:    postgresql.org/message-id/506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guyren@gmail.com
  Subject: Re: Thoughts on user-defined types for talk at Postgres conference?
  In-Reply-To: <506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark>
  References: <506dd5f4-65fe-4d34-8cfe-2ebc08b978e4@Spark>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox