mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-08 21:29:22 +02:00
We have seen one too many reports of people trying to use 9.1 extension files in the old-fashioned way of sourcing them in psql. Not only does that usually not work (due to failure to substitute for MODULE_PATHNAME and/or @extschema@), but if it did work they'd get a collection of loose objects not an extension. To prevent this, insert an \echo ... \quit line that prints a suitable error message into each extension script file, and teach commands/extension.c to ignore lines starting with \echo. That should not only prevent any adverse consequences of loading a script file the wrong way, but make it crystal clear to users that they need to do it differently now. Tom Lane, following an idea of Andrew Dunstan's. Back-patch into 9.1 ... there is not going to be much value in this if we wait till 9.2.
203 lines
4.7 KiB
SQL
203 lines
4.7 KiB
SQL
/* contrib/pgcrypto/pgcrypto--1.0.sql */
|
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
\echo Use "CREATE EXTENSION pgcrypto" to load this file. \quit
|
|
|
|
CREATE FUNCTION digest(text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_digest'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION digest(bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_digest'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION hmac(text, text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_hmac'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION hmac(bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_hmac'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION crypt(text, text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pg_crypt'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION gen_salt(text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pg_gen_salt'
|
|
LANGUAGE C VOLATILE STRICT;
|
|
|
|
CREATE FUNCTION gen_salt(text, int4)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pg_gen_salt_rounds'
|
|
LANGUAGE C VOLATILE STRICT;
|
|
|
|
CREATE FUNCTION encrypt(bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_encrypt'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION decrypt(bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_decrypt'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION encrypt_iv(bytea, bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_encrypt_iv'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION decrypt_iv(bytea, bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_decrypt_iv'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION gen_random_bytes(int4)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_random_bytes'
|
|
LANGUAGE 'C' VOLATILE STRICT;
|
|
|
|
--
|
|
-- pgp_sym_encrypt(data, key)
|
|
--
|
|
CREATE FUNCTION pgp_sym_encrypt(text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_encrypt_text'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_encrypt_bytea'
|
|
LANGUAGE C STRICT;
|
|
|
|
--
|
|
-- pgp_sym_encrypt(data, key, args)
|
|
--
|
|
CREATE FUNCTION pgp_sym_encrypt(text, text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_encrypt_text'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_encrypt_bytea'
|
|
LANGUAGE C STRICT;
|
|
|
|
--
|
|
-- pgp_sym_decrypt(data, key)
|
|
--
|
|
CREATE FUNCTION pgp_sym_decrypt(bytea, text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_decrypt_text'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_decrypt_bytea'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- pgp_sym_decrypt(data, key, args)
|
|
--
|
|
CREATE FUNCTION pgp_sym_decrypt(bytea, text, text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_decrypt_text'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_sym_decrypt_bytea'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- pgp_pub_encrypt(data, key)
|
|
--
|
|
CREATE FUNCTION pgp_pub_encrypt(text, bytea)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_encrypt_text'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_encrypt_bytea'
|
|
LANGUAGE C STRICT;
|
|
|
|
--
|
|
-- pgp_pub_encrypt(data, key, args)
|
|
--
|
|
CREATE FUNCTION pgp_pub_encrypt(text, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_encrypt_text'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_encrypt_bytea'
|
|
LANGUAGE C STRICT;
|
|
|
|
--
|
|
-- pgp_pub_decrypt(data, key)
|
|
--
|
|
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_text'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_bytea'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- pgp_pub_decrypt(data, key, psw)
|
|
--
|
|
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_text'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_bytea'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- pgp_pub_decrypt(data, key, psw, arg)
|
|
--
|
|
CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text, text)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_text'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pgp_pub_decrypt_bytea'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- PGP key ID
|
|
--
|
|
CREATE FUNCTION pgp_key_id(bytea)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pgp_key_id_w'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
--
|
|
-- pgp armor
|
|
--
|
|
CREATE FUNCTION armor(bytea)
|
|
RETURNS text
|
|
AS 'MODULE_PATHNAME', 'pg_armor'
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
CREATE FUNCTION dearmor(text)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'pg_dearmor'
|
|
LANGUAGE C IMMUTABLE STRICT;
|