diff --git a/HISTORY.md b/HISTORY.md index d811ed6..1177447 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,7 +1,9 @@ # count_nulls history -stable ------- +1.1.0 +----- + +Distribution-only release - the extension version itself stays at `1.0.0`. - Extension no longer requires superuser to install diff --git a/META.in.json b/META.in.json index c730255..82cfaca 100644 --- a/META.in.json +++ b/META.in.json @@ -16,7 +16,7 @@ "name": "count_nulls", "X_comment": "REQUIRED. Version of the distribution. http://pgxn.org/spec/#version", - "version": "1.0.0", + "version": "1.1.0", "X_comment": "REQUIRED. Short description of distribution.", "abstract": "Count the number of null arguments", diff --git a/META.json b/META.json index 19c84e1..9134d2b 100644 --- a/META.json +++ b/META.json @@ -16,7 +16,7 @@ "name": "count_nulls", "X_comment": "REQUIRED. Version of the distribution. http://pgxn.org/spec/#version", - "version": "1.0.0", + "version": "1.1.0", "X_comment": "REQUIRED. Short description of distribution.", "abstract": "Count the number of null arguments", diff --git a/count_nulls.control b/count_nulls.control index 19fcff1..41aa063 100644 --- a/count_nulls.control +++ b/count_nulls.control @@ -1,6 +1,6 @@ # count_nulls extension comment = 'Count the number of null arguments' -default_version = 'stable' +default_version = '1.0.0' relocatable = false # Pure SQL functions, nothing privileged - anyone with USAGE and CREATE on the # target schema can install it, holding nothing on the database itself. diff --git a/sql/count_nulls--1.0.0--stable.sql b/sql/count_nulls--1.0.0--stable.sql deleted file mode 100644 index dc73d7b..0000000 --- a/sql/count_nulls--1.0.0--stable.sql +++ /dev/null @@ -1 +0,0 @@ --- No actual SQL changes to this version bump diff --git a/sql/count_nulls--stable.sql b/sql/count_nulls--stable.sql deleted file mode 100644 index ef7c3b5..0000000 --- a/sql/count_nulls--stable.sql +++ /dev/null @@ -1,87 +0,0 @@ -/* DO NOT EDIT - AUTO-GENERATED FILE */ -CREATE OR REPLACE FUNCTION null_count( - VARIADIC argument anyarray -) RETURNS int LANGUAGE sql IMMUTABLE AS $body$ - SELECT sum( CASE WHEN a IS NULL THEN 1 ELSE 0 END )::int - FROM unnest( $1 ) a -$body$; - -CREATE OR REPLACE FUNCTION null_count( - argument jsonb -) RETURNS int LANGUAGE sql IMMUTABLE AS $body$ -SELECT count(*)::int - FROM jsonb_each_text( $1 ) a - WHERE value IS NULL -$body$; -CREATE OR REPLACE FUNCTION null_count( - argument json -) RETURNS int LANGUAGE sql IMMUTABLE AS 'SELECT @extschema@.null_count($1::jsonb)'; - -CREATE OR REPLACE FUNCTION null_count_trigger( -) RETURNS trigger LANGUAGE plpgsql IMMUTABLE AS $body$ -DECLARE - c_msg CONSTANT text := coalesce( - nullif( TG_ARGV[1], 'null' ) - , format( '%s must contain %s NULL fields', TG_RELID::regclass, TG_ARGV[0] ) - ); -BEGIN - IF TG_NARGS NOT BETWEEN 1 AND 2 THEN - RAISE '% usage: number of NULL columns[, error message]', TG_NAME; - END IF; - -- Casing intentional for cut/paste/replace/ - IF nullif(TG_ARGV[0], 'null') IS null THEN - RAISE '%: first argument must not be null', TG_NAME; - END IF; - - IF @extschema@.null_count( row_to_json(NEW) ) <> TG_ARGV[0]::int THEN - RAISE '%', c_msg; - END IF; - - RETURN NEW; -END -$body$; - - -CREATE OR REPLACE FUNCTION not_null_count( - VARIADIC argument anyarray -) RETURNS int LANGUAGE sql IMMUTABLE AS $body$ - SELECT sum( CASE WHEN a IS NOT NULL THEN 1 ELSE 0 END )::int - FROM unnest( $1 ) a -$body$; - -CREATE OR REPLACE FUNCTION not_null_count( - argument jsonb -) RETURNS int LANGUAGE sql IMMUTABLE AS $body$ -SELECT count(*)::int - FROM jsonb_each_text( $1 ) a - WHERE value IS NOT NULL -$body$; -CREATE OR REPLACE FUNCTION not_null_count( - argument json -) RETURNS int LANGUAGE sql IMMUTABLE AS 'SELECT @extschema@.not_null_count($1::jsonb)'; - -CREATE OR REPLACE FUNCTION not_null_count_trigger( -) RETURNS trigger LANGUAGE plpgsql IMMUTABLE AS $body$ -DECLARE - c_msg CONSTANT text := coalesce( - nullif( TG_ARGV[1], 'null' ) - , format( '%s must contain %s NOT NULL fields', TG_RELID::regclass, TG_ARGV[0] ) - ); -BEGIN - IF TG_NARGS NOT BETWEEN 1 AND 2 THEN - RAISE '% usage: number of NOT NULL columns[, error message]', TG_NAME; - END IF; - -- Casing intentional for cut/paste/replace/ - IF nullif(TG_ARGV[0], 'null') IS null THEN - RAISE '%: first argument must not be null', TG_NAME; - END IF; - - IF @extschema@.not_null_count( row_to_json(NEW) ) <> TG_ARGV[0]::int THEN - RAISE '%', c_msg; - END IF; - - RETURN NEW; -END -$body$; - --- vi: expandtab sw=2 ts=2