Can't use uuid and create an extension to use it - postgresql

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.

The operating system package that contains the extension is not installed. To install it:
apt-get install postgresql-contrib-9.2

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>

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')

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

Related

CREATE LANGUAGE plperlu; fails despite postgresql-plperl-12 being installed

I'm on an Ubuntu-derived system (specifically pop_os from System76). I am trying to get Bucardo installed, but it appears to be failing because plperlu is not functional.
In a psql prompt:
# CREATE LANGUAGE plperlu;
ERROR: could not access file "$libdir/plperl": No such file or directory
However, running:
$ pg_config --pkglibdir
/usr/lib/postgresql/12/lib
and:
$ ls /usr/lib/postgresql/12/lib/plperl*
/usr/lib/postgresql/12/lib/plperl.so
I do have the postgresql-plperl-12 package installed:
# apt install postgresql-plperl-12
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgresql-plperl-12 is already the newest version (12.7-0ubuntu0.20.10.1).
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
All the related errors I could find related either to the relevant package not being installed or the language not being created in postgres, so I'm a little stymied. The CREATE LANGUAGE statement's error appears to indicate that Postgres is looking for a file without an extension, but I'm not sure if that's fixable by a simple mv, and if so, who to report a package bug to.
Edit:
Prompted by #AdrianKlaver's comment:
# CREATE EXTENSION plperlu;
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/plperlu.control": No such file or directory
... now why is it looking in /usr/share/postgresql/10/?
I may be misinterpreting, but I have:
$ psql --version
psql (PostgreSQL) 12.7 (Ubuntu 12.7-0ubuntu0.20.10.1)
plperlu.control does exist in /usr/share/postgresql/12/extension/... but SELECT version() is indeed PostgreSQL 10.10... so something somewhere has gone wrong during an update. Does having a psql version that differs from the actualy postgres that is running cause issues?
The issue is that there are multiple versions of Postgres running as servers. Running pg_lsclusters will show what they are. The CREATE EXTENSION fails as the extension code for the version of Postgres that the command is being run on has not been installed.
Got the same problem on Debian 11 and Postgres 12. Solution that worked for me:
apt update
apt install -y postgresql-server-dev-12 wget
wget https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-12/postgresql-plperl-12_12.10-1.pgdg20.04+1+b1_amd64.deb
dpkg -i ./postgresql-plperl-12_12.10-1.pgdg20.04+1+b1_amd64.deb
apt --fix-broken install # because problems on dpkg command
apt list --installed | grep postgresql-plperl-12

How do i install postgis on ubuntu server?

My pc showing i have two versions of Postgres installed.
postgres=# \c viserver
psql (12.2 (Ubuntu 12.2-4), server 11.7 (Ubuntu 11.7-0ubuntu0.19.10.1))
I installed PostGIS using sudo apt-get install postgis but it installed PostGIS in Postgres 12.
But I want to install it in Postgres 11. cause my server version using postgres 11.
because CREATE EXTENSION postgis; on a database giving error
ERROR: could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
the error you see means that some packages are not installed.
To have postgis.control please check and install
postgresql-11-postgis-X.Y (e.g. X.Y = 2.5)
and
postgresql-11-postgis-X.Y-scripts
Regards,
Mohamad
It helped what S. Mohamad explained. But I want to share the exact answer.
Steps to resolve the error:
Try to run sudo apt install postgresql-11-postgis. This will install but provide suggestion what to install like below.
You can see the 2 versions of postgis I installed the latest version by sudo apt install postgresql-11-postgis-3
After installing required package you can run CREATE EXTENSION postgis; in postgres and it will show you following:
Yay!! No errors.

CREATE EXTENSION postgis fails,

I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1)
Running temba=# create extension postgis; fails with the following error
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory
I ran find /usr -name postgis.control only to find out postgis.control is inside a folder named 12 instead of 10
laptop#xyz-x:~$ find /usr -name postgis.control
/usr/share/postgresql/12/extension/postgis.control
Edit 1
I have already ran sudo apt-get install postgis
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgis is already the newest version (3.0.1+dfsg-2.pgdg18.04+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I ran this sudo apt install postgis postgresql-10-postgis-2.5 and it worked
I was not sure what version of postgres or postgis I needed, so I found sudo apt install postgis postgresql-postgis worked.
It either gave me the latest, or matched my installed postgres version.
I use Linux Mint and had this problem for postgres10, and also: could not access file "$libdir/postgis-2.4": No such file or directory following that. Installation of specific extension and scripts package cures it for me:
sudo apt install postgresql-10-postgis-2.4 postgresql-10-postgis-2.4-scripts Reading package lists... Done Building dependency tree Reading state information... Done postgresql-10-postgis-2.4-scripts is already the newest version (2.4.3+dfsg-4). postgresql-10-postgis-2.4-scripts set to manually installed. The following NEW packages will be installed libprotobuf-c1 postgresql-10-postgis-2.4
Then go, in my case to pgAdmin and CREATE EXTENSION postgis; returns successfully.
sudo apt install postgis postgresql-13-postgis-3 for postgres 13.1 and next CREATE EXTENSION postgis; (postgres command)
Alternatively, and easier, run sudo apt install postgis postgresql-12-postgis-2.5 for postgres12
Go to the file location where postgis is installed;
C:\Program Files\PostgreSQL\12\bin
Run stackbuilder.exe;
Select connected your database;
Select "Spatial Extensions" and install
If CREATE EXTENSION postgis is not working and giving you the error no such file or directory.then do follow the following steps:
Go to the file location where postgis is installed;
1.C:\Program Files\PostgreSQL\12\bin
2.Run stackbuilder.exe;
3.Select connected your database;
4.Select "Spatial Extensions" and install
and if you are stackbuilder is not responding wait for some time try with fast internet connection.
For PostgreSQL 14: sudo apt install postgis postgresql-14-postgis-3
Tested on Ubuntu 20.04

Can not find PostGIS extensions ( installed in a different directory ) and $libdir/postgis-2.3 in mac os

I'm using postgres in pycharm and it can't find the postGIS extensions. It is looking for them in: /Library/PostgreSQL/9.6/share/postgresql/extension/
however, when I install PostGIS, it tells me that: PostGIS extension modules are installed in: /usr/local/share/postgresql/extension
Another issue (don't know if it is related to the first) is : could not access file "$libdir/postgis-2.3": No such file or directory
I noticed this issue after having upgraded from PostGIS 2.3.0 to 2.4.0. My databases were still looking for 2.3.0 libraries when the 2.4.0 were installed.
The solution was to individually update the databases to look for the 2.4.0 versions:
ALTER EXTENSION postgis UPDATE;
SELECT PostGIS_full_version();
See Upgrading PostGIS section for further details
I installed using Homebrew and ran into this same issue. Seems to be resolved after following instructions from https://www.linuxquestions.org/questions/fedora-35/problems-to-start-postgresql-with-postgis-after-upgrade-to-fedora-28-a-4175629479/#post5853352:
Find where postgis-2.4.so is (e.g.
/database/postgresql/pgsql-10.0/lib/postgis-2.4.so) then create a
symbolic link to older name so for my example I'd do:
ln -s /database/postgresql/pgsql-10.0/lib/postgis-2.4.so /database/postgresql/pgsql-10.0/lib/postgis-2.3.so
For me, the fix was this exact command:
ln -s /usr/local/lib/postgresql/postgis-2.5.so /usr/local/lib/postgresql/postgis-2.3.so

Postgres create POSTGIS extension error with CentOS 6

I am running PostgreSQL 9.3 with Postgis 2.0 on CentOS 6.3.
I installed PostgreSQL and PostGIS according to this instructions:
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21CentOS6pgdg
When trying to create Postgis extension
Create Extension Postgis;
I get the following error,
ERROR: could not load library "/usr/pgsql-9.3/lib/rtpostgis-2.1.so": libhdf5.so.6: cannot open shared object file: No such file or directory
May I know how to install the POSTGIS extension successfully?
I have CentOs 6.5 and did this:
1) Install following packages
hdf5-1.8.11-42.1.x86_64.rpm
json-c-0.10-2.1.x86_64.rpm
libhdf5-8-1.8.11-42.1.x86_64.rpm
libhdf5_hl8-1.8.11-42.1.x86_64.rpm
I don't know if I can link files directly here, so look for those files at rpm.pbone.net, download CentOS 6 version.
2) As Postgis requires version hdf5 version 6, you have to execute this commands as root (# is prompt)
# cd /usr/lib64
# ln -s libhdf5_hl.so.8 libhdf5_hl.so.6
# ln -s libhdf5.so.8 libhdf5.so.6
PS Don't forget to install postgresql contrib package, as Postgis requires fuzzystrmatch extension for some modules.
Have you tried installing the package that contains libhdf5 and then tried running again the create extension command? Apparently postgis is linked to that package which is not present on your system.