Thread: Replacing uuid-ossp with uuid-freebsd

Replacing uuid-ossp with uuid-freebsd

From
Piotr Gasidło
Date:
Hello,

I've moved from Linux to FreeBSD. I've used uuid-ossp. Now I need to
aply patch to make it work under FreeBSD. This is rather dirty hack.
So I need to replace it once and for all with uuid-freebsd module. But
because in my database I use uuid type and uuid_* functions is not
easy:

test_uuid=# \d test
                 Table "public.test"
 Column | Type |              Modifiers
--------+------+-------------------------------------
 id     | uuid | not null default uuid_generate_v4()

test_uuid=# drop extension "uuid-ossp";
ERROR:  cannot drop extension uuid-ossp because other objects depend on it
DETAIL:  default for table test column id depends on function uuid_generate_v4()
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

test_uuid=# create extension "uuid-freebsd";
ERROR:  function "uuid_nil" already exists with same argument types
test_uuid=#

I can do this:

test_uuid=# CREATE OR REPLACE FUNCTION uuid_generate_v4()
RETURNS uuid
AS '/usr/local/lib/postgresql/uuid-freebsd.so', 'uuid_generate_v4'
VOLATILE STRICT LANGUAGE C;
CREATE FUNCTION

But THIS is now dirty hack - extension uuid-ossp is still there
(according to \dx) and I use functions from other, unregistered
extension.

I think, that I need do some low level hacking on pg_catalog. Any
hints how to do it cleanly (eq. replace functions, drop uuid-ossp and
add uuid-freebsd).

--
Piotr Gasidło


Re: Replacing uuid-ossp with uuid-freebsd

From
Adrian Klaver
Date:
On 05/25/2015 07:17 AM, Piotr Gasidło wrote:
> Hello,
>
> I've moved from Linux to FreeBSD. I've used uuid-ossp. Now I need to
> aply patch to make it work under FreeBSD. This is rather dirty hack.
> So I need to replace it once and for all with uuid-freebsd module. But
> because in my database I use uuid type and uuid_* functions is not
> easy:
>
> test_uuid=# \d test
>                   Table "public.test"
>   Column | Type |              Modifiers
> --------+------+-------------------------------------
>   id     | uuid | not null default uuid_generate_v4()
>
> test_uuid=# drop extension "uuid-ossp";
> ERROR:  cannot drop extension uuid-ossp because other objects depend on it
> DETAIL:  default for table test column id depends on function uuid_generate_v4()
> HINT:  Use DROP ... CASCADE to drop the dependent objects too.
>
> test_uuid=# create extension "uuid-freebsd";
> ERROR:  function "uuid_nil" already exists with same argument types
> test_uuid=#
>
> I can do this:
>
> test_uuid=# CREATE OR REPLACE FUNCTION uuid_generate_v4()
> RETURNS uuid
> AS '/usr/local/lib/postgresql/uuid-freebsd.so', 'uuid_generate_v4'
> VOLATILE STRICT LANGUAGE C;
> CREATE FUNCTION
>
> But THIS is now dirty hack - extension uuid-ossp is still there
> (according to \dx) and I use functions from other, unregistered
> extension.
>
> I think, that I need do some low level hacking on pg_catalog. Any
> hints how to do it cleanly (eq. replace functions, drop uuid-ossp and
> add uuid-freebsd).
>

What version of Postgres?

So did you see the section at the bottom of this page?:

http://www.postgresql.org/docs/9.4/interactive/uuid-ossp.html


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Replacing uuid-ossp with uuid-freebsd

From
Jan de Visser
Date:

On May 25, 2015 04:17:32 PM Piotr Gasidło wrote:

> test_uuid=# drop extension "uuid-ossp";

> ERROR:  cannot drop extension uuid-ossp because other objects depend on it

> DETAIL:  default for table test column id depends on function

> uuid_generate_v4() HINT:  Use DROP ... CASCADE to drop the dependent

> objects too.

 

Wouldn't a simple ALTER TABLE to change/drop the default of the id column do?

Re: Replacing uuid-ossp with uuid-freebsd

From
Piotr Gasidło
Date:
2015-05-25 16:28 GMT+02:00 Adrian Klaver <adrian.klaver@aklaver.com>:
> On 05/25/2015 07:17 AM, Piotr Gasidło wrote:
>> (...)
>> I've moved from Linux to FreeBSD. I've used uuid-ossp. Now I need to
>> aply patch to make it work under FreeBSD. This is rather dirty hack.
>> So I need to replace it once and for all with uuid-freebsd module. (...)

> What version of Postgres?
>
> So did you see the section at the bottom of this page?:
>
> http://www.postgresql.org/docs/9.4/interactive/uuid-ossp.html

Thanks - this helps.

Currently I'm running 9.3.4. My plan was to upgrade to latest 9.3.x
and then to 9.4. With your hint it's now easier.

--
Piotr Gasidło