Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn encode_tuples<'a>(schema: &SchemaRef, tuples: Vec<Tuple>) -> PgWireResult<Que
}
LogicalType::Date => encoder.encode_field(&value.date()),
LogicalType::DateTime => encoder.encode_field(&value.datetime()),
LogicalType::Time => encoder.encode_field(&value.time()),
LogicalType::Time(_) => encoder.encode_field(&value.time()),
LogicalType::Decimal(_, _) => {
encoder.encode_field(&value.decimal().map(|decimal| decimal.to_string()))
}
Expand All @@ -297,7 +297,7 @@ fn into_pg_type(data_type: &LogicalType) -> PgWireResult<Type> {
LogicalType::Varchar(..) => Type::VARCHAR,
LogicalType::Date | LogicalType::DateTime => Type::DATE,
LogicalType::Char(..) => Type::CHAR,
LogicalType::Time => Type::TIME,
LogicalType::Time(_) => Type::TIME,
LogicalType::Decimal(_, _) => Type::NUMERIC,
_ => {
return Err(PgWireError::UserError(Box::new(ErrorInfo::new(
Expand Down
7 changes: 2 additions & 5 deletions src/execution/dml/copy_from_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl CopyFromFile {
}

fn return_result(size: usize, tx: Sender<Tuple>) -> Result<(), DatabaseError> {
let tuple = TupleBuilder::build_result(format!("import {} rows", size));
let tuple = TupleBuilder::build_result(size.to_string());

tx.send(tuple).map_err(|_| DatabaseError::ChannelClose)?;
Ok(())
Expand Down Expand Up @@ -229,10 +229,7 @@ mod tests {
CoroutineState::Complete(()) => unreachable!(),
}
.unwrap();
assert_eq!(
tuple,
TupleBuilder::build_result(format!("import {} rows", 2))
);
assert_eq!(tuple, TupleBuilder::build_result(2.to_string()));

Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion src/execution/dml/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Delete {
.ok_or(DatabaseError::TableNotFound));
let mut indexes: HashMap<IndexId, Value> = HashMap::new();

let mut deleted_count = 0;
let mut coroutine = build_read(input, cache, transaction);

while let CoroutineState::Yielded(tuple) = Pin::new(&mut coroutine).resume(()) {
Expand Down Expand Up @@ -99,10 +100,11 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Delete {
}

throw!(unsafe { &mut (*transaction) }.remove_tuple(&table_name, tuple_id));
deleted_count += 1;
}
}
drop(coroutine);
yield Ok(TupleBuilder::build_result("1".to_string()));
yield Ok(TupleBuilder::build_result(deleted_count.to_string()));
},
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/execution/dml/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Insert {
throw!(Err(DatabaseError::NotNull))
}

let mut inserted_count = 0;
if let Some(table_catalog) =
throw!(unsafe { &mut (*transaction) }.table(cache.0, table_name.clone()))
.cloned()
Expand Down Expand Up @@ -149,10 +150,11 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Insert {
&types,
is_overwrite
));
inserted_count += 1;
}
drop(coroutine);
}
yield Ok(TupleBuilder::build_result("1".to_string()));
yield Ok(TupleBuilder::build_result(inserted_count.to_string()));
},
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/execution/dml/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Update {

let input_schema = input.output_schema().clone();
let types = types(&input_schema);
let mut updated_count = 0;

if let Some(table_catalog) =
throw!(unsafe { &mut (*transaction) }.table(cache.0, table_name.clone()))
Expand Down Expand Up @@ -135,10 +136,11 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Update {
&types,
is_overwrite
));
updated_count += 1;
}
drop(coroutine);
}
yield Ok(TupleBuilder::build_result("1".to_string()));
yield Ok(TupleBuilder::build_result(updated_count.to_string()));
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/slt/copy.slt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ create table test_copy (a int primary key, b float, c varchar(10))
query I
COPY test_copy FROM 'tests/data/copy.tbl' ( DELIMITER '|' );
----
import 2 rows
2

query I
SELECT * FROM test_copy
Expand Down
Loading