lib/share/postspec_schema.sql in postspec-0.2.5 vs lib/share/postspec_schema.sql in postspec-0.4.0
- old
+ new
@@ -5,19 +5,19 @@
set search_path to postspec;
-- Return a map from table UID to last value of sequence. All user tables are
-- included but tables without sequences (subtables) have last value set to
-- null
-create or replace function table_sequence_ids(ignore_schemas varchar[])
- returns table(table_uid text, record_id bigint)
+create or replace function table_sequence_ids(ignore_schemas varchar[])
+ returns table(table_uid text, record_id bigint)
as $$
declare
name varchar(255);
tuple record;
begin
ignore_schemas := ignore_schemas || array['information_schema', 'postspec']::varchar[];
- for tuple in
+ for tuple in
select tc.relnamespace::regnamespace::text || '.' || tc.relname as table_uid,
s.relnamespace::regnamespace::text || '.' || s.relname as sequence_uid
from pg_class tc
left join (
select d.refobjid,
@@ -36,10 +36,10 @@
if tuple.sequence_uid is null then
table_uid := tuple.table_uid;
record_id := null;
return next;
else
- return query execute
+ return query execute
'select ' || quote_literal(tuple.table_uid) || '::text as table_uid, ' ||
'case is_called when true then last_value else last_value - 1 end as last_value ' ||
'from ' || tuple.sequence_uid;
end if;
end loop;