Skip to content

Instantly share code, notes, and snippets.

@jasher
jasher / postgres-fx-functions.sql
Last active August 8, 2020 15:03
A set of general utility functions for Postgres (pgSQL); the antithesis of functional programming.
-- ********************************************************************************************
-- General FX utility functions in PL/pgSql (Postgres)
-- Released under the MIT license: http://opensource.org/licenses/mit-license.php by Jon Asher
-- Download current source at https://gist.github.com/jasher/6026284
-- ********************************************************************************************
CREATE FUNCTION array_contains(p_int_arr integer[], p_value integer) RETURNS boolean
LANGUAGE plpgsql
AS $$
BEGIN