[−][src]Struct postgres_parser::SqlStatementScanner
The SqlStatementScanner allows for scanning a blob of SQL statements and ultimately
iterating over each statement, one at a time, producing a ScannedStatement that includes
the raw SQL, that SQL's parsetree, and optional "COPY ... FROM stdin;" payload data.
When parsing multiple SQL statements, the SqlStatementScanner is superior to directly calling
parse_query() as each individual statement is parsed on its own. This provides for syntax
checking each statement individually, instead of failing if any statement is syntactically
incorrect.
Statement Scanning Notes
- Trailing whitespace after a statement end (
"SELECT 1; \n\n SELECT 2;") are included with the preceding statement. As such, this would scan into two statements:["SELECT 1; \n\n ", "SELECT 2;"] - Statement-terminating semicolons are included with the statement
- The final statement need not have a terminating semicolon
Examples
Parsing multiple statements:
use postgres_parser::SqlStatementScanner; let scanner = SqlStatementScanner::new("SELECT 0; SELECT 1; SELECT 2;"); for (idx, statement) in scanner.iter().enumerate() { assert_eq!(statement.sql.trim_end(), &format!("SELECT {};", idx)); }
Implementations
impl<'a> SqlStatementScanner<'a>[src]
Trait Implementations
impl<'a> IntoIterator for SqlStatementScanner<'a>[src]
type Item = ScannedStatement<'a>
The type of the elements being iterated over.
type IntoIter = SqlStatementScannerIterator<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> SqlStatementScannerIterator<'a>[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for SqlStatementScanner<'a>
impl<'a> Send for SqlStatementScanner<'a>
impl<'a> Sync for SqlStatementScanner<'a>
impl<'a> Unpin for SqlStatementScanner<'a>
impl<'a> UnwindSafe for SqlStatementScanner<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator, [src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,