247 KiB
| schema | function_name | definition |
|---|---|---|
| auth | CREATE OR REPLACE FUNCTION auth.email() | |
| RETURNS text | ||
| LANGUAGE sql | ||
| STABLE | ||
AS function |
||
| select | ||
| coalesce( | ||
| nullif(current_setting('request.jwt.claim.email', true), ''), | ||
| (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'email') | ||
| )::text | ||
function |
||
| auth | jwt | CREATE OR REPLACE FUNCTION auth.jwt() |
| RETURNS jsonb | ||
| LANGUAGE sql | ||
| STABLE | ||
AS function |
||
| select | ||
| coalesce( | ||
| nullif(current_setting('request.jwt.claim', true), ''), | ||
| nullif(current_setting('request.jwt.claims', true), '') | ||
| )::jsonb | ||
function |
||
| auth | role | CREATE OR REPLACE FUNCTION auth.role() |
| RETURNS text | ||
| LANGUAGE sql | ||
| STABLE | ||
AS function |
||
| select | ||
| coalesce( | ||
| nullif(current_setting('request.jwt.claim.role', true), ''), | ||
| (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role') | ||
| )::text | ||
function |
||
| auth | uid | CREATE OR REPLACE FUNCTION auth.uid() |
| RETURNS uuid | ||
| LANGUAGE sql | ||
| STABLE | ||
AS function |
||
| select | ||
| coalesce( | ||
| nullif(current_setting('request.jwt.claim.sub', true), ''), | ||
| (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub') | ||
| )::uuid | ||
function |
||
| extensions | algorithm_sign | CREATE OR REPLACE FUNCTION extensions.algorithm_sign(signables text, secret text, algorithm text) |
| RETURNS text | ||
| LANGUAGE sql | ||
| IMMUTABLE | ||
AS function |
||
| WITH | ||
| alg AS ( | ||
| SELECT CASE | ||
| WHEN algorithm = 'HS256' THEN 'sha256' | ||
| WHEN algorithm = 'HS384' THEN 'sha384' | ||
| WHEN algorithm = 'HS512' THEN 'sha512' | ||
| ELSE '' END AS id) -- hmac throws error | ||
| SELECT extensions.url_encode(extensions.hmac(signables, secret, alg.id)) FROM alg; | ||
function |
||
| extensions | armor | CREATE OR REPLACE FUNCTION extensions.armor(bytea) |
| RETURNS text | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_armor$function$ | ||
| extensions | armor | CREATE OR REPLACE FUNCTION extensions.armor(bytea, text[], text[]) |
| RETURNS text | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_armor$function$ | ||
| extensions | bytea_to_text | CREATE OR REPLACE FUNCTION extensions.bytea_to_text(data bytea) |
| RETURNS text | ||
| LANGUAGE c | ||
| IMMUTABLE STRICT | ||
| AS '$libdir/http', $function$bytea_to_text$function$ | ||
| extensions | crypt | CREATE OR REPLACE FUNCTION extensions.crypt(text, text) |
| RETURNS text | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_crypt$function$ | ||
| extensions | dearmor | CREATE OR REPLACE FUNCTION extensions.dearmor(text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_dearmor$function$ | ||
| extensions | decrypt | CREATE OR REPLACE FUNCTION extensions.decrypt(bytea, bytea, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_decrypt$function$ | ||
| extensions | decrypt_iv | CREATE OR REPLACE FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_decrypt_iv$function$ | ||
| extensions | digest | CREATE OR REPLACE FUNCTION extensions.digest(bytea, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_digest$function$ | ||
| extensions | digest | CREATE OR REPLACE FUNCTION extensions.digest(text, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_digest$function$ | ||
| extensions | encrypt | CREATE OR REPLACE FUNCTION extensions.encrypt(bytea, bytea, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_encrypt$function$ | ||
| extensions | encrypt_iv | CREATE OR REPLACE FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_encrypt_iv$function$ | ||
| extensions | gen_random_bytes | CREATE OR REPLACE FUNCTION extensions.gen_random_bytes(integer) |
| RETURNS bytea | ||
| LANGUAGE c | ||
| PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_random_bytes$function$ | ||
| extensions | gen_random_uuid | CREATE OR REPLACE FUNCTION extensions.gen_random_uuid() |
| RETURNS uuid | ||
| LANGUAGE c | ||
| PARALLEL SAFE | ||
| AS '$libdir/pgcrypto', $function$pg_random_uuid$function$ | ||
| extensions | gen_salt | CREATE OR REPLACE FUNCTION extensions.gen_salt(text) |
| RETURNS text | ||
| LANGUAGE c | ||
| PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_gen_salt$function$ | ||
| extensions | gen_salt | CREATE OR REPLACE FUNCTION extensions.gen_salt(text, integer) |
| RETURNS text | ||
| LANGUAGE c | ||
| PARALLEL SAFE STRICT | ||
| AS '$libdir/pgcrypto', $function$pg_gen_salt_rounds$function$ | ||
| extensions | grant_pg_cron_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_cron_access() |
| RETURNS event_trigger | ||
| LANGUAGE plpgsql | ||
AS function |
||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT | ||
| FROM pg_event_trigger_ddl_commands() AS ev | ||
| JOIN pg_extension AS ext | ||
| ON ev.objid = ext.oid | ||
| WHERE ext.extname = 'pg_cron' | ||
| ) | ||
| THEN | ||
| grant usage on schema cron to postgres with grant option; |
alter default privileges in schema cron grant all on tables to postgres with grant option;
alter default privileges in schema cron grant all on functions to postgres with grant option;
alter default privileges in schema cron grant all on sequences to postgres with grant option;
alter default privileges for user supabase_admin in schema cron grant all
on sequences to postgres with grant option;
alter default privileges for user supabase_admin in schema cron grant all
on tables to postgres with grant option;
alter default privileges for user supabase_admin in schema cron grant all
on functions to postgres with grant option;
grant all privileges on all tables in schema cron to postgres with grant option;
revoke all on table cron.job from postgres;
grant select on table cron.job to postgres with grant option;
END IF; END; $function$ | | extensions | grant_pg_graphql_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_graphql_access() RETURNS event_trigger LANGUAGE plpgsql AS $function$ DECLARE func_is_graphql_resolve bool; BEGIN func_is_graphql_resolve = ( SELECT n.proname = 'resolve' FROM pg_event_trigger_ddl_commands() AS ev LEFT JOIN pg_catalog.pg_proc AS n ON ev.objid = n.oid );
IF func_is_graphql_resolve
THEN
-- Update public wrapper to pass all arguments through to the pg_graphql resolve func
DROP FUNCTION IF EXISTS graphql_public.graphql;
create or replace function graphql_public.graphql(
"operationName" text default null,
query text default null,
variables jsonb default null,
extensions jsonb default null
)
returns jsonb
language sql
as $$
select graphql.resolve(
query := query,
variables := coalesce(variables, '{}'),
"operationName" := "operationName",
extensions := extensions
);
$$;
-- This hook executes when `graphql.resolve` is created. That is not necessarily the last
-- function in the extension so we need to grant permissions on existing entities AND
-- update default permissions to any others that are created after `graphql.resolve`
grant usage on schema graphql to postgres, anon, authenticated, service_role;
grant select on all tables in schema graphql to postgres, anon, authenticated, service_role;
grant execute on all functions in schema graphql to postgres, anon, authenticated, service_role;
grant all on all sequences in schema graphql to postgres, anon, authenticated, service_role;
alter default privileges in schema graphql grant all on tables to postgres, anon, authenticated, service_role;
alter default privileges in schema graphql grant all on functions to postgres, anon, authenticated, service_role;
alter default privileges in schema graphql grant all on sequences to postgres, anon, authenticated, service_role;
-- Allow postgres role to allow granting usage on graphql and graphql_public schemas to custom roles
grant usage on schema graphql_public to postgres with grant option;
grant usage on schema graphql to postgres with grant option;
END IF;
END; $function$ | | extensions | grant_pg_net_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_net_access() RETURNS event_trigger LANGUAGE plpgsql AS $function$ BEGIN IF EXISTS ( SELECT 1 FROM pg_event_trigger_ddl_commands() AS ev JOIN pg_extension AS ext ON ev.objid = ext.oid WHERE ext.extname = 'pg_net' ) THEN IF NOT EXISTS ( SELECT 1 FROM pg_roles WHERE rolname = 'supabase_functions_admin' ) THEN CREATE USER supabase_functions_admin NOINHERIT CREATEROLE LOGIN NOREPLICATION; END IF;
GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role;
ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
END IF;
END;
$function$
|
| extensions | hmac | CREATE OR REPLACE FUNCTION extensions.hmac(bytea, bytea, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pg_hmac$function$
|
| extensions | hmac | CREATE OR REPLACE FUNCTION extensions.hmac(text, text, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pg_hmac$function$
|
| extensions | http | CREATE OR REPLACE FUNCTION extensions.http(request http_request)
RETURNS http_response
LANGUAGE c
AS '$libdir/http', $function$http_request$function$
|
| extensions | http_delete | CREATE OR REPLACE FUNCTION extensions.http_delete(uri character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('DELETE', $1, NULL, NULL, NULL)::extensions.http_request) $function$
|
| extensions | http_delete | CREATE OR REPLACE FUNCTION extensions.http_delete(uri character varying, content character varying, content_type character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('DELETE', $1, NULL, $3, $2)::extensions.http_request) $function$
|
| extensions | http_get | CREATE OR REPLACE FUNCTION extensions.http_get(uri character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('GET', $1, NULL, NULL, NULL)::extensions.http_request) $function$
|
| extensions | http_get | CREATE OR REPLACE FUNCTION extensions.http_get(uri character varying, data jsonb)
RETURNS http_response
LANGUAGE sql
AS $function$
SELECT extensions.http(('GET', $1 || '?' || extensions.urlencode($2), NULL, NULL, NULL)::extensions.http_request)
$function$
|
| extensions | http_head | CREATE OR REPLACE FUNCTION extensions.http_head(uri character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('HEAD', $1, NULL, NULL, NULL)::extensions.http_request) $function$
|
| extensions | http_header | CREATE OR REPLACE FUNCTION extensions.http_header(field character varying, value character varying)
RETURNS http_header
LANGUAGE sql
AS function SELECT $1, $2 $function$
|
| extensions | http_list_curlopt | CREATE OR REPLACE FUNCTION extensions.http_list_curlopt()
RETURNS TABLE(curlopt text, value text)
LANGUAGE c
AS '$libdir/http', $function$http_list_curlopt$function$
|
| extensions | http_patch | CREATE OR REPLACE FUNCTION extensions.http_patch(uri character varying, content character varying, content_type character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('PATCH', $1, NULL, $3, $2)::extensions.http_request) $function$
|
| extensions | http_post | CREATE OR REPLACE FUNCTION extensions.http_post(uri character varying, data jsonb)
RETURNS http_response
LANGUAGE sql
AS $function$
SELECT extensions.http(('POST', $1, NULL, 'application/x-www-form-urlencoded', extensions.urlencode($2))::extensions.http_request)
$function$
|
| extensions | http_post | CREATE OR REPLACE FUNCTION extensions.http_post(uri character varying, content character varying, content_type character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('POST', $1, NULL, $3, $2)::extensions.http_request) $function$
|
| extensions | http_put | CREATE OR REPLACE FUNCTION extensions.http_put(uri character varying, content character varying, content_type character varying)
RETURNS http_response
LANGUAGE sql
AS function SELECT extensions.http(('PUT', $1, NULL, $3, $2)::extensions.http_request) $function$
|
| extensions | http_reset_curlopt | CREATE OR REPLACE FUNCTION extensions.http_reset_curlopt()
RETURNS boolean
LANGUAGE c
AS '$libdir/http', $function$http_reset_curlopt$function$
|
| extensions | http_set_curlopt | CREATE OR REPLACE FUNCTION extensions.http_set_curlopt(curlopt character varying, value character varying)
RETURNS boolean
LANGUAGE c
AS '$libdir/http', $function$http_set_curlopt$function$
|
| extensions | pg_stat_statements | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT blk_read_time double precision, OUT blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision)
RETURNS SETOF record
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pg_stat_statements', $function$pg_stat_statements_1_10$function$
|
| extensions | pg_stat_statements_info | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone)
RETURNS record
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pg_stat_statements', $function$pg_stat_statements_info$function$
|
| extensions | pg_stat_statements_reset | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements_reset(userid oid DEFAULT 0, dbid oid DEFAULT 0, queryid bigint DEFAULT 0)
RETURNS void
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pg_stat_statements', $function$pg_stat_statements_reset_1_7$function$
|
| extensions | pgp_armor_headers | CREATE OR REPLACE FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text)
RETURNS SETOF record
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_armor_headers$function$
|
| extensions | pgp_key_id | CREATE OR REPLACE FUNCTION extensions.pgp_key_id(bytea)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_key_id_w$function$
|
| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$
|
| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$
|
| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$
|
| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$
|
| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$
|
| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$
|
| extensions | pgp_pub_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt(text, bytea)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_text$function$
|
| extensions | pgp_pub_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt(text, bytea, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_text$function$
|
| extensions | pgp_pub_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_bytea$function$
|
| extensions | pgp_pub_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_bytea$function$
|
| extensions | pgp_sym_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt(bytea, text)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_text$function$
|
| extensions | pgp_sym_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt(bytea, text, text)
RETURNS text
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_text$function$
|
| extensions | pgp_sym_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_bytea$function$
|
| extensions | pgp_sym_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text)
RETURNS bytea
LANGUAGE c
IMMUTABLE PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_bytea$function$
|
| extensions | pgp_sym_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt(text, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_text$function$
|
| extensions | pgp_sym_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt(text, text, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_text$function$
|
| extensions | pgp_sym_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_bytea$function$
|
| extensions | pgp_sym_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text)
RETURNS bytea
LANGUAGE c
PARALLEL SAFE STRICT
AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_bytea$function$
|
| extensions | pgrst_ddl_watch | CREATE OR REPLACE FUNCTION extensions.pgrst_ddl_watch()
RETURNS event_trigger
LANGUAGE plpgsql
AS $function$
DECLARE
cmd record;
BEGIN
FOR cmd IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
IF cmd.command_tag IN (
'CREATE SCHEMA', 'ALTER SCHEMA'
, 'CREATE TABLE', 'CREATE TABLE AS', 'SELECT INTO', 'ALTER TABLE'
, 'CREATE FOREIGN TABLE', 'ALTER FOREIGN TABLE'
, 'CREATE VIEW', 'ALTER VIEW'
, 'CREATE MATERIALIZED VIEW', 'ALTER MATERIALIZED VIEW'
, 'CREATE FUNCTION', 'ALTER FUNCTION'
, 'CREATE TRIGGER'
, 'CREATE TYPE', 'ALTER TYPE'
, 'CREATE RULE'
, 'COMMENT'
)
-- don't notify in case of CREATE TEMP table or other objects created on pg_temp
AND cmd.schema_name is distinct from 'pg_temp'
THEN
NOTIFY pgrst, 'reload schema';
END IF;
END LOOP;
END; $function$
|
| extensions | pgrst_drop_watch | CREATE OR REPLACE FUNCTION extensions.pgrst_drop_watch()
RETURNS event_trigger
LANGUAGE plpgsql
AS $function$
DECLARE
obj record;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects()
LOOP
IF obj.object_type IN (
'schema'
, 'table'
, 'foreign table'
, 'view'
, 'materialized view'
, 'function'
, 'trigger'
, 'type'
, 'rule'
)
AND obj.is_temporary IS false -- no pg_temp objects
THEN
NOTIFY pgrst, 'reload schema';
END IF;
END LOOP;
END; $function$
|
| extensions | set_graphql_placeholder | CREATE OR REPLACE FUNCTION extensions.set_graphql_placeholder()
RETURNS event_trigger
LANGUAGE plpgsql
AS $function$
DECLARE
graphql_is_dropped bool;
BEGIN
graphql_is_dropped = (
SELECT ev.schema_name = 'graphql_public'
FROM pg_event_trigger_dropped_objects() AS ev
WHERE ev.schema_name = 'graphql_public'
);
IF graphql_is_dropped
THEN
create or replace function graphql_public.graphql(
"operationName" text default null,
query text default null,
variables jsonb default null,
extensions jsonb default null
)
returns jsonb
language plpgsql
as $$
DECLARE
server_version float;
BEGIN
server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float);
IF server_version >= 14 THEN
RETURN jsonb_build_object(
'errors', jsonb_build_array(
jsonb_build_object(
'message', 'pg_graphql extension is not enabled.'
)
)
);
ELSE
RETURN jsonb_build_object(
'errors', jsonb_build_array(
jsonb_build_object(
'message', 'pg_graphql is only available on projects running Postgres 14 onwards.'
)
)
);
END IF;
END;
$$;
END IF;
END;
$function$ | | extensions | sign | CREATE OR REPLACE FUNCTION extensions.sign(payload json, secret text, algorithm text DEFAULT 'HS256'::text) RETURNS text LANGUAGE sql IMMUTABLE AS $function$ WITH header AS ( SELECT extensions.url_encode(convert_to('{"alg":"' || algorithm || '","typ":"JWT"}', 'utf8')) AS data ), payload AS ( SELECT extensions.url_encode(convert_to(payload::text, 'utf8')) AS data ), signables AS ( SELECT header.data || '.' || payload.data AS data FROM header, payload ) SELECT signables.data || '.' || extensions.algorithm_sign(signables.data, secret, algorithm) FROM signables; $function$ | | extensions | text_to_bytea | CREATE OR REPLACE FUNCTION extensions.text_to_bytea(data text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/http', $function$text_to_bytea$function$ | | extensions | try_cast_double | CREATE OR REPLACE FUNCTION extensions.try_cast_double(inp text) RETURNS double precision LANGUAGE plpgsql IMMUTABLE AS $function$ BEGIN BEGIN RETURN inp::double precision; EXCEPTION WHEN OTHERS THEN RETURN NULL; END; END; $function$ | | extensions | url_decode | CREATE OR REPLACE FUNCTION extensions.url_decode(data text) RETURNS bytea LANGUAGE sql IMMUTABLE AS $function$ WITH t AS (SELECT translate(data, '-', '+/') AS trans), rem AS (SELECT length(t.trans) % 4 AS remainder FROM t) -- compute padding size SELECT decode( t.trans || CASE WHEN rem.remainder > 0 THEN repeat('=', (4 - rem.remainder)) ELSE '' END, 'base64') FROM t, rem; $function$ | | extensions | url_encode | CREATE OR REPLACE FUNCTION extensions.url_encode(data bytea) RETURNS text LANGUAGE sql IMMUTABLE AS $function$ SELECT translate(encode(data, 'base64'), E'+/=\n', '-'); $function$ | | extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(string bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/http', $function$urlencode$function$ | | extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(string character varying) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/http', $function$urlencode$function$ | | extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(data jsonb) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/http', $function$urlencode_jsonb$function$ | | extensions | uuid_generate_v1 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v1() RETURNS uuid LANGUAGE c PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_generate_v1$function$ | | extensions | uuid_generate_v1mc | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v1mc() RETURNS uuid LANGUAGE c PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_generate_v1mc$function$ | | extensions | uuid_generate_v3 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_generate_v3$function$ | | extensions | uuid_generate_v4 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v4() RETURNS uuid LANGUAGE c PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_generate_v4$function$ | | extensions | uuid_generate_v5 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_generate_v5$function$ | | extensions | uuid_nil | CREATE OR REPLACE FUNCTION extensions.uuid_nil() RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_nil$function$ | | extensions | uuid_ns_dns | CREATE OR REPLACE FUNCTION extensions.uuid_ns_dns() RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_ns_dns$function$ | | extensions | uuid_ns_oid | CREATE OR REPLACE FUNCTION extensions.uuid_ns_oid() RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_ns_oid$function$ | | extensions | uuid_ns_url | CREATE OR REPLACE FUNCTION extensions.uuid_ns_url() RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_ns_url$function$ | | extensions | uuid_ns_x500 | CREATE OR REPLACE FUNCTION extensions.uuid_ns_x500() RETURNS uuid LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_ns_x500$function$ | | extensions | verify | CREATE OR REPLACE FUNCTION extensions.verify(token text, secret text, algorithm text DEFAULT 'HS256'::text) RETURNS TABLE(header json, payload json, valid boolean) LANGUAGE sql IMMUTABLE AS $function$ SELECT jwt.header AS header, jwt.payload AS payload, jwt.signature_ok AND tstzrange( to_timestamp(extensions.try_cast_double(jwt.payload->>'nbf')), to_timestamp(extensions.try_cast_double(jwt.payload->>'exp')) ) @> CURRENT_TIMESTAMP AS valid FROM ( SELECT convert_from(extensions.url_decode(r[1]), 'utf8')::json AS header, convert_from(extensions.url_decode(r[2]), 'utf8')::json AS payload, r[3] = extensions.algorithm_sign(r[1] || '.' || r[2], secret, algorithm) AS signature_ok FROM regexp_split_to_array(token, '.') r ) jwt $function$ | | graphql | internal_resolve | CREATE OR REPLACE FUNCTION graphql.internal_resolve(query text, variables jsonb DEFAULT '{}'::jsonb, "operationName" text DEFAULT NULL::text, extensions jsonb DEFAULT NULL::jsonb) RETURNS jsonb LANGUAGE c AS '$libdir/pg_graphql', $function$resolve_wrapper$function$ | | graphql | comment_directive | CREATE OR REPLACE FUNCTION graphql.comment_directive(comment text) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $function$ /* comment on column public.account.name is '@graphql.name: myField' */ select coalesce( ( regexp_match( comment, '@graphql((.+))' ) )[1]::jsonb, jsonb_build_object() ) $function$ | | graphql | exception | CREATE OR REPLACE FUNCTION graphql.exception(message text) RETURNS text LANGUAGE plpgsql AS $function$ begin raise exception using errcode='22000', message=message; end; $function$ | | graphql | get_schema_version | CREATE OR REPLACE FUNCTION graphql.get_schema_version() RETURNS integer LANGUAGE sql SECURITY DEFINER AS $function$ select last_value from graphql.seq_schema_version; $function$ | | graphql | increment_schema_version | CREATE OR REPLACE FUNCTION graphql.increment_schema_version() RETURNS event_trigger LANGUAGE plpgsql SECURITY DEFINER AS $function$ begin perform nextval('graphql.seq_schema_version'); end; $function$ | | graphql | resolve | CREATE OR REPLACE FUNCTION graphql.resolve(query text, variables jsonb DEFAULT '{}'::jsonb, "operationName" text DEFAULT NULL::text, extensions jsonb DEFAULT NULL::jsonb) RETURNS jsonb LANGUAGE plpgsql AS $function$ declare res jsonb; message_text text; begin begin select graphql._internal_resolve("query" := "query", "variables" := "variables", "operationName" := "operationName", "extensions" := "extensions") into res; return res; exception when others then get stacked diagnostics message_text = message_text; return jsonb_build_object('data', null, 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); end; end; $function$ | | graphql_public | graphql | CREATE OR REPLACE FUNCTION graphql_public.graphql("operationName" text DEFAULT NULL::text, query text DEFAULT NULL::text, variables jsonb DEFAULT NULL::jsonb, extensions jsonb DEFAULT NULL::jsonb) RETURNS jsonb LANGUAGE sql AS $function$ select graphql.resolve( query := query, variables := coalesce(variables, '{}'), "operationName" := "operationName", extensions := extensions ); $function$ | | net | _await_response | CREATE OR REPLACE FUNCTION net._await_response(request_id bigint) RETURNS boolean LANGUAGE plpgsql PARALLEL SAFE STRICT AS $function$ declare rec net._http_response; begin while rec is null loop select * into rec from net._http_response where id = request_id;
if rec is null then
-- Wait 50 ms before checking again
perform pg_sleep(0.05);
end if;
end loop;
return true;
end; $function$ | | net | _encode_url_with_params_array | CREATE OR REPLACE FUNCTION net._encode_url_with_params_array(url text, params_array text[]) RETURNS text LANGUAGE c IMMUTABLE STRICT AS 'pg_net', $function$_encode_url_with_params_array$function$ | | net | _http_collect_response | CREATE OR REPLACE FUNCTION net._http_collect_response(request_id bigint, async boolean DEFAULT true) RETURNS net.http_response_result LANGUAGE plpgsql PARALLEL SAFE STRICT AS $function$ declare rec net._http_response; req_exists boolean; begin
if not async then
perform net._await_response(request_id);
end if;
select *
into rec
from net._http_response
where id = request_id;
if rec is null or rec.error_msg is not null then
-- The request is either still processing or the request_id provided does not exist
-- TODO: request in progress is indistinguishable from request that doesn't exist
-- No request matching request_id found
return (
'ERROR',
coalesce(rec.error_msg, 'request matching request_id not found'),
null
)::net.http_response_result;
end if;
-- Return a valid, populated http_response_result
return (
'SUCCESS',
'ok',
(
rec.status_code,
rec.headers,
rec.content
)::net.http_response
)::net.http_response_result;
end; $function$ | | net | _urlencode_string | CREATE OR REPLACE FUNCTION net._urlencode_string(string character varying) RETURNS text LANGUAGE c IMMUTABLE STRICT AS 'pg_net', $function$_urlencode_string$function$ | | net | check_worker_is_up | CREATE OR REPLACE FUNCTION net.check_worker_is_up() RETURNS void LANGUAGE plpgsql AS $function$ begin if not exists (select pid from pg_stat_activity where backend_type ilike '%pg_net%') then raise exception using message = 'the pg_net background worker is not up' , detail = 'the pg_net background worker is down due to an internal error and cannot process requests' , hint = 'make sure that you didn''t modify any of pg_net internal tables'; end if; end $function$ | | net | http_collect_response | CREATE OR REPLACE FUNCTION net.http_collect_response(request_id bigint, async boolean DEFAULT true) RETURNS net.http_response_result LANGUAGE plpgsql PARALLEL SAFE STRICT AS $function$ begin raise notice 'The net.http_collect_response function is deprecated.'; select net._http_collect_response(request_id, async); end; $function$ | | net | http_delete | CREATE OR REPLACE FUNCTION net.http_delete(url text, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{}'::jsonb, timeout_milliseconds integer DEFAULT 5000) RETURNS bigint LANGUAGE plpgsql PARALLEL SAFE STRICT AS $function$ declare request_id bigint; params_array text[]; begin select coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}') into params_array from jsonb_each_text(params);
-- Add to the request queue
insert into net.http_request_queue(method, url, headers, timeout_milliseconds)
values (
'DELETE',
net._encode_url_with_params_array(url, params_array),
headers,
timeout_milliseconds
)
returning id
into request_id;
return request_id;
end $function$ | | net | http_get | CREATE OR REPLACE FUNCTION net.http_get(url text, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{}'::jsonb, timeout_milliseconds integer DEFAULT 5000) RETURNS bigint LANGUAGE plpgsql PARALLEL SAFE STRICT SECURITY DEFINER SET search_path TO 'net' AS $function$ declare request_id bigint; params_array text[]; begin select coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}') into params_array from jsonb_each_text(params);
-- Add to the request queue
insert into net.http_request_queue(method, url, headers, timeout_milliseconds)
values (
'GET',
net._encode_url_with_params_array(url, params_array),
headers,
timeout_milliseconds
)
returning id
into request_id;
return request_id;
end $function$ | | net | http_post | CREATE OR REPLACE FUNCTION net.http_post(url text, body jsonb DEFAULT '{}'::jsonb, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{"Content-Type": "application/json"}'::jsonb, timeout_milliseconds integer DEFAULT 5000) RETURNS bigint LANGUAGE plpgsql PARALLEL SAFE SECURITY DEFINER SET search_path TO 'net' AS $function$ declare request_id bigint; params_array text[]; content_type text; begin
-- Exctract the content_type from headers
select
header_value into content_type
from
jsonb_each_text(coalesce(headers, '{}'::jsonb)) r(header_name, header_value)
where
lower(header_name) = 'content-type'
limit
1;
-- If the user provided new headers and omitted the content type
-- add it back in automatically
if content_type is null then
select headers || '{"Content-Type": "application/json"}'::jsonb into headers;
end if;
-- Confirm that the content-type is set as "application/json"
if content_type <> 'application/json' then
raise exception 'Content-Type header must be "application/json"';
end if;
select
coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}')
into
params_array
from
jsonb_each_text(params);
-- Add to the request queue
insert into net.http_request_queue(method, url, headers, body, timeout_milliseconds)
values (
'POST',
net._encode_url_with_params_array(url, params_array),
headers,
convert_to(body::text, 'UTF8'),
timeout_milliseconds
)
returning id
into request_id;
return request_id;
end $function$ |