Skip to content

PostgreSQL extension uuid-ossp installed visible in UI but not working in terminal ; Function uuid_generate_v4() does not exist on PostgreSQL #124

@iamraj007

Description

@iamraj007

The "uuid-ossp" extension is installed in Azure PostgreSQL flexible DB server yet its functions are not working as if its not installed.
Below we shows the thing tried and available output to understand the issue.

Exception without installed "uuid-ossp" extension 
Error: pq: extension "uuid-ossp" **is not allow-listed** for "azure_pg_admin" users in Azure Database for PostgreSQL

Above result then tried with below terraform code
resource "postgresql_extension" "uuid_ossp_extension" {
  name = "uuid-ossp"
}

After it was installed somehow, tf output:
# postgresql_extension.uuid_ossp_extension:
resource "postgresql_extension" "uuid_ossp_extension" {
    create_cascade = false
    database       = "database_name"
    drop_cascade   = false
    id               = "database_name.uuid-ossp"
    name            = "uuid-ossp"
    schema         = "public"
    version         = "1.1"
}

"uuid-ossp" is among available in Azure Database for PostgreSQL flexible server:
Link: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-extensions
Image: image

Terminal output: (After the extension was installed)

postgres=> SELECT oid, extname, extversion FROM pg_extension;
  oid  |  extname  | extversion
-------+-----------+------------
 14509 | plpgsql   | 1.0
 24577 | pgaadauth | 1.2
 24733 | pg_cron   | 1.4-1
 24786 | azure     | 1.0
(4 rows)

postgres=> SHOW azure.extensions;
 azure.extensions
------------------
 UUID-OSSP
(1 row)


postgres=> SELECT *  FROM pg_extension WHERE extname = 'uuid-ossp';
 oid | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
-----+---------+----------+--------------+----------------+------------+-----------+--------------
(0 rows)

Though above wont show as its a part of azure.extensions.

Portal UI after the extension was installed:
2024-09-05 11_30_22-Window

ISSUE :
NOT able to use uuid extension function
postgres=> SELECT uuid_generate_v1(), uuid_generate_v4(), uuid_nil();
ERROR: function uuid_generate_v1() does not exist
LINE 1: SELECT uuid_generate_v1(), uuid_generate_v4(), uuid_nil();
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Also the extension don't need database reboot as per document.

PostgreSQL version: 14.12
Terraform: v1.6.5

Solution to "Function uuid_generate_v4() does not exist on PostgreSQL" via terminal :
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Any one else facing this and found a solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions