After succesfully installing postgresql 9.2.2 from source (on OpenSUSE 11.4, which does not have this version in the repositories), I am trying to restore a database that makes use of the pg_trgm extension. This results in errors because pg_trgm is not found.
From this StackOverflow question: Similarity function in Postgres with pg_trgm, I gather that pg_trgm should be in /usr/share/postgresql//contrib, but there is no contrib folder anywhere in my /usr tree.
Also, I cannot seem to find a clear explanation of how the postgres extension mechanism works, or how to manually install an extension.
There is a contrib folder in the postgresql source tree, but I am not sure how to use this. Should I manually copy this somewhere to /usr tree? Can anyone point me to (or give) an explanation of how to install an extension like pg_trgm in postgresql?
Assuming you have configured postgresql with ./configure, it has used the default prefix /usr/local/pgsql, so that everything gets installed below that directory.
The answer you link to relates to Debian, which uses a different layout that conforms to the Debian policy, but in your case /usr/share... is irrelevant. Anyway it's not really necessary to know that in order to install stuff from contrib, since there is no need to copy anything manually.
To install the pg_trgm extension from source, there are two steps:
1) build and install it from your postgresql source tree:
$ cd /path/to/src/postgresql-9.2.2/contrib/pg_trgm
$ make
$ sudo make install # or su -c 'make install' if you don't use sudo
2) activate it with psql in your database:
$ sudo -u postgres psql -d database -c "create extension pg_trgm;"
To have it activated by default on any database created in the future, apply this command to the template1 database.
I've use Postgresql in the Centos 7 and the package with the pg_trgm allowed to install:
$yum install postgresql-contrib
Related
I installed the Apache-Age extension for postgres and this extension specifies that it works with postgres-11 or postgres-12. However I have already installed postgres-14 on my system. Am i gonna have a problem with that? And if I am how do i only uninstall the postgres-14 version?
I tried searching the deb packages installed to see if i find postgres-14 but i can't seem to find it
So mainly the apache-age extension works with PostgreSQL versions 11 and 12. It creates problems with different other versions of PostgreSQL.
In order to have a smooth installation follow the below steps:
uninstall PostgreSQL version 14
reinstall PostgreSQL version 11 or 12
Uninstalling PostgreSQL version 14:
For uninstalling the PostgreSQL from ubuntu:
sudo apt remove postgresql postgresql-contrib
The output would look something like this:
After uninstalling PostgreSQL, uninstall the dependencies
sudo apt autoremove
The output of the above command would look like this:
enter Y here and the PostgreSQL will be uninstalled.
Now reinstall the PostgreSQL version 11 or 12 using the below commands:
Download the files in any folder:
wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f postgresql-11.18.tar.gz
The command will download and extract the tar files for Linux users from Source in the working directory.
Installing PG:
Now we will move toward installing PG
cd postgresql-11.18
# configure by setting flags
./configure --enable-debug --enable-cassert --prefix=$(path) CFLAGS="-ggdb -Og
# now install
make install
References:
For more references you can also see:
https://dev.to/talhahahae/installation-of-apache-age-and-postgresql-from-source-in-linux-part-1-gka
https://www.commandprompt.com/education/how-to-uninstall-postgresql-from-ubuntu/#:~:text=Conclusion-,To%20uninstall%20Postgres%20from%20your%20Ubuntu%20operating%20system%2C%20open%20the,“sudo%20apt%20autoremove”%20command.
https://github.com/git-guides/install-git
https://age.apache.org/age-manual/master/intro/setup.html
https://www.postgresql.org/docs/current/install-procedure.html
Apache AGE only supports Postgres-11 and Postgres-12. You can follow the following to install Apache AGE with Postgres:
How to install AGE extension of postgresql from source code in ubuntu?
While Apache Age is designed to work with PostgreSQL 11 and 12, you can have multiple versions of PostgreSQL installed in your computer. However, the installations need to be in "different directories". Each version of PostgreSQL will have its own set of binaries and configuration files.
When you install multiple versions of PostgreSQL, it is important to ensure that each version is installed in a separate directory and that the ports used by each instance do not conflict with each other. Additionally, you may need to specify the correct version of PostgreSQL when running commands, by using the appropriate version-specific binary or setting the PATH environment variable to include the correct directory.
Looking to install the pgstattuple extension on my Postgres 12 DB on RHEL 7 to see index fragmentation. Currently I only have one extension installed and that's the plpgsql extension.
Executing 'CREATE EXTENSION pgstattuple' results in the following error:
SQL Error [58P01]: ERROR: could not open extension control file "/usr/pgsql-12/share/extension/pgstattuple.control": No such file or directory
And I verified that the pgstattuple.control is not located in the /usr/pgsql-12/share/extension folder.
Searching around the net, seemed to indicate that the postgresql-contrib needed to be installed to get the pgstattuple extension. So I did the following command:
$ sudo yum install postgresql-contrib
Unfortunately the yum install postgresql-contrib resulted in the pgstattuple and other extensions being installed into the /usr/pgsql-9.6/share/extension
folder, and not in the /usr/pgsql-12/share/extension folder where I want them.
For giggles, I tried copying all the pgstattuple* files in /usr/pgsql-9.6/share/extension to /usr/pgsql-12/share/extension folder, and then tried calling CREATE extension pgstattuple, but that didn't work with another error.
Questions are:
Should I expect sudo yum install postgresql-contrib to actually install the pgstattuple extension for Postgres 12?? Or is there some other package name for Postgres 12?
Could this be some problem with my Red Hat Repository configuration?
In general what's the command to install the pgstattuple extension for Postgres 12 so that the pgstattuple files will end up in /usr/pgsql-12/share/extension folder??
Really appreciate any suggestions you have.
Thank you.
I am getting the following error when I run create extension postgis;
ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory
I am using Postgres 9.6.3 and PostGIS 2.3.2 installed using Homebrew on OS X El Capitan.
mdfind -name postgis.control shows:
/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control
brew info postgis shows:
PostGIS extension modules installed to:
/usr/local/share/postgresql/extension
When I start the Postgres console I see:
psql (9.6.3, server 9.6.1)
I read a similar question, PostGIS Homebrew installation referencing an old path?, and tried to reload postgresql using the commands given in the top answer, but I am still seeing psql (9.6.3, server 9.6.1). Also, I believe my issue is different because it's looking for the extension control file in /Library and not /usr/local/Cellar.
Any help would be appreciated.
When you try to install postgis it install latest version of postgresql along with it as dependency.
So if you installed postgres#V (where V is user desired version )
brew install postgresql#V
later you run this command
brew install postgis
it will install postgres10.1 or whatever is latest.
So after that if run
create extension postgis;
In postgresql#V it will try to check its extension directory and it won't find postgis.control in extension directory as this postgis is installed in extension folder of postgresql version that is installed with that.
To solve this problem, you have to create a symlink from given installation of postgis to the desired postgresql#V
This example for postgresql#9.6
ln -s /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/postgresql#9.6/9.6.6/share/postgresql#9.6/extension/
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/postgis-2.3
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/
before running these commands, please check postgresql version and file path in your system
Thanks this gist for help.
I had a similar problem with full details here. When the server is mentioned in your Postgres console, it means that you're referencing an older codebase. Stop that server and launch the correct server with the following commands.
$ brew services list
That will give you a list of database servers that are running.
$ brew services stop postgresql#<older-version>
$ brew services start postgresql
Ubuntu 14.04.3, PostgreSQL 9.6
Maybe I can get the plpythonu source code from the PostgreSQL 9.6 source code or somewhere else, put it into the /contrib directory, make it and CREATE EXTENSION after that!? Or something like that.
Don't want to think that PostgreSQL reinstall is my only way.
you can simply run
python 2
sudo apt-get install postgresql-contrib postgresql-plpython-9.6
python 3
sudo apt-get install postgresql-contrib postgresql-plpython3-9.6
Then check the extension is installed
SELECT * FROM pg_available_extensions WHERE name like '%plpython%';
To apply the extension to the database, use
for python 2
CREATE EXTENSION plpython2u;
for python 3
CREATE EXTENSION plpython3u;
I need to add an extension called unaccent to my postgres database.
Postgres version PostgreSQL version: 9.3rc1
I have a problem to install the extension.
What i did:
sudo apt-get install postgresql-contrib-9.1
I know it's with 9.1 version, but on my test server i did everyting the same with postgres version 9.4, and everything works.
When i run a script on my production server
CREATE EXTENSION unaccent schema pg_catalog;
it throws me an error :
could not open extension control file "/usr/local/pgsql/share/extension/unaccent.control": Directory or file doesn't exist
What is the problem in this case? Extension has been installed into "wrong" (i guess) directory /usr/share/postgresql/9.1/extension instead of usr/local/pgsql/share/extension
Is there any chance to make postgres look into other directory than default for extensions?
Don't use PostgreSQL 9.3rc1. Just don't. That's not a production version.
You have to install the contrib modules from the same source and in the same version as PostgreSQL core. Everything else won't work.
So this is what you should do:
Upgrade PostgreSQL to something more recent, at leat 9.3.14.
Install the contrib modules from the same provider in the same version.