[−][src]Struct stellar_sql::sql::worker::SQL
Fields
user: Userdatabase: Databasequerydata: QueryDataresult_json: StringMethods
impl SQL[src]
pub fn new(username: &str) -> Result<SQL, SQLError>[src]
pub fn create_database(&mut self, db_name: &str) -> Result<(), SQLError>[src]
pub fn load_database(&mut self, db_name: &str) -> Result<(), SQLError>[src]
Load a database
pub fn drop_database(&mut self, db_name: &str) -> Result<(), SQLError>[src]
Drop the database
pub fn create_table(&mut self, table: &Table) -> Result<(), SQLError>[src]
Load the database and create a new table
pub fn drop_table(&mut self, table_name: &str) -> Result<(), SQLError>[src]
Drop the table
pub fn insert_into_table(
&mut self,
table_name: &str,
attrs: Vec<String>,
rows: Vec<Vec<String>>
) -> Result<(), SQLError>[src]
&mut self,
table_name: &str,
attrs: Vec<String>,
rows: Vec<Vec<String>>
) -> Result<(), SQLError>
Insert new rows into the table
pub fn select(&mut self) -> Result<(), SQLError>[src]
Handle the select query
Syntax:
(8) SELECT (9) DISTINCT (11) TOP <top_specification> <select_list>
(1) FROM <left_table>
(3) <join_type> JOIN <right_table>
(2) ON <join_condition>
(4) WHERE <where_condition>
(5) GROUP BY <group_by_list>
(6) WITH {CUBE | ROLLUP}
(7) HAVING <having_condition>
(10) ORDER BY <order_by_list>
Process:
- Semantic check: tables exists, fields exists, predicate is valid.
FROM: If there is no where clause or join-on clause join, the virtual tableVT3is that table, and go step 4. Else, it is a join. A Cartesian product (cross join) is performed between each two tables, and as a result:- 1-1. If the number of tables between
FROMandJOINare more than one, it is a where-clause inner join. Cross join tables and generate virtual tableVT3. Go step 4. - 1-2. Otherwise, there should be only a table between
FROMandJOIN, and there must beJOIN ONclause(s). If the firstJOIN ON, cross joinFROMandJOINto makeVT1, else cross joinVT1and the nextJOIN. Go step 2.
- 1-1. If the number of tables between
ON: TheONfilter is applied toVT1. Only rows for which the<join_condition>isTRUEare inserted toVT2.OUTER(join): If anOUTER JOINis specified (as opposed to anINNER JOIN), rows from the preserved table or tables for which a match was not found are added to the rows fromVT2as outer rows, generatingVT3. If more than two tables appear in theFROMclause, steps 1 through 3 are applied repeatedly between the result of the last join and the next table in theFROMclause until all tables are processed.WHERE: TheWHEREfilter is applied toVT3. Only rows for which the<where_condition>isTRUEare inserted toVT4.GROUP BY: The rows fromVT4are arranged in groups based on the column list specified in theGROUP BYclause.VT5is generated.CUBE | ROLLUP: Supergroups (groups of groups) are added to the rows fromVT5, generatingVT6.HAVING: TheHAVINGfilter is applied toVT6. Only groups for which the<having_condition>isTRUEare inserted toVT7.SELECT: TheSELECTlist is processed, generatingVT8.DISTINCT: Duplicate rows are removed fromVT8.VT9is generated.ORDER BY: The rows fromVT9are sorted according to the column list specified in the ORDER BY clause. A cursor is generated (VC10).TOP: The specified number or percentage of rows is selected from the beginning ofVC10. TableVT11is generated and returned to the caller.
reference: stack overflow #1018822
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.