Line data Source code
1 : //! Scripts that run only on request, from the `@manual` comment tag.
2 : //!
3 : //! ```sql
4 : //! /* All orders with their line items, expensive without a filter.
5 : //! @manual */
6 : //! select * from orders join lineitem on l_orderkey = o_orderkey;
7 : //! ```
8 : //!
9 : //! A script with `@manual` is a building block that is too expensive to run unfiltered. Runs of the whole session
10 : //! and the reruns of input changes leave it out, the scripts of its connection inline it with their own filters, and
11 : //! it runs when someone runs it directly. Like `@flow`, the tag may annotate any statement. The text after the tag
12 : //! is free, e.g. the reason, and further `@manual` tags change nothing.
13 :
14 : use super::state::AnalysisState;
15 :
16 : /// The tag of scripts that run only on request
17 : pub const MANUAL_TAG: &str = "manual";
18 :
19 : /// Read the `@manual` tags of the statements
20 3734 : pub(super) fn analyze(state: &mut AnalysisState) {
21 3734 : let parsed = state.parsed;
22 3734 : state.out.manual = parsed
23 3734 : .associate_descriptions()
24 3734 : .iter()
25 5252 : .any(|description| super::vis_tags::statement_tags(parsed, description, &[MANUAL_TAG]).next().is_some());
26 3734 : }
|