-- Function: metabib.staged_browse(text, integer[], integer, integer[], boolean, integer, boolean, integer, integer)
-- DROP FUNCTION metabib.staged_browse(text, integer[], integer, integer[], boolean, integer, boolean, integer, integer);
-
-CREATE OR REPLACE FUNCTION metabib.staged_browse(query text, fields integer[], context_org integer, context_locations integer[], staff boolean, browse_superpage_size integer, count_up_from_zero boolean, result_limit integer, next_pivot_pos integer)
- RETURNS SETOF metabib.flat_browse_entry_appearance AS
-$BODY$
+CREATE OR REPLACE FUNCTION metabib.staged_browse(
+ query TEXT,
+ fields INT[],
+ context_org INT,
+ context_locations INT[],
+ staff BOOL,
+ browse_superpage_size INT,
+ count_up_from_zero BOOL, -- if false, count down from -1
+ result_limit INT,
+ next_pivot_pos INT
+) RETURNS SETOF metabib.flat_browse_entry_appearance AS $p$
DECLARE
curs REFCURSOR;
rec RECORD;
END IF;
RETURN;
END IF;
- -- Gather aggregate data based on the MBE row we're looking at now, authority axis
- --Is unauthorized, i.e., 4xx on an auth record?
+ --Is unauthorized?
SELECT INTO unauthorized_entry *
FROM metabib.browse_entry_simple_heading_map mbeshm
INNER JOIN authority.simple_heading ash ON ( mbeshm.simple_heading = ash.id )
INNER JOIN authority.control_set_authority_field acsaf ON ( acsaf.id = ash.atag AND acsaf.tag like '4__')
WHERE mbeshm.entry = rec.id;
+ -- Gather aggregate data based on the MBE row we're looking at now, authority axis
IF (unauthorized_entry.record IS NOT NULL) THEN
- --Do unauthorized procedure, use the authorized term's auth record and it's bibs
+ --unauthorized term belongs to an auth linked to a bib?
SELECT INTO all_arecords, result_row.sees, afields
ARRAY_AGG(DISTINCT abl.bib),
STRING_AGG(DISTINCT abl.authority::TEXT, $$,$$),
)
WHERE abl.authority = unauthorized_entry.record;
ELSE
- --Do 'usual' procedures
+ --do usual procedure
SELECT INTO all_arecords, result_row.sees, afields
ARRAY_AGG(DISTINCT abl.bib), -- bibs to check for visibility
STRING_AGG(DISTINCT aal.source::TEXT, $$,$$), -- authority record ids
ash.atag = map.authority_field
AND map.metabib_field = ANY(fields)
)
- WHERE mbeshm.entry = rec.id;
+ WHERE mbeshm.entry = rec.id;
END IF;
-- Gather aggregate data based on the MBE row we're looking at now, bib axis
superpage_of_records := all_brecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.
-- Accurate? Well, probably.
result_row.accurate := browse_superpage_size IS NULL OR
browse_superpage_size >= full_end;
-
+
END IF;
-- Authority-linked vis checking
superpage_of_records := all_arecords[slice_start:slice_end];
qpfts_query :=
'SELECT NULL::BIGINT AS id, ARRAY[r] AS records, ' ||
- '1::INT AS rel FROM (SELECT UNNEST(' ||
+ 'NULL AS badges, NULL::NUMERIC AS popularity, ' ||
+ '1::NUMERIC AS rel FROM (SELECT UNNEST(' ||
quote_literal(superpage_of_records) || '::BIGINT[]) AS r) rr';
-- We use search.query_parser_fts() for visibility testing.
END IF;
IF result_row.sources > 0 OR result_row.asources > 0 THEN
+
-- The function that calls this function needs row_number in order
-- to correctly order results from two different runs of this
-- functions.
END IF;
END LOOP;
END;
-$BODY$
- LANGUAGE plpgsql VOLATILE
- COST 100
- ROWS 1000;
+$p$ LANGUAGE PLPGSQL;
-- ALTER FUNCTION metabib.staged_browse(text, integer[], integer, integer[], boolean, integer, boolean, integer, integer)
-- OWNER TO evergreen;