Search Postgresql Archives

Change UUID type default output representation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have been using UUIDs for PKs to allow me the flexibility of
generating PKs within PostgreSQL or at the application code level.

However, I have been storing them as CHAR(32) in the hex string
representation (no dashes) in order to simplify comparisons and
manipulations at a very practical level.

(For example, in my terminal, the dashes become "word boundaries" for
cut-and-paste operations, so that dealing with
"5371ab73-3421-4db2-95ce-441fb8621f92" is much more fraught than
dealing with its dashless form, "5371ab7334214db2-95ce441fb8621f92".)

I am now running into some issues with object sizes (link tables and
indices mainly) which I would think to ameliorate at least temporarily
by switching to the UUID type (128-bit binary storage instead of 32
bytes).  PostgreSQL's UUID type is very forgiving about accepting
input and will take the dashless form flawlessly.

Changing the UUID type's output representation to the dashless form,
however, has me stumped. Any ideas?  I looked at creating a domain or
a user-specified type, but I don't see how I can change what is output
by default in psql (and what is given in "string" format to my ORM
layer).

(Warning, pgsql-hackers territory below.)

Current best idea:

In src/backend/utils/adt/uuid.c at line 25, uuid_out seems to be hard-coded.

Can I compile my own version of uuid_out and update the system
catalogs, or create a "uuid_dashless" type that uses my own custom
uuid_dashless.c that's hacked to remove dashes?  Will I break
everything if I try this?


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux