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::*;
55pub(crate) use wrappers::atomic_body_end;
56#[doc(hidden)]
57pub use wrappers::explain_execution;
58
59/// Parse source text without a repository scan, catalog, or database connection.
60pub fn parse_postgres_source(source: &PostgresSqlSource) -> PostgresSqlFacts {
61    let locations = locations::Locations::new(&source.sql);
62    let prepared = super::parse::prepare_postgres_tokens(&source.sql);
63    parsing::collect_program(source, prepared, &locations, 0, false)
64}
65
66/// Batch independent sources while preserving input order and per-source ownership.
67pub fn parse_postgres_sources(sources: &[PostgresSqlSource]) -> Vec<PostgresSqlFacts> {
68    parse_postgres_sources_with_jobs(sources, 0)
69}
70
71#[doc(hidden)]
72pub fn parse_postgres_sources_with_jobs(
73    sources: &[PostgresSqlSource],
74    jobs: usize,
75) -> Vec<PostgresSqlFacts> {
76    use rayon::prelude::*;
77    batch_pool::install(jobs, || {
78        sources.par_iter().map(parse_postgres_source).collect()
79    })
80}
81
82#[cfg(all(test, any(nm_shard_all, nm_shard_2, nm_shard_postgres_source)))]
83mod tests;