Skip to main content

no_mistakes_postgres_sql/
source.rs

1//! Standalone source facts: one prepared token inventory, one AST per statement.
2
3mod adjacent_strings;
4mod alter;
5mod batch_pool;
6pub use batch_pool::record_global_rayon_threads;
7mod begin_atomic;
8#[doc(hidden)]
9pub use begin_atomic::conceal_body_keyword;
10mod body;
11mod columns;
12mod completeness;
13mod conflict_calls;
14#[doc(hidden)]
15pub use conflict_calls::PolicyArbiter;
16pub(super) use conflict_calls::{
17    parse_program as parse_conflict_program, recover as recover_conflict_calls,
18};
19mod conditional;
20mod conditional_partial;
21mod conditional_source;
22mod constraint_spans;
23mod copy_stdin;
24mod ddl;
25mod diagnostics;
26mod dialect;
27mod drop_facts;
28mod execute;
29mod execute_preparation;
30mod expression_children;
31mod expression_identity;
32mod expression_roots;
33mod expressions;
34mod generated;
35mod index_only;
36mod indexes;
37mod insert;
38mod locations;
39mod metadata;
40mod metadata_preparation;
41mod parsing;
42mod procedural;
43mod procedural_classify;
44mod procedural_occurrences;
45mod procedural_omit;
46mod procedural_prepare;
47mod procedural_walk;
48mod projection;
49mod query;
50mod recovery;
51mod type_facts;
52mod types;
53mod wrappers;
54pub use types::*;
55#[doc(hidden)]
56pub use wrappers::explain_execution;
57
58/// Parse source text without a repository scan, catalog, or database connection.
59pub fn parse_postgres_source(source: &PostgresSqlSource) -> PostgresSqlFacts {
60    let locations = locations::Locations::new(&source.sql);
61    let prepared = super::parse::prepare_postgres_tokens(&source.sql);
62    parsing::collect_program(source, prepared, &locations, 0, false)
63}
64
65/// Batch independent sources while preserving input order and per-source ownership.
66pub fn parse_postgres_sources(sources: &[PostgresSqlSource]) -> Vec<PostgresSqlFacts> {
67    parse_postgres_sources_with_jobs(sources, 0)
68}
69
70#[doc(hidden)]
71pub fn parse_postgres_sources_with_jobs(
72    sources: &[PostgresSqlSource],
73    jobs: usize,
74) -> Vec<PostgresSqlFacts> {
75    use rayon::prelude::*;
76    batch_pool::install(jobs, || {
77        sources.par_iter().map(parse_postgres_source).collect()
78    })
79}
80
81#[cfg(all(test, any(nm_shard_all, nm_shard_2, nm_shard_postgres_source)))]
82mod tests;