Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when creating unaccent extension on PostgreSQL

I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast.

I am using a fresh Ubuntu 12.04 server running PostgreSQL 9.1.5 installed using apt-get with the ppa:pitti/postgresql with precise.

I get the following error when trying to run the migration and when I try the same command in the psql console with the peer postgres user:

postgres=# CREATE EXTENSION unaccent; 

ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/unaccent.control":
No such file or directory

In my local box running Ubuntu 10.04 desktop I use the same repository (natty) and it works well.

Any insights would be greatly appreciated.

like image 795
fagiani Avatar asked Aug 23 '12 22:08

fagiani


People also ask

How do I enable PostgreSQL extension?

To activate and use an extension, you must download and install the necessary files (if not delivered with the standard download) and issue the command CREATE EXTENSION <extension_name>; within an SQL client like psql . To control which extensions are already installed use: \dx within psql .

How to remove accents in PostgreSQL?

The unaccent() function removes accents (diacritic signs) from a given string.

What is create extension in PostgreSQL?

Description. CREATE EXTENSION loads a new extension into the current database. There must not be an extension of the same name already loaded. Loading an extension essentially amounts to running the extension's script file.

What are PostgreSQL extensions?

Extensions were implemented in PostgreSQL 9.1 to allow for easier packaging of additions to PostgreSQL. Extensions can package user-visible functions or use hooks in the PostgreSQL to modify how the database does certain processes.


1 Answers

You need to install the package postgresql-contrib-9.1 in your system first. (Adapt to your version number! Here is the currently available list of packages.) That's the case under Debian, Ubuntu & friends anyway. Using a system user with the necessary privileges:

apt-get install postgresql-contrib-9.1 

If your currently logged in user does not have the necessary privileges (but sudo rights):

sudo apt-get install postgresql-contrib-9.1 

Quoting the PostgreSQL Apt Repository:

If the version included in your version of Debian is not the one you want, you can use the PostgreSQL Apt Repository.

There are basic install instructions on the Postgres website for each available OS.

For accent-insensitive indices using unaccent consider this related question:

  • Does PostgreSQL support "accent insensitive" collations?
like image 116
Erwin Brandstetter Avatar answered Sep 28 '22 06:09

Erwin Brandstetter