From: Nathan Wagner Date: Sat, 2 Oct 2021 18:37:41 +0000 (-0500) Subject: remove old function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74436798199a644d6a9824abd74b9c874950c543;p=pgm remove old function --- diff --git a/functions/consistency.sql b/functions/consistency.sql deleted file mode 100644 index 2ef76c0..0000000 --- a/functions/consistency.sql +++ /dev/null @@ -1,59 +0,0 @@ -create function zz_concat(bytea, bytea) returns bytea as - $$select digest($1 || $2,'sha256');$$ strict language 'sql'; - -create aggregate zz_hashagg(bytea) ( - sfunc = zz_concat, - stype = bytea -); - -create function table_hash(t regclass, key text) returns text -language plpgsql as $$ -declare - tval bytea; - sql text; -begin - sql := 'select zz_hashagg(digest(t::text, ''sha256'') order by ' - || quote_ident(key) - || ') from ' || t || ' t '; - execute sql into tval; - return encode(tval, 'hex'); -end; -$$; - -create function table_hash(t regclass, key text, firstn bigint) returns text -language plpgsql as $$ -declare - tval bytea; - sql text; -begin - sql := 'select zz_hashagg(digest(t::text, ''sha256'') order by ' - || quote_ident(key) - || ') from (' - || 'select * from ' || t || ' order by ' || quote_ident(key) - || ' limit ' || firstn - || ') t'; - - execute sql into tval; - return encode(tval, 'hex'); -end; -$$; - -/* -create function all_hash() returns text language plpgsql as $$ -declare - tval text; - sql text; -begin - select migration.zz_hashagg(migration.table_hash(C.oid) order by C.relname) into tval - from pg_attribute A - join pg_class C on C.oid = A.attrelid - where - A.attname = '_migration_id' - and C.relkind = 'r' - ; - - return tval; -end; -$$; -*/ - diff --git a/functions/table_hash.sql b/functions/table_hash.sql index dc32639..be14335 100644 --- a/functions/table_hash.sql +++ b/functions/table_hash.sql @@ -1,5 +1,3 @@ -begin; - create function zz_concat(bytea, bytea) returns bytea as $$select digest($1 || $2,'sha256');$$ strict language 'sql'; @@ -48,29 +46,3 @@ begin return encode(tval, 'hex'); end; $$; - -\timing -select table_hash('history.t_archivenotamserachfromns_20140328'::regclass, 10000); ---select table_hash('bar'::regclass, 'b', 100); - -rollback; - -/* -create function all_hash() returns text language plpgsql as $$ -declare - tval text; - sql text; -begin - select migration.zz_hashagg(migration.table_hash(C.oid) order by C.relname) into tval - from pg_attribute A - join pg_class C on C.oid = A.attrelid - where - A.attname = '_migration_id' - and C.relkind = 'r' - ; - - return tval; -end; -$$; -*/ -