32

I want to use uuid in Postgresql 9.2 on Ubuntu 13. So when I tried to check whether is available or not, I did:

select uuid_generate_v4() as one;

And it gave me ERROR: function uuid_generate_v4() does not exist

Then I did CREATE EXTENSION "uuid-ossp";

ERROR:  could not open extension control file "/usr/share/postgresql/9.2/extension/uuid-ossp.control": No such file or directory

Well, what do I do next?

By the way, SELECT * FROM pg_available_extensions; returns plpsql (1.0) only.

Incerteza
  • 32,326
  • 47
  • 154
  • 261

4 Answers4

44

The operating system package that contains the extension is not installed. To install it:

apt-get install postgresql-contrib-9.2
Peter Eisentraut
  • 35,221
  • 12
  • 85
  • 90
  • 1
    I ended up using a more generic package, postgresql-contrib, which I think maps to your current version. That also worked for me. – Vini.g.fer Apr 08 '15 at 18:40
14

For anyone using the asdf version manager with the asdf-postgres plugin, installing postgres versions as follows fixes this issue:

POSTGRES_EXTRA_CONFIGURE_OPTIONS=--with-uuid=e2fs asdf install postgres <VERSION>
user456584
  • 86,427
  • 15
  • 75
  • 107
  • 4
    For me this also required a `sudo apt install uuid-dev`, otherwise what a lifesaver, thanks! – steel Aug 22 '18 at 01:19
3

For you guys, who installed postgres using postgres rpm repo on Fedora or similar distro:

sudo dnf install postgresql-contrib

installs a package from default fedora repo, which conflicts with postgres, like:

/usr/pgsql-12/lib/libpq.so.5: no version information available (required by psql)

Right way is

sudo dnf install postgresql12-contrib

You can double check it during install, it has to be from pgdg12, same as postgresql-server

(you have insert your postgres version instead of '12')

1

If you still get the error, try to run manually the two SQL files inside /usr/share/postgresql/9.X/extension/uuid-ossp*.sql into your database

Mohamed Dernoun
  • 776
  • 5
  • 13