Merge branch 'clippy-formatting' into 'main'
Clippy formatting See merge request x433485/minisql!21
This commit is contained in:
commit
4d45da0cd1
13 changed files with 78 additions and 54 deletions
|
|
@ -7,6 +7,13 @@ pub struct ColumnIndex {
|
||||||
index: BTreeMap<IndexableValue, HashSet<Uuid>>,
|
index: BTreeMap<IndexableValue, HashSet<Uuid>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To satisfy clippy.
|
||||||
|
impl Default for ColumnIndex {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ColumnIndex {
|
impl ColumnIndex {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let index = BTreeMap::new();
|
let index = BTreeMap::new();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,13 @@ impl FromIterator<Value> for Row {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To satisfy clippy.
|
||||||
|
impl Default for Row {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Row {
|
impl Row {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(vec![])
|
Self(vec![])
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ impl Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn table_name(&self) -> &TableName {
|
pub fn table_name(&self) -> &TableName {
|
||||||
&self.schema.table_name()
|
self.schema.table_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======Selection======
|
// ======Selection======
|
||||||
|
|
@ -69,18 +69,18 @@ impl Table {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select_all_rows<'a>(&'a self, selected_columns: Vec<Column>) -> impl Iterator<Item=RestrictedRow> + 'a {
|
pub fn select_all_rows(&self, selected_columns: Vec<Column>) -> impl Iterator<Item=RestrictedRow> + '_ {
|
||||||
self.rows
|
self.rows
|
||||||
.values()
|
.values()
|
||||||
.map(move |row| row.restrict_columns(&selected_columns))
|
.map(move |row| row.restrict_columns(&selected_columns))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select_rows_where_eq<'a>(
|
pub fn select_rows_where_eq(
|
||||||
&'a self,
|
&self,
|
||||||
selected_columns: Vec<Column>,
|
selected_columns: Vec<Column>,
|
||||||
column: Column,
|
column: Column,
|
||||||
value: Value,
|
value: Value,
|
||||||
) -> DbResult<impl Iterator<Item=RestrictedRow> + 'a> {
|
) -> DbResult<impl Iterator<Item=RestrictedRow> + '_> {
|
||||||
let restrict_columns_of_row = move |row: Row| row.restrict_columns(&selected_columns);
|
let restrict_columns_of_row = move |row: Row| row.restrict_columns(&selected_columns);
|
||||||
match value {
|
match value {
|
||||||
Value::Indexable(value) => match self.fetch_ids_from_index(column, &value)? {
|
Value::Indexable(value) => match self.fetch_ids_from_index(column, &value)? {
|
||||||
|
|
@ -116,10 +116,7 @@ impl Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (column, column_index) in &mut self.indexes {
|
for (column, column_index) in &mut self.indexes {
|
||||||
match &row[*column] {
|
if let Value::Indexable(val) = &row[*column] { column_index.add(val.clone(), id) }
|
||||||
Value::Indexable(val) => column_index.add(val.clone(), id),
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = self.rows.insert(id, row);
|
let _ = self.rows.insert(id, row);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,13 @@ impl std::fmt::Debug for Response<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To satisfy clippy.
|
||||||
|
impl Default for State {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -55,7 +62,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn db_schema<'a>(&'a self) -> DbSchema {
|
pub fn db_schema(&self) -> DbSchema {
|
||||||
let mut schema: DbSchema = Vec::new();
|
let mut schema: DbSchema = Vec::new();
|
||||||
for (table_name, &table_position) in &self.table_name_position_mapping {
|
for (table_name, &table_position) in &self.table_name_position_mapping {
|
||||||
let table_schema = self.tables[table_position].schema();
|
let table_schema = self.tables[table_position].schema();
|
||||||
|
|
@ -64,11 +71,11 @@ impl State {
|
||||||
schema
|
schema
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_at<'a>(&'a self, table_position: TablePosition) -> &'a Table {
|
fn table_at(&self, table_position: TablePosition) -> &Table {
|
||||||
&self.tables[table_position]
|
&self.tables[table_position]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_at_mut<'a>(&'a mut self, table_position: TablePosition) -> &'a mut Table {
|
fn table_at_mut(&mut self, table_position: TablePosition) -> &mut Table {
|
||||||
&mut self.tables[table_position]
|
&mut self.tables[table_position]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ impl RestrictedRow {
|
||||||
self.0.len()
|
self.0.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.0.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> impl Iterator<Item=&(Column, Value)> {
|
pub fn iter(&self) -> impl Iterator<Item=&(Column, Value)> {
|
||||||
self.0.iter()
|
self.0.iter()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use minisql::{operation::Operation, interpreter::DbSchema};
|
use minisql::{operation::Operation, interpreter::DbSchema};
|
||||||
use crate::syntax::RawQuerySyntax;
|
use crate::syntax::RawQuerySyntax;
|
||||||
use nom::{branch::alt, multi::many0, IResult};
|
use nom::{branch::alt, IResult};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{parsing::{create::parse_create, delete::parse_delete, index::parse_create_index, insert::parse_insert, select::parse_select}, validation::{validate_operation, ValidationError}};
|
use crate::{parsing::{create::parse_create, delete::parse_delete, index::parse_create_index, insert::parse_insert, select::parse_select}, validation::{validate_operation, ValidationError}};
|
||||||
|
|
@ -13,7 +13,7 @@ pub enum Error {
|
||||||
ValidationError(#[from] ValidationError)
|
ValidationError(#[from] ValidationError)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_statement<'a>(input: &'a str) -> IResult<&str, RawQuerySyntax> {
|
fn parse_statement(input: &str) -> IResult<&str, RawQuerySyntax> {
|
||||||
alt((
|
alt((
|
||||||
parse_insert,
|
parse_insert,
|
||||||
parse_create,
|
parse_create,
|
||||||
|
|
@ -25,10 +25,6 @@ pub fn parse_statement<'a>(input: &'a str) -> IResult<&str, RawQuerySyntax> {
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_statements<'a>(input: &'a str) -> IResult<&str, Vec<RawQuerySyntax>> {
|
|
||||||
many0(parse_statement)(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_and_validate(str_query: String, db_schema: &DbSchema) -> Result<Operation, Error> {
|
pub fn parse_and_validate(str_query: String, db_schema: &DbSchema) -> Result<Operation, Error> {
|
||||||
let (_, op) = parse_statement(str_query.as_str())
|
let (_, op) = parse_statement(str_query.as_str())
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,10 @@ pub fn parse_number(input: &str) -> IResult<&str, Value> {
|
||||||
Some((_fsign, fdigits)) => {
|
Some((_fsign, fdigits)) => {
|
||||||
// Combine integer and fractional parts
|
// Combine integer and fractional parts
|
||||||
let combined_parts = format!(
|
let combined_parts = format!(
|
||||||
"{}{}",
|
"{}{}.{}",
|
||||||
format!("{}{}", sign.unwrap_or('+'), digits),
|
sign.unwrap_or('+'),
|
||||||
format!(".{}", fdigits)
|
digits,
|
||||||
|
fdigits
|
||||||
);
|
);
|
||||||
// Parse the combined parts as a floating-point number
|
// Parse the combined parts as a floating-point number
|
||||||
let value = combined_parts.parse::<f64>()
|
let value = combined_parts.parse::<f64>()
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ pub fn try_parse_column_selection(input: &str) -> IResult<&str, ColumnSelection>
|
||||||
});
|
});
|
||||||
let columns_parser = map(
|
let columns_parser = map(
|
||||||
separated_list0(terminated(char(','), multispace0), parse_column_name),
|
separated_list0(terminated(char(','), multispace0), parse_column_name),
|
||||||
|names| ColumnSelection::Columns(names),
|
ColumnSelection::Columns,
|
||||||
);
|
);
|
||||||
alt((all_parser, columns_parser))(input)
|
alt((all_parser, columns_parser))(input)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ fn validate_table_exists<'a>(db_schema: &DbSchema<'a>, table_name: &'a TableName
|
||||||
|
|
||||||
fn validate_create_table(raw_table_schema: RawTableSchema, db_schema: &DbSchema) -> Result<Operation, ValidationError> {
|
fn validate_create_table(raw_table_schema: RawTableSchema, db_schema: &DbSchema) -> Result<Operation, ValidationError> {
|
||||||
let table_name: &TableName = &raw_table_schema.table_name;
|
let table_name: &TableName = &raw_table_schema.table_name;
|
||||||
if let Some(_) = get_table_schema(db_schema, &table_name) {
|
if get_table_schema(db_schema, table_name).is_some() {
|
||||||
return Err(ValidationError::TableAlreadyExists(table_name.to_string()));
|
return Err(ValidationError::TableAlreadyExists(table_name.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,10 +89,11 @@ fn validate_table_schema(raw_table_schema: RawTableSchema) -> Result<TableSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure it has exactly one primary key that has correct type.
|
// Ensure it has exactly one primary key that has correct type.
|
||||||
if primary_keys.len() == 0 {
|
let number_of_primary_keys = primary_keys.len();
|
||||||
return Err(ValidationError::PrimaryKeyMissing(raw_table_schema.table_name.clone()))
|
if number_of_primary_keys == 0 {
|
||||||
} else if primary_keys.len() > 1 {
|
Err(ValidationError::PrimaryKeyMissing(raw_table_schema.table_name.clone()))
|
||||||
return Err(ValidationError::MultiplePrimaryKeysFound(raw_table_schema.table_name.clone()))
|
} else if number_of_primary_keys > 1 {
|
||||||
|
Err(ValidationError::MultiplePrimaryKeysFound(raw_table_schema.table_name.clone()))
|
||||||
} else {
|
} else {
|
||||||
let (primary_column_name, primary_key_type) = primary_keys[0].clone();
|
let (primary_column_name, primary_key_type) = primary_keys[0].clone();
|
||||||
if primary_key_type == DbType::Uuid {
|
if primary_key_type == DbType::Uuid {
|
||||||
|
|
@ -113,18 +114,18 @@ fn validate_select(table_name: TableName, column_selection: syntax::ColumnSelect
|
||||||
syntax::ColumnSelection::Columns(columns) => {
|
syntax::ColumnSelection::Columns(columns) => {
|
||||||
let non_existant_columns: Vec<ColumnName> =
|
let non_existant_columns: Vec<ColumnName> =
|
||||||
columns.iter().filter_map(|column|
|
columns.iter().filter_map(|column|
|
||||||
if schema.does_column_exist(&column) {
|
if schema.does_column_exist(column) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(column.clone())
|
Some(column.clone())
|
||||||
}).collect();
|
}).collect();
|
||||||
if non_existant_columns.len() > 0 {
|
if non_existant_columns.is_empty() {
|
||||||
Err(ValidationError::ColumnsDoNotExist(non_existant_columns))
|
|
||||||
} else {
|
|
||||||
let selection: operation::ColumnSelection =
|
let selection: operation::ColumnSelection =
|
||||||
columns.iter().filter_map(|column_name| schema.get_column(column_name)).collect();
|
columns.iter().filter_map(|column_name| schema.get_column(column_name)).collect();
|
||||||
let validated_condition = validate_condition(condition, schema)?;
|
let validated_condition = validate_condition(condition, schema)?;
|
||||||
Ok(Operation::Select(table_position, selection, validated_condition))
|
Ok(Operation::Select(table_position, selection, validated_condition))
|
||||||
|
} else {
|
||||||
|
Err(ValidationError::ColumnsDoNotExist(non_existant_columns))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syntax::ColumnSelection::All => {
|
syntax::ColumnSelection::All => {
|
||||||
|
|
@ -149,11 +150,11 @@ fn validate_insert(table_name: TableName, insertion_values: syntax::InsertionVal
|
||||||
let columns_in_query: HashSet<&ColumnName> = HashSet::from_iter(columns_in_query_vec);
|
let columns_in_query: HashSet<&ColumnName> = HashSet::from_iter(columns_in_query_vec);
|
||||||
let columns_in_schema: HashSet<&ColumnName> = HashSet::from_iter(schema.get_columns());
|
let columns_in_schema: HashSet<&ColumnName> = HashSet::from_iter(schema.get_columns());
|
||||||
let non_existant_columns = Vec::from_iter(columns_in_query.difference(&columns_in_schema));
|
let non_existant_columns = Vec::from_iter(columns_in_query.difference(&columns_in_schema));
|
||||||
if non_existant_columns.len() > 0 {
|
if !non_existant_columns.is_empty() {
|
||||||
return Err(ValidationError::ColumnsDoNotExist(non_existant_columns.iter().map(|column_name| column_name.to_string()).collect()));
|
return Err(ValidationError::ColumnsDoNotExist(non_existant_columns.iter().map(|column_name| column_name.to_string()).collect()));
|
||||||
}
|
}
|
||||||
let missing_required_columns = Vec::from_iter(columns_in_schema.difference(&columns_in_query));
|
let missing_required_columns = Vec::from_iter(columns_in_schema.difference(&columns_in_query));
|
||||||
if missing_required_columns.len() > 0 {
|
if !missing_required_columns.is_empty() {
|
||||||
return Err(ValidationError::RequiredColumnsAreMissing(missing_required_columns.iter().map(|str| str.to_string()).collect()));
|
return Err(ValidationError::RequiredColumnsAreMissing(missing_required_columns.iter().map(|str| str.to_string()).collect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,7 +195,7 @@ fn validate_condition(condition: Option<syntax::Condition>, schema: &TableSchema
|
||||||
if expected_type.eq(&value_type) {
|
if expected_type.eq(&value_type) {
|
||||||
Ok(Some(operation::Condition::Eq(column, value)))
|
Ok(Some(operation::Condition::Eq(column, value)))
|
||||||
} else {
|
} else {
|
||||||
return Err(ValidationError::TypeMismatch { column_name: column_name.to_string(), received_type: value_type, expected_type });
|
Err(ValidationError::TypeMismatch { column_name: column_name.to_string(), received_type: value_type, expected_type })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +229,7 @@ where T: Eq + std::hash::Hash
|
||||||
if already_seen_elements.contains(t) {
|
if already_seen_elements.contains(t) {
|
||||||
return Some(t);
|
return Some(t);
|
||||||
} else {
|
} else {
|
||||||
already_seen_elements.insert(&t);
|
already_seen_elements.insert(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@ where
|
||||||
R: AsyncBufRead + Unpin + Send,
|
R: AsyncBufRead + Unpin + Send,
|
||||||
{
|
{
|
||||||
async fn peek_special_message(&mut self) -> Result<Option<SpecialMessage>, ProtoPeekError> {
|
async fn peek_special_message(&mut self) -> Result<Option<SpecialMessage>, ProtoPeekError> {
|
||||||
if let Some(cancel) = try_get_cancel_request(&mut self).await? {
|
if let Some(cancel) = try_get_cancel_request(self).await? {
|
||||||
return Ok(Some(cancel));
|
return Ok(Some(cancel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ssl) = try_get_ssl_request(&mut self).await? {
|
if let Some(ssl) = try_get_ssl_request(self).await? {
|
||||||
return Ok(Some(ssl));
|
return Ok(Some(ssl));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(startup) = try_get_startup_message(&mut self).await? {
|
if let Some(startup) = try_get_startup_message(self).await? {
|
||||||
return Ok(Some(startup));
|
return Ok(Some(startup));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,11 +43,12 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: &SpecialMessage,
|
msg: &SpecialMessage,
|
||||||
) -> Result<(), ProtoConsumeError> {
|
) -> Result<(), ProtoConsumeError> {
|
||||||
Ok(match msg {
|
match msg {
|
||||||
SpecialMessage::CancelRequest(_) => consume_cancel_request(self),
|
SpecialMessage::CancelRequest(_) => consume_cancel_request(self),
|
||||||
SpecialMessage::SSLRequest => consume_ssl_request(self),
|
SpecialMessage::SSLRequest => consume_ssl_request(self),
|
||||||
SpecialMessage::StartupMessage(_) => consume_startup_message(self).await?,
|
SpecialMessage::StartupMessage(_) => consume_startup_message(self).await?,
|
||||||
})
|
};
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ where
|
||||||
{
|
{
|
||||||
async fn write_proto(&mut self, message: T) -> Result<(), ProtoWriteError> {
|
async fn write_proto(&mut self, message: T) -> Result<(), ProtoWriteError> {
|
||||||
let variant = message.variant();
|
let variant = message.variant();
|
||||||
let mut data = message.serialize()?;
|
let data = message.serialize()?;
|
||||||
let length = data.len() as i32 + 4;
|
let length = data.len() as i32 + 4;
|
||||||
|
|
||||||
self.inner.write_u8(variant).await?;
|
self.inner.write_u8(variant).await?;
|
||||||
self.inner.write_i32(length).await?;
|
self.inner.write_i32(length).await?;
|
||||||
self.inner.write_all(&mut data).await?;
|
self.inner.write_all(&data).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,10 @@ async fn create_token(tokens: &TokenStore) -> anyhow::Result<(i32, i32, ResetCan
|
||||||
let mut tokens = tokens.lock().await;
|
let mut tokens = tokens.lock().await;
|
||||||
loop {
|
loop {
|
||||||
let pid_key = random_pid_key();
|
let pid_key = random_pid_key();
|
||||||
if !tokens.contains_key(&pid_key) {
|
|
||||||
tokens.insert(pid_key, token.clone());
|
use std::collections::hash_map;
|
||||||
|
if let hash_map::Entry::Vacant(token_entry) = tokens.entry(pid_key) {
|
||||||
|
token_entry.insert(token.clone());
|
||||||
|
|
||||||
let (pid, key) = pid_key;
|
let (pid, key) = pid_key;
|
||||||
return Ok((pid, key, token));
|
return Ok((pid, key, token));
|
||||||
|
|
@ -190,7 +192,7 @@ async fn handle_query<W>(writer: &mut W, state: &SharedDbState, query: String, t
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Response::Selected(schema, columns, mut rows) => {
|
Response::Selected(schema, columns, mut rows) => {
|
||||||
writer.write_table_header(&schema, &columns).await?;
|
writer.write_table_header(schema, &columns).await?;
|
||||||
match rows.next() {
|
match rows.next() {
|
||||||
Some(row) => {
|
Some(row) => {
|
||||||
writer.write_table_row(&row).await?;
|
writer.write_table_row(&row).await?;
|
||||||
|
|
@ -226,7 +228,7 @@ async fn handle_query<W>(writer: &mut W, state: &SharedDbState, query: String, t
|
||||||
|
|
||||||
if need_write {
|
if need_write {
|
||||||
let state = state.read().await;
|
let state = state.read().await;
|
||||||
state_to_file(&state, &config.get_file_path()).await?;
|
state_to_file(&state, config.get_file_path()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use async_trait::async_trait;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use rand_pcg::Pcg64;
|
use rand_pcg::Pcg64;
|
||||||
use rand_seeder::Seeder;
|
use rand_seeder::Seeder;
|
||||||
|
use std::fmt;
|
||||||
use minisql::operation::ColumnSelection;
|
use minisql::operation::ColumnSelection;
|
||||||
use minisql::restricted_row::RestrictedRow;
|
use minisql::restricted_row::RestrictedRow;
|
||||||
use minisql::schema::{Column, TableSchema};
|
use minisql::schema::{Column, TableSchema};
|
||||||
|
|
@ -20,14 +21,14 @@ pub enum CompleteStatus {
|
||||||
CreateIndex,
|
CreateIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompleteStatus {
|
impl fmt::Display for CompleteStatus {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
CompleteStatus::Insert { oid, rows } => format!("INSERT {} {}", oid, rows),
|
CompleteStatus::Insert { oid, rows } => write!(f, "INSERT {} {}", oid, rows),
|
||||||
CompleteStatus::Delete(rows) => format!("DELETE {}", rows),
|
CompleteStatus::Delete(rows) => write!(f, "DELETE {}", rows),
|
||||||
CompleteStatus::Select(rows) => format!("SELECT {}", rows),
|
CompleteStatus::Select(rows) => write!(f, "SELECT {}", rows),
|
||||||
CompleteStatus::CreateTable => "CREATE TABLE".to_string(),
|
CompleteStatus::CreateTable => write!(f, "CREATE TABLE"),
|
||||||
CompleteStatus::CreateIndex => "CREATE INDEX".to_string(),
|
CompleteStatus::CreateIndex => write!(f, "CREATE INDEX"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,4 +119,4 @@ fn column_to_description(schema: &TableSchema, column: Column) -> anyhow::Result
|
||||||
fn table_name_to_oid(table_name: &str) -> i32 {
|
fn table_name_to_oid(table_name: &str) -> i32 {
|
||||||
let mut rng: Pcg64 = Seeder::from(table_name).make_rng();
|
let mut rng: Pcg64 = Seeder::from(table_name).make_rng();
|
||||||
rng.gen::<i32>()
|
rng.gen::<i32>()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue