Is there a clean way to create a type-safe BLOB?

5 views
Skip to first unread message

Bear Giles

unread,
Aug 4, 2015, 11:08:34 PM8/4/15
to pgxn-...@googlegroups.com
Is there a way to create at type-safe BLOB? There's no natural string representation so a traditional type seems out but a new composite type like

CREATE TYPE jpeg AS ( image BLOB )

isn't as transparent as I would like.  There would be CAST functions to transparently convert between a BLOB and the typesafe type (modulo correct format, of course).

The alternative is to create a BLOB column and add a check constraint to verify the column contains the expected type of data but that isn't as intuitive as "image jpeg".

(BTW I'm using jpeg as an example so don't read too much into it.)

Thanks,

Bear

Jim Nasby

unread,
Aug 5, 2015, 12:50:17 AM8/5/15
to pgxn-...@googlegroups.com
You should post this on pgsql-general; it has nothing to do with pgxn.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Data in Trouble? Get it in Treble! http://BlueTreble.com

Bear Giles

unread,
Aug 5, 2015, 9:06:08 AM8/5/15
to pgxn-...@googlegroups.com
It does in the sense that I'm working on a C extension and it's centered on a typesafe blob object. I've done a composite type and a couple C types but don't know the PXGN extensions well enough to know if anyone has dealt with a blob-type type.

--
You received this message because you are subscribed to the Google Groups "PGXN Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pgxn-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David E. Wheeler

unread,
Aug 5, 2015, 1:46:38 PM8/5/15
to pgxn-...@googlegroups.com
On Aug 5, 2015, at 6:05 AM, Bear Giles <bgi...@coyotesong.com> wrote:

> It does in the sense that I'm working on a C extension and it's centered on a typesafe blob object. I've done a composite type and a couple C types but don't know the PXGN extensions well enough to know if anyone has dealt with a blob-type type.

Well, they’re not PGXN extensions, they’re PostgreSQL extensions. PGXN is about distribution, really. So this probably is pgsql-general material. You’re more likely to find more people who understand these sorts of issues there -- *much* bigger audience.

Best,

DvAid
Reply all
Reply to author
Forward
0 new messages