Change UUID type default output representation

Поиск
Список
Период
Сортировка
От Randall Lucas
Тема Change UUID type default output representation
Дата
Msg-id CAHL9ZMzngzyjrdO_jDEnXvDuov1D9U=w-Yx-NmHEz+F1e1trqw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Change UUID type default output representation
Список pgsql-general
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?


В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: [HACKERS] Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1