From 309a9e4701b61723b71f6a4ec18a29650f7e7a2f Mon Sep 17 00:00:00 2001 From: xwg Date: Mon, 4 Aug 2025 13:42:12 +0800 Subject: [PATCH 1/6] chore: fix server logic_type convert --- src/bin/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index 39973c86..222365a0 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -270,7 +270,7 @@ fn encode_tuples<'a>(schema: &SchemaRef, tuples: Vec) -> PgWireResult 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())) } @@ -297,7 +297,7 @@ fn into_pg_type(data_type: &LogicalType) -> PgWireResult { 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( From 34198a976cfc57dc3774d6c6588057fccc7e83f7 Mon Sep 17 00:00:00 2001 From: xwg Date: Mon, 4 Aug 2025 14:29:41 +0800 Subject: [PATCH 2/6] chore: fix insert count --- src/execution/dml/insert.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/execution/dml/insert.rs b/src/execution/dml/insert.rs index ac1e8e77..15c79bd5 100644 --- a/src/execution/dml/insert.rs +++ b/src/execution/dml/insert.rs @@ -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() @@ -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())); }, ) } From 28293f8eba987c644feb6fb7e3e1289403af8552 Mon Sep 17 00:00:00 2001 From: Kould Date: Mon, 4 Aug 2025 12:08:54 +0800 Subject: [PATCH 3/6] chore: fix delete & update result count --- src/execution/dml/delete.rs | 4 +++- src/execution/dml/update.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/execution/dml/delete.rs b/src/execution/dml/delete.rs index 5df5958a..4a06b5ca 100644 --- a/src/execution/dml/delete.rs +++ b/src/execution/dml/delete.rs @@ -48,6 +48,7 @@ impl<'a, T: Transaction + 'a> WriteExecutor<'a, T> for Delete { .ok_or(DatabaseError::TableNotFound)); let mut indexes: HashMap = 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(()) { @@ -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())); }, ) } diff --git a/src/execution/dml/update.rs b/src/execution/dml/update.rs index e4f1138d..ee60c351 100644 --- a/src/execution/dml/update.rs +++ b/src/execution/dml/update.rs @@ -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())) @@ -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())); }, ) } From 758d580141e4ccdfa9720c1c0ca45f69c72a6b3b Mon Sep 17 00:00:00 2001 From: Kould Date: Mon, 4 Aug 2025 12:10:09 +0800 Subject: [PATCH 4/6] chore: fix copy from file result count --- src/execution/dml/copy_from_file.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/execution/dml/copy_from_file.rs b/src/execution/dml/copy_from_file.rs index 116b1dad..f6b79604 100644 --- a/src/execution/dml/copy_from_file.rs +++ b/src/execution/dml/copy_from_file.rs @@ -114,7 +114,7 @@ impl CopyFromFile { } fn return_result(size: usize, tx: Sender) -> 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(()) From 43be5184ff4a6a541dd49365e8299c7d6995a4b4 Mon Sep 17 00:00:00 2001 From: Kould Date: Mon, 4 Aug 2025 12:18:27 +0800 Subject: [PATCH 5/6] chore: codefmt --- tests/slt/copy.slt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/slt/copy.slt b/tests/slt/copy.slt index 937fe6be..c5985203 100644 --- a/tests/slt/copy.slt +++ b/tests/slt/copy.slt @@ -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 From 98fcb64114e40ee97f2de2685bf27cbf9b53eaaf Mon Sep 17 00:00:00 2001 From: Kould Date: Mon, 4 Aug 2025 15:13:27 +0800 Subject: [PATCH 6/6] chore: codefmt --- src/execution/dml/copy_from_file.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/execution/dml/copy_from_file.rs b/src/execution/dml/copy_from_file.rs index f6b79604..8ab3bf66 100644 --- a/src/execution/dml/copy_from_file.rs +++ b/src/execution/dml/copy_from_file.rs @@ -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(()) }