diff --git a/CHANGELOG.md b/CHANGELOG.md index 680f650..91f3d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [0.23.0] - 2024-11-16 + +* Refine the behavior of `update_record_with_output` / `--override` + - runner: Previously, `query` returning 0 rows will become `statement ok`. Now it returns `statement count 0`. + - bin: Now `--override` will not change the type chars of `query `, since in practice + it becomes `?`s which might cause confusion. +* runner: `statement count ` is incorrectly handled when the result is a `query`. + ## [0.22.1] - 2024-11-11 * engines/bin: fix compatibility with the new tokio-postgres minor version. diff --git a/Cargo.lock b/Cargo.lock index e9da7ca..12eab1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5327f6c99920069d1fe374aa743be1af0031dea9f250852cdf1ae6a0861ee24" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" dependencies = [ "borsh-derive", "cfg_aliases", @@ -220,9 +220,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10aedd8f1a81a8aafbfde924b0e3061cd6fedd6f6bbcfc6a76e6fd426d7bfe26" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" dependencies = [ "once_cell", "proc-macro-crate", @@ -282,9 +282,9 @@ checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.37" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -339,9 +339,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -349,9 +349,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -373,9 +373,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "cmake" @@ -413,9 +413,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -603,9 +603,9 @@ checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "libz-sys", @@ -635,9 +635,9 @@ dependencies = [ [[package]] name = "fs-err" -version = "2.11.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +checksum = "8bb60e7409f34ef959985bc9d9c5ee8f5db24ee46ed9775850548021710f807f" dependencies = [ "autocfg", ] @@ -1061,14 +1061,14 @@ dependencies = [ [[package]] name = "libtest-mimic" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc0bda45ed5b3a2904262c1bb91e526127aa70e7ef3758aba2ef93cf896b9b58" +checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33" dependencies = [ + "anstream", + "anstyle", "clap", "escape8259", - "termcolor", - "threadpool", ] [[package]] @@ -1193,7 +1193,7 @@ dependencies = [ "serde", "serde_json", "socket2", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-util", "twox-hash", @@ -1228,7 +1228,7 @@ dependencies = [ "sha2", "smallvec", "subprocess", - "thiserror", + "thiserror 1.0.69", "uuid", "zstd", ] @@ -1290,16 +1290,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.36.5" @@ -1541,24 +1531,24 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-junit" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc1a6a5406a114913df2df8507998c755311b55b78584bed5f6e88f6417c4d4" +checksum = "62ffd2f9a162cfae131bed6d9d1ed60adced33be340a94f96952897d7cb0c240" dependencies = [ "chrono", "indexmap", "newtype-uuid", "quick-xml", "strip-ansi-escapes", - "thiserror", + "thiserror 1.0.69", "uuid", ] [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" dependencies = [ "memchr", ] @@ -1625,7 +1615,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -1640,9 +1630,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1779,18 +1769,18 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -1900,7 +1890,7 @@ dependencies = [ [[package]] name = "sqllogictest" -version = "0.22.0" +version = "0.23.0" dependencies = [ "async-trait", "educe", @@ -1917,13 +1907,13 @@ dependencies = [ "similar", "subst", "tempfile", - "thiserror", + "thiserror 2.0.3", "tracing", ] [[package]] name = "sqllogictest-bin" -version = "0.22.0" +version = "0.23.0" dependencies = [ "anyhow", "async-trait", @@ -1945,7 +1935,7 @@ dependencies = [ [[package]] name = "sqllogictest-engines" -version = "0.22.0" +version = "0.23.0" dependencies = [ "async-trait", "bytes", @@ -1959,7 +1949,7 @@ dependencies = [ "serde", "serde_json", "sqllogictest", - "thiserror", + "thiserror 2.0.3", "tokio", "tokio-postgres", "tokio-util", @@ -2081,15 +2071,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "tests" version = "0.1.0" @@ -2105,7 +2086,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -2120,22 +2110,24 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "1.1.8" +name = "thiserror-impl" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ - "cfg-if", - "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] -name = "threadpool" -version = "1.8.1" +name = "thread_local" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ - "num_cpus", + "cfg-if", + "once_cell", ] [[package]] @@ -2544,15 +2536,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 905cdc1..6a7df83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["sqllogictest", "sqllogictest-bin", "sqllogictest-engines", "tests"] [workspace.package] -version = "0.22.1" +version = "0.23.0" edition = "2021" homepage = "https://github.com/risinglightdb/sqllogictest-rs" keywords = ["sql", "database", "parser", "cli"] diff --git a/sqllogictest-bin/Cargo.toml b/sqllogictest-bin/Cargo.toml index 51a0c7c..342b12b 100644 --- a/sqllogictest-bin/Cargo.toml +++ b/sqllogictest-bin/Cargo.toml @@ -21,10 +21,10 @@ console = { version = "0.15" } futures = { version = "0.3", default-features = false } glob = "0.3" itertools = "0.13" -quick-junit = { version = "0.4" } +quick-junit = { version = "0.5" } rand = "0.8" -sqllogictest = { path = "../sqllogictest", version = "0.22" } -sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.22" } +sqllogictest = { path = "../sqllogictest", version = "0.23" } +sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.23" } tokio = { version = "1", features = [ "rt", "rt-multi-thread", @@ -33,6 +33,6 @@ tokio = { version = "1", features = [ "fs", "process", ] } -fs-err = "2.9.0" +fs-err = "3.0.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing = "0.1" diff --git a/sqllogictest-bin/src/main.rs b/sqllogictest-bin/src/main.rs index 0398c84..564f0de 100644 --- a/sqllogictest-bin/src/main.rs +++ b/sqllogictest-bin/src/main.rs @@ -17,7 +17,7 @@ use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use rand::distributions::DistString; use rand::seq::SliceRandom; use sqllogictest::{ - default_validator, strict_column_validator, update_record_with_output, AsyncDB, Injected, + default_column_validator, default_validator, update_record_with_output, AsyncDB, Injected, MakeConnection, Record, Runner, }; @@ -750,7 +750,7 @@ async fn update_record( &record_output, "\t", default_validator, - strict_column_validator, + default_column_validator, ) { Some(new_record) => { writeln!(outfile, "{new_record}")?; diff --git a/sqllogictest-engines/Cargo.toml b/sqllogictest-engines/Cargo.toml index 1e3ad75..cbd6d8b 100644 --- a/sqllogictest-engines/Cargo.toml +++ b/sqllogictest-engines/Cargo.toml @@ -16,12 +16,12 @@ futures = { version = "0.3", default-features = false } log = "0.4" mysql_async = { version = "0.34.2", default-features = false, features = ["minimal"] } pg_interval = "0.4" -postgres-types = { version = "0.2.5", features = ["derive", "with-chrono-0_4"] } -rust_decimal = { version = "1.30.0", features = ["tokio-pg"] } +postgres-types = { version = "0.2.8", features = ["derive", "with-chrono-0_4"] } +rust_decimal = { version = "1.36.0", features = ["tokio-pg"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -sqllogictest = { path = "../sqllogictest", version = "0.22" } -thiserror = "1" +sqllogictest = { path = "../sqllogictest", version = "0.23" } +thiserror = "2" tokio = { version = "1", features = [ "rt", "rt-multi-thread", diff --git a/sqllogictest/Cargo.toml b/sqllogictest/Cargo.toml index 6a4780e..1eb21ae 100644 --- a/sqllogictest/Cargo.toml +++ b/sqllogictest/Cargo.toml @@ -11,19 +11,19 @@ description = "Sqllogictest parser and runner." [dependencies] async-trait = "0.1" educe = "0.6" -fs-err = "2.9.0" +fs-err = "3" futures = "0.3" glob = "0.3" humantime = "2" itertools = "0.13" -libtest-mimic = "0.7" +libtest-mimic = "0.8" md-5 = "0.10" owo-colors = "4" -regex = "1.9.1" -similar = "2.2.1" +regex = "1" +similar = "2" subst = "0.3" tempfile = "3" -thiserror = "1" +thiserror = "2" tracing = "0.1" [dev-dependencies] diff --git a/sqllogictest/src/runner.rs b/sqllogictest/src/runner.rs index 8386b90..71db46c 100644 --- a/sqllogictest/src/runner.rs +++ b/sqllogictest/src/runner.rs @@ -849,7 +849,9 @@ impl> Runner { Record::Statement { sql, expected, loc, .. }, - RecordOutput::Query { error: None, .. }, + RecordOutput::Query { + error: None, rows, .. + }, ) => { if let StatementExpect::Error(_) = expected { return Err(TestErrorKind::Ok { @@ -858,6 +860,16 @@ impl> Runner { } .at(loc)); } + if let StatementExpect::Count(expected_count) = expected { + if expected_count != rows.len() as u64 { + return Err(TestErrorKind::StatementResultMismatch { + sql, + expected: expected_count, + actual: format!("returned {} rows", rows.len()), + } + .at(loc)); + } + } } ( Record::Query { @@ -1332,6 +1344,9 @@ impl> Runner { if matches!(record, Record::Halt { .. }) { *halt = true; writeln!(outfile, "{record}")?; + tracing::info!( + "halt record found, all following records will be written AS IS" + ); continue; } let record_output = self.apply_record(record.clone()).await; @@ -1380,9 +1395,11 @@ pub fn update_record_with_output( loc, conditions, connection, - expected: expected @ (StatementExpect::Ok | StatementExpect::Count(_)), + expected: mut expected @ (StatementExpect::Ok | StatementExpect::Count(_)), + }, + RecordOutput::Query { + error: None, rows, .. }, - RecordOutput::Query { error: None, .. }, ) => { // statement ok // SELECT ... @@ -1391,6 +1408,10 @@ pub fn update_record_with_output( // but don't care about the output. // DuckDB has a few of these. + if let StatementExpect::Count(expected_count) = &mut expected { + *expected_count = rows.len() as u64; + } + Some(Record::Statement { sql, loc, @@ -1408,13 +1429,13 @@ pub fn update_record_with_output( connection, expected: _, }, - RecordOutput::Statement { error: None, .. }, + RecordOutput::Statement { error: None, count }, ) => Some(Record::Statement { sql, loc, conditions, connection, - expected: StatementExpect::Ok, + expected: StatementExpect::Count(*count), }), // statement, statement ( @@ -1737,7 +1758,7 @@ Caused by: record_output: statement_output(3), expected: Some( - "statement ok\n\ + "statement count 3\n\ select * from foo;", ), } @@ -1970,6 +1991,7 @@ Caused by: } impl TestCase<'_> { + #[track_caller] fn run(self) { let Self { input, diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 5b22650..dac90ae 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -regex = "1.9.1" +regex = "1.11.1" rusty-fork = "0.3" sqllogictest = { path = "../sqllogictest" }