Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install pgcrypto in postgresql 9.1 on Windows?

The web page for Postgresql says that pgcrypto is included in the download for Postgresql 9.1. There is no pgcrypto.sql file, however. If I look in the share\extension directory there are 3 files:

pgcrypto--1.0.sql pgcrypto--unpackaged--1.0.sql pgcrypto.control

If I try to install with

\i pgcrypto--1.0.sql

I get a bunch of errors like this:

psql:pgcrypto--1.0.sql:194: ERROR:  could not access file "MODULE_PATHNAME": No such file or directory

Maybe the files in share\extension were meant to be called by the share\contrib\pgcrypto.sql file (which doesn't exist).

On linux on Postgresql 8.4 I have to install the contrib package to get pgcrypto.sql. Is there another package I have to install on Windows for Postgresql 9.1?

Thanks.

like image 995
Dean Schulze Avatar asked Nov 03 '11 19:11

Dean Schulze


3 Answers

In v9.1 the way to install extra modules was changed, those are now called EXTENSIONS and are installed with a special SQL statement CREATE EXTENSION.

like image 100
Milen A. Radev Avatar answered Nov 14 '22 19:11

Milen A. Radev


1.add the extensions: create extension pgcrypto

2.check the extensions: select * from pg_available_extensions enter image description here

3.use the extensions: select '{SHA}'||encode(digest('test', 'sha1'), 'base64');

enter image description here

like image 30
liyuhui Avatar answered Nov 14 '22 20:11

liyuhui


If you need use some extension, the way is for example for pgcrypto: "CREATE EXTENSION pgcrypto" from a window query, but is very important to said that this script must be executed in the DB that you need to use this extension, after having finished the script to verify that it is installed, check in pgAdmin over your DB the extensions seccion.

I hope this help.

like image 1
hermeslm Avatar answered Nov 14 '22 20:11

hermeslm