Error Creating pgcrypto Extension - Mailing list pgsql-general

From Mark Hill
Subject Error Creating pgcrypto Extension
Date
Msg-id BYAPR05MB6632AA793C3F51F016FE752EEEB82@BYAPR05MB6632.namprd05.prod.outlook.com
Whole thread
Responses Re: Error Creating pgcrypto Extension
List pgsql-general

We are trying to run this code in Postgres 18.6:
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA pg_catalog CASCADE;

and getting the error

postgres=# CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA pg_catalog CASCADE;

ERROR:  function "gen_random_uuid" already exists with same argument types

CONTEXT:  SQL statement "CREATE FUNCTION gen_random_uuid()

RETURNS uuid

AS '$libdir/pgcrypto', 'pg_random_uuid'

LANGUAGE C VOLATILE PARALLEL SAFE"

extension script file "pgcrypto--1.3.sql", near line 66

That’s because pgcrypto—1.3.sql has the following 4 lines starting at line 66:
CREATE FUNCTION gen_random_uuid()

RETURNS uuid

AS 'MODULE_PATHNAME', 'pg_random_uuid'

LANGUAGE C VOLATILE PARALLEL SAFE;


which try to create the gen_random_uuid() function but since it already exists it throws an error.

1)  Should pgcrytpo—1.3.sql be trying to create gen_random_uuid() if/when it already exists?


The pgcrypto.control file contains:
# pgcrypto extension

comment = 'cryptographic functions'

default_version = '1.4'

module_pathname = '$libdir/pgcrypto'

relocatable = true

trusted = true


2) given what’s in pgcrypto.control should there be a pgcrypto—1.4.sql file?


NOTE:  If I comment lines 66-69 in pgcrypto—1.3.sql the
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA pg_catalog CASCADE;
code completes successfully.

I’m hesitant to alter pgcrypto—1.3.sql.   Thoughts?

Thanks, Mark

 

pgsql-general by date:

Previous
From: lakshmi
Date:
Subject: Extension - ai_image_search: Image Search Inside PostgreSQL
Next
From: "David G. Johnston"
Date:
Subject: Re: Error Creating pgcrypto Extension