1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use *;
/// Gives search an exact count, by splitting the matching rules out of the
/// paging.
///
/// `search_content` did its own paging, so a caller had no way to know how many
/// matches there were in total — which is what a pager needs. The obvious fix is
/// a counting function, and the obvious problem is that it is a second copy of
/// the four search branches, free to drift from the first. The reference
/// implementation solved this with a `search_content_count` RPC written
/// alongside its search RPC, which is the same duplication.
///
/// So nothing is copied. The branches move into `search_all_hits`, and both
/// wrappers read from it: one pages, one counts. The total and the page are
/// then the same query by construction rather than by review.
///
/// A composite type, not `RETURNS TABLE`, because `RETURNS TABLE` turns its
/// column names into plpgsql variables — which is what forced the original to
/// route every UNION through a derived table purely to qualify its ORDER BY.
;
const UP: &str = include_str!;