Can't create extensions plv8 postgresql - postgresql

After install postgres, can't create extension plv8.
I'm use: CREATE EXTENSION plv8;
I'm getting:
ERROR: could not open extension control file "/usr/local/share/postgresql/extension/plv8.control": No such file or directory
********** Error **********
ERROR: could not open extension control file "/usr/local/share/postgresql/extension/plv8.control": No such file or directory
SQL state: 58P01
version postgres: 9.6.2
version pgAdmin4: 1.4
How to install plv8?

This should work on most platforms (https://github.com/plv8/plv8/issues/212#issuecomment-287589193):
$ easy_install pgxnclient
$ pgxnclient install plv8
It didn't work for me though. The only solution I came up with was building the library from source.
If you don't have wget installed, run:
$ brew install wget
Then run:
$ wget https://github.com/plv8/plv8/archive/v2.0.0.tar.gz
$ tar -xvzf v2.0.0.tar.gz
$ cd plv8-2.0.0
$ make static
$ make install
It worked for me.

I. Docker-images with postgres and plv8. It's free, images for Postgres 13, 14, and 15 based on Debian and Alpine are available, amd64 and arm64 architectures supported.
docker pull sibedge/postgres-plv8
Default is Alpine/last Postgres version. the complete tag list
Pay attention, that BigInt is not serializable in v8 and by default in plv8 v3.0.0 and higher BigInt numbers are converted into string(!). But if you need BigInt as numbers support, use this image with Postgres and specific version of plv8:
docker pull sibedge/postgres-plv8-bigint
II. Or, you can build images (for PostgreSQL with installed plv8) yourself with Dockerfiles:
Postgres 14.2, plv8 v3.0.0, Alpine based. size of image is 235MB.
Postgres 13.6, plv8 v3.0.0, Alpine based. size of image is 231MB.
Postgres 13.4, plv8 v2.13.15, Debian based. size of image is 351MB.
Postgres 13.6, plv8 v3.0.0, Debian based. size of image is 427MB.
III. Simple installing plv8 v3.0.0 on Debian Linux (PostgreSQL 13 must be preinstalled) :
$ git clone https://github.com/sibedge-llc/plv8-build.git
$ cd plv8-build
$ git checkout pg13-3.0.0-debian
$ sudo make install

I find a new way. Just copy and Paste!
if you using postgresql version of: 9.5, 9.6 beta, 10 go this link to download package and learn what shoud you copy and where to past:
https://github.com/JasperFx/marten/blob/master/documentation/documentation/admin/installing-plv8-windows.md
if you using postgresql version of: 9.3, 9.4, 9.5, 9.6, 10, 11 and 12 for downloading package you can go here:
http://updates.xtuple.com/updates/plv8/win/xtuple_plv8.zip
for downloading package and then copy past like has mentioned in first link

Related

Postgres: Install a specific version of plv8

I'm installing plv8 in docker:
FROM postgres:13 AS build
ENV PLV8_VERSION=v3.0.0
RUN apt-get update && apt-get upgrade \
&& apt-get install -y git curl glib2.0 libc++-dev python python3-pip
libv8-dev postgresql-server-dev-$PG_MAJOR libncurses5
RUN pip install pgxnclient
RUN pgxn install plv8
This still seems to install the 2.3.11 version of plv8 though, which is incompatible with Postgres 13.
Is there any way I can specify the version that pgxn installs? Or any other way I can install a Postgres 13 version of plv8?
You can use our finished docker-images with postgres and plv8. It's free, images for Postgres 13, 14, and 15 based on Debian and Alpine are available, amd64 and arm64 architectures supported.
docker pull sibedge/postgres-plv8
Default uses Alpine and last Postgres version. All available tags here
Pay attention, that BigInt is not serializable in v8 and by default in plv8 v3.0.0 and higher BigInt numbers are converted into string(!). But if you need BigInt as numbers support, use this image with Postgres and specific version of plv8:
docker pull sibedge/postgres-plv8-bigint
OR you can use our binaries with these Dockerfiles and fast build compact images with postgres and plv8 yourself:
Postgres 14.2, plv8 v3.0.0, Alpine based. size of image is 235MB.
Postgres 13.6, plv8 v3.0.0, Alpine based. size of image is 231MB.
Postgres 13.4, plv8 v2.13.15, Debian based. size of image is 351MB.
Postgres 13.6, plv8 v3.0.0, Debian based. size of image is 427MB.
$ git clone https://github.com/sibedge-llc/plv8-build.git
$ cd plv8-build/docker
$ docker build -t pg14-plv8-3
$ docker run -it -d --name pg14-plv8-3 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432/tcp pg14-plv8-3
You can use it right now.
It looks like the latest versions of plv8 are not yet published on pgxn network yet. The last published version is 2.3.11 and that is what you see here.
To install the latest version of plv8 you can update your Dockerfile to build plv8 from source by following the build instructions. A good starting point would be to refer to the docker image clkao/postgres-plv8 which was built with postgres:10 base image.

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.

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

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

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.