+++ /dev/null
-create function zz_concat(text, text) returns text as
- 'select md5($1 || $2);' language 'sql';
-
-create aggregate zz_hashagg(text) (
- sfunc = zz_concat,
- stype = text,
- initcond = '');
-
-
-create function table_hash(t regclass) returns text language plpgsql as $$
-declare
- tval text;
- sql text;
-begin
- sql := 'select migration.zz_hashagg(md5(t::text) order by _migration_id) from ';
- execute sql into tval;
- return tval;
-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;
-$$;
-
-create function zz_concat(bytea, bytea) returns bytea as
+create function zz_concat(bytea, bytea) returns bytea
+as
$$select digest($1 || $2,'sha256');$$ strict language 'sql';
create aggregate zz_hashagg(bytea) (
);
create function table_hash(t regclass, key text) returns text
-language plpgsql as $$
+language plpgsql
+set search_path from current
+as $$
declare
tval bytea;
sql text;
$$;
create function table_hash(t regclass, firstn bigint) returns text
-language plpgsql as $$
+language plpgsql
+set search_path from current
+as $$
declare
P migration.posting;
tval bytea;
key text;
begin
select * into strict P from migration.posting where table_oid = t;
- selq := regexp_replace(P.selectq, ' where [[:print:]]+ = \?$', '');
+ selq := regexp_replace(P.selectq, E' where [[:print:]]+ = \\?$', '');
key := P.keycol;
sql := 'select zz_hashagg(digest(t::text, ''sha256'') order by '